mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
[ms8607] Fix humidity calc (#9499)
This commit is contained in:
parent
37982290f7
commit
bd0fe34b14
@ -356,7 +356,7 @@ void MS8607Component::read_humidity_(float temperature_float) {
|
|||||||
|
|
||||||
// map 16 bit humidity value into range [-6%, 118%]
|
// map 16 bit humidity value into range [-6%, 118%]
|
||||||
float const humidity_partial = double(humidity) / (1 << 16);
|
float const humidity_partial = double(humidity) / (1 << 16);
|
||||||
float const humidity_percentage = lerp(humidity_partial, -6.0, 118.0);
|
float const humidity_percentage = std::lerp(-6.0, 118.0, humidity_partial);
|
||||||
float const compensated_humidity_percentage =
|
float const compensated_humidity_percentage =
|
||||||
humidity_percentage + (20 - temperature_float) * MS8607_H_TEMP_COEFFICIENT;
|
humidity_percentage + (20 - temperature_float) * MS8607_H_TEMP_COEFFICIENT;
|
||||||
ESP_LOGD(TAG, "Compensated for temperature, humidity=%.2f%%", compensated_humidity_percentage);
|
ESP_LOGD(TAG, "Compensated for temperature, humidity=%.2f%%", compensated_humidity_percentage);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user