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.com/tedd/Espruino_DHT11/master/DHT11_test.js?3").connect(D27);
function readSensor() {
dht.read(
function (a) {
console.log(a);
setTimeout(readSensor, 5000);
});
}
readSensor();
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 @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.