mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 06:58:11 +01:00
Improve temperature precision in BME280 and BMP280 (#6124)
* Update bme280_base.cpp Change read_temperature to get better precision float const temperature = (*t_fine * 5 + 128); return temperature / 25600.0f; * Update bmp280.cpp increase precision in read_temperature * Update bmp280.cpp clang-format correction
This commit is contained in:
parent
0cbc06a9b9
commit
c35a21773e
2 changed files with 4 additions and 4 deletions
|
@ -265,8 +265,8 @@ float BME280Component::read_temperature_(const uint8_t *data, int32_t *t_fine) {
|
|||
int32_t const var2 = (((((adc >> 4) - t1) * ((adc >> 4) - t1)) >> 12) * t3) >> 14;
|
||||
*t_fine = var1 + var2;
|
||||
|
||||
float const temperature = (*t_fine * 5 + 128) >> 8;
|
||||
return temperature / 100.0f;
|
||||
float const temperature = (*t_fine * 5 + 128);
|
||||
return temperature / 25600.0f;
|
||||
}
|
||||
|
||||
float BME280Component::read_pressure_(const uint8_t *data, int32_t t_fine) {
|
||||
|
|
|
@ -200,8 +200,8 @@ float BMP280Component::read_temperature_(int32_t *t_fine) {
|
|||
int32_t var2 = (((((adc >> 4) - t1) * ((adc >> 4) - t1)) >> 12) * t3) >> 14;
|
||||
*t_fine = var1 + var2;
|
||||
|
||||
float temperature = (*t_fine * 5 + 128) >> 8;
|
||||
return temperature / 100.0f;
|
||||
float temperature = (*t_fine * 5 + 128);
|
||||
return temperature / 25600.0f;
|
||||
}
|
||||
|
||||
float BMP280Component::read_pressure_(int32_t t_fine) {
|
||||
|
|
Loading…
Reference in a new issue