diff --git a/MHZ.cpp b/MHZ.cpp index b3081c9..5e607a2 100644 --- a/MHZ.cpp +++ b/MHZ.cpp @@ -6,16 +6,19 @@ #include "MHZ.h" const int MHZ14A = 14; -const int MHZ19B = 19; +const int MHZ19B = 119; +const int MHZ19C = 219; const int MHZ_2K = 1; const int MHZ_5K = 2; const int MHZ_10K = 3; const unsigned long MHZ14A_PREHEATING_TIME = 3L * 60L * 1000L; const unsigned long MHZ19B_PREHEATING_TIME = 3L * 60L * 1000L; +const unsigned long MHZ19C_PREHEATING_TIME = 1L * 60L * 1000L; const unsigned long MHZ14A_RESPONSE_TIME = (unsigned long)60 * 1000; const unsigned long MHZ19B_RESPONSE_TIME = (unsigned long)120 * 1000; +const unsigned long MHZ19C_RESPONSE_TIME = (unsigned long)120 * 1000; const int STATUS_NO_RESPONSE = -2; const int STATUS_CHECKSUM_MISMATCH = -3; @@ -80,6 +83,8 @@ boolean MHZ::isPreHeating() { return millis() < (MHZ14A_PREHEATING_TIME); } else if (_type == MHZ19B) { return millis() < (MHZ19B_PREHEATING_TIME); + } else if (_type == MHZ19C) { + return millis() < (MHZ19C_PREHEATING_TIME); } else { Serial.println(F("MHZ::isPreHeating() => UNKNOWN SENSOR")); return false; @@ -87,12 +92,15 @@ boolean MHZ::isPreHeating() { } boolean MHZ::isReady() { - if (isPreHeating()) return false; - if (_type == MHZ14A) + if (isPreHeating()) { + return false; + } else if (_type == MHZ14A) { return lastRequest < millis() - MHZ14A_RESPONSE_TIME; - else if (_type == MHZ19B) + } else if (_type == MHZ19B) { return lastRequest < millis() - MHZ19B_RESPONSE_TIME; - else { + } else if (_type == MHZ19C) { + return lastRequest < millis() - MHZ19C_RESPONSE_TIME; + } else { Serial.print(F("MHZ::isReady() => UNKNOWN SENSOR \"")); Serial.print(_type); Serial.println(F("\"")); @@ -250,7 +258,7 @@ int MHZ::readCO2PWM() { return ppm_pwm; } -void MHZ::setAutoCalibrate(boolean b) //only available for MHZ-19B with firmware < 1.6 and MHZ 14a +void MHZ::setAutoCalibrate(boolean b) //only available for MHZ-19B with firmware < 1.6, MHZ-19C and MHZ 14a { uint8_t cmd_enableAutoCal[9] = { 0xFF, 0x01, 0x79, 0xA0, 0x00, 0x00, 0x00, 0x00, 0xE6 }; uint8_t cmd_disableAutoCal[9] = { 0xFF, 0x01, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86}; diff --git a/MHZ.h b/MHZ.h index 5cdeaec..e3a7514 100644 --- a/MHZ.h +++ b/MHZ.h @@ -16,6 +16,7 @@ // types of sensors. extern const int MHZ14A; extern const int MHZ19B; +extern const int MHZ19C; extern const int MHZ_2K; extern const int MHZ_5k; extern const int MHZ_10K; diff --git a/README.md b/README.md index d478be8..4f96cab 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MH-Z14A, MH-Z19B CO2 ... Module -Arduino implementation for MH-Z CO2 sensors such as **MH-Z14A**, **MH-Z19B** (as I didn't find all info in one place). +Arduino implementation for MH-Z CO2 sensors such as **MH-Z14A**, **MH-Z19B** and **MH-Z19C** (as I didn't find all info in one place). The sensor is available for ~20 bucks at the usual places. @@ -20,9 +20,12 @@ The implementation is mostly based on https://forum.arduino.cc/index.php?topic= ## Resources: -Datasheet: +Datasheet (MH-Z19B): http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf +Datasheet (MH-Z19C): +https://pdf1.alldatasheet.com/datasheet-pdf/view/1303687/WINSEN/MH-Z19C.html + More info about the sensor: https://revspace.nl/MHZ19