# ds18b20 temperature sensor data changes with additional lead wire

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".

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.

• OK...so the "extension cord" might be allowing more heat to "dissipate/disperse", hence causing the reduced temperature reading? That would make sense. My initial thought was that the "extension cord" was too short to make a difference but that's why I ask the experts. Can you maybe elaborate a bit on what this means and what are the implications: "the ground pin has high conductivity to the temperature sensing element" May 2, 2020 at 0:58
• The last part means that if you change the temperature that the ground wire is exposed to, you will likely change the reading to some degree. The classic example of this is mounting the sensor in a probe, where the wire is not at the same temperature as the medium being measured. That's not the case for you, but it still make have an effect depending on the mechanical arrangement.
– Drew
May 2, 2020 at 5:43

lets do a bit of math:

Standard copper foil (35 microns thick) has 70 ° Centigrade per watt per square of foil, for any size foil.

Lets use that to predict your 1 ° C temperature change.

22 AWG is area of 0.32 square milliMeters, or about 0.55mm on a side. 550micron/35micron is about 17 layers of that foil.

Thus our thermal resistance, per square (which is 0.55mm), is 70 ° C. In a 0.55mm cube, the Rthermal is 70/17 (the # of layers) or about 4 degree.

Your wire is 5cm or 50mm long, or 100 cubes of 0.55 mm.

Thus the thermal resistance of that wire is 400 ° Centigrade per watt.

Apparently you have 2.5 milliWatts flowing out of the MCU PCB.

========================

For 26 AWG? Lets do this for 25AWG, because the wire-extruding dies double in area for every 3 (THREE) numbers of decrease. Thus we know 25AWG has 1/2 the area and (forbidding in our thought experiment any heat escaping from the wire) the Thermal Resistance precisely doubles, to 800 ° C pre watt.

By the way, your head/face has to dump 100 watts into the environment; is your nearly body causing the temperature gradient?

• I really like your quantitative approach. The information you provided helps me understand some properties of the "main" leads (22AWG solid) extending from the sensor. However the 1C drop is due to the addition of the "extension cord" (26AWG stranded). I think we'd have to swap out the 22AWG for a 26AWG wire (assume solid) in your analysis? May 2, 2020 at 1:38
• You can use HTML entities in your posts: &deg; for degrees, &Omega;, &mu;, etc. + <sub>...</sub> and <sup>...</sup> for sub and superscript. May 2, 2020 at 15:53