mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 06:58:11 +01:00
Improved compensation sgp30 (#5208)
This commit is contained in:
parent
00f9af70a9
commit
62fed4c1eb
1 changed files with 12 additions and 3 deletions
|
@ -181,9 +181,18 @@ void SGP30Component::send_env_data_() {
|
|||
ESP_LOGD(TAG, "External compensation data received: Temperature %0.2f°C", temperature);
|
||||
}
|
||||
|
||||
float absolute_humidity =
|
||||
216.7f * (((humidity / 100) * 6.112f * std::exp((17.62f * temperature) / (243.12f + temperature))) /
|
||||
float absolute_humidity;
|
||||
if (temperature < 0) {
|
||||
absolute_humidity =
|
||||
216.67f *
|
||||
((humidity * 0.061121f * std::exp((23.036f - temperature / 333.7f) * (temperature / (279.82f + temperature)))) /
|
||||
(273.15f + temperature));
|
||||
} else {
|
||||
absolute_humidity =
|
||||
216.67f *
|
||||
((humidity * 0.061121f * std::exp((18.678f - temperature / 234.5f) * (temperature / (257.14f + temperature)))) /
|
||||
(273.15f + temperature));
|
||||
}
|
||||
uint8_t humidity_full = uint8_t(std::floor(absolute_humidity));
|
||||
uint8_t humidity_dec = uint8_t(std::floor((absolute_humidity - std::floor(absolute_humidity)) * 256));
|
||||
ESP_LOGD(TAG, "Calculated Absolute humidity: %0.3f g/m³ (0x%04X)", absolute_humidity,
|
||||
|
|
Loading…
Reference in a new issue