Weight-based plant watering

重さで測る自動水やり ・ 称重式自动浇水

Weigh the pot on a load cell; when it gets lighter, pump back exactly the water that was lost.

鉢をロードセルに載せて重さを測り、軽くなった分だけポンプで水を戻す。蒸発・吸水を重量で正確に把握。

把花盆放在称重传感器上测重,变轻后用水泵补回流失的水量,按重量精准判断蒸发与吸水。

Parts (BOM)

PartRolePortsLinks
M5Stack Core2 Controller grove_i2c, grove_analog, grove_uart, mbus official page
Unit Mini Scales Weight unit (load cell) grove_i2c official page
Unit Watering Water pump grove_analog official page

Wiring

How to build

Build a self-watering planter that decides by weight. The pot sits on a Mini Scales load-cell unit; the M5Stack Core2 reads how heavy it is. As the plant uses water and the soil dries, the pot gets lighter — when it drops below your target weight, the Core2 runs the Watering Unit's pump just long enough to put the lost water back.

  1. Gather your parts — You need: the M5Stack Core2, a Mini Scales Unit (U177, weighing unit with a load cell), a Watering Unit (U101, pump), two Grove cables (usually included), a flat board or tray to mount the pot on the scale, a small water container, and a USB-C cable.
  2. Mount the pot on the scale — Fix a flat board or tray to the top of the Mini Scales load cell, and stand the plant pot on it. Keep the whole thing level and free to move — the pot must rest only on the scale, not touch any wall or tube, or the weight reading will be wrong. Put a saucer under the pot so drainage water doesn't run onto the electronics.
  3. Wire both units to the Core2 — The Mini Scales is I2C: plug it into the Core2's red Port.A. The Watering Unit is analog/IO: plug it into the black Port.B. The Grove connectors only fit one way — don't force them. Put the pump's intake tube into the water container and aim the output tube at the soil.
  4. Connect to your computer and flash MicroPython — Connect the Core2 with the USB-C cable. With UIFlow or Thonny, make sure MicroPython is on the device, then copy the sketch below and run it. You should see a live weight reading on the screen.
  5. Tare, then set the target weight — Press the Mini Scales tare button (or zero it in code) with the empty pot setup so the load cell reads from a known baseline. Water the plant fully, let it drain, and note the weight shown — that is your TARGET_G. Put that number in the code. Set TOLERANCE to how many grams of drying you'll allow before watering (start around 40 g for a small pot).
  6. Run it and tune — Run the sketch. When the pot drops below TARGET_G − TOLERANCE, the pump runs for a short burst, then waits for the water to soak in before measuring again. If it overshoots, shorten PUMP_BURST; if the soil stays too dry, raise TOLERANCE or PUMP_BURST a little. Re-check TARGET_G as the plant grows, since the plant's own weight changes the baseline.

Sample code (micropython)

# M5Stack Core2 + Mini Scales (U177) + Watering Unit (U101)
# Weight-based watering: weigh the pot; when it gets lighter than the
# target by more than TOLERANCE grams, pump until the weight comes back.
# Wiring: Mini Scales -> Core2 red Port.A (I2C, addr 0x26)
#         Watering Unit -> Core2 black Port.B (analog/IO, pump pin 26)
import time
from machine import Pin, I2C
from m5stack import lcd

i2c = I2C(0, scl=Pin(22), sda=Pin(21))   # Core2 Port.A I2C
SCALES_ADDR = 0x26                       # Mini Scales default address
pump = Pin(26, Pin.OUT)                  # Port.B pump control

def read_grams():
    # Mini Scales returns a 4-byte signed weight (grams) from register 0x10
    raw = i2c.readfrom_mem(SCALES_ADDR, 0x10, 4)
    g = int.from_bytes(raw, 'little')
    if g >= 0x80000000:
        g -= 0x100000000
    return g / 100.0                     # unit reports centigrams

TARGET_G = 850        # pot weight right after a full watering (set this!)
TOLERANCE = 40        # how many grams it may drop before we water
PUMP_BURST = 2        # seconds of pumping per cycle

while True:
    w = read_grams()
    lcd.clear()
    lcd.print('Weight: %.0f g' % w, 10, 20)
    if w < TARGET_G - TOLERANCE:
        lcd.print('Watering...', 10, 50)
        pump.on()
        time.sleep(PUMP_BURST)
        pump.off()
        time.sleep(20)    # let water soak in before re-measuring
    else:
        time.sleep(30)

Tips & safety

Open the interactive diagram →

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