add disableABC for mhz19

This commit is contained in:
interfisch 2020-10-15 23:13:25 +02:00
parent 79a314938a
commit a53e00b216
1 changed files with 14 additions and 0 deletions

View File

@ -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.h>
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