adafruit / Adafruit_CircuitPython_DHT

CircuitPython support for DHT11 and DHT22 type temperature/humidity devices
MIT License
179 stars 62 forks source link

fix DHT22 handling of negative temperatures #10

Closed jerryneedell closed 6 years ago

jerryneedell commented 6 years ago

modified driver to correctly handle sign bit for the DHT22.

tested in freezer - dht_simpletest converts to F so the transition was failing at 32 F. see issue #9

 Temp: 33.8 F Humidity: 18.6% 
Temp: 33.6 F Humidity: 18.8% 
Temp: 33.3 F Humidity: 18.9% 
Temp: 33.1 F Humidity: 19.0% 
Temp: 32.9 F Humidity: 19.2% 
Temp: 32.5 F Humidity: 19.3% 
Temp: 32.4 F Humidity: 19.4% 
Temp: 32.0 F Humidity: 19.5% 
Temp: 31.8 F Humidity: 19.7% 
Temp: 31.6 F Humidity: 19.8% 
Temp: 31.5 F Humidity: 20.0% 

Note - tested DHT11 in the freezer, but it never reported any value < 1 C - according to the data sheet, its range is 0- 50 C so there is no need for a sign bit.