Skip to content

Fix negative temperatures for DHT22#16

Merged
winlinvip merged 1 commit intowinlinvip:masterfrom
danielfaust:patch-1
Jan 2, 2018
Merged

Fix negative temperatures for DHT22#16
winlinvip merged 1 commit intowinlinvip:masterfrom
danielfaust:patch-1

Conversation

@danielfaust
Copy link
Contributor

This commit fixes issue #14
The MSB carries the sign information, which is filtered with & 0x8000. If the flag is present, the remainder will get multiplied by -1.
All the remaining bits contain the value and are filtered with & 0x7FFF.

This commit fixes issue #14
The MSB carries the sign information, which is filtered with `& 0x8000`. If the flag is present, the remainder will get multiplied by `-1`.
All the remaining bits contain the value and are filtered with `& 0x7FFF`.
@winlinvip
Copy link
Owner

👍

@winlinvip winlinvip merged commit 3c63797 into winlinvip:master Jan 2, 2018
@winlinvip
Copy link
Owner

Release 1.0.8.

@winlinvip
Copy link
Owner

It seems that you only fixed for DHT22, not for DHT11? Could you please fix it for DHT11 at https://github.com/winlinvip/SimpleDHT/blob/master/SimpleDHT.cpp#L112 ?

@danielfaust
Copy link
Contributor Author

danielfaust commented Jan 2, 2018

I don't have a DHT11 to test with. But since the DHT11 only works with temperatures equal to or above 0 °C, I think that sign flag never gets set. I preferred not to touch that code.

Good for 0-50°C temperature readings ±2°C accuracy

@winlinvip
Copy link
Owner

👌 Agreed, I will release a new version.

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

Successfully merging this pull request may close these issues.

2 participants