Electronic – Fine-tuning/calibrating DS18b20 thermometer via 1-wire

1-wirecalibrationraspberry pitemperature

I am trying to enable remote reading of the temperature gauges in my furnace room by adding DS18B20 thermometers.
Since I had some Raspberry Pis and DS18B20s, and some networking equipment on hand, I decided to crimp on a couple of RJ45 jacks and chain some RJ45 sockets together, with a final network cable with a 1kΩ resistor between the data and 3v wires. This works fine, except for the fact that the temperatures diverge more than I'd like…

Executing cat /sys/bus/w1/devices/28*/w1_slave returns the temperature, but even with the sensors lying next to each other, they diverge by more than 1.5°C I have monitored them over a longer period of time, even covering them with my hand, and keeping them right next to each other.

Sample output

ad 01 55 05 7f 7e 81 66 16 : crc=16 YES
ad 01 55 05 7f 7e 81 66 16 t=26812
b4 01 55 05 7f 7e 81 66 2b : crc=2b YES
b4 01 55 05 7f 7e 81 66 2b t=27250

My setup

Raspberry pi model B rev 2 with RJ45 connectors and 2 DS18B20 thermometers attached

Is there a way to calibrate them to the same temperature? I would hate to have to take individual quirks into account, as even if I was to round to nearest 2°C there is no real way to be sure they would be in the same increment. And replacing sensors would mean recalibrating values in my code.

The reason for wanting this is that I want to detect whether the furnace is heating the water at the moment, or the water is at target temperature, or (hopefully not) that the incoming water is warmer than the outgoing water, meaning that my hot water tank is heating the house. If I cannot trust the readings, I may get too many false positives.

I have read guides like this instructable, but as far as I can see, this is gathering the calibration data, and not calibrating the actual sensor…

Best Answer

Unfortunately, fake DS18B20 devices are well known to be (a) inaccurate, and (b) have varying readings even in a stable environment. The chances of your devices from eBay being fake, is approximately 100%.

This graph, taken from this answer on the earlier question: "Which one of these DS18B20 temperature sensors is fake?" shows the problem. The one genuine device is obviously the stable, top red line. The other 4 unstable and inaccurate readings are from the fake devices.

Graph showing unstable and inaccurate readings from fake DS18B20 devices

Answers to that earlier question have several useful links, including this GitHub repo:

https://github.com/cpetrich/counterfeit_DS18B20

which has two Arduino sketches that can help to identify fakes.

Useful search terms include - DS18B20 counterfeit accuracy

Related Topic