ESP32 Poolcontroller

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

4 Likes

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 …

1 Like

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.

Randy

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.

Tom

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.

Randy

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 …

Hey @myLens figured I would make an account just to let you know that I have been checking back for any update.

Is your pool in yet? How is the project progressing?

Hi ! Thank you for your interest !
All the electronic parts are ready but not yet installed in the pool.
The only basin filled is the overflow basin with an ultrasonic level gauge (TTL-serial->STM8->Modbus) but the pool still lacks the foil and I need help to finish this - which might become March as it is getting cold :frowning:
For that reason I do not have any real-life experience with the device yet (especially the calculation of chemistry to add). Control of the pumps, driving the 4 steppers, reading PH and ORB, level of chemistry canisters, temp sensors) all seems to be working fine. I have also started a sub-project to automate the pool-cover (not existing yet) with 4 independent solar powered elements and I hope some day I will be proud to show the final result :smiley:
If you need any specific information or PCB layouts just ask.
BR, Tom

Hi Tom,
I’m building the same pool automation than you, and I’ve been doing several improvements but sometimes I got stuck due to ORP values, I’ve bought a dfrobot ORP kit:
https://www.dfrobot.com/product-1071.html
But the readings are not very consistent, I’d like to know if you have good reedings with chinesse orp kit?
For this project I’m following this project: https://github.com/segalion/raspipool but with ESP8266 esphome devices and integrated to HA.

It thanks if you can share more details about your configuration and experience.

BR

Hi Maximo !
Sorry for not responding earlier. My pool was just finished 3 weeks ago and the pool-controller is just starting to get alive an I installed it in the control-room just recently. I had to use a range extender (AV600 kit) to get the signal down to the pool.
When trying to calibrate the PH-probe before it showed that it had to be replaced (because not stored properly it delivered out of range values) and I have ordered a new PH-Probe. I did not yet verify whether the ORP values make sense but likely this probe has to be replaced as well. At least it reacts to chlorine being added but I am not sure about the absolute value yet. I will update you with more information once I have finished installation. I also did not yet finish all scripts, automations and scenes and am thankful for your reference of the raspipool-project which might help.
In the moment I am struggling with the modbus driving the pumps ans measuring levels (used to work but in the moment VFDs don’t communicate). I had some other problems that took my time (broken pump, sand in the pipes,…) but I rewarded myself with jumps in the pool :smiley:

As soon I have information that could be helpful I will post !

BR, Tom

That was easy - a weak soldering at the RS485 transceiver, so next will be the ultrasonic level sensor and the water measurement loop

Hi Tom,
I am very much interesting in your project. My pool will be finished in 3 weeks and I’d love to hire you to help me install your solution in my pool too.

Here is what I am hoping to achieve:

  1. Control my Chinese vdf pump ( I have asked if it supports modbus)

https://m.alibaba.com/product/1600511106217/EAKP-Series-High-Speed-2-HP.html?__sceneInfo={"cacheTime"%3A"1800000"%2C"type"%3A"appDetailShare"}&from=Android

  1. Either user the orp and pH probes you recommended ( waiting for you to confirm if they work correctly) or I read the EZO seonsers are solid but the kit cost 440 usd)

  2. Control the Chinese salt chlorinator I purchased based on the ORP readings.

  3. Control the 3 phase air source pool heatpump

  4. PH- and ph+ dosing

  5. Monitor the level of the overflow pool tank and fill it in with water.

  6. Integration with HA

Pm me if interested deyanshkodrov78 at gmail.com

Sorry i have already replied but the post was not saved properly …

  1. well you need to have the register map for the VFD device to be able to control it by modbus
  2. both probes are working fine now, they have an RS232 interface with an ugly protocol so i attached them by 4-20mA interface
  3. I don’t know this device
  4. I think you can only switch this on/off but not regulate it, you can use a solid state output to drive a 3phase switch
  5. you might not need ph+, i use four peristaltic pumps with steppers run by 4 wires + enable
  6. i have attached an ultrasonic sensor to a stm8 board interfacing to my ESP32 controller by modbus but i am using the information only to log the waterlevel and prevent the pump from running dry. I use two separate pumps - one from the overflow tank and one from the floor drain, but you might also drive a solenoid to add water
  7. sure but i have not finished all automations yet

BR, Tom

p.s: I can share one of the 20x10cm PCB’s but there are some small mistakes on them

Hi,
How you configure the VFD on Homeassistant?

Hi Alex !
Well i had to write a CustomUART Driver implementing the modbus communication.

then in the config it looks like:

  - id: cuart
    lambda: |-
        auto modBus = new esphome::customUARTComponent( id(mod_bus) );
        modBus->setrtspin( id(modbus_xmit) );
        App.register_component( modBus );        
        auto vfd1 = new esphome::ModbusRTUDeviceVFD( 0x11, "vfd1" );
        vfd1->set_parent( modBus );
        App.register_component( vfd1 );        
        auto vfd2 = new esphome::ModbusRTUDeviceVFD( 0x12, "vfd2" );
        vfd2->set_parent( modBus );
        App.register_component( vfd2 );
        return { vfd1, vfd2 };

The custom driver implements commands to start or run the motor.
I don’t know if the standard “modbus implementation” has improved but that time it was completely USELESS.

BR, Tom