rjsears / Pool_Fill_Control

Raspberry Pi / Arduino / Python Project to automate management of swimming pool.
23 stars 4 forks source link
arduino emoncm etape flask gpio grafana-dashboard home-automation influxdb motei mysql pool-automation python rapsberrypi

Pool_Fill_Control V3.5.1 (2019-03-02)

Major updates to data storage using MySQL and InfluxDB and away from flat files. Please see the bottom of this readme for more updates!
Raspberry Pi / Arduino / Python / Alexa Project to automate pump management and filling of swimming pool along with tracking of various temperature and humidity sensors, smart water meters and more. Includes Flask based Web Interface and Alexa Skill.

This software is not really intended to be "plug-and-play" but rather sharing of code, hardware and sensor ideas that you can use as a starting point in your own pool management and/or home automation system. Enjoy!

While this readme is pretty specific to the code portion of the project, an in-depth writeup of the entire project from start to finish is available on Hackster.io with tons more detail and pictures! I have tried to include the different parts of the system in this readme, and over time I will expand this readme to include more about the project.



Updated Web Interface created and managed with Flask

alt tag


This pool control software system was designed to automate and manage some everyday pool management tasks. It started out with just filling the pool, hence the name of the repo: pool_fill_control. It grew into far more than that and now is integrated into a variety of systems around our home. Here is a current (as of V3.5.0) list of items managed or monitored by the system:


The basic premise of the system is pretty simple. Utilizing a variety of low-power arduino clones as system "sensors" we measure the water level of the pool and check to see if the sprinklers are running. If the water is low and the sprinklers are not running, we turn on a transformer that powers a sprinkler valve and we refill the pool. Once the pool has been filled to a specific level, we shut off the water. Since we fill from our irrigation system, we need to know if the sprinklers are running. If they are, we do not have enough water pressure to run several zones at once so the system will keep checking and will refill the pool once the sprinklers are done.

Over time I added temperature monitoring, pH and ORP monitoring (but not control), Acid tank level monitoring, pool filter pressure monitoring, electrical (including solar) monitoring and pool pump management utilizing Russell Goldin's poolController Software. Because much of our house has other sensors I included monitoring of battery levels of various temperature and humidity sensors around the house that have nothing to do with the pool, but since I had the system in place to monitor and alert for these I went ahead and added them anyway. This is the same for overall power utilization and solar production.

I have also been working on adding in Alexa integration and learning how to build Alexa skills around the house. I have created a skill that allows you to query the system for all of the pool stats as well as to start and stop filling of the pool. The kids can also ask it if it is ok to go swimming and Alexa will ask them for the temperature they like the water, compare that to the current water temperature and then let them know if it is ok to go swimming. More a programming challenge than anything else. The Alexa interface is coded using the Flask-Ask python framework, but as I understand it, Flask-Ask is no longer being maintained so I may have to move to the much more difficult Pythin Alexa SDK in the future.


Alexa Echo Show Display


alt tag alt tag alt tag



Our system relies on a lot of external applications and hardware. Depending on how you plan on setting up your system you may or may not need all of these applications or hardware devices. It is outside the scope of this readme to go through the installation procedures of the various software system and setup of hardware, but you can always email if you run into trouble. I am sure I might have missed something so this might not be an exhaustive list:
  1. Raspberry Pi
    • The "brains" behind the operation. Our main python code runs on a Raspberry Pi Model 3 with a 65GB SD Card.
  2. OpenEnergyMonitor's EmonPi
    • A RaspberryPi powered hardware device that allows for electrical and temperature monitoring as well as being a hub for the reception of all wireless sensor data. Manages storing data to MySQL for use by other systems as well as forwarding this data to other EmonCMS instances (locally or in the cloud).
  3. OpenEnergyMonitor's Open Source Energy Monitoring Platform (EmonCMS)
    • This system gathers and writes various sensor data to a MySQL database for use by pool_fill_control. We utilize 433Mhz radios from our sensors and transmit our data to EmonCMS. From there we can access it from our program. This runs on our EmonPi as well as on several "backup" servers to house our environmental data.
  4. LowPowerLab's MightyHat
    • MightyHat is a Raspberry Pi Hat with that makes it easy to build a compact, robust, battery backed-up gateway for the internet of things. It accepts RFM69W/HW/HCW or LoRa transceivers and acts as a power controller and UPS for the RaspberryPi. This is on the main RaspberryPi that runs our system at the pool.
  5. LowPowerLab's R6 Moteino
    • The Moteino is a super-low-power Arduino clone that incorpoprates a 433Mhz FSK (RFM69HCW) transceiver which transmits data to our EmonPi.
  6. Atlas Scientific pH and ORP Probes and boards
    • USB input boards and probes for pH and ORP.
  7. pH and ORP Flow Cell
    • Flow cell purchased from Sunplay to house our pH and ORP sensors as well as to provide water flow sensing.
  8. Elecall Stainless Steel Tank Water Level Sensor Float Switch
    • Stainless steel dual level water level sensor used to monitor the water level in the pool so we know when to refill it. Has "low" and a "high" side floats that are monitored with an EmonTH sensor.
  9. MySQL
    • Used by EmonCMS as well as our pool control system to store both environmental data as well as system states and other data.
  10. InfluxDB
    • Used to store temperature, humidity, pH, ORP and electrical data specifically for graphing by Grafana.
  11. Grafana
    • Used to build grahing interfaces for web interface via i-frames for our web interface (pH & ORP) as well as other system graphing needs.
  12. Flask
    • Python Microframework used to build the front-end web interface for our pool control project.
  13. Flask-Ask
    • Alexa skills kit for Python by John Wheeler. (Will be moving away from Flask-Ask as the rumor is that John is no longer maintaining the project).
  14. PoolController
    • Software written by Russell Goldin to manage Pentair pool pumps via an RS485 interface. This is how we control our pump.
  15. Apache
    • Web server for both the web frontend as well as https frontend for our Alexa skills.
  16. Pushbullet
    • Used as one of our notification methods.
  17. pushbullet.py
    • Python client for working with PushBullet
  18. Twilio
    • Used to send SMS text messages as one of our notification methods.
  19. Steel Series Gauges
    • Gauges for use with our web interface.
  20. DF Robot Liquid Level Sensor
    • Non-Contact liquid level sensor used to monitor the level of Acid in our holding tank. Connected to a Raspberry Pi.
  21. Brultech GEM Greeneye Electrical Monitor
    • Home electrical monitoring system and dashboard. Monitors every single electrical circuit in our house and utilizes a python script to write all of the data to EmonCMS where we can use it to monitor pool system electrical load, solar production and household electrical usage.
EmonCMS software EmonPi Hub and EmonTH sensors comprise the core of our sensor monitoring capabilities!

We utilize the EmonPi as our wireless hub:



Revision History

V2.4 now includes 5 different system status LEDs. These include:

V2.5 (2016-06-04)



V2.6 (2016-06-05)


V2.7 (2016-06-11)


V2.8 (2016-06-13)


V2.9 (2016-06-18)


V3.0 (2016-09-04)


V3.2 (Unpublished)


V3.3.03.01 (2018-02-22)

V3.3.05 (2018-02-27)


V3.4 (2018-03-16)


V3.4.6 (2018-09-23)


V3.5.0 (2019-02-16)


V3.5.1 (2019-03-02)

Author

Richard J. Sears - richardjsears@gmail.com - The RS Technical Group, Inc.

License

This project is licensed under the MIT License - see the MIT License for details

Acknowledgments

While there are a lot of people that deserve acknowledgments because they wrote amazing code, these folks went out of their way to help me out on this project and I want to call them out: