Pool Control - 22 Steps (With Pictures) - Instructables
Pool Control - 22 Steps (With Pictures) - Instructables
Download Favorite
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/)
Teacher Notes
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.
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
/
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.
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
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.
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
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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?
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.
/
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.
/
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.
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.
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/)
Step
Follow
9: Managing the Pump Download Favorite w I Made It
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!
/
Step Follow
Pool Control by MD500_Pilot (/member/MD500_Pilot/)
10: Monitoring Filter Pressure
Download Favorite w I Made It
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
/
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.
(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.
/
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.
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
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")
Step 15: Mounting the Water Level Sensor & Making It Work...
/
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.
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
/
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.
{
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!
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.
/
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
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
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" %}
{% 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
/
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))
/
import sys (/member/MD500_Pilot/)
Pool Control by MD500_Pilot
sys.path.append('../')
Follow Download Favorite w I Made It
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
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!
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
/
Pool Control by MD500_Pilot (/member/MD500_Pilot/) Follow Download Favorite w I Made It
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.
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
(/contest/arduino2020/) (/contest/fta2020/)
Add Tip
V Ask Question
| Post Comment
10 Discussions
S13BranstonR (/member/S13BranstonR/)
(/member/S13BranstonR/)
Question 9 days ago on Introduction
Answer / Upvote
how much did it cost
1 answer F
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
Post Comment