🎉
ESPBoards Store is Now Open! Find the best ESP32, ESP8266 boards & accessories

MH-Z19 NDIR CO₂ Sensor

MH-Z19 NDIR CO₂ Sensor image

View on Amazon

Overview

The MH-Z19 is a high-accuracy CO₂ sensor using NDIR technology, suitable for air quality monitoring. It supports UART and PWM communication, with a detection range up to 2000 ppm (optionally 5000 ppm). Its compact design and long lifespan make it ideal for HVAC and indoor air quality systems.

About MH-Z19 NDIR CO₂ Sensor

The MH-Z19 is a Non-Dispersive Infrared (NDIR) CO₂ sensor designed for precise carbon dioxide (CO₂) measurement. With high sensitivity, selectivity, and a long lifespan, it is ideal for HVAC systems, indoor air quality monitoring, and industrial applications.

Key Features

  • NDIR Technology – Ensures accurate CO₂ detection with minimal interference.
  • Flexible Data Output – Supports both UART and PWM communication.
  • Long Lifespan & High Stability – Reliable for continuous air quality monitoring.
  • Ideal for Smart Air Quality Systems – Commonly used in HVAC, greenhouses, and CO₂ monitoring devices.

For VOC and multi-gas detection, consider the CCS811, which detects TVOCs and eCO₂. 🚀

The MH-Z19 offers a detection range of 0 to 2000 ppm (extendable to 5000 ppm upon request) with an accuracy of ±50 ppm + 5% of the reading. It also includes temperature compensation for reliable readings under varying environmental conditions. Compact in design, it is easy to integrate into a variety of projects.

Where to Buy

Get Your MH-Z19

MH-Z19 NDIR CO₂ Sensor

Starting from

25$ per piece

Amazon com
Amazon.com Ships worldwide
Amazon de
Amazon.de Ships to EU
Aliexpress
AliExpress Best value option

💡 Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.

Technical Specs

MH-Z19 Specifications

Complete technical specification details for MH-Z19 NDIR CO₂ Sensor

📊 Technical Parameters

Operating Voltage 3.6V to 5.5V
Current Consumption Max 18 mA
Detection Range 0 to 2000 ppm (optional 5000 ppm)
Accuracy ±50 ppm + 5% of reading
Response Time <60 seconds
Operating Temperature 0°C to 50°C
Communication Protocols UART, PWM
Dimensions 33mm × 20mm × 9mm
Pin Configuration

MH-Z19 Pinout

The MH-Z19 has a 9-pin interface supporting UART communication and optional PWM output.

Visual Pinout Diagram

Pinout Diagram Primary
MH-Z19 NDIR CO₂ Sensor pinout
9
Total Pins

Pin Types

Power
3

Quick Tips

[object

Object],[object Object]

NDIR

technology for accurate CO₂ measurement,Includes temperature compensation

[object

Object]

Pin Descriptions

Pin NameTypeDescriptionNotes
1 Pin 1 (Vout)
Power

3.3V output (max 10mA). Can power low-current 3.3V devices.

Not suitable for powering ESP32.

2 Pin 2 (RXD)
UART

UART receive input (3.3V logic). Receives commands from microcontroller.

Connect to ESP32 TX pin.

3 Pin 3 (TXD)
UART

UART transmit output (3.3V logic). Sends CO₂ data to microcontroller.

Connect to ESP32 RX pin.

4 Pin 4 (SR)
Reserved

Factory reserved. Do not connect.

5 Pin 5 (HD)
Calibration

Zero calibration input. Pull low for >7 seconds to calibrate at 400ppm.

Use in fresh air environment for calibration.

6 Pin 6 (Vin)
Power

Power supply input (3.6V-5.5V). Connect to 5V for optimal performance.

Requires stable power supply.

7 Pin 7 (GND)
Power

Ground connection. Connect to system ground.

8 Pin 8 (AOT)
Reserved

Factory reserved. Do not connect.

9 Pin 9 (PWM)
PWM

PWM output for CO₂ concentration. Alternative to UART communication.

Optional - can use UART or PWM, not both.

Connection Guide

Wiring MH-Z19 to ESP32

To interface the MH-Z19 with an ESP32 via UART, connect Vin to 5V, GND to ground, TXD to ESP32 RX (GPIO 16), and RXD to ESP32 TX (GPIO 17).

Visual Wiring Diagram

Wiring Diagram Recommended
MH-Z19 NDIR CO₂ Sensor wiring with ESP32
5
Connections

Connection Status

Required
4
Optional
1

Protocol

UART

Pin Connections

MH-Z19 PinConnectionESP32 PinDescription
1 Pin 6 (Vin) Required
5V

Power supply (3.6V-5.5V). Use 5V for best performance.

2 Pin 7 (GND) Required
GND

Ground connection.

3 Pin 3 (TXD) Required
GPIO 16 (RX2)

Sensor transmits CO₂ data to ESP32.

4 Pin 2 (RXD) Required
GPIO 17 (TX2)

Sensor receives commands from ESP32.

5 Pin 5 (HD) Optional
Optional GPIO

Zero calibration trigger. Pull low for >7s in fresh air.

[object

Object]

Allow

3+ minutes warm-up time after power-on

Calibrate

in fresh air (~400ppm CO₂) for accuracy

Sensor

has 3.3V logic levels - directly compatible with ESP32

Use

level shifter if interfacing with 5V-only microcontrollers

[object

Object]

Help & Support

MH-Z19 Troubleshooting

Common issues and solutions to help you get your sensor working

Common Issues

Debugging Tips

Code Examples

MH-Z19 Programming Examples

Ready-to-use code examples for different platforms and frameworks

Summary

Wrapping Up MH-Z19

The ESP32 MH-Z19 NDIR CO₂ Sensor is a powerful Air Quality sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.

Best Practices

For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.

Safety First

Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.

Ready to Start Building?

Now that you have all the information you need, it's time to integrate the MH-Z19 into your ESP32 project and bring your ideas to life!