Erriez MH-Z19B CO2 sensor library for Arduino  1.0.0
This is a MH-Z19B CO2 sensor library for Arduino with a small footprint.
Classes | Macros | Enumerations
ErriezMHZ19B.h File Reference

MH-Z19B CO2 sensor library for Arduino. More...

#include <Arduino.h>
Include dependency graph for ErriezMHZ19B.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ErriezMHZ19B
 Class ErriezMHZ19B. More...
 

Macros

#define MHZ19B_WARMING_UP_TIME_MS   (3UL * 60000UL)
 3 minutes warming-up time after power-on before valid data returned More...
 
#define MHZ19B_READ_INTERVAL_MS   (5UL * 1000UL)
 Minimum response time between CO2 reads (EXPERIMENTALLY DEFINED)
 
#define MHZ19B_SERIAL_RX_BYTES   9
 Fixed 9 Bytes response.
 
#define MHZ19B_SERIAL_RX_TIMEOUT_MS   120
 Response timeout between 15..120 ms at 9600 baud works reliable for all commands.
 
#define MHZ19B_CMD_SET_AUTO_CAL   0x79
 Command set auto calibration on/off.
 
#define MHZ19B_CMD_READ_CO2   0x86
 Command read CO2 concentration.
 
#define MHZ19B_CMD_CAL_ZERO_POINT   0x87
 Command calibrate zero point at 400ppm.
 
#define MHZ19B_CMD_CAL_SPAN_POINT   0x88
 Command calibrate span point (NOT IMPLEMENTED)
 
#define MHZ19B_CMD_SET_RANGE   0x99
 Command set detection range.
 
#define MHZ19B_CMD_GET_AUTO_CAL   0x7D
 Command get auto calibration status (NOT DOCUMENTED)
 
#define MHZ19B_CMD_GET_RANGE   0x9B
 Command get range detection (NOT DOCUMENTED)
 
#define MHZ19B_CMD_GET_VERSION   0xA0
 Command get firmware version (NOT DOCUMENTED)
 

Enumerations

enum  MHZ19B_Result_e {
  MHZ19B_RESULT_OK = 0 , MHZ19B_RESULT_ERROR = -1 , MHZ19B_RESULT_ERR_CRC = -2 , MHZ19B_RESULT_ERR_TIMEOUT = -3 ,
  MHZ19B_RESULT_ARGUMENT_ERROR = -4
}
 Response on a command. More...
 
enum  MHZ19B_Range_e { MHZ19B_RANGE_2000 = 2000 , MHZ19B_RANGE_5000 = 5000 }
 PPM range. More...
 

Detailed Description

MH-Z19B CO2 sensor library for Arduino.

Source: https://github.com/Erriez/ErriezMHZ19B Documentation: https://erriez.github.io/ErriezMHZ19B

Definition in file ErriezMHZ19B.h.

Macro Definition Documentation

◆ MHZ19B_WARMING_UP_TIME_MS

#define MHZ19B_WARMING_UP_TIME_MS   (3UL * 60000UL)

3 minutes warming-up time after power-on before valid data returned

Enable smart warming-up to return false when CO2 value changes within 3 minutes pre-heating time. Can be used when MCU is reset and sensor powered-up for >3 minutes. Recommended to disable for deployment to ensure warming-up timing.

Definition at line 45 of file ErriezMHZ19B.h.

Enumeration Type Documentation

◆ MHZ19B_Range_e

PPM range.

Enumerator
MHZ19B_RANGE_2000 

Range 2000 ppm.

MHZ19B_RANGE_5000 

Range 5000 ppm (Default)

Definition at line 82 of file ErriezMHZ19B.h.

◆ MHZ19B_Result_e

Response on a command.

Enumerator
MHZ19B_RESULT_OK 

Response OK.

MHZ19B_RESULT_ERROR 

Response error.

MHZ19B_RESULT_ERR_CRC 

Response CRC error.

MHZ19B_RESULT_ERR_TIMEOUT 

Response timeout.

MHZ19B_RESULT_ARGUMENT_ERROR 

Response argument error.

Definition at line 71 of file ErriezMHZ19B.h.