diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index e56b291fca792e4228960f1f05f70bcab109771b..8906bf563766ab73d047949b150495dcca255bd1 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 == 60) { calibrateAndRestart();