The function getTC() is called inside its own definition, maybe that's why, you could try..
var ow = new OneWire(D14); var sensor = require("DS18B20").connect(ow); var cnt=1; function getTC() { sensor.getTemp(function (temp) { console.log("Temp is "+temp+"°C : ",cnt++); }); } setInterval( function() { if(sensor.isPresent()) getTC(); else console.log('no sensor detected'); }, 1000 );
Does that work?
@countxerox started
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.
The function getTC() is called inside its own definition, maybe that's why, you could try..
Does that work?