Skip to content

Temperatures over 42.5 C are coming back as negative #4

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
mshannon78660 opened this issue Dec 22, 2020 · 1 comment
Closed

Temperatures over 42.5 C are coming back as negative #4

mshannon78660 opened this issue Dec 22, 2020 · 1 comment

Comments

@mshannon78660
Copy link
Contributor

Temperatures higher than 42.5 degress C (108.5 degrees F) are coming back as very large negative numbers. I think this is due to line 198 (

raw_temp = unpack_from(">h", temp_data)[0]
) unpacking the measurement as a signed short - I think it should be unsigned, just like with relative humidity. So that line would change from
raw_temp = unpack_from(">h", temp_data)[0]
to
raw_temp = unpack_from(">H", temp_data)[0]

In the next line, we're already subtracting 4500 from the value, which is how we get to negative temperatures. Looking at the Arduino library, it looks like they use the value as unsigned:
https://github.com/adafruit/Adafruit_SHTC3/blob/8d48fd2708027c0f943743077f3fbae8b51a9f29/Adafruit_SHTC3.cpp#L159

@ladyada
Copy link
Member

ladyada commented Dec 22, 2020

kk can you submit a PR please :)

mshannon78660 added a commit to mshannon78660/Adafruit_CircuitPython_SHTC3 that referenced this issue Dec 22, 2020
…stead of signed to fix issue with high temperatures (over 42.5C) coming out as negative values (issue adafruit#4)
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

3 participants