charlielito / node-red-contrib-sensor-ds18b20

Node-Red Contrib module to read temperature from DS19B20 Temperature Sensor
Apache License 2.0
2 stars 4 forks source link

Usage of DS1820 #2

Closed mboremski closed 6 years ago

mboremski commented 6 years ago

I testet you code with two different sensores: DS18B20 (what it is designed for) and DS1820. Found different values: DS18B20 leads to values around 25.5 whats correct. DS1820 leads to values around 3.18 what seems to small for roomtemperature.

Next i had a look at the code where you get the data from sensors : https://github.com/charlielito/node-red-contrib-sensor-ds18b20/blob/99e870167a05bc729ba61fe030ee2e40969b42b2/node_modules/ds18b20/lib/ds18b20.js#L39-L56

my "w1_slave" files look like this:

I am not really uset do java but it looks like you are calculating the value and you dont use the "t=" to find the value.

Could you maybe have a look on this?

charlielito commented 6 years ago

Hi! The problem is in the node underlaying library ds18b20, because I didn't program this as it it supposed to work only with ds18b20 out of the shelf. Nonetheless I'll take a look at this issue

mboremski commented 6 years ago

TY for replying. :smile:

For me the code in "underlaying lib ds18b20" looks slightly different: https://github.com/chamerling/ds18b20/blob/6a8e71af54feea22edcac9945a38e615525d40da/lib/ds18b20.js#L77-L88

The files generated by the kernel-ow-driver look good so far. I also tried to get sensordata via console like this:

for dev in $(cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves)
do
  tail -1 /sys/bus/w1/devices/w1_bus_master1/$dev/w1_slave |\
    awk -F 't=' '{print $2/1000}'
done

As you can see this watches out for the 't=' string to get the temperature-value. This results in propper values, no matter what kind of sensor connected.

Would be great if you could have a look on this. TY

charlielito commented 6 years ago

Hi! You were right, I had an old version of the underlaying library. My bad. Just corrected that in npm with a new version, you can install the new version with npm since the node-red repo havent updated it yet.