iwiber
Posts: 11
Joined: Thu May 02, 2019 1:43 pm

My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 12:11 pm

Hi guys,

My ds18b20 is off (lower) by 3 to 5 °F randomly and I'm not sure what to test anymore. I put together a new one, same results. I followed this plan, with the exact same resistance.

Image

I assume it's off because, I test with a pool thermometer, and I also use an Aqua Euro Max Chill 1/2 HP Chiller, which indicates the temp. As I'm writing this:

Pool Thermometer: 58°F
Chiller: 55°F
ds18b20: 53°F

The pool Thermometer I'm using is cheap ($4), but the chiller it's another story ($1000+). Also, it's the first time the difference is over 1° betweem the pool thermometer and the chiller.

What do you guys think?

User avatar
B.Goode
Posts: 10725
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 12:24 pm

My ds18b20 is off (lower) by 3 to 5 °F randomly

Ref: https://www.maximintegrated.com/en/prod ... 18B20.html
The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements

So one 'obvious' question (to my inquiring mind) is: how are you converting the temperature? (Could there be a repeatable or random error in that calculation?)

Are all the readings taken simultaneously at the same point, free from convection, currents, eddys...

User avatar
bensimmo
Posts: 4988
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 12:32 pm

It's much easier to debug in C as the device measures in C.
Are you reading 11.5 and 12.0C or do you get the values in between.
Or lot read to half a degreeC by default

...
So the difference between 53F and 55C is just 1C, these have a 0.5C accuracy iirc, so if the reading is between two, that may be you full degree C out
Couple that with a conversion and the rounding.

Which seem pretty good to me.
Last edited by bensimmo on Mon May 13, 2019 12:36 pm, edited 1 time in total.

pcmanbob
Posts: 10116
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 12:33 pm

Well no temperature sensor is 100% accurate unless its been calibrated against a known good / calibrated thermometer.

The DS18B20 has an accuracy of ±0.5°C Accuracy from -10°C to +85°C, but its still possible yours might be outside the error range depending were you got them from there of lots of rejects for sale on the web.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
bensimmo
Posts: 4988
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 12:43 pm

pcmanbob wrote:
Mon May 13, 2019 12:33 pm
Well no temperature sensor is 100% accurate unless its been calibrated against a known good / calibrated thermometer.

The DS18B20 has an accuracy of ±0.5°C Accuracy from -10°C to +85°C, but its still possible yours might be outside the error range depending were you got them from there of lots of rejects for sale on the web.
Official proper DS18B20 are calibrated at source, they still have the ±0.5°C Accuracy you mention.

The cooler will have an accuracy as well, perhaps a response time too.

Andyroo

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 12:57 pm

I would ask how you know the other thermometers are correct? Just because they show the same temperature does not mean they are right.

Having worked for many many years with temperature controlled warehouse logging and reporting kit (some costing £k to set up), you have to go to an external calibration tool (with its calibration history) to set your kit up.

Given that most folk cannot tell a change of one or two degrees centigrade, I would not worry :lol: humidity is a greater factor in how ‘warm’ or how ‘cold’ people think it is than most folk understand.

Then again, this is being posted by a guy who has a clock in the room with no numbers on it so you may want to take a pinch of salt with the above :roll:

If you really need them to show the same temperature then you could always build a fudge factor into your program even if it’s a dictionary (assuming python) look up for each temperature:

[14: 1, 15: -2] etc where the key is the temp from the device and the data is the adjustment (code not checked :lol: )

iwiber
Posts: 11
Joined: Thu May 02, 2019 1:43 pm

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 1:06 pm

Hi guys,

In C:

DS18B20 = 11.6
Pool T. = 14.4

For the chiller I can't say, should be between 12.8-13.2

Andyroo

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 1:12 pm

Sorry but you have three uncalibrated devices, any one could be correct OR all three could be wrong.

I’ll bet my money on the last :roll:

iwiber
Posts: 11
Joined: Thu May 02, 2019 1:43 pm

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 1:22 pm

