DS18B20 - offset increases with temperature

When I got my first ds18b20 digital temperature sensors I was surprised at how accurate and stable they were compared to the analog sensors I had been using. Now after a few months I've noticed that this is only in a certain temperature range. It appears that the offset from real temperature increases as the temp rises. Two examples:

  1. Monitoring room temperature. At 16.5°C the sensor is off by less than 0.2°, but at 17.5°C it is off by up to 0.5°. I check this against the room thermostat, which is ~50cm away from the sensor, and against an IR thermometer. Kinda sucks since I'm trying to build my own thermostat, so I'd like the offset to at least be constant.
  2. I have sensors monitoring the heating system's supply and return water temperature. The sensors are inside the boiler, on the copper pipes where the boiler's temp sensors are, covered with foam insulation. When the boiler is off and the plumbing has cooled down to ~20°C then the ds18b20's show about the same temp as the boiler's sensors, but when the boiler is on and the supply is at 50°C, then the ds18b20 shows no more than 42°C. On a few occasions I've checked the temps with the IR thermometer and it is closer to the boiler's sensors than the ds18b20.

All 4 of my ds18b20's have these discrepancies, while the data sheet claims ±0.5°C accuracy from -10°C to +85°C.

You can't measure an accurate temperature with an IR temperature meter. The material you are pointing at influences the temperature. You need for example a thermocouple meter.

I wouldn't surprise me, if the DS18B20 turned out to be accurate after all.

Can you cover the DS18B20 in something and use boiling water to see if it is 100 degrees Celcius.

Two examples

That's assuming that the other measurements are more accurate than the DS. How do you know that?

Krodal:
You can't measure an accurate temperature with an IR temperature meter. The material you are pointing at influences the temperature.

I know that copper is good at reflecting heat, so I put black electrical tape on the spot where I check with the IR. Didn't change the reading much, though, if at all.

dhenry:
That's assuming that the other measurements are more accurate than the DS. How do you know that?

I don't know for sure, but I admit that I assumed that the sensors on the boiler are more or less accurate. Even if they aren't, and the ds18b20 is, then could they be off by more than 10° at the temperatures they were designed/installed for (showing 55°C when the ds18b20 shows only 44°C)? I woundn't expect that on a not-too-cheap boiler.

but when the boiler is on and the supply is at 50°C, then the ds18b20 shows no more than 42°C.

Does the DS18B20 itself have the same temperature as the boiler's sensor? That means, have you ensured that there's a good heat transfer from the copper pipes to the DS18B20? The value it's returning is the temperature of the black enclosing it's in. If you don't take care that this temperature is the same as that of the object you wanna measure you will get differences in the reading.

In my experience the DS18B20 is accurate to about 0.5°C, at least in the range of -20°C to 100°C. But I used it only for measuring air and liquid temperatures (the later using a sealed steel version of the sensor).

pylon:
Does the DS18B20 itself have the same temperature as the boiler's sensor? That means, have you ensured that there's a good heat transfer from the copper pipes to the DS18B20?

The copper pipe is wrapped in foam insulation and the DS is tucked under that insulation. It is either touching the pipe, or is within 1mm of it (if I move the insulation to see, then the sensor moves around). So the reaction time may not be fast, but since copper is a much worse insulator than foam, then the temperature under the insulation should be very close to the temp of the water after a few minutes.

I checked around with the IR meter and when the boiler claims its supply is 55°C, then the pipes (many types, sizes, etc.) in the basement were all above 51°C, while the ds18b20 was still registering 42-44°C.

Since this seems to be only my problem I'll try to reinstall the sensors, maybe I'll tape them to the pipes to ensure contact, and add insulation around it.

I checked around with the IR meter and when the boiler claims its supply is 55°C, then the pipes (many types, sizes, etc.) in the basement all above 51°C, while the ds18b20 was still registering 42-44°C

you could use a heat conductive glue/pasta that is also used for processors and the cooling aluminium thingies.
Or if you use tape, you can take a iron file [metalowe opi?ki ?] to make the DS18 a bit round matching the diameter of the copper pipe. (maximizing contact)

Piwoslaw:

pylon:
Does the DS18B20 itself have the same temperature as the boiler's sensor? That means, have you ensured that there's a good heat transfer from the copper pipes to the DS18B20?

The copper pipe is wrapped in foam insulation and the DS is tucked under that insulation. It is either touching the pipe, or is within 1mm of it (if I move the insulation to see, then the sensor moves around). So the reaction time may not be fast, but since copper is a much worse insulator than foam, then the temperature under the insulation should be very close to the temp of the water after a few minutes.

I checked around with the IR meter and when the boiler claims its supply is 55°C, then the pipes (many types, sizes, etc.) in the basement were all above 51°C, while the ds18b20 was still registering 42-44°C.

Since this seems to be only my problem I'll try to reinstall the sensors, maybe I'll tape them to the pipes to ensure contact, and add insulation around it.

You don't have good thermal contact between the DS18B20 and the pipe.

Firstly you allow one side of the DS18B20 to radiate heat into the surroundings - the foam is probably highly transparent at
the long IR wavelengths that carry radiated heat.

Secondly you haven't bonded the sensor to the pipe with a thermal compound - so its not conducting heat very well from the pipe.

Thirdly the sensor will be conducting heat away down the wires to the surroundings.

You need to put the sensor and the first few inches of wiring inside a shiny aluminium tube, and bond that to the pipe
thermally, then wrap in foam. The metal tube is shiny - much less radiation loss. The tube conducts heat well to the sensor's
entire surface and wiring.

[edit: its a pity the device doesn't come in a metal can with a lug to screw it down! ]

Piwoslaw, I hope you are still reading this.

I bought the cheapest DS18B20 on Ebay that I could find.
And I used the OneWire library with the example for the DS18B20, so I'm sure that the checksum is tested.

I tried boiling water (should be 100 degrees Celsius) and read 98.8
I tried ice-water (should be 0 degrees Celsius) and read 0.9

My conditions are not optimal. I think that my wires took away some of the heat and cold. I soldered wires very close to the black plastic.

So I can say that the DS18B20 is very accurate.

I tried boiling water (should be 100 degrees Celsius) and read 98.8
I tried ice-water (should be 0 degrees Celsius) and read 0.9

Note these are on see level and with distilled water!
@Krodal,
at what elevation do you live?

assuming linear error in formula: RealTemp = (measuredtemp - 0.9) *100.0/(98.8 - 0.9);
Q: at which temp is real temp == measured temp ?

robtillaart, I did this in a mug in my kitchen with normal tap water, about 3 meters above sea level.
So my measurements are not very accurate, but it's close enough to assume that the DS18B20 is very accurate.

yes, they are quite accurate (although not calibrated).

As your measurement is at sea level the boiling point is ~100°C but it goes down quite fast with heigth (-1.1°C for every 1000 feet)
See - Water Boiling Point vs. Altitude -