An AI-powered automated irrigation system for Controlled Environment Agriculture (CEA), built on Raspberry Pi 5 with Google Coral Edge TPU acceleration. The system monitors soil moisture, temperature, humidity, and light in real time, drives up to 4 independent pump channels, and provides a desktop GUI with live camera feed and AI-powered plant health detection.
- 4 independent irrigation channels — per-channel soil moisture sensing and pump relay control
- AI plant health monitoring — YOLO inference on Google Coral USB TPU via a pan-tilt camera gimbal
- Auto & manual watering modes — moisture-setpoint-based auto-loop and one-click manual control
- Real-time automatic watering — checks every 2 seconds; starts after 3 consecutive fresh checks below the start threshold; stops each channel on the first reading at its moisture target (default 80%) or after the 60-second safety limit
- Real-time telemetry — soil moisture, soil/air temperature, humidity, and ambient light
- Historical data plots — day / week / month views with water volume tracking per pump
- Remote access — Tailscale VPN for SSH and dashboard access from anywhere
- Watering records — telemetry and images saved every second telemetry update during automatic watering; telemetry also records pump starts and stops
| Component | Part / SKU | Notes |
|---|---|---|
| Raspberry Pi 5 | Main compute controller | |
| Arduino (Uno/Mega) | Serial sensor & relay bridge via USB | |
| Soil Moisture Sensor ×4 | Generic analog capacitive | Wired to Arduino analog pins A0–A3 |
| Air Temp & Humidity Sensor | DHT22 | Arduino digital pin 7 |
| Soil Temperature Sensor | DS18S20 / DS18B20 | OneWire, Arduino digital pin 8 |
| Ambient Light Sensor | DFRobot SEN0228 (VEML7700, I²C) | GitHub |
| IO Expansion Shield | DFRobot DFR0265 | Wiring guide |
| Relay Module ×4 | Any 4-channel 5 V relay | Arduino digital pins 2–5 |
| Submersible Water Pump ×4 | — | One per irrigation channel |
| Google Coral USB TPU | Coral USB Accelerator | AI inference accelerator (optional) |
| Camera Module | ArduCam / Raspberry Pi Camera | Mounted on pan-tilt gimbal |
| Pan-Tilt Servos | 2× standard servo | Arduino pins 9 (pan), 10 (tilt) |
cea_irrigation/
├── firmware/
│ ├── controller/ # Arduino production firmware
│ ├── hardware_tests/ # Per-sensor Arduino test sketches
│ └── libraries/ # Arduino C++ libraries (DHT, OneWire, DFRobot_VEML7700)
├── gui/ # Desktop GUI application & vision modules
│ └── models/ # TFLite model
├── scripts/ # CLI controller
├── tests/ # pytest suite
├── docs/ # Diagrams for README
├── setup.sh # One-shot setup script
└── pyproject.toml
- Raspberry Pi OS Bookworm 64-bit (recommended)
- Arduino IDE (for flashing firmware)
- Python 3.13+
uv(Python package manager — installed automatically bysetup.sh)- Google Coral USB TPU driver (
libedgetpu1-std) — installed bysetup.sh
git clone https://github.com/gabe-zhang/cea_irrigation.git
cd cea_irrigation
bash setup.shReboot required after setup for the USB3 max current setting to take effect.
uv run --extra gui python -m gui.psc_irr_guiuv run python scripts/controller.pyThe GUI and CLI automatically log watering events, hardware failures, and errors
to Data/logs/gui.jsonl and Data/logs/controller.jsonl, with readable console
output. Records include UTC timestamps, session/run IDs, context, and tracebacks.
Files rotate at 5 MiB with five backups.
Logging defaults to INFO. Set CEA_LOG_LEVEL=DEBUG for detailed diagnostics
or CEA_LOG_DIR to change the directory:
CEA_LOG_LEVEL=DEBUG uv run --extra gui python -m gui.psc_irr_gui
tail -f Data/logs/gui.jsonlRepeated errors are rate limited; critical errors always emit. Console logging continues if file storage fails. Use separate log directories for concurrent instances of the same application.
Flash the production firmware to your Arduino:
- Open Arduino IDE
- Load
firmware/controller/controller.ino - Install libraries (already copied to
~/Arduino/libraries/bysetup.sh):DHT(DHT22 air sensor)OneWire(DS18S20 soil temp)DFRobot_VEML7700(ambient light)
- Select your board and port, then upload
Hardware test sketches are available in firmware/hardware_tests/ for validating each sensor individually.
Coral TPU not detected
lsusb | grep Google # should show "Google Inc. Coral USB Accelerator"
ls /dev/bus/usb/ # verify device node existsMake sure usb_max_current_enable=1 is in /boot/firmware/config.txt and you have rebooted. Also confirm your user is in the plugdev group (groups $USER).
Serial port not found (/dev/ttyACM0)
ls /dev/ttyACM*
sudo usermod -aG dialout $USER # then log out and back inCamera not initializing
libcamera-hello --list-cameras # verify camera is detected
# Ensure picamera2 is installed (system package, not pip):
sudo apt install python3-picamera2Tailscale re-authentication
sudo tailscale upuv command not found after setup
source ~/.local/bin/env
# or add to ~/.bashrc:
export PATH="$HOME/.local/bin:$PATH"James Y. Kim (USDA-ARS) · Yuan Zhang
Note: gui/psc_irr_gui.py carries a USDA-ARS proprietary notice. Licensing terms will be updated in a future release.
