Skip to content
Martin Mwiti
All documentation

Hydroponics Control System

Architecture and design of a multi-zone hydroponics controller with ESP32 nodes and a Raspberry Pi supervisor.

ESP32Zephyr RTOSRaspberry PiMQTTView project

The Story Behind It

Indoor growers needed finer control over nutrient delivery than timer-based pumps could provide. Manual calibration of pH and EC was eating labor hours, and off-the-shelf controllers did not scale cleanly past a single reservoir.

This project started as a weekend prototype and evolved into a field pilot across three grow rooms.

Requirements

  • Independent control of up to 8 zones
  • pH, EC, temperature, and level sensing per reservoir
  • Peristaltic dosing with volume accounting
  • Offline-capable zone controllers
  • Local dashboard; optional cloud export
  • Safe defaults: stop dosing on sensor fault or empty tank
  • Modular PCB so sensors and pumps can be replaced independently

Design Process

We split the system into edge (hard real-time dosing and safety) and supervisor (recipes, UI, logging). Edge firmware is Zephyr on ESP32-S3 for Wi-Fi and deterministic timers. The supervisor is a Raspberry Pi 4 running a small Python service and MQTT broker.

Sensor selection favored industrial-grade probes with known drift characteristics over hobby modules. Calibration workflows were designed into the UI from day one.

Hardware Design

Each zone board includes:

  • Isolated 12 V pump drivers with flyback diodes
  • Dual ADC front-ends for pH and EC
  • 1-Wire / I²C headers for temperature and ambient sensors
  • Watchdog and brownout-safe power path

A shared backplane carries power and RS-485 for environments where Wi-Fi is unreliable. Enclosure ratings target IP54 for humid grow rooms.

Firmware Architecture

Zephyr work queues separate:

  • Sensor sampling (periodic)
  • Dosing state machine
  • Network / MQTT
  • Safety supervisor (highest priority)
enum dose_state {
  DOSE_IDLE,
  DOSE_PRIMING,
  DOSE_RUNNING,
  DOSE_SETTLING,
  DOSE_FAULT,
};

Recipes are downloaded as JSON and validated before activation. Volume is estimated from calibrated pump flow rates and cross-checked against level deltas.

Challenges

pH probes drift and need wet storage discipline — software cannot fix poor probe hygiene, so the UI nags aggressively. Wi-Fi dead zones forced the RS-485 fallback path. Pump tubing wear changed flow rates over time; calibration reminders became a product feature.

Lessons Learned

  • Safety interlocks belong in firmware, not only in the cloud
  • Calibration UX is part of the control system
  • Humidity kills connectors; conformal coat and gaskets matter
  • Start with fewer zones and prove reliability before scaling

Future Improvements

  • Auto-calibration assist with reference solutions
  • Vision-assisted plant health notes (optional camera node)
  • Energy monitoring per rack
  • Open recipe exchange format for growers