ds18b20 temperature freezing wrong (BSP-419)
Closed this issue · 0 comments
morgana2313 commented
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;