From 8d49d71c3d3fd2b81c8ea17e678abd16d86daa06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20K=C3=A4ppler?= <michael_kaeppler@web.de>
Date: Wed, 28 Apr 2021 21:15:43 +0200
Subject: [PATCH] co2_sensor: Reset SCD30 after startup

Sometimes after a hard reset of the ESP the SCD30
needs a long time until returning the first measurement.
Resetting it after startup seems to fix this behaviour.
---
 ampel-firmware/co2_sensor.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp
index 23655a2..37388a6 100644
--- a/ampel-firmware/co2_sensor.cpp
+++ b/ampel-firmware/co2_sensor.cpp
@@ -83,6 +83,10 @@ namespace sensor {
       ESP.restart();
     }
 
+    // Sometimes after a hard reset of the ESP the SCD30 needs
+    // a long time until returning the first measurement. Resetting it
+    // after startup seems to fix this behaviour.
+    scd30.reset();
     switchState(BOOTUP);
 
     Serial.print(F("Setting temperature offset to -"));
-- 
GitLab