Cheap DH22 sensors return incorrect readings of negative temperature

Some DHT22 temperatures are being sold (Ebay) that are not genuine. Genuine sensors will read temperatures down to -50degC. The defective types measure temperature OK above zero but return large and incorrect values when the temperature drops below zero. This has been a topic of discussion before:

I have investigated this and discovered that the sensor will produce a reading of -3276.8 at the point that the temperature drops below zero. The readings do change with temperature: e.g at -0.4 degC the reading is -3276.4; at -0.8 degC the reading is - -3276.0. So it is possible to correct for this error using the following code:

float t = dht.readTemperature();
// Read temperature as degC
Add this code to make the correction if required.
if (t < -50) { // The correction will not be applied if a genuine DHT22 is used
t = -3276.8 - t ; // correct value if t< 0
}
This will return negative temperatures correctly

Or put another way they use sign and magnitude coding rather than 2's complement like the genuine ones, in units of 0.1 degree, hence 3276.8 which is 2^15 / 10

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.