ESP32 Poolcontroller

Tags: #<Tag:0x00007f32659cc658>

This is my first “project” that I’m want to share with with the HA community.

It is still work in progress but when my pool is finished in spring it should be ready to control most of the functions foreseen.

The poolcontroller is supposed to:

  • Measure PH and ORP and run up to 4 peristaltic dosing pumps.
  • Measure water level of pool and surge tank and control 2 independent pumps using Modbus controlled VFD’s.
  • Control another VFD attached to the hydro flow system, user control with reed switches
  • Measure water pressure ahead of the filter to judge filter condition.
  • Measure temperature values of water and air to control solar heating and electrical heating
  • Measure/control cabinet temperature with small PTC heater
  • Observe levels of chlorine and ph-minus using scale modules
  • Additional power outputs for pool light, solar pump, …
  • Simple user interface to envoke test and calibration functions.

I have designed a PCB around an ESP Module, stepper drivers and INA219 modules mainly.

To run the 4 steppers i have written a small custom device.
The Modbus controlled VFD driver has been started but not tested yet.
The pressure sensor, PH sensor, ORP sensor, … are attached to 4-20mA channels
Waterlevels will be measured by low cost Lidar devices attached to I²C (not tested yet).
The user interface will be done using a 2.8" SPI touchdisplay and LVGL library.

The HA automation part is still unclear as some features seem to be missing or have not been discovered yet. I installed influx-DB to keep track of historic data and base calculations on long term mean-values. In the beginning I will have to learn when and how to add chemicals depending on temperature, season, swimming activity, …

Maybe some of you find the project appealing and if you have suggestions and questions I will be glad.

Greets, Tom

1 Like

The TOL sensor is very nice but it seems to be a bit unreliable in detecting the water surface. Maybe I will try the L1X sensorversion (allowing the reduce the viewing angle) and a swimmer reflecting the light.
Another idea is to use a gyrosensor and measure the angle of a swimmer attached to a swinging arm or ultrasonic sensors. I have to measure 4 levels:

  • the water level in the pool
  • the water level in the 4m³ surge tank
  • the level in the chlorine tank (i want to measure the weight with a load cell)
  • the level in the acid tank (i want to measure the weight with a load cell)

The two water levels and their history are used to balance the two pumps - one circulating water from pool to pool and the other from the surge tank to the pool. I also have to find out why the water level rises in the surge-tank (i.e: rainfall or people in the pool).

Display finally working …

Cool project, looking forward to seeing your progress.

Can you share a little more on what the PWB does? I’m not sure what all the parts you are using to interface to, some links would be nice.

Also you can post over here

for pool related expertise.


Hi Randy !
Thanks for the link I will visit the mentioned forum later.

As AliExpress shopper :smiley: all the parts used where sourced from there.

The prototype board has still some bugs but i was too eager getting them :wink:
I tried to include all peripherals coming to my mind driven by a single ESP32 module. This is not a typical ESPHOME application i guess but I can still drop functions and handle them by dedicated devices.

What the device is supposed to do is to intelligently control the two pool pumps and add chemicals to the water when needed. Later it should also automatically drive the solar pump and/or heat exchanger.


Thanks for the links

So you’re going to use the VFD’s to control your pumps, to turn a single speed pump into a variable speed pump? Interesting.
I have a Hayward variable speed pump. My local utility offered a rebate, so it was really cheap to install after the rebate. Really like it, saves a lot of electricity over a single speed pump. I can control the speed of the pump with 3 signal level relays that let me choose from 7 speeds I programmed into the pump.

Will also be curious to see how your orb and ph sensors work out. Cheaper than I have seen from other places.


You’re welcome Randy !

Yes i wanted to control the pumps by Modbus-RTU which also allows torque control, reading power consumption, current speed, +another 20 values. The massage pump will be operated by small reed-switches hidden under tiles to control speed +/- and switching between two outlets.
Well the measuring devices delivering 4-20mA signal are nice. The probes look nice too but I don’t know how long they will last. Cheap anyways :wink:

Proceeded further with my project and wrote two custom drivers.
The existing stepper implementation was way too slow for the steppers so my custom driver is now interrupt driven. Modbus interface is also working fine now readinf temperatures and controlling the VFD’s.
I used query sensors to my influxdb database and an automation to publish the average values down to the ESP controller. Right now I am only displaying these values along with the actual values to show the trends. LVGL is really a nice library for your user interface tasks and my mainmenu has now grown to 8 items :smiley: But the UI still needs plenty of time to be completed.

VFD with the SAKO780 devices is now almost finished. Have to learn how to finetune motor parameters.
Will have to figure out how to write an intelligent automation running the pumps at the right torque depending on temperature, usage, season, time of day, …
I think I will have a m³/day target value and a curve on how to distribute the throughput within the day/night.

HX711 scale support pretty easily implemented but I want to hook up two to four sensors to an STM8 doing the HX711 reading and providing data by I2C or Modbus RTU. This will ease cabling a lot.
The UI will be updated to include calibration functions for the scales and to show current weight/volume of the chemicals so to never run out.
I’m still not sure which method I will chose to measure the level of the surge tank. Lidar or pressure sensor are the candidates right now.

With the STM STVD IDE and Cosmic compiler the STM8S103 is now polling up to four HX711 with loadcells and providing data on Modbus like a charm. Could have done this easier with a separate ESP module but I had a bunch of STM8 lying around. Scale zero adjustment and calibration is done by simply calling a service envoking the Modbus-Master.
I hope the pool will soon be finished and I can test this all in real life …