Commit 968f6f68 authored by Eric Duminil's avatar Eric Duminil
Browse files

Merge branch 'develop'

parents daf9e805 7305369b
Pipeline #4035 passed with stage
in 1 minute and 50 seconds
# Change Log # 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!) * 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) * MQTT works again for ESP32 (board needs to be updated in Arduino IDE/PlaftormIO)
......
...@@ -126,8 +126,7 @@ namespace sensor { ...@@ -126,8 +126,7 @@ namespace sensor {
return (co2 > 0 && delta < ((uint32_t) co2 * config::max_deviation_during_bootup / 100)); return (co2 > 0 && delta < ((uint32_t) co2 * config::max_deviation_during_bootup / 100));
} }
bool countStableMeasurements() { bool enoughStableMeasurements() {
// Returns true, if a sufficient number of stable measurements has been observed.
static int16_t previous_co2 = 0; static int16_t previous_co2 = 0;
if (co2 > (previous_co2 - config::max_deviation_during_calibration) if (co2 > (previous_co2 - config::max_deviation_during_calibration)
&& co2 < (previous_co2 + config::max_deviation_during_calibration)) { && co2 < (previous_co2 + config::max_deviation_during_calibration)) {
...@@ -164,6 +163,7 @@ namespace sensor { ...@@ -164,6 +163,7 @@ namespace sensor {
scd30.setForcedRecalibrationFactor(config::co2_calibration_level); scd30.setForcedRecalibrationFactor(config::co2_calibration_level);
Serial.println(F(" Done!")); Serial.println(F(" Done!"));
Serial.println(F("Sensor calibrated.")); 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! //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. //At least one measurement needs to happen in order for the calibration to be correctly applied.
} }
...@@ -206,11 +206,11 @@ namespace sensor { ...@@ -206,11 +206,11 @@ namespace sensor {
} }
scd30.setMeasurementInterval(config::measurement_timestep); // [s] 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)) { if ((current_state == PREPARE_CALIBRATION_UNSTABLE) || (current_state == PREPARE_CALIBRATION_STABLE)) {
// Check for pre-calibration states first, because we do not want to if (enoughStableMeasurements()) {
// leave them before calibration is done.
bool ready_for_calibration = countStableMeasurements();
if (ready_for_calibration) {
calibrate(); calibrate();
} }
} else if (co2 < 250) { } else if (co2 < 250) {
...@@ -304,7 +304,7 @@ namespace sensor { ...@@ -304,7 +304,7 @@ namespace sensor {
if (timestep >= 2 && timestep <= 1800) { if (timestep >= 2 && timestep <= 1800) {
Serial.print(F("Setting Measurement Interval to : ")); Serial.print(F("Setting Measurement Interval to : "));
Serial.print(timestep); Serial.print(timestep);
Serial.println(F("s.")); Serial.println(F("s (change will only be applied after next measurement)."));
scd30.setMeasurementInterval(timestep); scd30.setMeasurementInterval(timestep);
config::measurement_timestep = timestep; config::measurement_timestep = timestep;
led_effects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
......
...@@ -38,7 +38,7 @@ class Ampel { ...@@ -38,7 +38,7 @@ class Ampel {
private: private:
static void showFreeSpace(); static void showFreeSpace();
public: 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 *board;
const char *sensorId; const char *sensorId;
uint32_t max_loop_duration; uint32_t max_loop_duration;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment