You are reading a single comment by @th and its replies. Click here to read the full conversation.
  • Thanks @maze1980, that did the trick.

    Moved setWatch to ctor, writes to shared buffer. Set a cap on how many readings it will buffer (in case read is never called), and clear buffer upon fresh read. I'll look into making it more efficient later. As long as we have enough data "continously" there is no need for waiting, so it could return immediately.

    var dht = require("https://raw.githubusercontent.c­om/tedd/Espruino_DHT11/master/DHT11_test­.js?3").connect(D27);
    
    function readSensor() {
      dht.read(
        function (a) {
        console.log(a);
        setTimeout(readSensor, 5000);
      });
    }
    
    readSensor();
    
About

Avatar for th @th started