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:
jxl77 2024-01-21 02:57:39 +01:00 committed by GitHub
parent 0cbc06a9b9
commit c35a21773e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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) {

View File

@ -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) {