diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index 1fe9297cd104f1ac46bc8dcb0136387275767c2c..cd4058d8547c36f17efe2d838393d41d812bc4d5 100644 --- a/ampel-firmware/co2_sensor.cpp +++ b/ampel-firmware/co2_sensor.cpp @@ -48,8 +48,6 @@ namespace sensor { state current_state = INITIAL; void switchState(state); - bool should_calibrate = false; - void initialize() { #if defined(ESP8266) Wire.begin(12, 14); // ESP8266 - D6, D5; @@ -140,7 +138,6 @@ namespace sensor { scd30.setMeasurementInterval(2); // [s] The change will only take effect after next measurement. Serial.println(F("Waiting until the measurements are stable for at least 2 minutes.")); Serial.println(F("It could take a very long time.")); - should_calibrate = true; switchState(PREPARECALIBRATION); } @@ -223,7 +220,7 @@ namespace sensor { } else if (co2 < 250) { // Sensor should be calibrated. switchState(NEEDSCALIBRATION); - } else if (should_calibrate) { + } else if (current_state == PREPARECALIBRATION) { countStableMeasurements(); if (stable_measurements == config::enough_stable_measurements) { calibrateAndRestart();