-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix negative temperatures #12
Conversation
The DHT22 supports negative temperatures which weren't read correctly. Fixes #10.
Tested in my freezer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
src/dht11.toit
Outdated
/** | ||
Driver for the DHT11 sensor. | ||
|
||
Should also work for compatible sensors like the DHT12, or KY-015. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also work for compatible sensors like the DHT12, or KY-015. | |
Should also work for compatible sensors like the DHT12 or KY-015. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
src/dht22.toit
Outdated
// second bit to determine which approach the sensor uses. | ||
byte1 := data[TEMPERATURE_INDEX_] | ||
temperature10/int := ? | ||
if (byte1 & 0x80 == 0) or (byte1 & 0x04 == 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe spell out the range implied by 0x04 constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done and fixed a typo. (It should have been "0x40").
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done and fixed a typo. (It should have been "0x40"). done.
That's kinda what I expected :)
The DHT22 supports negative temperatures which weren't read correctly.
Fixes #10.