Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

61 Commits

Folders and files

Repository files navigation

CEA Irrigation System

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.

Hardware Architecture


Features

  • 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

Hardware Requirements

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)

Project Structure

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

Software Requirements

  • Raspberry Pi OS Bookworm 64-bit (recommended)
  • Arduino IDE (for flashing firmware)
  • Python 3.13+
  • uv (Python package manager — installed automatically by setup.sh)
  • Google Coral USB TPU driver (libedgetpu1-std) — installed by setup.sh

Quick Setup (Raspberry Pi 5)

git clone https://github.com/gabe-zhang/cea_irrigation.git
cd cea_irrigation
bash setup.sh

Reboot required after setup for the USB3 max current setting to take effect.


Usage

Run the GUI

uv run --extra gui python -m gui.psc_irr_gui

Run the CLI controller (serial only, no GUI)

uv run python scripts/controller.py

Event and error logs

The 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.jsonl

Repeated 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.


Firmware

Flash the production firmware to your Arduino:

  1. Open Arduino IDE
  2. Load firmware/controller/controller.ino
  3. Install libraries (already copied to ~/Arduino/libraries/ by setup.sh):
    • DHT (DHT22 air sensor)
    • OneWire (DS18S20 soil temp)
    • DFRobot_VEML7700 (ambient light)
  4. Select your board and port, then upload

Hardware test sketches are available in firmware/hardware_tests/ for validating each sensor individually.


Troubleshooting

Coral TPU not detected

lsusb | grep Google   # should show "Google Inc. Coral USB Accelerator"
ls /dev/bus/usb/      # verify device node exists

Make 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 in

Camera not initializing

libcamera-hello --list-cameras   # verify camera is detected
# Ensure picamera2 is installed (system package, not pip):
sudo apt install python3-picamera2

Tailscale re-authentication

sudo tailscale up

uv command not found after setup

source ~/.local/bin/env
# or add to ~/.bashrc:
export PATH="$HOME/.local/bin:$PATH"

Authors

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages