Skip to content
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

Merged
merged 2 commits into from
Jan 6, 2025
Merged

Fix negative temperatures #12

merged 2 commits into from
Jan 6, 2025

Conversation

floitsch
Copy link
Member

@floitsch floitsch commented Jan 2, 2025

The DHT22 supports negative temperatures which weren't read correctly.

Fixes #10.

The DHT22 supports negative temperatures which weren't read correctly.

Fixes #10.
@floitsch floitsch requested a review from kasperl January 2, 2025 12:08
@floitsch
Copy link
Member Author

floitsch commented Jan 2, 2025

Tested in my freezer.

Copy link
Contributor

@kasperl kasperl left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Should also work for compatible sensors like the DHT12, or KY-015.
Should also work for compatible sensors like the DHT12 or KY-015.

Copy link
Member Author

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):
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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 :)

@floitsch floitsch merged commit 5b0abf1 into main Jan 6, 2025
2 checks passed
@floitsch floitsch deleted the floitsch/negative-temps branch January 6, 2025 11:02
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.

wrong negative temperature
2 participants