You are reading a single comment by @Wilberforce and its replies. Click here to read the full conversation.
  • 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.c­om/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 ]
    
About

Avatar for Wilberforce @Wilberforce started