mirror of
https://github.com/sigmasternchen/MH-Z-CO2-Sensors
synced 2025-03-14 22:28:56 +00:00
added support for MH-Z19C
This commit is contained in:
parent
7be7cf0f22
commit
51af0b1d84
3 changed files with 20 additions and 8 deletions
20
MHZ.cpp
20
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};
|
||||
|
|
1
MHZ.h
1
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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue