0

This is a follow-up question from this other question

I followed of the user Jot (get the sensor away from the sun and use a delay in arduino program)

But the results are still varying.

I recorded the temperature measured in the sensor, the temperature measured using a mercury thermometer and calculated the difference. The data was collected within 8 days

Here's the data (sorted):

SENSOR  THERM   DIFF
32.69   31.25   1.44
32.00   30.25   1.75
31.94   30.50   1.44
31.87   30.50   1.37
31.44   29.50   1.94
31.00   29.00   2.00
30.75   29.00   1.75
30.50   29.00   1.50
30.44   28.80   1.64
30.31   28.90   1.41
30.25   28.75   1.50
29.87   28.00   1.87
29.81   28.00   1.81
29.81   28.00   1.81
29.81   28.25   1.56
29.75   28.20   1.55
29.69   28.00   1.69
29.56   27.00   2.56
28.75   27.25   1.50
28.69   27.00   1.69
28.56   27.00   1.56
28.44   27.00   1.44
28.25   26.80   1.45
28.00   26.50   1.50
28.00   25.50   2.50
28.00   25.00   3.00
27.75   25.50   2.25

The average difference is around +1.76°C but that's not linear, and as you can see there are fluctuation in the same sensor value, 28.00 has three associated temperatures(25.0, 25.5, 26.5).

I'm not sure what to do, if the difference was regular I could simply subtract that from the sensor readings, but it seems that it varies a lot(Min: 1.37°C, Max: 3.00°C)

Any ideas?

  • good use of data! it's actually not that far off for a $1 sensor. If you subtract 1-2C from the sensor, you'll be pretty close on almost every sample. try a DHT22 for more precision. – dandavis Mar 9 '17 at 20:50
  • The best fit linear model would be THERM_HAT=SENSOR*1.10237- 4.81422 per ` summary(fit<-lm(THERM ~ SENSOR,x))` in R. – Dave X Mar 9 '17 at 21:03
  • Most readings are pretty consistent. There are only a few that are way of. But there could be some other factor that was influencing the reading. Maybe there was a draft. Maybe you made multiple reading in a row which would slightly warm up the part.... – Gerben Mar 10 '17 at 11:26
1

This isn't so much an Arduino question, but you are asking how to do better than a simple offset. The next level of complexity is to do an offset and scale.

If this is the best data you can get from your setup, a better calibration than just an offset would be finding the best offset and scale. You can do this with your data in R with:

> x<- read.table(header=TRUE,text="SENSOR  THERM   DIFF
 32.69   31.25   1.44
 32.00   30.25   1.75
 31.94   30.50   1.44
 31.87   30.50   1.37
 31.44   29.50   1.94
 31.00   29.00   2.00
 30.75   29.00   1.75
 30.50   29.00   1.50
 30.44   28.80   1.64
 30.31   28.90   1.41
 30.25   28.75   1.50
 29.87   28.00   1.87
 29.81   28.00   1.81
 29.81   28.00   1.81
 29.81   28.25   1.56
 29.75   28.20   1.55
 29.69   28.00   1.69
 29.56   27.00   2.56
 28.75   27.25   1.50
 28.69   27.00   1.69
 28.56   27.00   1.56
 28.44   27.00   1.44
 28.25   26.80   1.45
 28.00   26.50   1.50
 28.00   25.50   2.50
 28.00   25.00   3.00
 27.75   25.50   2.25
 ")

summary(lm(THERM ~ SENSOR,x))

... to get:

Call:
lm(formula = THERM ~ SENSOR, data = x)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.05217 -0.16263  0.08482  0.21809  0.47224 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) -4.81422    1.60425  -3.001  0.00602 ** 
SENSOR       1.10237    0.05369  20.533  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.3816 on 25 degrees of freedom
Multiple R-squared:  0.944, Adjusted R-squared:  0.9418 
F-statistic: 421.6 on 1 and 25 DF,  p-value: < 2.2e-16

... from which you can use the intercept and SENSOR parameters as an intercept and scale like:

therm_estimate = -4.81422 + 1.10237 * sensor;

You could plot the data in R like:

library(ggplot2)
ggplot(x,aes(x=SENSOR,y=THERM))+geom_point() +geom_smooth(method='lm')

Plot of THERM vs SENSOR with best-fit line

Looking at the graph and data, your mercury thermometer is reading sometimes to the nearest 0.1th, and sometime to the 0.25th, and that is causing patterns in your data. Maybe use a better, high-accuracy, calibrated lab thermometer if you want to be sure you aren't calibrating against something unreliable.

0

Can you buy a few more from other (more reliable) sellers ? Perhaps it is damaged. Did you accidently connect it wrong and it got very hot ?

There has been counterfeit DS18B20 sensors, but they were transistors that were re-labeled as DS18B20. Those didn't work at all.

You have not convinced me that you are only measuring the air temperature. Maybe there is still something nearby that causes it to get warmer. The 3 degrees difference is a lot. There must be a good reason for that, or else the DS18B20 is broken. How accurate is that mercury thermometer ?

I wrote before: "To be sure you can put it in distilled water at sea level at 0°C (water and ice cubes) and 100°C (boiling water)". That is what I did, out of curiosity. It turned out to be accurate.

  • Yes, I did the distilled water test. The mercury sensor is spot on on those temperatures. I was about to buy some others sensors but I can't be sure if those will be good either, buying from the internet is always a risk, I haven't damaged the sensor as far as I know. – f.rodrigues Mar 9 '17 at 20:53
  • Make sure there they are measuring the exact same physical temperature -- pack the thermometer and sensor together in a little box or something to minimize air currents and stabilize the transients. The mercury thermometer could also be non-linear in the range of interest, even it it matches at the 0,100C. Lab-grade thermometers are graduated to the nearest 0.1C, rather than the 0.25C you are reporting. – Dave X Mar 9 '17 at 21:09
  • Buy a few more to compare. The DS18B20 can return a temperature that is maximum 0.5°C below up to 0.5°C above the actual temperature. As far as I know every single one of them meets that specification. – Jot Mar 9 '17 at 21:37
  • The DS18B20s would be easy to automatically test and cull during production. Much easier than consumer-grade liquid thermometers. – Dave X Mar 9 '17 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.