diff --git a/CHANGELOG.md b/CHANGELOG.md index 1053e4e401d83397a1f2b9d6ce4b860f32c9a15e..312ff6223810b88e11bf3fe2d9355643707e47ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [v0.2.0](https://transfer.hft-stuttgart.de/gitlab/co2ampel/ampel-firmware/-/releases/v0.2.0) 2021/06/06 +## [v0.2.1](https://transfer.hft-stuttgart.de/gitlab/co2ampel/ampel-firmware/-/releases/v0.2.1) 2021/06/06 * BUGFIX: Calibration was not applied correctly (Thanks Michael Käppler for bug finding & fixing!) * MQTT works again for ESP32 (board needs to be updated in Arduino IDE/PlaftormIO) diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index 261e5a341f85395701d76f24c31d2f334ee32f58..1eb76fc9352de9222d5447107502e3131f170683 100644 --- a/ampel-firmware/co2_sensor.cpp +++ b/ampel-firmware/co2_sensor.cpp @@ -126,8 +126,7 @@ namespace sensor { return (co2 > 0 && delta < ((uint32_t) co2 * config::max_deviation_during_bootup / 100)); } - bool countStableMeasurements() { - // Returns true, if a sufficient number of stable measurements has been observed. + bool enoughStableMeasurements() { static int16_t previous_co2 = 0; if (co2 > (previous_co2 - config::max_deviation_during_calibration) && co2 < (previous_co2 + config::max_deviation_during_calibration)) { @@ -164,6 +163,7 @@ namespace sensor { scd30.setForcedRecalibrationFactor(config::co2_calibration_level); Serial.println(F(" Done!")); Serial.println(F("Sensor calibrated.")); + switchState(BOOTUP); // In order to stop the calibration and select the desired timestep. //WARNING: Do not reset the ampel or the SCD30! //At least one measurement needs to happen in order for the calibration to be correctly applied. } @@ -206,11 +206,11 @@ namespace sensor { } scd30.setMeasurementInterval(config::measurement_timestep); // [s] } + + // Check for pre-calibration states first, because we do not want to + // leave them before calibration is done. if ((current_state == PREPARE_CALIBRATION_UNSTABLE) || (current_state == PREPARE_CALIBRATION_STABLE)) { - // Check for pre-calibration states first, because we do not want to - // leave them before calibration is done. - bool ready_for_calibration = countStableMeasurements(); - if (ready_for_calibration) { + if (enoughStableMeasurements()) { calibrate(); } } else if (co2 < 250) { @@ -304,7 +304,7 @@ namespace sensor { if (timestep >= 2 && timestep <= 1800) { Serial.print(F("Setting Measurement Interval to : ")); Serial.print(timestep); - Serial.println(F("s.")); + Serial.println(F("s (change will only be applied after next measurement).")); scd30.setMeasurementInterval(timestep); config::measurement_timestep = timestep; led_effects::showKITTWheel(color::green, 1); diff --git a/ampel-firmware/util.h b/ampel-firmware/util.h index 1813292858b6d0e9655f98d8f0497442a6cda082..19a32cdfee7231a3ae0bd0fbec947126b01a95d9 100644 --- a/ampel-firmware/util.h +++ b/ampel-firmware/util.h @@ -38,7 +38,7 @@ class Ampel { private: static void showFreeSpace(); public: - const char *version = "v0.2.1-DEV"; // Update manually after significant changes. + const char *version = "v0.2.1"; // Update manually after significant changes. const char *board; const char *sensorId; uint32_t max_loop_duration;