Overview
The MH-Z19B is an NDIR (Non-Dispersive Infrared) carbon dioxide () gas sensor manufactured by Winsen Electronics. It utilizes infrared absorption spectroscopy to accurately measure atmospheric concentration from 400 ppm to 5,000 ppm (with optional 10,000 ppm variant).
The gold-plated optical chamber houses an internal IR light source, a narrow bandpass optical filter, an IR detector, and temperature compensation. It outputs concentration data via UART serial (9600 baud) and a PWM duty cycle output line.
Quick reference
Operating Voltage (Vin) | 4.5 V to 5.5 V DC (5.0 V nominal) |
| Measurement Range | 400 ppm to 5,000 ppm |
| Accuracy | |
| Warm-up Time | 3 minutes (180 seconds) |
| UART Interface | 9600 baud, 8 data bits, 1 stop bit, no parity (9600,N,8,1) |
| PWM Cycle Period | 1004 ms () |
| Average Current | average / 150 mA peak during IR heating |
Pinout
Standard 7-Pin Gold Module Header
| Pin | Name | Type | Description |
|---|---|---|---|
| 1 | Vout / VO | Analog Output | Analog voltage output (0.4 V to 2.0 V, optional) |
| 2 | NC | Not Connected | Unused |
| 3 | GND | Power | Ground (0 V) |
| 4 | Vin | Power Input | Supply voltage (+4.5 V to +5.5 V DC) |
| 5 | Rx | Digital Input | UART Receive line (3.3V TTL logic level input) |
| 6 | Tx | Digital Output | UART Transmit line (3.3V TTL logic level output) |
| 7 | PWM | Digital Output | PWM output pin (pulse width proportional to CO2 PPM) |
Specifications
| Parameter | Symbol | Min | Typ | Max | Unit | Conditions |
|---|---|---|---|---|---|---|
| Supply Voltage | 4.5 | 5.0 | 5.5 | V | DC | |
| Average Current | — | 40 | 60 | mA | Active operating mode | |
| Peak Current | — | 150 | 200 | mA | IR lamp pulse | |
| Preheating Time | — | 180 | — | s | Initial stabilization | |
| Response Time () | — | — | s | Natural convection | ||
| Temperature Drift | — | — | % FS/°C | Internal temp compensation |
UART Command Protocol (9600 Baud)
Send a 9-byte packet to read concentration:
- Request Command:
0xFF 0x01 0x86 0x00 0x00 0x00 0x00 0x00 0x79 - Response Packet (9 Bytes):
0xFF 0x86 HIGH LOW TT 0x00 0x00 0x00 CS
Check Byte 8 Checksum (): .
Wiring
| MH-Z19B Module Pin | → | Microcontroller (Arduino / ESP32) | Notes |
|---|---|---|---|
Vin | 5V | Requires 5V supply for internal IR lamp | |
GND | GND | Ground | |
Tx | RX (e.g. GPIO16 / D2 for SoftwareSerial) | 3.3V TTL output | |
Rx | TX (e.g. GPIO17 / D3 for SoftwareSerial) | 3.3V TTL input | |
PWM | GPIO Pin (optional for PWM reading) | Pulse width proportional to PPM |
Automatic Zero Calibration (ABC) Warning:
By default, the MH-Z19B has ABC (Automatic Baseline Calibration) enabled. Every 24 hours, the module assumes the lowest concentration it recorded during that period was (fresh outdoor air). If used continuously in an unventilated bedroom or greenhouse, ABC will miscalibrate. Disable ABC via UART command 0x79 for indoor environments.
Common mistakes
- Powering from 3.3V: Operating the sensor from a 3.3V rail causes incomplete IR lamp heating and erratic UART timeouts. Always supply 5.0 V DC.
- Inverted RX/TX lines: Connecting module
Txto MCUTX. - Forgetting 3-minute warm-up: Reading data immediately upon cold boot outputs invalid readings ( or ). Wait 180 seconds after applying power.
Notes
- Fully supported in ESPHome via the dedicated
mhz19component.
Assets & downloads
- datasheetdatasheet
- product-pagereference