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)
Wiring
- M5Stack Core2 → Unit PaHub2 (grove_i2c)
- Unit PaHub2 → Unit ENV III (grove_i2c)
- Unit PaHub2 → Unit CO2 (grove_i2c)
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- If readings show 0 or never update, a Grove cable is loose or in the wrong port. Both sensors must run from the red Port A (I2C); the black and blue ports will not work for them.
- Driver class names (ENV3Unit, SCD40Unit) differ slightly between firmware versions. If you get an import error, check your firmware's unit library and use the matching name.
- The CO2 sensor warms up. Let it run a few minutes before trusting the ppm value, and place the unit away from your face for an accurate room reading.
- Power only from the USB-C port or an official M5Stack supply. Keep all units dry and away from water, soil, and misting nozzles in a greenhouse.
Open the interactive diagram →
UnitKit — describe what you want to build, get a parts list and wiring diagram.