Electronic – ds18b20 temperature sensor data changes with additional lead wire

1-wireraspberry pisensorthermalwire

I've been working with some ds18b20 temperature sensors and I noticed something funny which I can't wrap my head around. For starters, I know the ds18b20 sensors are not "top of the line" and I've also read there are "many knockoffs" found in the market. These facts are not the focus of this question and the sensors fit my application. On to the question…

There are numerous resources out there which tell you how to wire up the sensors, so I'm pretty sure I got this right. I'm taking readings using a Raspberry Pi, which again, there are many resources which tell you how to interface the 1-wire device in software. In summary, the sensor is connected to a 5V pin on the Pi with a 4.7K pullup resistor between the 5V and data pins (also grounded of course). I'm able to read the sensor data via a Python script and the values are certainly within the ballpark. Again, this is not the issue, I'm just painting the full picture for completeness.

I have the Pi + sensor in a small box about 10cm^3 which is enclosed for the most part (i.e. no direct light, wind, etc.) and I've been running some tests indoors (consistent ambient temperature). I run the software for about 5mins until the temperature stabilizes in the box at 31.687 C, which is very close to what other temperature sensors (multimeter and infrared gun) are reading. Now to be very clear, I'm not trying to calibrate the sensors…I'm just trying to see if they're in the ballpark of other sensors.

The wiring for the temperature sensor uses 22 AWG solid core with lead wires about 5-7cm in length. Again, the initial temperature stabilizes at 31.687 C. I then added 26 AWG stranded core lead wires about 20cm in length between the Pi and the previous 22 AWG lead wires (basically, an "extension cord"). The temperature now stabilizes at 30.437 C. This is where my question comes in.

I get that the sensors have a +/-0.5 C rating, but I'm using the same sensor in the same box under the same conditions. I've repeated this test probably 10 times and I consistently get the same difference of about 1C. I don't understand why adding the "extension cord" would cause a difference. As a sanity check, I also swapped out the sensor and repeated the experiment. I found consistent behavior, but a difference of about 0.5 C. Overall, it seems the conclusion is that an "extension cord" will reduce the temperature readout (in my case 1/0.5 C respectively).

I don't know how to explain this "conclusion" and I'm hoping for insights. I initially thought it would be related to the "added resistance" of the "extension cord", but it is only about 20cm long, which from what I gather is "negligible" (I could very well be wrong here). I don't know…at this point I'm grasping at anything to understand why the sensors would give a different reading with the addition of the "extension cord".

Best Answer

I've spoken to an engineer at maxim about this sensor, and one thing he told me is that the ground pin has high conductivity to the temperature sensing element.

It may be that the change in wiring is conducting heat into the sensor differently. The pi will be dissipating a fair amount of heat in the box, so there will have to be some gradients in there.