Intelligent Pool Automation System

Published at 8/14/2020

#Programming
#IoT
#Hardware
#PCB Design
#Personal

Overview

A DIY full-stack hardware and software solution to automate swimming pool chemistry monitoring and valve control. This project replaced manual maintenance with algorithmic precision, integrating custom PCB hardware with a Node.js backend and Home Assistant for control.

The Problem

When we moved into our house in Florida, I had no idea about running a swimming pool. It was a standard setup: salt chlorinator, fountains, big filter, and solar hot water panels. It required weekly checks for pH and chlorine, and my wife was always asking about the water temperature or if we should run the solar heaters—which required manually switching valves and turning on the pump. I figured it wouldn’t take too much to setup an automated system.

Hardware Design & Architecture

1. Pool Monitor (Sensing)

The initial goal was to leverage Home Assistant to display pool stats. I built a bypass pipe that took a sample of pool water from the pressure side after the pump to house the sensor array.

  • Sensors:
    • DS18B20 (OneWire) in a stainless steel tube for accurate water temperature.
    • Atlas Scientific pH and ORP (Chlorine) sensors.
    • Water Pressure Sensor to detect when the pump was running.
    • BME680 for outside air temperature and humidity.
  • Controller: Raspberry Pi Zero running a custom JavaScript program sending data via MQTT to Home Assistant.
Bypass Sensor pipe

By-pass pipe for sensor array.

2. Valve Controller (Actuation)

The pool utilized 24V AC motorized valves to control the waterfall, fountains, and solar panels. These valves were simple “bang-bang” controls: applying power moved them to a hard stop. This was a problem because I wanted proportional control—for example, to set the valve halfway for a gentle fountain effect without losing flow to the waterfall.

The Solution: A custom control board with a relay matrix.

  • Logic: By measuring the time it took to travel full-span, I could drive the valve for a computed duration to achieve any percentage opening (e.g., 50%).
  • Interface: Exposed as a slider in Home Assistant.

Custom PCB Design

I designed the circuit schematics, laid out the PCB traces, and had them manufactured by JLCPCB. The board connects to a Raspberry Pi Zero via I2C.

  • Inputs: I2C bus, power management.
  • Outputs: Relays for valve direction and power control.
  • Connectivity: Power over Ethernet (PoE) splitter powered the Pi and the 24V valve system.
Pool Valve Controller Schematic
Pool Valve Controller PCB layout

When I got the boards, I soldered the through-hole components, flashed the firmware (C++/Arduino), and tested the motion logic.

Pool Valve Controller PCB as manufactured
Pool Valve Controller Finished PCB

A second board was designed to operate full 120VAC loads, including the main pump and solar heaters.

Pool Valve Pump Controller PCB
Pool Valve Pump Controller PCB back side
Pool Valve Pump Controller PCB assembled

Software Stack

  • Firmware (C++): Custom Arduino firmware for the ATmega328p on the control board, handling the low-level relay timing and I2C interrupts.
  • Backend (Node.js): Running on the Raspberry Pi Zero.
    • Logic Engine: Acted as the brain, translating high-level commands (“Set Fountains to 50%”) into low-level I2C commands for the controller.
    • Communication: Published all state changes to MQTT topics (pool/fountain/set, pool/temp/value).
  • Frontend: Home Assistant (Dashboard & Mobile App).

Planned Expansion: Chemical Dosing

I had planned to implement a closed-loop PID controller for pH and Chlorine using Pentair dosing pumps. The system would read the pH/ORP sensors and trickle-dose acid or liquid chlorine to maintain perfect chemistry without user intervention. While we moved before this was fully installed, the software hooks and sensor infrastructure were already in place.

Outcome

This project provided us with easily accessible pool information and valve control right from our phones. I didn’t have to do another manual pool water test for the rest of the time we lived there, and the system autonomously managed the solar heating optimization.

Project Resources

Judson Hartley © 2023-2026