You literally just insert it in-line and it'll overwrite the existing implementation:
var ow = new OneWire(A1); var sensor = require("DS18B20").connect(ow); sensor.getTemp = function(callback) { function read(me) { var s = me._r(); var temp = s[0] + (s[1]<<8); if (temp & 32768) temp -= 65536; temp = temp / ((me.type==10)?2:16); if (callback) callback(temp); return temp; } this.bus.select(this.sCode); this.bus.write(0x44, true); if (!callback) return read(this); var tim = {9:94, 10:188, 11:375, 12:750}; setTimeout(read, tim[this.getRes()], this); }; setInterval(function() { sensor.getTemp(function (temp) { console.log("Temp is "+temp+"°C"); }); }, 1000);
@Gordon 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.
You literally just insert it in-line and it'll overwrite the existing implementation: