Skip to content
Arduino-based (ATMega2560) Home pool filtration and pH and Orp regulation system
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
NodeRed
docs
libraries
source/PoolMaster
.gitattributes
Changelog.md
LICENSE
README.md

README.md

PoolMaster 3.0.1

Arduino Mega2560/Controllino-Maxi based Ph/Orp regulator for home pools

Brief description

Four main metrics are measured and periodically reported over MQTT and an LCD display: water temperature and pressure, pH and ORP values.
Pumps states, tank-level states and other parameters are also periodically reported
Two PID regulation loops are running in parallel: one for PH, one for ORP
pH is regulated by injecting Acid from a tank into the pool water (a relay starts/stops the Acid peristaltic pump)
ORP is regulated by injecting Chlorine from a tank into the pool water (a relay starts/stops the Chlorine peristaltic pump)
Defined time-slots and water temperature are used to start/stop the filtration pump for a daily given amount of time (a relay starts/stops the filtration pump)
An API function enables telling the system what the outside air temperature is. In case it is below -2.0°C, filtration is started until it rises back above +2.0°C
A lightweight webserver provides a simple dynamic webpage with a summary of all system parameters. An XML file with more info is available at http://ARDUINO_LOCAL_IP/Info
Communication with the system is performed using the MQTT protocol over an Ethernet connection to the local network/MQTT broker.

Every 30 seconds (by default), the system will publish on the "PoolTopic" (hardcoded, see code) the following payload in Json format:

{"Tmp":818,"pH":321,"PSI":56,"Orp":583,"FilUpT":8995,"PhUpT":0,"ChlUpT":0,"IO":11,"IO2":0}

Tmp: measured Water temperature value in °C x100 (8.18°C in the above example payload)
pH: measured pH value x100 (3.21 in the above example payload)
PSI: measured Water pressure value in bar x100 (0.56bar in the above example payload)
Orp: measured Orp (aka Redox) value in mV (583mV in the above example payload)
FiltUpT: current running time of Filtration pump in seconds (reset every 24h. 8995secs in the above example payload)
PhUpT: current running time of Ph pump in seconds (reset every 24h. 0secs in the above example payload)
ChlUpT: current running time of Chl pump in seconds (reset every 24h. 0secs in the above example payload)
IO: a variable of type BYTE where each individual bit is the state of a digital input on the Arduino. These are :

  • FiltPump: current state of Filtration Pump (0=on, 1=off)
  • PhPump: current state of Ph Pump (0=on, 1=off)
  • ChlPump: current state of Chl Pump (0=on, 1=off)
  • PhlLevel: current state of Acid tank level (0=empty, 1=ok)
  • ChlLevel: current state of Chl tank level (0=empty, 1=ok)
  • PSIError: over-pressure error
  • pHErr: pH pump overtime error flag
  • ChlErr: Chl pump overtime error flag

IO2: a variable of type BYTE where each individual bit is the state of a digital input on the Arduino. These are :

  • pHPID: current state of pH PID regulation loop (1=on, 0=off)
  • OrpPID: current state of Orp PID regulation loop (1=on, 0=off)
  • Mode: (0=manual, 1=auto)

How to compile

- this code was developped for two main hardware configurations (list in the hardware section below):

  • Controllino-Maxi or
  • Arduino Mega 2560 + Ethernet shield + relay shield + RTC module
- select the target board type in the Arduino IDE (either "Arduino Mega 2560" or "Controllino Maxi") code should compile for both types

Compatibility

For this sketch to work on your setup you must change the following in the code:
- possibly the pinout definitions depending on your wiring
- MAC address of DS18b20 water temperature sensor
- MAC and IP address of the Ethernet shield
- MQTT broker IP address and login credentials
- possibly the topic names on the MQTT broker to subscribe and publish to
- the Kp,Ki,Kd parameters for both PID loops in case your peristaltic pumps have a different throughput than 1.5Liters/hour for the pH pump and 3.0Liters/hour for the Chlorine pump. Also the default Kp values were adjusted for a 50m3 pool volume. You might have to adjust the Kp values in case of a different pool volume and/or peristaltic pumps throughput (start by adjusting it proportionally). In any case these parameters are likely to require adjustments for every pool









