33 #ifndef ERRIEZ_MHZ19B_H_
34 #define ERRIEZ_MHZ19B_H_
45 #define MHZ19B_WARMING_UP_TIME_MS (3UL * 60000UL)
48 #define MHZ19B_READ_INTERVAL_MS (5UL * 1000UL)
51 #define MHZ19B_SERIAL_RX_BYTES 9
54 #define MHZ19B_SERIAL_RX_TIMEOUT_MS 120
57 #define MHZ19B_CMD_SET_AUTO_CAL 0x79
58 #define MHZ19B_CMD_READ_CO2 0x86
59 #define MHZ19B_CMD_CAL_ZERO_POINT 0x87
60 #define MHZ19B_CMD_CAL_SPAN_POINT 0x88
61 #define MHZ19B_CMD_SET_RANGE 0x99
64 #define MHZ19B_CMD_GET_AUTO_CAL 0x7D
65 #define MHZ19B_CMD_GET_RANGE 0x9B
66 #define MHZ19B_CMD_GET_VERSION 0xA0
110 int8_t
getVersion(
char *version, uint8_t versionLen);
125 int8_t
sendCommand(uint8_t cmd,
byte b3=0,
byte b4=0,
byte b5=0,
byte b6=0,
byte b7=0);
132 unsigned long _tLastReadCO2;
135 uint8_t calcCRC(uint8_t *data);
#define MHZ19B_SERIAL_RX_BYTES
Fixed 9 Bytes response.
@ MHZ19B_RANGE_5000
Range 5000 ppm (Default)
@ MHZ19B_RANGE_2000
Range 2000 ppm.
MHZ19B_Result_e
Response on a command.
@ MHZ19B_RESULT_ERR_TIMEOUT
Response timeout.
@ MHZ19B_RESULT_OK
Response OK.
@ MHZ19B_RESULT_ERR_CRC
Response CRC error.
@ MHZ19B_RESULT_ARGUMENT_ERROR
Response argument error.
@ MHZ19B_RESULT_ERROR
Response error.
int8_t setAutoCalibration(bool calibrationOn)
Enable or disable automatic calibration.
int8_t sendCommand(uint8_t cmd, byte b3=0, byte b4=0, byte b5=0, byte b6=0, byte b7=0)
Send serial command to sensor and read response.
int8_t getAutoCalibration()
Get status automatic calibration (NOT DOCUMENTED)
int8_t startZeroCalibration()
Start Zero Point Calibration manually at 400ppm.
bool isWarmingUp()
Check if sensor is warming-up after power-on.
ErriezMHZ19B(Stream *serial)
Constructor with serial Stream.
bool detect()
Detect MHZ19B sensor.
int8_t setRange2000ppm()
Set CO2 range 2000 ppm.
bool isReady()
Check minimum interval between CO2 reads.
int16_t getRange()
Get CO2 range in PPM (NOT DOCUMENTED)
int8_t getVersion(char *version, uint8_t versionLen)
Get firmware version (NOT DOCUMENTED)
int8_t setRange5000ppm()
Set CO2 range 5000 ppm.
~ErriezMHZ19B()
Destructor.
int16_t readCO2()
Read CO2 from sensor.