adafruit / adafruit/DHT-sensor-library
Resolution reported for DHT11 temp is 2° - should be 0.1°, %RH should be 1% instead of 5%
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
See https://forums.adafruit.com/viewtopic.php?p=957161 for discussion thread.
The **Resolution** values for both Temperature and Humidity are incorrectly defined in DHT-U.cpp for DHT11 sensors.
Lines 213-217
```
case DHT11:
sensor->max_value = 80.0F;
sensor->min_value = 20.0F;
sensor->resolution = 5.0F;
break;
```
and lines 138-144
```
case DHT11:
sensor->max_value = 50.0F;
sensor->min_value = 0.0F;
sensor->resolution = 2.0F;
break;;
```
Both values are the respective **accuracy** values, not their resolution.
The resolution 'field' in the Adafruit Unified sensor layer is defined in Adafruit_Sensor.h
`float resolution; /**< smallest difference between two values reported by this sensor */`
i.e. is clearly a resolution and not 'accuracy'
The correct values should be:
Lines 213-217
```
case DHT11:
sensor->max_value = 80.0F;
sensor->min_value = 20.0F;
sensor->resolution = 1.0F; // corrected from 5
break;
```
and lines 138-144
```
case DHT11:
sensor->max_value = 50.0F;
sensor->min_value = 0.0F;
sensor->resolution = 0.1F; // corrected from 2
break;;
```
The erroneous data is visible in the output of the Adafruit DHT library sample program: DHT_Unified_Sensor.ino
> 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. Here one can see sequential values differing by 0.1°:
> Temperature: 19.90°C Humidity: 35.00%
> Temperature: 19.80°C Humidity: 35.00%
The same goes for the humidity values.
The correct values are found in numerous online data sheets for the DHT11
The fix involves changing values on two lines:
143: sensor->resolution = 0.1F; // corrected from 2
216: sensor->resolution = 1.0F; // corrected from 5
Contributor guide
Research direction
Open DHT-U.cpp and inspect the DHT11 cases around lines 143 and 216, then compare their resolution fields with the definition in Adafruit_Sensor.h. Use DHT_Unified_Sensor.ino to verify the reported metadata. Done means DHT11 reports 0.1°C temperature resolution and 1.0% humidity resolution, with the existing sample output reflecting those values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100