From a53e00b216d7b99f9410035df3ddcdae1d72a43f Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 15 Oct 2020 23:13:25 +0200 Subject: [PATCH] add disableABC for mhz19 --- src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index f3c5d90..d1241f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,6 +106,8 @@ struct sensordata //SW Serial TX: to mhz19 rx (blue cable) //co2 sensor needs 5v + //if ABC is disabled (see in setup function) sensor should be calibrated manually. leave outdoors (=400ppm) with no direct sunlight for >20min, then connect HD pin to GND for at least 7 seconds. + #include SoftwareSerial mhz19_swSerial; @@ -143,6 +145,8 @@ void setup() { Serial.println(); Serial.println("Booting"); + delay(1000); //wait for sensors to get powered + #ifdef SENSOR_DHT22 Serial.println("initializing dht"); dht.begin(); @@ -221,6 +225,16 @@ void setup() { mhz19_swSerial.begin(BAUD_RATE_MHZ19, SWSERIAL_8N1, MHZ19_SERIAL_RX, MHZ19_SERIAL_TX, false, 256); mhz19.setSerial(&mhz19_swSerial); + + uint8_t mhz19abctries=10; + while(!mhz19.disableABC() && mhz19abctries>0) { //disable automatic baseline correction (abc does calibration every 24h -> needs to have 400ppm co2 level sometime during that time) + delay(500); //wait some time for mhz to be initialized + Serial.print("disableABC Failed! try="); Serial.println(mhz19abctries); + mhz19abctries--; + } + if (mhz19abctries>0) { + Serial.println("mhz19 abc disabled successfully"); + } #endif