Arduino CO2 sensor with WiFi , MQTT and charts on webserver

Homebrew (DIY) IoT CO2 sensor. Uses ESP32 module and MH-Z19C (or similar) sensor. Arduino platform.

Features:

  • WiFi connectivity (todo: with WPS)
  • MQTT transmit to SmartNest.cz (using Thermometer template)
  • OLED display
  • Web server with live charts
  • CO2 sensor is connected to UART 2 on ESP32 chip

Hardware

  • Any ESP32 module

Tested on following DEV boards (you must select different pins for OLED)

Tested with sensors:

IMPORTANT !!! Make sure you have a good power supply (stable, low noise and capable of delivering enough current). USB cable (if using development board) must be short and with thick wires. Required are enough filtering capacitors next to the OLED display, CO2 sensor and ESP32 chip.

Unstable power supply manifests as unstable CO2 readings with lots of variation and noise.

Too weak power supply causes abnormal high CO2 readings.

Libraries required

Sources