adafruit / DHT-sensor-library

Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
https://learn.adafruit.com/dht
MIT License
1.97k stars 1.43k forks source link

ASAIR DHT11 sensor type, wrong temperature values below 0C #199

Open schayg opened 1 year ago

schayg commented 1 year ago

The current DHT11 section of the DHT code -- to my understanding -- handles negative temperatures strangely: it FIRST transforms the integral part into negative by subtracting from -1, and THEN simply adds the decimals. Not sure this is how it should be, as the original DHT11 sensor is not certified for negative temperatures.

However, the ASAIR made DHT11, which is now the dominant version on the market, handles the negative values exactly the same way as the DHT12, i.e. the decimal part has the highest bit set to 1 (value & 0x80)=0x80 but no other transforms.

maybe a section could be added to the code, like a new type of DHT11 to accommodate this. The current code with the ASAIR DHT11 reads wrong numbers below 0C.