MH-Z19B CO2 sensor
NDIR CO2 sensor with UART and PWM output.
What is the MH-Z19B CO2 sensor and what is it used for?
NDIR CO2 sensor with UART and PWM output. Makers use it for CO2 monitors.
NDIR: an infrared lamp shines through a chamber, and CO2 absorbs a specific wavelength, so less light reaches the detector.
Key specifications
| Sensor spec | Value |
|---|---|
| Measures | CO2 |
| Range | 0 to 5000 ppm |
| Accuracy | ±(50 ppm + 5 %) |
| Interface | UART or PWM |
| Supply voltage | 4.5 to 5.5 V |
Pinout
How to use it
Use UART at 9600 baud with the MH-Z19 library. Let it warm up for three minutes. Its automatic baseline correction assumes fresh air once a day; disable it for greenhouses or closed rooms.
Applications
Builds that use it
Alternatives
- SCD40 CO2 sensorSmaller I2C sensor
- MQ-135 air quality sensor moduleCheap trend sensor, not real CO2
Common questions
What is the MH-Z19B CO2 sensor used for?
In maker projects: CO2 monitors.
How does the MH-Z19B CO2 sensor work?
NDIR: an infrared lamp shines through a chamber, and CO2 absorbs a specific wavelength, so less light reaches the detector.
What voltage does the MH-Z19B CO2 sensor need?
4.5 to 5.5 V.
How do I connect the MH-Z19B CO2 sensor to an Arduino or ESP32?
UART or PWM. Pins: Vin (4.5 to 5.5 V), GND (Ground), TX (UART data out (3.3 V logic)), RX (UART data in), PWM (CO2 as a pulse width), HD (Calibration (pull low 7 s in fresh air)).
What can I use instead of the MH-Z19B CO2 sensor?
SCD40 CO2 sensor and MQ-135 air quality sensor module.
