I'd try breaking sendForm() and bh.read() out of the dht.read() callback. Not sure if that will help, but it might relieve some memory shortage. Untested code:
// global vars up near the top
var lastTemp = "";
var lastHumidity = "";
var lastLight = "";
function sendSensorData(){
sendForm(lastTemp, lastHumidity, lastLight);
}
// ........
// further down, in place of your setInterval() section
setInterval(function() {
lastLight = Math.round(bh.read()).toString();
dht.read(function (a) {
lastTemp = a.temp.toString();
lastHumidity = a.rh.toString();
// let's give Espruino an opportunity to do housekeeping
// before sending our form
setTimeout(sendSensorData, 5000);
});
}, 60000); // once a minute
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.
I'd try breaking
sendForm()
andbh.read()
out of thedht.read()
callback. Not sure if that will help, but it might relieve some memory shortage. Untested code: