DHT-sensor-library icon indicating copy to clipboard operation
DHT-sensor-library copied to clipboard

Resolution reported for DHT11 temp is 2° - should be 0.1°, %RH should be 1% instead of 5%

Open DaleSchultz opened this issue 2 years ago • 1 comments

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

DaleSchultz avatar Jan 22 '23 20:01 DaleSchultz

same issue here!!

Jaorow avatar Jul 06 '24 07:07 Jaorow