Thanks Gordon.
Here is the code modified to save the results to an array, updating every 1/2 sec and displaying every sec:
var pin = D5; // update for your hardware! var ow = new OneWire(pin); ds = require("https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/DS18B20.js"); var s = ow.search(); console.log({ search : s }); var sensors = s.map(function (device) { return ds.connect(ow, device); }); var temps = []; setInterval(function () { sensors.forEach(function (sensor, index) { sensor.getTemp(function (temp) { temps[index] = temp; }); }); }, 500); setInterval(function () { console.log(temps); }, 1000);
{ "search": [ "28cc2e230500006b", "283260dc04000001" ] } =undefined [ ] [ 24.5, 24.4375 ] [ 24.5625, 24.4375 ] [ 24.5, 24.4375 ] [ 24.5, 24.4375 ]
@Wilberforce started
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.
Thanks Gordon.
Here is the code modified to save the results to an array, updating every 1/2 sec and displaying every sec: