tock
tock copied to clipboard
Fix temperature sign in bme280 and bmp280 drivers
Pull Request Overview
Temperature is a 20-bit, two's complement value in both the BME280 and BMP280 chips. Further, the datasheets provide example code, which treats all units as signed, 32-bit values while doing math.
This came up when considering #2967 and looking through temperature sensor drivers and datasheets. I wanted to decouple it though, since it's chip-specific changes.
Functionally, this PR should make no difference except for temperatures below zero Celsius. They still won't work right until #2967 lands, but that's an easy fix.
Testing Strategy & Help Wanted
I don't have hardware for these sensors! @dcz-self and @alistair23 are you able to ensure I didn't break temperature readings?
TODO or Help Wanted
- [ ] Test BME280
- [ ] Test BMP280
Documentation Updated
- [N/A] Updated the relevant files in
/docs, or no updates are required.
Formatting
- [X] Ran
make prepush.
For double-checking me, see pages 25-26 here: https://www.mouser.com/datasheet/2/783/BST-BME280-DS002-1509607.pdf and page 22 here: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf
Thanks so much for testing this @alistair23. Would you mind running the temperature app again now that I added a commit?
Same problem, I get values like this:
check run BME280 Temperature...
Temperature: 9330
[ok]
check run BME280 Humidity...
Humidity: 4294967186
[ok]
Alright, I've got a BME280 breakout coming and will debug. Thanks for trying this out @alistair23
@brghena ping!
@brghena reminder on this if you get the chance to work on it! Once it is ready again feel free to re-assign Johnathan