Adafruit DHT library returns incorrect resolution for DHT11

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ModelTrainGuy
 
Posts: 9
Joined: Tue Oct 30, 2018 8:01 pm

Adafruit DHT library returns incorrect resolution for DHT11

Post by ModelTrainGuy »

I wanted to open an issue at https://github.com/adafruit/DHT-sensor-library for the Adafruit DHR sensor library but it suggests I make sure its a bug over here first.

The sample sketch provided called DHT_Unified_Sensor.ino displays details about the temperature and humidity sensors. One of the properties is the resolution. For the tempertaure sensor it reports a resolution of 2.0°C
Temperature Sensor
Sensor Type: DHT11
Driver Ver: 1
Unique ID: -1
Max Value: 50.00°C
Min Value: 0.00°C
Resolution: 2.00°C
The resolution for this sensor is 0.1°C according to both the spec sheet and observation:
Temperature: 19.90°C Humidity: 35.00%
Temperature: 19.80°C Humidity: 35.00%
Here is a spec sheet that states 0.1°C:
https://image.dfrobot.com/image/data/KI ... asheet.pdf

The AOSONG DHT11 has a 2° accuracy, and they claim a 1°C resolution. See https://www.electronicoscaldas.com/data ... Aosong.pdf

I suspect someone has confused resolution (smallest difference reported) with accuracy (max delta to actual temp), here is an Adafruit description of the DHT11 and DHT22 in which the accuracy is slated to be 2.0°C
https://cdn-learn.adafruit.com/downloads/pdf/dht.pdf

Here is a data sheet that says it has a 1°C resolution (probably an AOSANG):
https://www.mouser.com/datasheet/2/758/ ... 143054.pdf

Anyway, I believe it is 0.1°C. that is what I am getting out of a 4 pin module on a small breakout board.
2.0 is incorrect on all counts, it should be 1 or 0.1

User avatar
bidrohini
 
Posts: 202
Joined: Thu Oct 20, 2022 10:03 am

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by bidrohini »

Does it mean that the sample code in the library has got a bug? Hope Adafruit will check.

User avatar
ModelTrainGuy
 
Posts: 9
Joined: Tue Oct 30, 2018 8:01 pm

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by ModelTrainGuy »

I believe the bug is in the library file DHT_U.cpp file:

Code: Select all

case DHT11:
    sensor->max_value = 50.0F;
    sensor->min_value = 0.0F;
    sensor->resolution = 2.0F;
    break;
When I change that to 0.1F I get that value reported back by the sample sketch.

User avatar
ModelTrainGuy
 
Posts: 9
Joined: Tue Oct 30, 2018 8:01 pm

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by ModelTrainGuy »

I just noticed that the Humidity resolution also has had the accuracy value used instead of resolution!

also DHT-U.cpp:

Code: Select all

case DHT11:
    sensor->max_value = 80.0F;
    sensor->min_value = 20.0F;
    sensor->resolution = 5.0F;
    break;
results in:
Humidity Sensor
Sensor Type: DHT11
Driver Ver: 1
Unique ID: -1
Max Value: 80.00%
Min Value: 20.00%
Resolution: 5.00%
Instead of 5% it should be 1%

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by adafruit2 »

the resolution is kinda meaningless without the accuracy, so we mean accuracy in this case :)

User avatar
ModelTrainGuy
 
Posts: 9
Joined: Tue Oct 30, 2018 8:01 pm

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by ModelTrainGuy »

adafruit2 wrote: Sat Jan 21, 2023 4:45 pm the resolution is kinda meaningless without the accuracy, so we mean accuracy in this case :)
I disagree.

Resolution is not meaningless. If the resolution is an integer then we can use inter variables to handle the data. If resolution shows two decimal places we can choose to use floats or multiply everything by 100 and use integer math, etc.

The whole purpose of creating the AdaFruit_Unified_Sensor layer to accurately define a common set of interface properties. in In Adafruit_Sensor.h, the struct defines resolution as follows:

Code: Select all

float resolution; /**< smallest difference between two values reported by this sensor */
Conflating resolution and accuracy is poor engineering. If you want to add an accuracy properly that should also be done, but polluting resolution with accuracy, just ruins resolution and defeats the purpose of Unification.

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by adafruit2 »

we wish the originators of the sensor definition for android used accuracy not resolution as resolution is not very useful. but they didnt. if you'd like you can submit a PR or issue, there's no guarantee on when we'd get to reviewing & merging or what we may do with it. for now, just follow the datasheets.

User avatar
ModelTrainGuy
 
Posts: 9
Joined: Tue Oct 30, 2018 8:01 pm

Re: Adafruit DHT library returns incorrect resolution for DHT11

Post by ModelTrainGuy »


Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”