Is there any way to get OneWire and BLE reliably work together?
Using a Pixl with 2v08.188, have three DS18B20 attached to A0. If Bluetooth is connected, mostly only 0 or 1 sensor are detected, and there are a bunch of null values returned when reading temperature.
Tested with Pixl on serial, and with an Espruino Wifi, and all sensors are detected, and almost no null values returned.
If I'm right, OneWire is done in software, and I assume BLE communication is interfering with that, right? Is there anything that could improve? Do the coding, and disconnect & disable BLE to run the code?
And other question: Assuming I'm not using BLE while running the code, what are my chances of reading multiple DS18B20 and reading accelerometer and writing to SD card together? Ok, let's just try it :D
Code is below:
var ow = new OneWire(A0);
//R: VCC, G: Gnd, Y: Data
var sensors = [];
function scan(){ sensors = ow.search().map(function (device) { return require("DS18B20").connect(ow, device);}); }
setInterval(function() {
sensors.forEach(function (sensor, index) {
sensor.getTemp(function (temp) {
console.log(index, sensor.sCode, ": " + temp + "°C");
});
});
}, 1000);
setTimeout(scan, 1234);
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.
Is there any way to get OneWire and BLE reliably work together?
Using a Pixl with 2v08.188, have three DS18B20 attached to A0. If Bluetooth is connected, mostly only 0 or 1 sensor are detected, and there are a bunch of
null
values returned when reading temperature.Tested with Pixl on serial, and with an Espruino Wifi, and all sensors are detected, and almost no
null
values returned.If I'm right, OneWire is done in software, and I assume BLE communication is interfering with that, right? Is there anything that could improve? Do the coding, and disconnect & disable BLE to run the code?
And other question: Assuming I'm not using BLE while running the code, what are my chances of reading multiple DS18B20 and reading accelerometer and writing to SD card together? Ok, let's just try it :D
Code is below: