Temperature sensor accuracy.
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 57
- Joined: 22 Sep 2022, 20:04
Temperature sensor accuracy.
Just a small question, how to have the real precision of a temperature sensor ?
If I define 5 as decimal value, the values 3 and 4 etc... are always 0.
But if I use a direct arduino code, I have the right value, which seems to validate that the temperature sensor gives the right precision.
ESP Easy Arduino test ESPEseay Oled Regards
If I define 5 as decimal value, the values 3 and 4 etc... are always 0.
But if I use a direct arduino code, I have the right value, which seems to validate that the temperature sensor gives the right precision.
ESP Easy Arduino test ESPEseay Oled Regards
You do not have the required permissions to view the files attached to this post.
-
- Normal user
- Posts: 4341
- Joined: 10 Jun 2018, 12:06
- Location: NL
Re: Temperature sensor accuracy.
Looking at the ESPEasy code and the Arduino library code, they both use the same method for extracting the temperature and humidity from the received data. That is a signed int value, to be divided by 10 (or multiplied by 0.1), so the actual accuracy is only 1 decimal. I expect the Arduino inaccuracy comes from the Serial.print() function, and the ESPEasy code is returning the most accurate result.
/Ton (PayPal.me)
-
- Core team member
- Posts: 9921
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Temperature sensor accuracy.
The nr of decimals only represent the formatting of the values already present.
But it looks like the temperature from the DHT22 is already "rounded" to 1 decimal before it is handed over for further processing.
As can be seen here, it is actually been truncated to 1 decimal:
https://github.com/letscontrolit/ESPEas ... #L288-L318
However, I do remember some of these sensors may have a separate register for the extra bits of resolution (pun intended
)
I will check the datasheet to see if this is actually true for the DHT22.
Edit:
Nope, the resolution is 0.1C.
See the datasheets:
https://www.sparkfun.com/datasheets/Sen ... /DHT22.pdf
https://cdn-shop.adafruit.com/datasheet ... AM2302.pdf
Edit2:
I noticed you try to convert it to Fahrenheit.
See here what you can use for the formula field: https://espeasy.readthedocs.io/en/lates ... fahrenheit
But it looks like the temperature from the DHT22 is already "rounded" to 1 decimal before it is handed over for further processing.
As can be seen here, it is actually been truncated to 1 decimal:
https://github.com/letscontrolit/ESPEas ... #L288-L318
However, I do remember some of these sensors may have a separate register for the extra bits of resolution (pun intended

I will check the datasheet to see if this is actually true for the DHT22.
Edit:
Nope, the resolution is 0.1C.
See the datasheets:
https://www.sparkfun.com/datasheets/Sen ... /DHT22.pdf
https://cdn-shop.adafruit.com/datasheet ... AM2302.pdf
Edit2:
I noticed you try to convert it to Fahrenheit.
See here what you can use for the formula field: https://espeasy.readthedocs.io/en/lates ... fahrenheit
-
- Core team member
- Posts: 9921
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Temperature sensor accuracy.
Just wondering, as I never heard of this "Heat Index".
I see it being defined here: http://www.wpc.ncep.noaa.gov/html/heati ... tion.shtml
But this is using the temperature in Fahrenheit.
Is this "Heat Index" something mainly used in the States?
I see it being defined here: http://www.wpc.ncep.noaa.gov/html/heati ... tion.shtml
But this is using the temperature in Fahrenheit.
Is this "Heat Index" something mainly used in the States?
-
- Normal user
- Posts: 57
- Joined: 22 Sep 2022, 20:04
Re: Temperature sensor accuracy.
Forget about Fahrenheit.
It was simply in the DHT Arduino example code.
For me the °C was enough.
Let's not look for conversion, just precision.
It was simply in the DHT Arduino example code.
For me the °C was enough.
Let's not look for conversion, just precision.

-
- Core team member
- Posts: 9921
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Temperature sensor accuracy.
Well the sensor doesn't have any extra resolution.
Your Arduino test code does show the same in the first 2 columns.
The later columns have values which were converted to this "heat index" (Celsius and Fahrenheit)
Your Arduino test code does show the same in the first 2 columns.
The later columns have values which were converted to this "heat index" (Celsius and Fahrenheit)
-
- Normal user
- Posts: 57
- Joined: 22 Sep 2022, 20:04
Re: Temperature sensor accuracy.
If I understand your explanations, it is the Ardruino code that gives a virtual precision, the DHT returns in this format XXX.X
It is therefore the sensor that returns a limited format and if I want a greater precision, I must use another type of sensor (MCP9808).
It is therefore the sensor that returns a limited format and if I want a greater precision, I must use another type of sensor (MCP9808).
-
- Core team member
- Posts: 9921
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Temperature sensor accuracy.
Nope, the Arduino library you're using does give the same resolution.
Only if you convert the temperature to compute some Heat Index value based on both temp and humidity, then you see extra decimals occur.
Before you're diving into buying expensive sensors, let me show you this chart:

Blog where this image is used
It is very hard to get accurate temperature measurements as you need to take into account lots of factors.
For example reading a sensor more often, may heat up the sensor itself.
Also the location of the sensor makes a lot of difference. Like the ESP itself will produce heat and thus affect the readings when the sensor is close.
So you have to ask yourself:
Why do I need a higher resolution?
Do I need higher precision or higher accuracy?
After you've found yourself a satisfying answer, please throw away those DHTxx sensors as they aren't really that good anyway. (even though the DHT22 is already way better than the DHT11)
We can of course help you with finding a proper sensor, but then we must also know about the use case.
Only if you convert the temperature to compute some Heat Index value based on both temp and humidity, then you see extra decimals occur.
Before you're diving into buying expensive sensors, let me show you this chart:

Blog where this image is used
It is very hard to get accurate temperature measurements as you need to take into account lots of factors.
For example reading a sensor more often, may heat up the sensor itself.
Also the location of the sensor makes a lot of difference. Like the ESP itself will produce heat and thus affect the readings when the sensor is close.
So you have to ask yourself:
Why do I need a higher resolution?
Do I need higher precision or higher accuracy?
After you've found yourself a satisfying answer, please throw away those DHTxx sensors as they aren't really that good anyway. (even though the DHT22 is already way better than the DHT11)
We can of course help you with finding a proper sensor, but then we must also know about the use case.
-
- Normal user
- Posts: 57
- Joined: 22 Sep 2022, 20:04
Re: Temperature sensor accuracy.
In fact, you don't need to be very precise.
My question was related to the fact that in ESPEasy we could define the number of decimal places.
Let's not waste any more time with that, it was if there was an error in my use or in the code.
By reading your comments, by reading documents, indeed the heat index is a bit like the dew point, it is calculated.
Thank you very much for all your answers.
My question was related to the fact that in ESPEasy we could define the number of decimal places.
Let's not waste any more time with that, it was if there was an error in my use or in the code.
By reading your comments, by reading documents, indeed the heat index is a bit like the dew point, it is calculated.
Thank you very much for all your answers.
-
- Core team member
- Posts: 9921
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Temperature sensor accuracy.
The nr of decimals is merely a formatting parameter.
Thus "10" may become "10.0000" when set to 4 decimals.
If there isn't any more decimals available in the data, it may not make sense to increase the nr of decimals.
For example the amount of free memory in Bytes doesn't even make sense to have any decimals at all.
Most can do perfectly well with 2 decimals. Some units of measure, like GPS lattitude and longitude coordinates may typically need upto 6 decimals to not loose any present information/resolution.
Thus "10" may become "10.0000" when set to 4 decimals.
If there isn't any more decimals available in the data, it may not make sense to increase the nr of decimals.
For example the amount of free memory in Bytes doesn't even make sense to have any decimals at all.
Most can do perfectly well with 2 decimals. Some units of measure, like GPS lattitude and longitude coordinates may typically need upto 6 decimals to not loose any present information/resolution.
-
- Normal user
- Posts: 57
- Joined: 22 Sep 2022, 20:04
Re: Temperature sensor accuracy.
I agree with you.
I was just asking the question, I didn't ask about the accuracy of the sensor used itself.
But yes, the real question is, what accuracy do I need.
What will I do with the value I get.
Real questions.
For what I'm doing right now, 1 or 2 decimal places is enough.
I was just asking the question, I didn't ask about the accuracy of the sensor used itself.
But yes, the real question is, what accuracy do I need.
What will I do with the value I get.
Real questions.
For what I'm doing right now, 1 or 2 decimal places is enough.
-
- Core team member
- Posts: 9921
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: Temperature sensor accuracy.
And do realize that resolution, precision and accuracy are related but absolutely different parameters.
You can have low resolution, low accuracy and high precision.
But such a combination is often as useful as a stopped clock.
You can have low resolution, low accuracy and high precision.
But such a combination is often as useful as a stopped clock.
Who is online
Users browsing this forum: Ahrefs [Bot], Anthropic Claude Bot [bot] and 1 guest