Great! As for OneWire, I'm surprised there is any difference as I didn't think much changed there.
But basically the issue is that you're always meant to give the Bluetooth stack priority. I think at some point in the past I was disabling it for OneWire, and that made Espruino unstable and it could spontaneously reboot.
I decided it was better to just have OneWire fail every so often (which is easy to recover from) rather than to have a reboot :)
function getTempReliable(callback) {
sensor.getTemp(function (temp) {
if (temp===null) getTempReliable(callback);
else callback(temp);
});
}
Note that you may also need to do similar stuff at boot time (when you're finding the address of the OneWire sensor to use) as occasionally it may not find it.
Or... you could use NRF.sleep() to disable advertising while you read the temperature and NRF.wake after() - but IMO the retry is safer
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Great! As for OneWire, I'm surprised there is any difference as I didn't think much changed there.
But basically the issue is that you're always meant to give the Bluetooth stack priority. I think at some point in the past I was disabling it for OneWire, and that made Espruino unstable and it could spontaneously reboot.
I decided it was better to just have OneWire fail every so often (which is easy to recover from) rather than to have a reboot :)
I looked just now and there may be a hacky solution: https://github.com/espruino/Espruino/issues/1831
However you're using OneWire for a DS18B20? http://www.espruino.com/DS18B20
If so you can just do:
Note that you may also need to do similar stuff at boot time (when you're finding the address of the OneWire sensor to use) as occasionally it may not find it.
Or... you could use
NRF.sleep()
to disable advertising while you read the temperature andNRF.wake after()
- but IMO the retry is safer