philipBC
Posts: 14
Joined: Fri Aug 12, 2016 1:15 pm

DS18B20 reads -20.5

Wed Oct 05, 2016 10:59 am

I have a several DS18B20 temperature sensors used on RPi3 on the 1-wire bus using the supplied dtoverlay driver.
A couple of the sensors sometimes report the temperature -20.5.. ie the first two data bytes in the w1_slave file are 98 FE.

Code: Select all

98 fe ff ff 7f ff ff ff 1c : crc=1c YES
98 fe ff ff 7f ff ff ff 1c t=-22500
This reading is clearly wrong, since this result appears in a time stream of readings between 18 and 22 degrees C.

I know the device/driver will report 85C upon reset, but I have not found any information as to why -22.5C might be returned. The driver is reporting that the CRC is valid and the probe config byte reads correctly as 7f indicating the max resolution of 1/16 of a degree.

Has anyone else got the same issue.

Is it a hardware(probe) fault? in which case why do two probes both report exactly the same wrong reading, does -22.5 have a meaning which the driver should trap / report.

Each installation that shows the problem uses a single probe on the 1-wire bus powered from the Pi 3.3V pin. The data line has a single 4.7k pull-up resistor connected to the 3.3V line. Oh and GND of course.

philipBC
Posts: 14
Joined: Fri Aug 12, 2016 1:15 pm

Re: DS18B20 reads -20.5

Wed Oct 05, 2016 3:15 pm

After a little more research, I think the -22.5 occurs when attempting a second read on the sensor as quickly as possible. So a timing issue.

The DS18B20 datasheet states the sensor takes 750ms when in mode 7F to carry out the A/D conversion.

What is not clear is how the DT Overlay 1-wire driver handles a second request for data if under the 750 ms required to make a new conversion.

I am going to try to ensure a 1000ms gap between requests for data from the same sensor... and see how that goes.

philipBC
Posts: 14
Joined: Fri Aug 12, 2016 1:15 pm

Re: DS18B20 reads -20.5

Fri Oct 07, 2016 1:50 pm

Yes, if I ensure that I don't re-read the same sensor for 1sec (1000ms) then the reading of -22.5 does not occur.
I have built my own function (in NODEJS) to interpret the w1_slave file and I now trap readings of ...

85 - occurs upon sensor power reset
-22.5 - occurs as described
0, when the resolution config byte is not 7F - occurs when the sensor is trying to power from the data line (parasitic power mode) but the line cannot supply the necessary current... and it cant if you have a 4.7K pullup resistor on the data line.

In each case, I use a setTimeout call for 1000 ms and then fetch the data from w1_slave again.

This seems to do the trick.

I suspect that most of these conditions should really be caught by the DTOverlay Driver, rather than require a workaround.. but there you go.

Return to “Other programming languages”