
Tasmota MH-Z19B CO2 Monitor
Build a WiFi CO2 monitor using MH-Z19B NDIR sensor with ESP8266/ESP32 and Tasmota. Measures 0-5000ppm CO2 concentration for indoor air quality and ventilation automation via MQTT.
Tasmota MH-Z19B CO2 Monitor
Build a WiFi-connected CO2 monitor that measures indoor carbon dioxide levels using the MH-Z19B NDIR (non-dispersive infrared) sensor. Published via MQTT to Home Assistant for ventilation automation and air quality alerts.
Why This Project
- Indoor air quality — CO2 above 1000ppm causes drowsiness and reduced cognitive function
- Ventilation automation — trigger fans or open windows when CO2 is high
- NDIR technology — accurate, stable, long-lasting (no chemical sensor drift)
- COVID-era relevance — CO2 levels correlate with room ventilation quality
- 5-year lifespan — MH-Z19B has built-in auto-calibration
Components Required
| Component | Purpose | Est. Cost |
|---|---|---|
| Wemos D1 Mini (or any ESP board) | WiFi microcontroller | $3 |
| MH-Z19B (or MH-Z19C) sensor | NDIR CO2 measurement | $15-20 |
| Jumper wires | UART connections | $0.50 |
Wiring (UART)
MH-Z19B Wemos D1 Mini
─────── ─────────────
Vin → 5V (sensor needs 5V!)
GND → GND
TX → GPIO14 (D5) — Tasmota RX
RX → GPIO12 (D6) — Tasmota TX
Important: The MH-Z19B requires 5V power (not 3.3V), but its UART TX output is 3.3V compatible with ESP8266/ESP32.
Tasmota Setup
- Flash
tasmota-sensors.bin(ESP8266) ortasmota32(ESP32) - Configuration → Configure Module
- Set GPIO14 to MHZ Rx
- Set GPIO12 to MHZ Tx
- Reboot — CO2 readings appear on the dashboard
Configuration Commands
# Set measurement range (default 2000ppm, max 5000ppm)
Sensor15 5000
# 3-minute warm-up time before first accurate reading
# Sensor auto-calibrates over 24 hours (ABC logic)
CO2 Level Reference
| CO2 (ppm) | Level | Action |
|---|---|---|
| 400-600 | Excellent | Normal outdoor/well-ventilated |
| 600-1000 | Good | Acceptable indoor |
| 1000-1500 | Fair | Open windows, increase ventilation |
| 1500-2000 | Poor | Drowsiness, reduced concentration |
| 2000+ | Bad | Headaches, must ventilate immediately |
Home Assistant Automation
automation:
- alias: "High CO2 alert"
trigger:
- platform: numeric_state
entity_id: sensor.tasmota_mhz19b_co2
above: 1000
action:
- service: fan.turn_on
target:
entity_id: fan.ventilation
- service: notify.mobile
data:
message: "CO2 is {{ states('sensor.tasmota_mhz19b_co2') }}ppm — ventilate!"
Compatible Boards
- Wemos D1 Mini — compact, widely available
- NodeMCU — if you need additional sensors alongside
- Any ESP32 board — add a display for local CO2 readings
- ESP-01S — possible but tight on GPIOs (uses TX/RX pins)