MQTT API

Below are the Payloads/commands to publish on the "PoolTopicAPI" topic (see hardcoded in code) in Json format in order to launch actions on the Arduino:

  • {"Mode":1} or {"Mode":0} -> set "Mode" to manual (0) or Auto (1). In Auto, filtration starts/stops at set times of the day and pH and Orp are regulated
  • {"FiltPump":1} or {"FiltPump":0} -> manually start/stop the filtration pump
  • {"ChlPump":1} or {"ChlPump":0} -> manually start/stop the Chl pump to add more Chlorine
  • {"PhPump":1} or {"PhPump":0} -> manually start/stop the Acid pump to lower the Ph
  • {"PhPID":1} or {"PhPID":0} -> start/stop the Ph PID regulation loop
  • {"OrpPID":1} or {"OrpPID":0} -> start/stop the Orp PID regulation loop
  • {"PhCalib":[4.02,3.8,9.0,9.11]} -> multi-point linear regression calibration (minimum 1 point-couple, 6 max.) in the form [ProbeReading_0, BufferRating_0, xx, xx, ProbeReading_n, BufferRating_n]
  • {"OrpCalib":[450,465,750,784]} -> multi-point linear regression calibration (minimum 1 point-couple, 6 max.) in the form [ProbeReading_0, BufferRating_0, xx, xx, ProbeReading_n, BufferRating_n]
  • {"PhSetPoint":7.4} -> set the Ph setpoint, 7.4 in this example
  • {"OrpSetPoint":750.0} -> set the Orp setpoint, 750mV in this example
  • {"WSetPoint":27.0} -> set the water temperature setpoint, 27.0deg in this example (for future use. Water heating not handled yet)
  • {"WTempLow":10.0} -> set the water low-temperature threshold below which there is no need to regulate Orp and Ph (ie. in winter)
  • {"OrpPIDParams":[2857,0,0]} -> respectively set Kp,Ki,Kd parameters of the Orp PID loop. In this example they are set to 2857, 0 and 0
  • {"PhPIDParams":[1330000,0,0.0]} -> respectively set Kp,Ki,Kd parameters of the Ph PID loop. In this example they are set to 1330000, 0 and 0
  • {"OrpPIDWSize":3600000} -> set the window size of the Orp PID loop in msec, 60mins in this example
  • {"PhPIDWSize":1200000} -> set the window size of the Ph PID loop in msec, 20mins in this example
  • {"Date":[1,1,1,18,13,32,0]} -> set date/time of RTC module in the following format: (Day of the month, Day of the week, Month, Year, Hour, Minute, Seconds), in this example: Monday 1st January 2018 - 13h32mn00secs
  • {"FiltT0":9} -> set the earliest hour (9:00 in this example) to run filtration pump. Filtration pump will not run beofre that hour
  • {"FiltT1":20} -> set the latest hour (20:00 in this example) to run filtration pump. Filtration pump will not run after that hour
  • {"PubPeriod":30} -> set the periodicity (in seconds) at which the system info (pumps states, tank levels states, measured values, etc) will be published to the MQTT broker
  • {"PumpsMaxUp":1800} -> set the Max Uptime (in secs) for the Ph and Chl pumps over a 24h period. If over, PID regulation is stopped and a warning flag is raised
  • {"Clear":1} -> reset the pH and Orp pumps overtime error flags in order to let the regulation loops continue. "Mode" also needs to be switched back to Auto (1) after an error flag was raised
  • {"DelayPID":30} -> Delay (in mins) after FiltT0 before the PID regulation loops will start. This is to let the Orp and pH readings stabilize first. 30mins in this example. Should not be > 59mins
  • {"TempExt":4.2} -> Provide the system with the external temperature. Should be updated regularly and will be used to start filtration for 10mins every hour when temperature is less than 2°C. 4.2deg in this example
  • {"PSIHigh":1.0} -> set the water high-pressure threshold (1.0bar in this example). When water pressure is over that threshold, an error flag is set.


Hardware


Cloud integration example (BLYNK)

See NodeRed folder for more info and code



Non-cloud home automation integration example (JEEDOM)





You can’t perform that action at this time.