You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • @Wilberforce I think it's best not to worry about the initial value - people have been using this DS18B20 module for years and are happy to just put up with it.

    Producing a good first value half the time is worse than never doing it :)

    Should getTemp return the last value, even with a callback, rather than undefined?

    I don't think so... It's another request over OneWire and more calculation that will never be used most of the time...

    The callback needs some sort of identifier, as you can't assume the order of the readings in the callbacks.

    I don't think so - you can easily re-write your code:

       sensors.forEach(function (sensor, index) {
          sensor.getTemp(function(temp) {
            console.log(index + ": " + temp));
          });
      });
    

    And there are plenty of other ways to do this that don't require changes in the module.

About

Avatar for Gordon @Gordon started