Any good ways to verify the real temp with quite good accuracy? I mean, besides a $50000 unit lol

Andyroo

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 1:50 pm

Four ways I can think of (though the guys at http://www.wxforum.net/ may have more):

Ice and boiling water assuming you do not live high in the mountains but even then you get differences due to the accuracy of the device sensor and risk killing the device.

If you know a store keeper who has fridges / freezers that are checked by the local health inspectors or council you could ask them to borrow a bit of space :lol:

Look for an official weather station locally and see if they have manual readings or if you can get a live feed from them.

The last way is to raid eBay / Amazon etc and buy a pile of cheap sensors and pick the ones that are close to each other :lol:

Just to really wind you up :lol: you also need to think about direct / indirect sun light, wet vs dry readings and even wind chill factor :roll: As soon as something goes digital the requirement for accuracy seeps into our brains - rather than ‘it is about 10 deg’ we need to see ‘it is 10.123456 deg’ :lol:

I’m more a https://en.m.wikipedia.org/wiki/Weather_rock type of guy - accuracy is fine for work when customers demand it or public health is involved but the cost outweighs the string and stone solution.

User avatar
omegaman477
Posts: 148
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 5:43 pm

iwiber wrote:
Mon May 13, 2019 1:22 pm
Any good ways to verify the real temp with quite good accuracy? I mean, besides a $50000 unit lol
Boiling water and ice in distilled water, compensate for your altitude, there are online calculators.

But I would bet your only reading the top 9 bits and calculating against that, rather than the full 12. Or you have the two 'bytes' assembled in the wrong order.
..the only thing worse than a stupid question is a question not asked.

iwiber
Posts: 11
Joined: Thu May 02, 2019 1:43 pm

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 5:48 pm

omegaman477 wrote:
Mon May 13, 2019 5:43 pm
iwiber wrote:
Mon May 13, 2019 1:22 pm
Any good ways to verify the real temp with quite good accuracy? I mean, besides a $50000 unit lol
Boiling water and ice in distilled water, compensate for your altitude, there are online calculators.

But I would bet your only reading the top 9 bits and calculating against that, rather than the full 12. Or you have the two 'bytes' assembled in the wrong order.
Hello,

Not sure if you're referring to this, but I take the t= / 1000

c0 00 55 05 7f a5 a5 66 94 : crc=94 YES
c0 00 55 05 7f a5 a5 66 94 t=12000

Andyroo

Re: My temp sensor ds18b20 doesn't seems accurate

Mon May 13, 2019 6:31 pm

The t= does give you the temperature directly - no changes needed and it’s one of the reasons I like those chips.

The conversion to that odd measurement scale is straightforward and should not loose any real accuracy but do not forget if two accurate sensors are used you still may see a 1 deg C difference as one could be -0.5 and the other +0.5 so assuming it’s 0C you would read 31.1F and 32.9F - both are correct as they are in spec but the 31-33 range looks a lot to the mind...

This is assuming you have a real chip and not a ‘quick and dirty’ copy that may be a few deg C out or have a larger inaccuracy.

JohnsUPS
Posts: 188
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: My temp sensor ds18b20 doesn't seems accurate

Wed May 15, 2019 1:18 am

I have had this happen to me also.

Where were the sensors purchased?

I have about 30 of these sensors. 10 each were purchased from three different vendors. Two of the vendors were of Chinese origin, and the other was Mouser.

After the first order of 10, I realized they were not calibrated because they were not tracking each other to within the published specs - they should have at least tracked within about 1 deg C of each other. So, I ordered another 10 from a different Chinese vendor - same result - differing readings. Finally decided to spend a buck more per sensor and ordered some from Mouser (Digi-Key would also source directly from Dallas/Maxim). All of these sensors tracked each other perfectly - I recall it was much better than half a degree C. Not having any other temperature references handy (that were as accurate) for absolute comparison, I trusted that the Maxim sensors were in calibration partially because they all tracked each other so well.

The Chinese temperature sensors were all out of calibration (compared to the Maxim parts), and one was off by about 3 degrees C. I had six of the "bad" sensors in parallel, mounted next to each other in a row, so they all saw the same ambient temperature and source voltage, but the readings varied. Readings were consistent up or down depending on the room temperature, but all offset from one sensor to the next. The good sensors were deployed with a project I had going on at the time. To possibly get some use from the counterfeit sensors, I calculated offsets. I averaged the readings from four known good sensors (the "calibration standard") compared to one "bad" one. All wired in parallel and very close in physical proximity in order to calculate offsets for the bad sensors.

I would recommend that when it comes to these sensors, source from a reputable vendor and save some heartburn.

iwiber
Posts: 11
Joined: Thu May 02, 2019 1:43 pm

Re: My temp sensor ds18b20 doesn't seems accurate

Wed May 15, 2019 9:24 am

JohnsUPS wrote:
Wed May 15, 2019 1:18 am
I have had this happen to me also.

Where were the sensors purchased?

I have about 30 of these sensors. 10 each were purchased from three different vendors. Two of the vendors were of Chinese origin, and the other was Mouser.

After the first order of 10, I realized they were not calibrated because they were not tracking each other to within the published specs - they should have at least tracked within about 1 deg C of each other. So, I ordered another 10 from a different Chinese vendor - same result - differing readings. Finally decided to spend a buck more per sensor and ordered some from Mouser (Digi-Key would also source directly from Dallas/Maxim). All of these sensors tracked each other perfectly - I recall it was much better than half a degree C. Not having any other temperature references handy (that were as accurate) for absolute comparison, I trusted that the Maxim sensors were in calibration partially because they all tracked each other so well.

The Chinese temperature sensors were all out of calibration (compared to the Maxim parts), and one was off by about 3 degrees C. I had six of the "bad" sensors in parallel, mounted next to each other in a row, so they all saw the same ambient temperature and source voltage, but the readings varied. Readings were consistent up or down depending on the room temperature, but all offset from one sensor to the next. The good sensors were deployed with a project I had going on at the time. To possibly get some use from the counterfeit sensors, I calculated offsets. I averaged the readings from four known good sensors (the "calibration standard") compared to one "bad" one. All wired in parallel and very close in physical proximity in order to calculate offsets for the bad sensors.

I would recommend that when it comes to these sensors, source from a reputable vendor and save some heartburn.

I guess it's that then. I bought from Amazon but just saw the manufacturer is called Esooho

cpetrich
Posts: 1
Joined: Tue Oct 22, 2019 2:08 am

Re: My temp sensor ds18b20 doesn't seems accurate

Tue Oct 22, 2019 2:20 am

Based on the content of the scratchpad registers you posted it is clear that you got particularly poorly calibrated counterfeit DS18B20 sensors: we've calibrated a fair number of those sensors in an ice--water bath before and decided to call it a loss and use different ones instead. There are clearly better calibrated fakes available, if buying originals is not an option.

Here's a bit more general information on how to identify the bad guys and what surprises I found after looking at counterfeit DS18B20 more closely: https://github.com/cpetrich/counterfeit_DS18B20

lurifax.no
Posts: 1
Joined: Thu Sep 10, 2020 4:51 pm

Re: My temp sensor ds18b20 doesn't seems accurate

Thu Sep 10, 2020 4:58 pm

All these answers, and not one suggestion on how to calibrate the sensor?
Who care which device he owns is the most correct? All he wants is to calibrate the readings and make them read the same number.

DS18B20,1 - Reads 18c
DS18B20,2 - Reads 21c
DS18B20,3 - Reads 22

All in same vessel to calibrate the readings, whatever master temp is choosen, people who use and reads from several DS18B20, just want them to show the same temp in a known liquid.

And yes, it can be done. There is a brewing software named CraftBeerPi3 - in this software, there is a plugin to calibrate - and suprise suprise, after calibrating them in one known solution - they show the same reading from 20c - 99,5C

JohnsUPS
Posts: 188
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: My temp sensor ds18b20 doesn't seems accurate

Sun Sep 13, 2020 2:37 am

lurifax.no wrote:
Thu Sep 10, 2020 4:58 pm
All these answers, and not one suggestion on how to calibrate the sensor?
Who care which device he owns is the most correct? All he wants is to calibrate the readings and make them read the same number.

DS18B20,1 - Reads 18c
DS18B20,2 - Reads 21c
DS18B20,3 - Reads 22

All in same vessel to calibrate the readings, whatever master temp is choosen, people who use and reads from several DS18B20, just want them to show the same temp in a known liquid.

And yes, it can be done. There is a brewing software named CraftBeerPi3 - in this software, there is a plugin to calibrate - and suprise suprise, after calibrating them in one known solution - they show the same reading from 20c - 99,5C
I looked at a CraftBeerPi3 plugin that offered a DS18B20 calibration feature, and from the description of this particular plugin, all it does is calculate an offset for each sensor, and not modify the calibration register within the sensor itself. I was hoping that it modified the calibration register within the sensor - that would have been great.
https://onbrewing.com/craftbeerpi-3-plugins/

So long as the sensors maintain linearity over temp, which you indicated that they did, I guess then it would be OK. After all, this is what I did with the out-of-spec sensors I received. However I ultimately didn't use them. If I need to replace a sensor, then I would like to rely on the datasheet specs (which were adequate for my application) and not recalculate an offset each time. It just adds uncertainty into the system that I would rather do without.

mwrich4
Posts: 128
Joined: Wed Jul 25, 2012 1:24 pm
Location: Stuart, Florida

Re: My temp sensor ds18b20 doesn't seems accurate

Sun Sep 13, 2020 10:20 pm

Buy a thermistor and use an ADC to sample voltage after a properly scaled voltage divider and then calibrate for a more precise reading.


You can set the resolution of the ds18b20 to 12-bit, try calibrating, and check for stability. But as said, this part is rated at +/- 0.5C.

The one-wire bus is an interesting place to find a stable voltage, perhaps you can adjust the settle time before a read after the bus is energized and see if that helps repeatability.

Another thought about that one-wire part. Check that your internal port pullups are consistent between read/write modes and compatible with your external pull-up.

mlp6868
Posts: 35
Joined: Sun Sep 27, 2020 11:48 pm

Re: My temp sensor ds18b20 doesn't seems accurate

Mon Sep 28, 2020 9:26 pm

ok, this is a long thread already. One more suggestion: the sensors have an immutable and unique 64 bit serial number etched in. You see it here, on one of my Pis with 3 such sensors:

Code: Select all

# ls  -l /sys/devices/w1_bus_master1/
total 0
drwxr-xr-x 4 root root    0 Sep 12 10:35 28-00000673891b
drwxr-xr-x 4 root root    0 Sep 12 10:35 28-000006741c74
drwxr-xr-x 4 root root    0 Sep 12 10:35 28-0000067471a8


so the "28-" identifies the type of device and the rest is the serial number. Check yours if they look like that. Counterfeit ones might have strange values for the serial number.

You see that my serials are reasonably close. At work I have a setup where I bought a large number of sensors, hoping that there would be enough from the same production batch (and a good portion were, some with almost contiguous serials) . Those same-batch ones show a temperature that's even closer together than the rated 0.5 degC; when I put them together I get 0.2 degC between them.

Here are my readings from different places in the same general area from those 3 sensors:

Code: Select all

# cat  /sys/devices/w1_bus_master1/28-0000*/w1_slave | grep t=
d1 01 4b 46 7f ff 0f 10 6c t=29062
e5 01 4b 46 7f ff 0b 10 be t=30312
dd 01 4b 46 7f ff 03 10 1e t=29812
I have always been getting reasonable readings.

Hope it helps,
- mlp

Return to “Automation, sensing and robotics”