Mhz19 warmup (#6214)

This commit is contained in:
Fabio Pugliese Ornellas
2024-03-11 18:17:47 +00:00
committed by GitHub
parent e4df422798
commit 430ee43b93
3 changed files with 18 additions and 0 deletions
+10
View File
@@ -29,6 +29,14 @@ void MHZ19Component::setup() {
}
void MHZ19Component::update() {
uint32_t now_ms = millis();
uint32_t warmup_ms = this->warmup_seconds_ * 1000;
if (now_ms < warmup_ms) {
ESP_LOGW(TAG, "MHZ19 warming up, %ds left", (warmup_ms - now_ms) / 1000);
this->status_set_warning();
return;
}
uint8_t response[MHZ19_RESPONSE_LENGTH];
if (!this->mhz19_write_command_(MHZ19_COMMAND_GET_PPM, response)) {
ESP_LOGW(TAG, "Reading data from MHZ19 failed!");
@@ -101,6 +109,8 @@ void MHZ19Component::dump_config() {
} else if (this->abc_boot_logic_ == MHZ19_ABC_DISABLED) {
ESP_LOGCONFIG(TAG, " Automatic baseline calibration disabled on boot");
}
ESP_LOGCONFIG(TAG, " Warmup seconds: %ds", this->warmup_seconds_);
}
} // namespace mhz19