Temperature / humidity / CO2 monitor

温湿度・CO2モニター ・ 温湿度・CO2 监测

Environmental sensing for a greenhouse or room, all over one I2C bus.

温度・湿度・気圧とCO2を測る。温室や部屋の環境を見える化。I2Cなので数珠つなぎでOK。

测量温度・湿度・气压和 CO2,让温室或房间环境可视化。I2C 可串联。

Parts (BOM)

PartRolePortsLinks
M5Stack Core2 Controller grove_i2c, grove_analog, grove_uart, mbus official page
Unit PaHub2 I2C hub (1→6) grove_i2c official page
Unit ENV III Temp / humidity / pressure grove_i2c official page
Unit CO2 CO2 sensor grove_i2c official page

Wiring

How to build

Build a desktop air-quality monitor that shows temperature, humidity, and CO2 on the M5Stack Core2 screen. Perfect for a greenhouse, grow room, or any room where you want to keep an eye on the air. No soldering and no breadboard needed: everything connects with snap-in Grove cables, and the readings appear on the built-in display.

  1. Gather your parts — Lay out the three pieces: the M5Stack Core2 (the screen unit), the Unit ENV III (temperature/humidity/pressure), and the Unit CO2 (CO2 sensor). You also need the two white Grove cables that came in the unit boxes and a USB-C cable.
  2. Connect ENV III to the Core2 — These sensors talk over I2C, which uses the red Port A. Plug one Grove cable from the Core2's red Port A into the Grove socket on the Unit ENV III. The cable only fits one way, so push until it clicks.
  3. Chain the CO2 unit to the ENV III — I2C units can be daisy-chained. Use the second Grove cable to connect the free Grove socket on the Unit ENV III to the Unit CO2. Both sensors now share the single Port A line back to the Core2.
  4. Install the firmware tools — On your computer, install UIFlow or the Thonny editor with the M5Stack MicroPython firmware. Connect the Core2 to the computer with the USB-C cable and select the matching serial port.
  5. Flash the sketch — Copy the MicroPython code below into the editor and upload (Run) it to the Core2. The screen should clear and start showing labels for temperature, humidity, and CO2.
  6. Test the readings — Watch the screen update every few seconds. Breathe gently near the CO2 unit: the number should rise, then fall again. Cup the ENV III in your hand and humidity should climb. If a value stays at 0 or dashes, recheck the Grove cables.

Sample code (micropython)

from m5stack import lcd
from machine import I2C, Pin
import time

# Core2 Grove Port A (red) = I2C: SDA=32, SCL=33
i2c = I2C(0, sda=Pin(32), scl=Pin(33), freq=100000)

# Driver libraries bundled with M5Stack firmware.
# ENV III uses an SHT30 (temp/humidity); CO2 unit uses an SCD40.
from unit import ENV3Unit, SCD40Unit  # adjust names to your firmware
env = ENV3Unit(i2c)
co2 = SCD40Unit(i2c)

lcd.clear()
lcd.setTextColor(lcd.WHITE)

while True:
    t = env.temperature      # degrees C
    h = env.humidity         # percent
    c = co2.co2              # ppm (parts per million)

    lcd.clear()
    lcd.print("Temp: %.1f C" % t, 20, 40)
    lcd.print("Humidity: %.1f %%" % h, 20, 90)
    lcd.print("CO2: %d ppm" % c, 20, 140)

    time.sleep(5)  # refresh every 5 seconds

Tips & safety

Open the interactive diagram →

UnitKit — describe what you want to build, get a parts list and wiring diagram.