Hello Andrey, for me it works this way. Type of sensor can be recognized in device info of sensor regards Juergen
function OneWireTemp(pin){ var me = this; me.ow = new OneWire(pin); me.device = me.ow.search()[0]; me.deviceType = me.device - ((me.device >> 8) << 8); me.readRegister = function(callback,n){ if(!n)n = 8; var reg = []; me.ow.reset();me.ow.select(me.device);me.ow.write(0x44,true); me.ow.reset();me.ow.select(me.device);me.ow.write(0xBE); for(var i = 0; i < n; i++){reg.push(me.ow.read());} return reg; }; me.getTemp = function(callback){ var t,reg = me.readRegister(2); t = reg[0] + (reg[1] << 8); if(t > 32767) t -= 65536; switch(me.deviceType){ case 40: t = t / 16; break;//ds18B20 case 16: t = t / 2; break;//ds18S20 } return t; }; }
@JumJum 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.
Hello Andrey,
for me it works this way. Type of sensor can be recognized in device info of sensor
regards
Juergen