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

ds18b20 temperature freezing wrong (BSP-419) #258

Closed
morgana2313 opened this issue Dec 2, 2023 · 0 comments · Fixed by #279
Closed

ds18b20 temperature freezing wrong (BSP-419) #258

morgana2313 opened this issue Dec 2, 2023 · 0 comments · Fixed by #279

Comments

@morgana2313
Copy link

The temperature returned with this component in function ds18b20_get_temperature is wrong (4095C) for temperatures below 0C. The sign-bit is not extended properly because of the typecast to int16_t.

Fix:

-    *ret_temperature = (((int16_t)scratchpad.temp_msb << 8) | lsb_masked)  / 16.0f;
+    *ret_temperature = (((int8_t)scratchpad.temp_msb << 8) | lsb_masked)  / 16.0f;
@github-actions github-actions bot changed the title ds18b20 temperature freezing wrong ds18b20 temperature freezing wrong (BSP-419) Dec 2, 2023
suda-morris added a commit to suda-morris/esp-bsp that referenced this issue Jan 16, 2024
because of the drop of the sign when doing the temerature conversion

Closes espressif#258
suda-morris added a commit to suda-morris/esp-bsp that referenced this issue Jan 16, 2024
because of the drop of the sign when doing the temperature conversion

Closes espressif#258
suda-morris added a commit to suda-morris/esp-bsp that referenced this issue Jan 16, 2024
because of the drop of the sign when doing the temperature conversion

Closes espressif#258
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 a pull request may close this issue.

1 participant