Skip to content

DHT22 negative temperatures are not handled correctly. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jerryneedell opened this issue Apr 28, 2018 · 1 comment
Closed

DHT22 negative temperatures are not handled correctly. #9

jerryneedell opened this issue Apr 28, 2018 · 1 comment

Comments

@jerryneedell
Copy link

The DHT22 sensor returs a 16 bit temperature with bits 0-14 containing the magnitude and the MSB indicating the sign. The driver as written incorrectly treat the value as a twos-complement signed integer and gives incorrect results below 0 C .
I put the sensor in a freezer.
the dht_simpletest converts to F so this example shows the error as the temperature crosses 32 F

Temp: 32.9 F Humidity: 23.4% 
Temp: 32.7 F Humidity: 23.5% 
Temp: 32.5 F Humidity: 23.6% 
Temp: 32.4 F Humidity: 23.7% 
Temp: 32.2 F Humidity: 23.8% 
Temp: 32.0 F Humidity: 23.8% 
Temp: 5930.4 F Humidity: 24.0% 
Temp: 5930.4 F Humidity: 24.1% 
Temp: 5930.5 F Humidity: 24.2% 
Temp: 5930.7 F Humidity: 24.3% 
Temp: 5930.9 F Humidity: 24.4% 
Temp: 5931.1 F Humidity: 24.5% 
Temp: 5931.3 F Humidity: 24.5% 
Temp: 5931.4 F Humidity: 24.7% 
Temp: 5931.6 F Humidity: 24.8% 
Temp: 5931.6 F Humidity: 25.1% 
Temp: 5931.8 F Humidity: 25.7% 
Temp: 5931.6 F Humidity: 26.3% 
Temp: 5931.6 F Humidity: 26.9% 
Temp: 5931.6 F Humidity: 27.6% 
Temp: 5931.3 F Humidity: 28.7% 
Temp: 5931.1 F Humidity: 29.2% 
Temp: 5930.9 F Humidity: 29.7% 
Temp: 5930.5 F Humidity: 30.2% 
Temp: 5930.4 F Humidity: 30.9% 
Temp: 32.0 F Humidity: 31.4% 
Temp: 32.5 F Humidity: 32.7% 
Temp: 32.9 F Humidity: 33.3%

Note - the DHT 11 appear to only measure down to 1 C - so there is no problem there.

@jerryneedell
Copy link
Author

fixed by PR #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant