0% found this document useful (0 votes)
57 views34 pages

Pool Control - 22 Steps (With Pictures) - Instructables

This document describes a system to automatically monitor and control a home swimming pool. It allows monitoring of water levels, temperature, pH, ORP, filter pressure, electricity usage, and more. The system controls pumps and refills the pool as needed. It also includes notifications and Alexa integration.

Uploaded by

windo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views34 pages

Pool Control - 22 Steps (With Pictures) - Instructables

This document describes a system to automatically monitor and control a home swimming pool. It allows monitoring of water levels, temperature, pH, ORP, filter pressure, electricity usage, and more. The system controls pumps and refills the pool as needed. It also includes notifications and Alexa integration.

Uploaded by

windo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

 (/) Circuits (/circuits/) Workshop (/workshop/) Craft (/craft/) Cooking (/cooking/)

Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow


Teachers (/teachers/)
Living (/living/) Outside (/outside/)
Download Favorite w
Login (/account/login/)
I Made It| Sign Up
(/account/register/)

instructables (/circuits/) Projects (/circuits/projects/) Community (/circuits/community/) Let's Make...


circuits 
Pool Control
By MD500_Pilot (/member/MD500_Pilot/) in Circuits (/circuits/) > Raspberry Pi (/circuits/raspberry-pi/projects/) 1.086 22 10 Featured

Download Favorite

(https://content instructables com/FNC/WT7T/K7ETG7WZ/FNCWT7TK7ETG7WZ


auto=webp&frame=1&fit=bounds) LARGE jpg? (https://content instructables com/FCB/0Y17/K7ETGA0D/FCB0Y17K7ETGA0D
auto=webp&frame=1&fit=bounds) LARG

This is a system to monitor and manage water level, temperature, pH, ORP, lter pressure,
electrical usage, acid tank level, and pump operations. Allows control of Pentair pool pump and
re lls pool when necessary. Has a full noti cation system utilizing email, SMS, and PushBullet as
well as system logging. Includes Alexa integration.

Supplies:

Raspberry Pi x 2 (https://www.newark.com/raspberry-pi/rpi4-modbp-2gb-bulk/raspberry-pi-
4-model-b-2gb-bulk/dp/02AH3163)
LowPower Labs MoteinoUSB x 4 (https://lowpowerlab.com/guide/moteino/)
LowPower Labs MightyHat x 1 (https://lowpowerlab.com/guide/mightyhat/)
Atlas Scienti c Electrically Isolated USB Sensor Board x 2 (https://www.atlas-
scienti c.com/product_pages/components/usb-iso.html)
Atlas Scienti c EZO pH Circuit Chip x 1 (https://www.atlas-
scienti c.com/product_pages/circuits/ezo_ph.html) /
Atlas Scienti
Pool Control by MD500_Pilot c EZO ORP Circuit
(/member/MD500_Pilot/) Chip
Follow x 1 (https://www.atlas- Download Favorite w I Made It

scienti c.com/product_pages/circuits/ezo_orp.html)
Sainsmart 2-Channel 5V Relay Module (https://www.sainsmart.com/products/2-channel-5v-
relay-module)
eTape - Liquid Level Tape (https://milonetech.com/) x 1
Adafruit PKCell 4400mAh 3.7V LiPo Battery Pack x 1 (https://www.adafruit.com/product/354)
NEMA3 External Enclosure x 1 (https://www.streakwave.com/itemdesc.asp?ic=HW-N14-2F)
15A Outlet x 1 (https://www.homedepot.com/p/Leviton-15-Amp-Residential-Grade-
Grounding-Duplex-Outlet-White-10-Pack-M24-05320-WMP/100055784)
TP-Link N300 USB Wireless Adaptor x 1
(https://www.amazon.com/gp/product/B00416Q5KI/ref=od_aui_detailpages00?
ie=UTF8&psc=1)
HA28W-6A 250V Line Noise Supressor x 1 (https://www.amazon.com/Power-Filter-HA28W-6A-
Lines-Adapter/dp/B01D3RW10S)
Basler 240VAC - 24VAC Transformer x 1 (https://www.ebay.com/itm/Basler-Electric-
BE23761001-Transformer-PRI-208-240-480V-50-60Hz-SEC-24V-50VA/112162915855?
hash=item1a1d6e460f:g:VE4AAOSwySlaAe7u)
Adafruit Rugged Metal Pushbutton Switch - Momentary x 2
(https://www.adafruit.com/product/481)
Adafruit Rugged Latching LED DPDT Switch x 1 (https://www.adafruit.com/product/482)
OpenEnergyMonitor EmonPi Base Station x 1 (https://shop.openenergymonitor.com/emonpi-
3/)
MAX6816 Debouncer (for water meter) x 1
(https://datasheets.maximintegrated.com/en/ds/1896.pdf )
Maxim Integrated DS18B20 Waterproof Temperature Sensor x 3
(https://www.adafruit.com/product/381)
Adafruit Waterproof DC Power Cable x 2 (https://www.adafruit.com/product/743)
Adafruit PG-9 Cable Waterproof Cable Gland x 2 (https://www.adafruit.com/product/761)
Adafruit Project Box - Waterproof x 2 (https://www.adafruit.com/product/903)
Desiccant Dehumidi er Packets x 1
(https://www.amazon.com/gp/product/B00E880DYS/ref=pe_385040_195497350_pd_te_s_c
h_ti/188-8111963-6999408)
Pressure Sensor x 1 (https://www.ebay.com/itm/Pressure-transducer-or-sender-100-psi-5V-
for-oil-fuel-air-water-/261260635816)
DFRobot XKC-Y25-T12V Liquid Level Sensor x 1 (https://wiki.dfrobot.com/Non-
contact_Liquid_Level_Sensor_XKC-Y25-T12V_SKU__SEN0204)
EmonCMS - Environmental Data Monitoring Application (https://emoncms.org/)

 Add Tip V Ask Question | Comment Download

Teacher Notes

Teachers! Did you use this instructable in your classroom?


Add a Teacher Note to share how you incorporated it into your lesson.
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Add Teacher Note Download Favorite w I Made It

Step 1: The Idea

(https://content instructables com/F0I/G0YD/K7ETG7UZ/F0IG0YDK7ETG7UZ LARGE jpg?auto=webp&frame=1&fit=bounds)

Over the summer my sons and I rebuilt our entire pool system. It started with a problem with the
water lines and valves that we inherited when we got the house, lter issues and a basically
inept pool company that was a holdover from when we got the house. Once it started to look
like a swamp, I decided it was time to do something.

 Add Tip V Ask Question | Comment Download

Step 2: At Last, a Clean Pool...

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/FET/K4JF/K7ETG7SF/FETK4JFK7ETG7SF LARGE jpg?auto=webp&frame=1&fit=bounds)

The rst priority was to get the pool cleaned up and then gure out how to keep it that way. I
always loved automation and I gured this was a perfect place to try it out. Shortly, the pool
looked great again.

But the problem still remained that the overall system lacked in both capability and intelligence,
something that I wanted to change. So rst things rst, we needed to replace the lter, pump
and a bunch of the valves. I spent a lot of time on a website called Trouble Free Pool
(https://www.troublefreepool.com/blog/) and it was a lifesaver for the DIYer.

 Add Tip V Ask Question | Comment Download

Step 3: Identify the Problems

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

3 More Images
(https://content instructables com/F06/ZWLU/K7ETG7V8/F06ZWLUK7ETG7V8
auto=webp&frame=1&fit=bounds) LARGE jpg? (https://content instructables com/FFC/YNT1/K7ETG7WV/FFCYNT1K7ETG7WV
auto=webp&frame=1&fit=bounds) LARG

While our pool was now looking crystal clear, the problem remained that the system running
the pool was way old and out of date. Something needed to be done and that is when my son's
and I decided to overhaul the entire pool system and write our own code to run it all.

/
We were hit
Pool Control by MD500_Pilot with a few setbacks,
(/member/MD500_Pilot/) one
Follow
of which was when they installed the fence they
Download w
pouredI Made It
Favorite
concrete around the lines going from the lter system to the pool.

Needless to say, all of that concrete and those pool lines had to be replaced in order for the
project to move forward. Pretty much everything had to go.

Early on I had decided to incorporate some automation into the new pool system. I opted for a
management system called the Autopilot. (My family says I chose it because I am a pilot and
liked the name!) This system would allow me to convert the pool to a saltwater pool and handle
some of the management, mainly running the saltwater generator when necessary and
pumping acid to manage the pH. There was no other automation beyond those things.

Eventually, we got everything gured out. We also got our kitchen back which ended up being
my workshop for the project.

 Add Tip V Ask Question | Comment Download

Step 4: Automation: the Beginning

(https://content instructables com/FXC/1QTD/K7ETG7TP/FXC1QTDK7ETG7TP


auto=webp&frame=1&fit=bounds) LARG

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/FLJ/PLPW/K7ETG85W/FLJPLPWK7ETG85W


auto=webp&frame=1&fit=bounds) LARGE jpg? (https://content instructablesauto=webp&frame=1&fit=bounds)
com/F22/Z5RJ/K7ETG7T6/F22Z5RJK7ETG7T6 LARGE

Now that the physical plant was installed and operational, I thought it would be nice to be able
to ll the pool without having to get the hose out all of the time. I gured with a Raspberry Pi
and a normal sprinkler valve, I would be in business! I purchased another Pi (I use them all over
the place for various projects) and laid out what I wanted it to do.

Initially, I gured I needed to be able to do two things:

A way to measure the level of the water


A way to ll the pool once the water was low

I started to doing research and came along a company that manufactured a liquid tape measure
that changed resistance as the level of the water (or other liquid) went up or down. Milone
would be happy to create a speci c sized unit for me as well since none of their sizes would t
where I wanted to place it.

UPDATE: Unfortunately for some reason, my Milone eTape su ered from getting water inside
the actual jacket and failed. After discussing the issue with Milone I decided that the cost to
replace it and potentially su er the same problem was not worth the cost of replacement. To
make matters worse, I need a special size that they have to make speci cally for me.

So I needed another way to measure my pool level and decided on using one of the dual oats
shown above.

Since the di erence between my low water level and my normal water level is about three
inches, this worked perfectly for me. I just needed to gure out a way to mount it and make it
work correctly. /
Since I know
Pool Control by MD500_Pilot several other people
(/member/MD500_Pilot/) using
Follow
the eTape with great results, Download
I am going toFavorite
leave
w I Made It
everything about the eTape in my project and add to it the way I did the dual oat setup. This
way people can see several di erent options.

 Add Tip V Ask Question | Comment Download

Step 5: Gathering Sensor Data

(https://content instructables auto=webp&frame=1&fit=bounds)


com/F4B/30GJ/K7ETG7V9/F4B30GJK7ETG7V9 LARGE jpg?

Since it was going to be located across the yard from where my Pi would reside, it was going to
be necessary to connect it to its own device for reporting. Since I did not need a Pi for this, I
choose a battery-operated, low-power Arduino wireless clone that would transmit the
information back to an existing system that I already had in place around the house.

These units I purchased from Low Power Labs (https://lowpowerlab.com/). I ended up using four
of them in my project: one for the water level, one for the temperature of the water and two in
the main system to monitor a combination of internal enclosure temperature, lter pressure,
and water usage.

These Arduino clones use extremely low power - just ~7uA in deep sleep mode which means
they would last a very, very long time on two AA batteries. My water temp sensor oats around
my pool and my level sensor is nowhere near a power source, so I had to use battery-powered
wireless equipment.

Initially, I had no intention of doing anything other than add water to the pool automatically, but
as these things often go, the project grew with a mind of its own. Eventually, I would be able to
do the following:

/
Monitor(/member/MD500_Pilot/)
Pool Control by MD500_Pilot water level & add water
Follow as necessary Download Favorite w I Made It

Monitor pool temperature


Monitor lter pressure
Monitor pH
Monitor ORP
Monitor power use to determine if the pool pump is running
Monitor my sprinkler system to see if the sprinklers are running
Notify me when the system starts or adds water (via Pushbullet, Email or SMS)
Notify me when the system stops adding water
Notify me if the system encounters an error condition
Manually add water via CLI or by pressing a button on the enclosure
Provide a clean web interface to see the status of the system and allow me to start and stop
lling the pool via the web.
Interact with my Pool Control System via Alexa (get information and start/stop water)

 Add Tip V Ask Question | Comment Download

Step 6: Filling the Pool

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/FBX/PRV6/K7ETG813/FBXPRV6K7ETG813


auto=webp&frame=1&fit=bounds) LARG

(https://content instructables com/FY1/D9UB/K7ETG7T8/FY1D9UBK7ETG7T8


auto=webp&frame=1&fit=bounds) LARGE jpg? (https://contentauto=webp&frame=1&width=1024&height=1024&fit=bounds)
instructables com/F82/Q68F/K7ETG86P/F82Q68FK7ETG86P LARGE

Regardless of what triggers the pool lling routing (manually or automatically), I had to have a
way to get the water into the pool. Since we are required to have a vacuum breaker between our
irrigation and our city water supply already, I choose to tie it into my existing sprinkler system to
get water for the pool. I was basically creating another "zone" for my sprinkler system, complete
with a valve.

/
This presented
Pool Control by MD500_Pilot a problem in that
(/member/MD500_Pilot/) if my
Follow
sprinklers are running and I decided to ll the
Download pool, I
Favorite w I Made It
would be robbing whatever lawn zone was running water and it would not water the lawn
properly. So I had to devise a way to determine if the sprinklers were running. Initially, I used a
"blackout" time zone - i.e., if I knew my sprinklers were running from 3 am to 6 am, don't ll the
pool during that time. But that seemed a little non-technical. In researching my Rachio sprinkler
system I learned that they had a built-in API that would allow me to programmatically query the
status of the sprinkler system. In my case, I just had to ask a simple question: Are you running?

rachio_url = 'curl -s -X GET -H "Content-Type: application/json" -H "Authorization: Bearer xxxx-xxxxx-xx-xx


xx-xxxxx-xxx" <a href="https://api.rach.io/1/public/device/00xx00x-00xxx000-xxx0x000-00x0x0x0/current_schedu
le'"> <a href="https://api.rach.io/1/public/device/00xx00x-00xxx...</a"> https://api.rach.io/1/public/devic
e/00xx00x-00xxx...>>

This is called by my get_sprinkler_status function like such:

output = subprocess.check_output(pooldb.rachio_url, shell=True)


if output == "{}":
sprinklers_on = "No"

Now I can tell if my sprinklers are running!

My main application runs every 60 seconds, so if my sprinklers are running, I just do nothing for
another 60 seconds and check again. Eventually, the sprinklers will stop running and the pool
will start to ll automatically.

In order to actually ll the pool, I utilized a normal 24V AC sprinkler valve that I picked up at
Home Depot. I installed this with a one-way valve directly into my pool piping going to my pool.
The one-way valve prevents pressure from the pump from pushing water against the sprinkler
valve when the pump is in operation.

Since my pool electrical panel is 240V and I have no neutral in the panel, I had to get a 240VAC
to 24VAC transformer. Simple enough. However, I didn't want to run the transformer 24x7 for no
reason, so I used a relay to 1) turn on the transformer and then 2) take the 24VAC output from
the transformer and connect it to the sprinkler valve.

I used the Sainsmart solid-state relays (very inexpensive) in an optically isolated mode where I
have a separate power input powering the relays as opposed to using the 5v or 3.3v VCC from
the Pi. This is supposed to help with interference from the relays.

 Add Tip V Ask Question | Comment Download

Step 7: Tracking Water Usage

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

I also added a smart meter which I can read in real-time to show me that water is owing and
how much water over time I have been using. This information is stored in a MySQL database
and it stored historically.

 Add Tip V Ask Question | Comment Download

Step 8: Power, Power, Power

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

Now came the next thing I needed to gure out. While my pump was running, if I was
attempting to ll the pool, I would be ghting the pressure of the pump. I determined by
measuring water ow that I lost about 50% of my lling ow while the pump was running, so I
gured it would be best to not ll while the pump was running at all. So I needed a way to
monitor the power from my pump and gure out if it was running or not.

In this case, I had a very easy way to do this. Every single circuit in my home is monitored by an
electrical monitoring system. This system is called the GEM and it is sold by Brultech
(http://www.brultech.com/).

With this system, I can monitor all of the electrical usage in my house and as part of the
monitoring process, I store this data in a MySQL database. So once per minute I simply query my
MySQL database and gure out how many watts are currently in use by my pool panel.

if pool_pump_running_watts > pooldb.max_wattage:


pool_fill_control.led_control(PUMP_RUN_LED, "ON")
pool_pump_running = "Yes"
logger.debug('PUMP_RUN_LED should be ON. This is the YELLOW LED')
if DEBUG:
print("PUMP_RUN_LED should be ON. This is the YELLOW LED")
else:
pool_fill_control.led_control(PUMP_RUN_LED, "OFF")
pool_pump_running = "No"
logger.debug('PUMP_RUN_LED should be OFF. This is the YELLOW LED')
if DEBUG:
print("PUMP_RUN_LED should be OFF. This is the YELLOW LED")

I have various buttons, switches, and LEDs on the physical unit that allow me to see if the
sprinklers are running, the pump is running, the pool is lling or if there is a system error of some
sort. Above you can see where I toggle the pump running LED on and o when necessary.

In addition to the system LEDs, I have a system ON/OFF button (top left) which allows me to use
the MightyHat system to reboot or shutdown my Pi intelligently without having to log in to the
Pi to do it from the CLI. I also have a momentary switch (second on the left) that allows me to
manually ll my pool when I want, and nally, on the left side, I have a DPDT switch that
physically interrupts power from my system to the sprinkler valve and triggers a GPIO event to
tell the system we have manually disabled lling the pool. Nothing works when this switch has
been triggered and if something were to fail programmatically, no power can make it from the
transformer to the sprinkler valve regardless.

 Add Tip V Ask Question | Comment Download

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/)
Step
Follow
9: Managing the Pump Download Favorite w I Made It

(https://content instructables com/FTI/CFOQ/K7ETG85R/FTICFOQK7ETG85R


auto=webp&frame=1&fit=bounds) LARGE jpg? (https://content instructables com/FNQ/DOMI/K7ETGZKS/FNQDOMIK7ETGZKS
auto=webp&frame=1&fit=bounds) LARG

Over time I added in another piece to my pool control system. The ability to manage my Pentair
variable speed pump. Enter Russell Goldin (tageyoureit) (https://github.com/tagyoureit/nodejs-
poolController) and his pool controller software project. Russell's software allowed me to
communicate directly with my pool pump via an RS485 interface. Once connected, I can query
the pump directly for system information like RPM, GPM, and Watts in use:

def get_pump_data(key):
verbose_debug("get_pump_data() Started")
verbose_debug("get_pump_data() called with '{}' ".format(key))
log("INFO", "get_pump_data() called with '{}' ".format(key))
if pump_control_active:
global json
try:
req = urllib2.Request(pooldb.PUMP_DATA_URL)
opener = urllib2.build_opener()
f = opener.open(req)
data = json.load(f)
pump_data = data["pump"]["1"][key]
verbose_debug("get_pump_data() returned {}".format(pump_data))
log("INFO", "get_pump_data() returned {}".format(pump_data))
verbose_debug("get_pump_data() - Completed")
log("INFO", "get_pump_data() - Completed")
if key == "gpm":
pump_gpm = pump_data
update_database("pump_status", "pump_gpm", pump_gpm)
log("INFO", "Current GPM: {}".format(pump_gpm))
log("DEBUG", "get_pump_gpm() Completed")
debug("Current GPM: {}".format(pump_gpm))
verbose_debug("get_pump_gpm() Completed")
elif key == "rpm":
pump_rpm = pump_data
update database("pump status" "pump rpm" pump rpm)

Now I can query the pump and control my pump adding in another capability that I did not
have before. By altering my web interface, I added the ability to start or stop my pump as well as
run one of four di erent pump programs that I had con gured on my pump.

A big bene t of course, we get to look at RPM, GPM and Watts in real time!

 Add Tip V Ask Question | Comment Download

/
Step Follow
Pool Control by MD500_Pilot (/member/MD500_Pilot/)
10: Monitoring Filter Pressure
Download Favorite w I Made It

(https://content instructables com/FAU/NXIE/K7ETG85M/FAUNXIEK7ETG85M


auto=webp&frame=1&fit=bounds) LAR

(https://content instructables com/FFZ/TUNO/K7ETG85P/FFZTUNOK7ETG85P


auto=webp&frame=1&fit=bounds) LAR

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/F7N/VGAU/K7ETG85J/F7NVGAUK7ETG85J


auto=webp&frame=1&fit=bounds) LARGE jpg?

One thing I also wanted to do was to monitor the lter pressure so I knew when to back ush our
lter. I purchased a 100 PSI pressure sensor o eBay and tied it into my lter next to my analog
pressure gauge already on the lter.

I purchased an inexpensive sender unit o eBay (see link above) and tied it into my lter as
shown above.

I then tied this into a Moteino-R5 and I read the pressure once per minute and then output that
information to my MySQL database and then use that information to drive the gauge output on
my website.

// Get our Filter Pressure


void get_filter_pressure()
{
sensorVoltage = analogRead(PSI_SENSOR_PIN); // Let's read our pressure sensor voltage
PSI = ((sensorVoltage-146)/204)*25; // Some calibration to convert the voltage to PSI and zero it
pool_sensors.PSI = PSI;
}

 Add Tip V Ask Question | Comment Download

Step 11: Power Backup & Local Display

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/FTC/24RD/K7ETH1JE/FTC24RDK7ETH1JE LARGE jpg?auto=webp&frame=1&fit=bounds)

The main system is written almost entirely in Python, but I utilized other software and hardware
to make my system work.

On my Raspberry Pi, I utilize a Low Power Labs MightyHat which provides UPS power backup to
the Pi, an LCD status screen and intelligent power control for the Pi. I can run the Pi for about
two hours or so on the small battery I have attached to the system and if the power does not
come back on it time, then the MightyHat will automatically shut down the Pi to prevent it from
crashing due to a sudden power failure.

The MightyHat is an Arduino clone so I used the Arduino IDE to program it to t the needs of my
project.

 Add Tip V Ask Question | Comment Download

Step 12: Graphing Pool Data

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

For sensing, I use a variety of sensors and methods of getting the information into a usable
format. For pretty much all sensor data, I utilize OpenEnergyMonitor.org
(http://OpenEnergyMonitor.org) free EmonCMS platform. This platform allows me to collect all
of my sensor data from everywhere in my house wirelessly on 433Mhz. It stores this information
in a MySQL database where I can then grab it for utilization in my pool control system.

 Add Tip V Ask Question | Comment Download

Step 13: Prototype and I/O

(https://content instructablesauto=webp&frame=1&fit=bounds)
com/FZ8/ED8I/K7ETG7V3/FZ8ED8IK7ETG7V3 LARGE

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

I did a lot of work on prototyping before actually putting the system together and online. I
needed to design and make up my LED control board, test and retest everything and ne-tune a
lot of stu before mounting everything.

 Add Tip V Ask Question | Comment Download

Step 14: PH and ORP Monitoring

(https://content instructables com/FD0/LCMB/K7ETG7UU/FD0LCMBK7ETG7UU


auto=webp&frame=1&fit=bounds) LARGE

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

3 More Images

In order to get accurate pH and ORP readings, I utilize Atlas Scienti c pH and ORP sensors as well
as their interface boards. I installed them in a ow cell which also monitors if the pump is
running. I tied the ow cell into the lines using standard John Guest 3/8" quick connects, one on
the pressure side of the lter and one on the suction side of the pump to keep water owing
through the ow cell.

Reading our pH:

def get_ph_reading():
log("DEBUG", "get_ph_reading() Started")
pool_pump_running = read_pool_sensor_status_values("pool_sensor_status", "led_status", "pump_run_led" )
if pool_pump_running == "True":
if pooldb.temp_probe == "Yes":
pool_temp = float(read_pool_sensor_status_values("pool_sensor_status", "system_status", "pool_c
urrent_temp" ))
ph_value = float(get_ph.get_current_ph_with_temp(pool_temp))
else:
ph_value = float(get_ph.get_current_ph_no_temp())
debug("Current pH is: {}".format(ph_value))
influx_data.write_data("pH", ph_value)
influx_data.write_data("pool_temp", pool_temp)
if pooldb.emoncms_server1 == "Yes":
res = requests.get("http://" + pooldb.server1 + "/" + pooldb.emoncmspath1 + "/input/post?&node
=" + str(
pooldb.ph_node) + "&csv=" + ph_value + "&apikey=" + pooldb.apikey1)
log("DEBUG", "Sent current pH Value of {} to Emoncms Server 1".format(ph_value))
debug("Sent current pH Value of {} to Emoncms Server 1".format(ph_value))
if pooldb.emoncms_server2 == "Yes":
res = requests.get("https://" + pooldb.server2 + "/" + pooldb.emoncmspath2 + "/input/post?&node
=" + str(
pooldb.ph_node) + "&csv=" + ph_value + "&apikey=" + pooldb.apikey2)
log("DEBUG",
"Sent current pH Value of {} to Emoncms Server 2".format(
ph value))

This code calls the "get_ph.py" module which looks like this:

/
#!/usr/bin/python
Pool Control by MD500_Pilot (/member/MD500_Pilot/)
## For use with pool_control_master.py
Follow Download Favorite w I Made It

__author__ = 'Richard J. Sears'


VERSION = "V3.4 (2018-03-16)"
# richard@sears.net
# This is for use with Atlas Scientific pH board only.
import serial
import sys
import time
from serial import SerialException
usbport = '/dev/PH'
try:
ser = serial.Serial(usbport, 38400, timeout=0)
except serial.SerialException as e:
print "Error, ", e
sys.exit(0)
def read_line():
lsl = len('\r')
line_buffer = []
while True:
next_char = ser.read(1)
if next_char == '':
break
line_buffer.append(next_char)
if (len(line_buffer) >= lsl and
line buffer[ lsl:] == list('\r')):

The ORP is done the same way. This ow cell also has a ow indicator installed. If water is owing
through the cell, the ring rises and closes a magnetic switch. The wiring for the switch is
connected to a GPIO pin on the pi. Here is my code to read that switch:
def pool_pump_running_chemical():
pool_pump_running_chemical = GPIO.input(pool_pump_running_pin)
if pool_pump_running_chemical == False:
debug("Pool Pump Running via Chemical Sensor Chamber: TRUE - PUMP IS RUNNING")
else:
debug("Pool Pump Running via Chemical Sensor Chamber: FALSE - PUMP IS OFF")

 Add Tip V Ask Question | Comment Download

Step 15: Mounting the Water Level Sensor & Making It Work...

(https://content instructables com/FU0/3A2V/K7ETG7US/FU03A2


auto=webp&frame=1&fit=bounds)

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

3 More Images

Because my Milon eTape failed early on, I moved to a super simple dual oat setup. This means
that I had to gure out a way to mount the oat in such a way that it gave me good information
about the level of my pool. I used a plastic nut on the bottom plate of the oats to " ne-tune"
the height of the oats. With two oats, I get "Low", "Medium" and "Full" readings for my water
level.

Here is the code:

UPPER_Float = digitalRead(17);
LOWER_Float = digitalRead(3);

if (UPPER_Float == LOW)
{
UPPER_Float_Position = "Closed";
}
else
{
UPPER_Float_Position = "Open";
}
if (LOWER_Float == LOW)
{
LOWER_Float_Position = "Closed";
}
else
{
LOWER_Float_Position = "Open";
}
if ((UPPER_Float == LOW) && (LOWER_Float == LOW))
{
pool_level.level = 2; // Both closed = Pool is FULL
}
else if ((UPPER_Float == HIGH) && (LOWER_Float == LOW))
{
pool level level = 1; // Lower closed Upper open = Pool MIDWAY

So the value of 0, 1 or 2 is transmitted to EmonCMS and written to my database. Each minute we


query that database to see if we need to add water:
get_pool_level_value = read_emoncms_database("data", pooldb.pool_level_table)

and if it is low, we add water:


if get_pool_level_value == 0:
get_pool_level = "LOW"
pool_fill_valve("OPEN")

/
From there(/member/MD500_Pilot/)
Pool Control by MD500_Pilot I took a /4" piece ofFollow
plexiglass and used a dremmel to shape it so that itFavorite
Download w
would t IinMade It
my basin where I measure the water level. I then "calibrated" the level and used epoxy to glue it
into the place where I wanted it. The electronics all went into my waterproof box and it works
like a charm.

One thing to note is that I graph both the temperature and humidity of my sensor boxes so I
know if/when I end up with high humidity in the box. I use desiccant in my boxes but inevitably I
need to change it out from time-to-time. The humidity sensor tells me when I need to do that.

As I showed above, the water level sensor utilizes a battery-powered MoteinoUBS by


LowPowerLab. This is a perfect microcontroller for this application. Basically, I wake the Moteino
up every sixty seconds, take a resistance reading from the eTape, re up my transmitter and send
this information to my EmonCMS system for use by my pool scripts. Then I power everything
down again:

{
digitalWrite(ETAPE_POWER, HIGH); // Turn on the power to eTape
pool.resistance = analogRead(ETAPE); // read etape resistance
digitalWrite(ETAPE_POWER, LOW); // Turn off power to eTape
take_battery_reading(); // Take Battery Reading
power_spi_enable();
rf12_sleep(RF12_WAKEUP);
rf12_sendNow(0, &pool, sizeof pool);
rf12_sendWait(2);
rf12_sleep(RF12_SLEEP);
power_spi_disable();
if (debug){
flash_led(50);
}
// That's it - wait until next time :)
sleep_until_next_reading();
}

By doing it this way I can run for over a year without having to change the batteries!

 Add Tip V Ask Question | Comment Download

Step 16: Pool Temperature Sensor - Making It Work

(https://content instructables auto=webp&frame=1&fit=bounds)


com/F6D/Y7FB/K7ETG81Z/F6DY7FBK7ETG81Z LARGE jpg? (https://content instructables auto=webp&frame=1&fit=bounds)
com/F4I/AXQS/K7ETG81Y/F4IAXQSK7ETG81Y LARGE jp
/
Following (/member/MD500_Pilot/)
Pool Control by MD500_Pilot in the footsteps of my level sensor, I build the same con guration
Follow Download for myFavorite
pool
w I Made It
temperature sensor. Like my level sensor, I have both temperature and humidity sensors in the
box. It would also let me know what the temperature was just above the surface of the water in
the pool. A second temperature sensor was fed through the PG-9 cable gland and into the pool
water. I then just tossed the enclosure into the pool and thought I was done. However, my kids
had other ideas. They thought it was fun to grab the temperature sensor hanging down from
the enclosure and spin it around like a top and throw it at each other. Needless to say, the rst
one didn't last long.

So I went down to my local pool store and purchased a chlorine oater and installed the
enclosure and temp probe into it. We have not had a problem since doing so. Even if they throw
it, it won't bother it at all. Most people leave it alone since they think it is chlorine even though
we have a saltwater pool.

 Add Tip V Ask Question | Comment Download

Step 17: Keeping Track of Our Acid Level

(https://content instructables com/FVF/8R1B/K7ETG7S8/FVF8R1BK7ETG7S8


auto=webp&frame=1&fit=bounds) LARGE

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

Part of the pool automation system that is not yet handled by my project is the dispensing of
muriatic acid to keep our pH under control. While the Pool AutoPilot system handles that, we
still need to be able to see if we need acid added to the tank. For this task, I used a $9.00
DFRobot Liquid Level Sensor. This sensor is epoxied to the acid tank at the level I want it to alert.

This particular sensor is weatherproof and works by sensing when there is no longer liquid
behind whatever you have it attached to and then sending a signal to the GPIO that you can
read. Once you can read it, you can then do your alerting, etc.

I simply connected this to my Pi (it utilizes the 5v rail and one GPIO pin) and then added in a
little bit of code to read the state of the sensor:

def acid_level():
acid_level_ok = GPIO.input(acid_level_sensor_pin)
if acid_level_ok == True:

This tank has a pretty thick wall and this sensor worked great. I tested it before a xing it just to
make sure.
 Add Tip V Ask Question | Comment Download

Step 18: Web Interface

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables auto=webp&frame=1&fit=bounds)


com/FJ9/6OXF/K7ETG88R/FJ96OXFK7ETG88R LA

Once I had all of this pretty much working as I wanted it, I decided that I needed to have a nice
interface so we could track all of the data, manually add water to the pool without having to go
to the pool room, stop an automatic ll that may be in progress and check the status of the
batteries in our temperature sensor and our level sensor.

The main capabilities of the web interface as of right now are:

Visually see all sensor data on nice gauges


See system status including overall status, pump status, lling status, sprinkler status (we
cannot ll while the sprinklers are running) and our Acid level
Visually see battery status of pool level and temp sensors (including household temp sensors)
See temperature and humidity inside the actual sensor boxes so I can see if I have a potential
water leak in my "water proof" boxes.
/
Have the
Pool Control by MD500_Pilot ability to toggle various
(/member/MD500_Pilot/) Follow noti cations such as debug, logging, email, pushbullet,
Download Favorite w
and
I Made It

sms messages from the interface


Control Pentair Intelli o pool pump

I am very thankful to Russell Goldin (russ.goldin@gmail.com) for his amazing work on the Pentair
RS-485 control software needed for my system to be able to talk to and control my pump. You
can check out his GitHub HERE (https://github.com/tagyoureit/nodejs-poolController/tree/4.x-
DEV).
With Russ's software, I am able to directly control my Pentair pump without having to spend
several thousand dollars on their proprietary hardware!

I spent a lot of time programming everything in python but I did not have any experience
building a web interface so I asked around and eventually decided on Flask as the web
framework that I would use to build the web interface. Flask is used on many sites including a
very small one called Instagram! I gured it was up to the task of running my pool system.
Learning Flask was not as hard as I had thought it was going to be and it integrates very well
with the python code that I had already written to control the pool. Flask is a mix of python-like
code and html like templates (called junja2) and did everything that I needed it to do.

The control part of the interface is very easy. If I want to start a manual ll, I simply click on the
"Manual Fill" button and as long as there is not a system problem, we are not running the
sprinklers and we are not already "automatically" lling the pool, the system starts a manual ll
of the pool. The "Pool Filling" led will turn blue, then "Manual Fill" button will toggle on and the
"Fill Timer" will start a count up. Click the "Manual Fill" button again and the system stops lling
and reverts back to normal.
If we are lling the pool automatically and I want to stop that process, I simply click the "Pool
Filling" button (led reverts to button to show that you can push it to stop the automatic ll) and
the system stops lling and sends me noti cations based on the con guration of the system
(debug, logging, email, pushbullet, sms).

Flask has the ability to process things prior to showing you the html output:

{% if system_error_led == "True" %}

{% elif system_run_led == "True" %}

{% else %}

{% endif %}

This is called jinja templeting and it is truly and amazing and powerful feature. In this example, if
there is a system error I show a red led, otherwise if the system is running I show a green led and
if I am not running and there is no error, then I show a grey led. This statement is processed
before the html is rendered and is a very powerful way to interact with a python driven system.
 Add Tip V Ask Question | Comment Download

Step 19: Historical Graphing With Grafana

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

As I continue to extend the system and learn more about what I can do, I wanted to start to
watch historical trends in my pool system along with a lot of other home automation stu I have
been playing around with lately. After looking around I choose Grafana and In uxDB.

Basically I already had my data being recorded utilizing EmonCMS so I just needed to have a
quick way to get it into In uxDB so Grafana could do it's magic. Basically within the mail pool
program whenever I get a pH, ORP or temp reading, I write it to the in uxdb:

def get_ph_reading():
log("DEBUG", "get_ph_reading() Started")
pool_pump_running = read_pool_sensor_status_values("pool_sensor_status", "led_status", "pump_run_led" )
if pool_pump_running == "True":
if pooldb.temp_probe == "Yes":
pool_temp = float(read_pool_sensor_status_values("pool_sensor_status", "system_status", "pool_c
urrent_temp" ))
ph_value = float(get_ph.get_current_ph_with_temp(pool_temp))
else:
ph_value = float(get_ph.get_current_ph_no_temp())
debug("Current pH is: {}".format(ph_value))
influx_data.write_data("pH", ph_value)
influx_data.write_data("pool_temp", pool_temp)
if pooldb.emoncms_server1 == "Yes":
res = requests.get("http://" + pooldb.server1 + "/" + pooldb.emoncmspath1 + "/input/post?&node
=" + str(
pooldb.ph_node) + "&csv=" + ph_value + "&apikey=" + pooldb.apikey1)
log("DEBUG", "Sent current pH Value of {} to Emoncms Server 1".format(ph_value))
debug("Sent current pH Value of {} to Emoncms Server 1".format(ph_value))
if pooldb.emoncms_server2 == "Yes":
res = requests.get("https://" + pooldb.server2 + "/" + pooldb.emoncmspath2 + "/input/post?&node
=" + str(
pooldb.ph_node) + "&csv=" + ph_value + "&apikey=" + pooldb.apikey2)
log("DEBUG",
"Sent current pH Value of {} to Emoncms Server 2".format(
ph value))

and from in ux_data.py:

/
import sys (/member/MD500_Pilot/)
Pool Control by MD500_Pilot
sys.path.append('../')
Follow Download Favorite w I Made It

from influxdb import InfluxDBClient


import pooldb
def write_data(measurement, value):
client = InfluxDBClient(pooldb.influx_host, pooldb.influx_port, pooldb.influx_user, pooldb.influx_passwor
d, pooldb.influx_dbname)
json_body = [
{
"measurement": measurement,
"fields": {
"value": value
}
}
]
client.write_points(json_body)

From there it is a simple matter of setting up Grafana to look at the In uxDB and make the
graphs!
 Add Tip V Ask Question | Comment Download

Step 20: Notifications

(https://content instructables com/F31/ICUX/K7ETHEO8/F31ICUXK7ETHEO8 LARGE jpg?auto=webp&frame=1&fit=bounds) /


My system(/member/MD500_Pilot/)
Pool Control by MD500_Pilot relies heavily on notiFollow
cations. Currently, the system can provide
Downloadnoti cations w
Favorite via I Made It
logging to a log le, debug messages to stdout allowing for the running of the main program
from the command line with valuable, immediate feedback, pushbullet, email and SMS via
Twillio. Because of all the types of noti cations as well as areas where there can be noti cations, I
created a system that allows me to ne-tune my noti cations very easily via my web interface.

By setting up the code in this manner, I can very easily and quickly adjust my noti cation
settings as well as di erent categories that I want to have those noti cations applied to at that
time. In future versions of the code, I am going to create an entire "Noti cations" panel that
allows me the ability to set speci c noti cation types by category. For example, I might want an
SMS message about lling events, but email noti cations about system errors and pushbullet
noti cations about my pump. In this manner I am able to tweak all of my noti cation settings to
be exactly how I want then to notify me...both the how and the when!

Running from the CLI:


root scruffy: www # ./pool_control_master.py
Started is_database_online()
MightyHat Serial setup completed
System Reset Status = No Reset Requested
Started get_pool_temp()
get_pool_temp returned 67.30F
pool_temp in C is 19.61
Started is_pool_pump_running()
pool_pump_running_watts returned 563 watts in use by pump.
PUMP_RUN_LED should be ON. This is the YELLOW LED
Current unix datetime stamp is: 1521835161
Pool LEVEL sensor last updated at: 1521835044
Pool LEVEL sensor battery voltage is: 3.2
Pool LEVEL sensor battery percentage is 100
Pool TEMP sensor last updated at: 1521835131
Pool TEMP sensor battery voltage is: 3.2
Pool TEMP sensor battery percentage is 100
Pool FILTER PSI is: 21
Time dfference between last pool LEVEL sensor reading is: 117 seconds.
Time dfference between last pool TEMP sensor reading is: 30 seconds.
Everything appears to be OK with the pool sensors!
pool_sensors: Pool Resistance is: 724
pool_sensors: Pool Level Percentage is: 85
pooldb: Static critical pool level resistance set at (740).
pooldb: Static normal pool level resistance set at (710).
Our Pool Level is MIDWAY

 Add Tip V Ask Question | Comment Download

Step 21: Alexa Skill and Interface

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/FN0/WO1L/K7ETG7S9/FN0WO1LK7ETG7S9 LARGE jpg?auto=webp&frame=1&fit=bounds)

One of the last things I wanted to tackle was to integrate my pool control system with Alexa. We
have Echo Dots and Echo Shows and I wanted to use the visual Echo Show when I could. So I
spent a bunch of time learning how to do Alexa skills and then I used the Python
microframework Flask-Ask to program the interconnection between my pool control system and
the Alexa Skill.

It was a very interesting learning curve, but now I can query Alexa and get all of our pool stats
and we can ll (or stop lling) our pool via voice commands.

 Add Tip V Ask Question | Comment Download

Step 22: Conclusions

/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

(https://content instructables com/FKW/JS6Y/K7ETG7UV/FKWJS6YK7ETG7UV LARGE jpg?auto=webp&frame=1&fit=bounds)

I am running V3.5.0 of my code now which seriously changes the way I am checking sensors,
and handling error checking. I have also started breaking out my code into separate python
functions instead of a monolithic block of 4,000+ lines of code. I will put it up and include all of
the Flask programming as well.

This project has taught me a lot about programming, the Pi and Arduinos.

To view all of the code, please visit my Github site HERE


(https://github.com/rjsears/Pool_Fill_Control)! Thank you for reading about my project.

 Add Tip V Ask Question | Comment Download

Be the First to Share


Did you make this project? Share it with us!

I Made It!
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
Recommendations

(/id/Smart-Indoor-Herb-Garden/) (/id/Light-Clock-Alarm/)

Smart Indoor Herb Garden (/id/Smart- Upcycled Alarm Clock Smart Light
Indoor-Herb-Garden/) by Sunyecz22 (/id/Light-Clock-Alarm/) by theredbryophyte
(/member/Sunyecz22/) in Arduino (/member/theredbryophyte/) in Raspberry Pi

 126 8 7.7K  43 8 5.4K

(/contest/arduino2020/) (/contest/fta2020/)

 Add Tip

V Ask Question

| Post Comment

We have a be nice policy.


Please be positive and constructive.

Add Images Post

10 Discussions

S13BranstonR (/member/S13BranstonR/)
(/member/S13BranstonR/)
Question 9 days ago on Introduction
Answer / Upvote
how much did it cost
1 answer F

(/member/welties24/) welties24 (/member/welties24/) Question 5 weeks ago on Step 16

Answer / Upvote
If the pool temperature sensor works wireless can you install a small solar panel to keep the battery
pack charged at all times as the floater is permanently in the pool and the sun can charge it
5 answers F

/2 (/member/jessyratfink/) jessyratfink (/member/jessyratfink/) 2 months ago


Reply / Upvote
Dang - that is a huge job! Great work :D
1 reply F /
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It

Post Comment

Categories About Us Resources


 Circuits  Living Who We Are Sitemap (/sitemap/)
(/circuits/) (/living/) (/about/) Help (/id/how-to-
 Workshop  Outside Why Publish? write-a-great-
(/workshop/) (/outside/) (/create/) instructable/)

 Craft  Teachers Jobs (/jobs/) Contact (/contact/)


(/craft/) (/teachers/)
 Cooking
(/cooking/)
Find Us

(https://www.instagram.com/instructables/) (https://www.pinterest.com/instructables) (https://www.facebook.com/instructables) (https://www.twitter.com/instructables)

© 2020 Autodesk, Inc. Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721)


Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079)
Privacy settings
Legal Notices & Trademarks (http://usa.autodesk.com/legal-notices-trademarks/)
(http://www.autodesk.com)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy