← Projects
electronics advanced 15 days ago ◑ 19 views ◯ 4 min read

Build a Reef Aquarium Controller with ESP32: Dosing Pumps, Auto Top-Off, and Lighting Schedules

Build time: A weekend to build the controller, plus a second weekend of in-tank testing with fail-safes deliberately triggered before unattended use
Tools needed: Soldering iron, multimeter, basic ESP32 programming environment, drill for sensor/pump mounting, graduated cylinder for pump calibration
esp32reef aquariumauto top offdosing pumpssaltwateraquarium automation
Parts List

A reef aquarium is a far less forgiving automation target than the hydroponic and garden-irrigation projects makers usually reach for — a saltwater reef tank's chemistry (calcium, alkalinity, magnesium) has to stay within a tight band for coral to survive, salt water is brutal on electronics and connectors, and a top-off pump that sticks "on" overnight can crash salinity and kill a tank in hours. This project builds an ESP32-based reef controller that handles automated dosing, auto top-off (ATO) with real fail-safes, and lighting schedules, with the sensor and plumbing details that make the difference between a controller that helps and one that eventually floods your stand.

Difficulty and What to Expect

This is an intermediate-to-advanced project, less for the electronics (which are fairly standard ESP32 relay and pump control) than for the fail-safe plumbing and sensor placement that keep a mistake from becoming a dead tank. Budget a weekend for the controller build and a second weekend for careful in-tank testing with fail-safes deliberately triggered before you trust it unattended.

What the Controller Actually Does

SubsystemHardwareFunction
Auto top-off (ATO)Dual optical or float sensors + peristaltic pumpReplaces evaporated fresh water to hold salinity steady
Dosing (Ca/Alk/Mg)3x peristaltic dosing pumpsScheduled small doses to hold reef chemistry stable
Lighting0-10V or PWM dimming interface to LED fixtureSunrise/sunset ramping and photoperiod scheduling
MonitoringTemperature probe, optional pH probeLogging and threshold alerts

Auto Top-Off: Where Most DIY Builds Fail

A single-sensor ATO is a known failure mode in the reef-keeping world for good reason: if that one optical sensor gets a salt-creep film or a bubble stuck on it and reads "low" continuously, the pump runs until your freshwater reservoir is empty into the tank, or worse, until the reservoir itself is empty and the pump runs dry — or the sensor fails the other way and never tops off at all. Build this with redundancy, not just as a feature, but as the actual design basis:

Dosing Pumps and Chemistry Stability

Peristaltic dosing pumps (the same type used in hobby-grade commercial dosers) driven by the ESP32 through simple relay or MOSFET switching handle calcium, alkalinity, and magnesium supplements on a scheduled, small-and-frequent basis — several small doses spread through the day hold chemistry far more stable than one large daily dose, which causes swings corals respond to poorly. Calibrate each pump's actual mL-per-second output by timing a dosing run into a graduated cylinder rather than trusting the pump's rated flow, since tubing wear and head height change real output over time; recalibrate monthly as tubing ages.

Lighting Schedules

Most mid-range and higher reef LED fixtures accept either a 0-10V analog dimming signal or a digital control protocol — check your fixture's manual before assuming PWM-from-GPIO will work directly, since many fixtures need a proper 0-10V driver stage between the ESP32 and the light. A basic sunrise/sunset ramp (gradually increasing and decreasing intensity rather than a hard on/off) reduces fish and coral stress and is a simple time-based lookup table in firmware, no feedback sensor required.

Electronics Near Salt Water

Salt creep and humidity will find any exposed connector eventually. Keep all electronics — the ESP32 itself, relay boards, and especially any mains-voltage connections — outside the tank's splash zone in a sealed or conformally-coated enclosure, and route sensor and pump wiring with drip loops so condensation or a splash runs off the cable before it reaches a connector rather than wicking straight into it.