Smart greenhouse starter

温室まるごと自動化(入門) ・ 智能温室入门

Sense temp/humidity, water on dry soil, and ventilate. The showcase build.

温湿度を測り、土が乾けば水やり、暑くなればファン。温室自動化の入り口。Port.A(I2C)とPort.B(アナログ)を使い分け。

测温湿度、土干则浇水、过热则通风。温室自动化入门,分别使用 Port.A(I2C) 与 Port.B(模拟)。

Parts (BOM)

PartRolePortsLinks
M5Stack CoreS3 Controller grove_i2c, grove_analog, grove_uart, mbus, usb_c, sdcard 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
Unit Watering Moisture sensor + pump grove_analog official page

Wiring

How to build

Build a smart greenhouse starter with M5Stack. The CoreS3 reads temperature, humidity, and pressure from the ENV III sensor, watches soil moisture with the Watering unit, and turns on the Fan unit when it gets too hot. The screen shows live readings and the pump waters when the soil is dry. Everything connects with plug-in Grove cables, so no soldering is needed.

  1. Lay out the parts — Gather the CoreS3 controller, ENV III sensor, Fan unit, Watering unit (moisture sensor + pump), and the Grove cables that came with them. Place the CoreS3 in the center where you can reach all units.
  2. Connect the ENV III sensor (I2C, red) — Plug a Grove cable from the CoreS3 Port.A (red, I2C) to the ENV III sensor. This is the temperature, humidity, and pressure sensor.
  3. Chain the Fan unit to the sensor (I2C, red) — The Fan unit also uses I2C. Plug a Grove cable from the ENV III's second I2C socket to the Fan unit so both share the red I2C bus.
  4. Connect the Watering unit (analog, black) — Plug a Grove cable from the CoreS3 Port.B (black, analog/IO) to the Watering unit. Put the moisture probe in the soil and set the pump's water tube into a small water container.
  5. Flash the firmware — Install UIFlow2 or Thonny on your computer, connect the CoreS3 with the USB-C cable, and upload the MicroPython sketch below. Make sure MicroPython firmware is already on the device.
  6. Power on and test — Run the program. The screen should show temperature and moisture. Warm the sensor with your hand to see the fan turn on; touch the moisture probe to dry then wet to watch the pump respond.

Sample code (micropython)

# Smart greenhouse starter for M5Stack CoreS3
# ENV III + Fan share the red I2C bus; Watering uses the black analog port.
import time
from machine import ADC, Pin
from M5 import Lcd
import M5

# Library names vary by firmware; adjust if your version differs.
from unit import ENVUnit, FanUnit   # I2C units on Port.A

M5.begin()
env = ENVUnit()                     # temperature / humidity / pressure
fan = FanUnit()                     # ventilation fan
moist = ADC(Pin(8))                 # Watering moisture sensor on Port.B
moist.atten(ADC.ATTN_11DB)          # read full 0-3.3V range

TEMP_ON = 28      # fan turns on above 28 C
DRY = 1500        # below this ADC value = dry soil (tune for your sensor)

while True:
    t = env.read_temperature()
    h = env.read_humidity()
    soil = moist.read()             # raw 0-4095; lower = wetter (typical)

    fan.set_state(t > TEMP_ON)      # auto ventilation
    pump_on = soil < DRY            # water when dry
    # NOTE: pump control depends on your Watering unit firmware API.
    # Many versions expose a digital output pin; keep it simple here.

    Lcd.clear()
    Lcd.setCursor(10, 20)
    Lcd.print('Temp: %.1f C' % t)
    Lcd.setCursor(10, 50)
    Lcd.print('Humi: %.0f %%' % h)
    Lcd.setCursor(10, 80)
    Lcd.print('Soil: %d' % soil)
    Lcd.setCursor(10, 110)
    Lcd.print('Fan:%s Pump:%s' % ('ON' if t>TEMP_ON else 'off',
                                  'ON' if pump_on else 'off'))
    time.sleep(2)

Tips & safety

Open the interactive diagram →

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