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

Fails to read negative temperatures!! (Any more!!) #6

Closed oldironUK closed 3 years ago

oldironUK commented 3 years ago

Hi

This node has stopped reading negative temperatures - I've tried 3 different sensors and 2 different pi (a Pi 4 2gb and Pi 4 4gb). The same sensors display negative numbers on my sonoff with tasmota so I don't believe there is anything wrong with the sensors.
What is really strange is that the node was able to report negative temperatures several weeks ago. I've run various updates on the pi's since that time but that shouldn't have broken this. Any ideas - (I can obviously fix it with a function block!)

If you need any other info - let as know.

Thanks in advance

Data:

Probes placed outside monitoring the temperature dropping)

Sonoff | Pi 0.7 | 0.7 0.6 | 0.6 0.5 | 0.5 0.4 | 0.4 0.3 | 0.3 0.2 | 0.2 0.1 | 0.1 0 | 0 -0.1 | 4095.9 -0.2 | 4095.8 -0.3 | 4095.7 -0.4 | 4095.6

Node red v1.2.9 running in docker (IOTstack build)

Pi 4 2gb & 4gb Versions: PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster

colinl commented 3 years ago

At least one other person has seen this problem. Something is miscalculating the temperature. It is not allowing for the fact the value wraps around at 4096. Do you know what you upgraded?

charlielito commented 3 years ago

AFAIK the problem is with the underlying node library that reads the sensor data https://www.npmjs.com/package/ds18b20 as @colinl pointed out. Because it has nothing to do with this library I am closing it.

The link has a workaround which is adding a function block to process the temperature.

 if (msg.payload > 2048) msg.payload = msg.payload-4096; 
return msg;

@oldironUK do you think this should be handled by this library? If so please re open this issue I could address that particular case.