Electronic – I have three DS18B20’s. I can’t tell if any of them are working correctly

1-wirelinuxsensortemperature

I have three DS18B20's (or I believe at least two of them are DS18B20's). I am currently reading them through an embedded Linux board (Raspberry Pi in this case).

I have two of the sensors in a breadboard, they give seemingly accurate temperatures. The third one is one of those DS18B20's enclosed in a "waterproof" cable from Ebay like this:

enter image description here

When I read the sensors I get the following readings:

pi@raspberrypi:~ $ cat /sys/bus/w1/devices/28-*/w1_slave
45 01 4b 46 7f ff 0b 10 84 : crc=84 YES
45 01 4b 46 7f ff 0b 10 84 t=20312
57 01 4b 46 7f ff 09 10 c7 : crc=c7 YES
57 01 4b 46 7f ff 09 10 c7 t=21437
60 01 80 80 1f ff 80 80 2e : crc=2e YES
60 01 80 80 1f ff 80 80 2e t=22000

So what this command does is simply get all the sensors and read from them. Pretty simple. Divide t=20312 by 1000 and you get 20.312°C

But the odd thing is that the third sensor will only ever give temperature measurements that are to within 0.5 degrees, whereas the other two are capable of measuring down to what seems to be 0.1 degrees. At first I thought that the third one was broken, but when I checked the datasheet it clearly specifies that the part is accurate to ~0.5 degrees.

I have made a table of the values I'm getting:

Breadboard Sensor #1 | Breadboard Sensor #2 | Cable Sensor
21.937                 21.562                 22.00
21.812                 21.562                 22.00
20.468                 20.478                 22.50
19.584                 20.201                 27.00
19.625                 19.687                 28.00

So now I'm totally confused. Are the breadboard sensors broken, or is the cable? If they are all working, they why is that two of them seem to have a higher resolution?

Edit: I've been searching around more and it seems that there a few people who have encountered this, and other people have suggested that they might be fake chips!

Update: The device driver for the sensors (https://www.kernel.org/doc/Documentation/w1/slaves/w1_therm):

The driver also doesn't support reduced precision (which would also
reduce the conversion time).

Best Answer

Looking at w1_therm's source code, it doesn't ever touch the configuration register, therefore relying on the programmed precision setting in EEPROM.

Indeed your own data dump shows that the configuration byte is 0x7F for two of your sensors and 0x1F for one of your sensors. This corresponds to 12 bits and 9 bits of precision respectively.

So all you need to do is initialize the configuration of your low-precision temp sensor once, store to EEPROM and then you can use the original driver again. Of course, a contribution of some cleaned-up code to set precision would probably be welcomed by the Linux community ;)