SHT31 Accuracy

I just purchased 4 of the SHT31 temperature and humidity sensors with the goal of setting them up around the house. I was able to quickly get one set up and working connected to an ESP8266 controller using the Adafruit library. However, I noticed that the temperature reported is about 5-6 degrees (F) warmer than the other thermometers I own (my thermostat and a little weather station). As an example, I have my thermostat set to 70, but my office is a bit warmer due to lights and PCs, so my weather station reports 74, and the SHT31 is reporting 80! This discrepancy is on all 4 devices. I converted the output of the library from C to F (C*9/5 +32) myself, and I don't think there's that much error in the conversion. Are these devices really accurate to 0.3 degrees C (0.5-0.6 F)? Have I overlooked something?

ahettlin

Posts: 6
Joined: Thu Feb 15, 2018 9:48 pm

Re: SHT31 Accuracy

Make sure you are using floating point math. In some compilers if you use integers in your formula the result is cast as an integer. try
Code: Select all | TOGGLE FULL SIZE
(c * 1.80) + 32.0

franklin97355

Posts: 19437
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: SHT31 Accuracy

I should have mentioned that I did check to make sure it was doing floating-point math. I had originally used integer constants assuming it would up-cast to floats, but then changed them to be explicit float values with no change in the result. I even changed the multiplication+division to just the single multiplication with no change (as expected).

I'm also using the Arduino IDE.

My exact code is
Code: Select all | TOGGLE FULL SIZE
if (! isnan(t)) {
t = (t * 1.8) + 32.0;

// ... do stuff with the value
}

ahettlin

Posts: 6
Joined: Thu Feb 15, 2018 9:48 pm

Re: SHT31 Accuracy

Temperature sensors can vary a lot. Sometimes due to factors such as self-heating or heating from adjacent components. And the manufacturer's spec definition of 'accuracy' often comes with lots of footnotes and fine print.

The good news is that most of them do tend to produce consistent results, so good accuracy can be achieved via calibration.

Posts: 70480
Joined: Sat Feb 07, 2009 10:11 am

Re: SHT31 Accuracy

Thanks for that article! Too bad I didn't find that sooner. I was suspecting that I may have to do some calibration. Even a simple offset will likely be good enough for my purposes. Maybe if I'm feeling up to it I could try to get a linear scale factor. Thanks again.

ahettlin

Posts: 6
Joined: Thu Feb 15, 2018 9:48 pm

Re: SHT31 Accuracy

Glad that you found the article to be useful. Some sensor manufacturers use the word 'accuracy' when what they are really testing is 'linearity' and/or 'precision'. Although the terminology is somewhat misleading, you can still achieve true accuracy with calibration.

Posts: 70480
Joined: Sat Feb 07, 2009 10:11 am

Re: SHT31 Accuracy

Looking at the suggestions for the 2-pint calibration, it will be pretty hard to give the sensor an ice/boiling water bath given that it isn't waterproof. Any suggestions for going about that? Maybe calibrating a different thermometer that is waterproof with the baths, then calibrating the SHT31 against that over a range of temperatures?

ahettlin

Posts: 6
Joined: Thu Feb 15, 2018 9:48 pm

Re: SHT31 Accuracy

Yeah, the terminology can be a sticking point. There definitely is a difference between accuracy and precision and I may have gotten a bit too excited when I read "accuracy". I did notice the readings are fairly precise, fluctuating only a couple tenths of a degree.

ahettlin

Posts: 6
Joined: Thu Feb 15, 2018 9:48 pm

Re: SHT31 Accuracy

Yea, you don't want to be dunking the SHT in water - regardless of the temperature. I'd run it side-by-side with a calibrated reference thermometer over the range that spans the expected temperatures for your SHT.

Posts: 70480
Joined: Sat Feb 07, 2009 10:11 am

Re: SHT31 Accuracy

Thanks. That's what I was thinking.

ahettlin

Posts: 6
Joined: Thu Feb 15, 2018 9:48 pm