Components / Sensors / MH-Z19B CO2 sensor

MH-Z19B CO2 sensor

NDIR CO2 sensor with UART and PWM output.

MeasuresCO2
Range0 to 5000 ppm
Accuracy±(50 ppm + 5 %)
InterfaceUART or PWM
SensorsReviewedMPN MH-Z19BUsed in 2 projects
Z19B
In short

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.

How it works

NDIR: an infrared lamp shines through a chamber, and CO2 absorbs a specific wavelength, so less light reaches the detector.

Key specifications

Sensor specValue
MeasuresCO2
Range0 to 5000 ppm
Accuracy±(50 ppm + 5 %)
InterfaceUART or PWM
Supply voltage4.5 to 5.5 V

Pinout

Vin4.5 to 5.5 V
GNDGround
TXUART data out (3.3 V logic)
RXUART data in
PWMCO2 as a pulse width
HDCalibration (pull low 7 s in fresh air)
VoAnalog output on some versions

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

Alternatives

Buy at

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.