Saturday, June 27, 2015

Arduino, Raspberry Pi, Pool Controller and Another Guest Speaker

Let me introduce Mike He's another one of us folk that wanted automation, but didn't want to pay unreasonable prices or be locked into the control of some system 'out there.' He's been working on a project that I want to get into deeply at some point (when I get sorta caught up), and he's way ahead of me on it. Go ahead Mike:

The initial project...

   Several years ago, I was trying to think of a way to extend my swimming season without breaking the bank. I have a heat pump on the pool but they aren't very cost effective to operate. As I live in Florida,  we have plenty of sun so solar was an obvious choice.  Problem is that I didn't want my roof covered with plastic pool panels as I intend to install PV electric panels there and since they tend to develop leaks, i didn't want salt water on the roof. I already heat my hot water with solar so I started looking into using the same concept for the pool.

   I located a pair of glazed DHW panels and set them up with a titanium heat exchanger so that I wasn't running corrosive salt water through the panels. Here's a picture of the panel...

   I used a circulation pump to pump the water in the closed solar loop and quickly discovered I could gain 5 to 6 degrees a day in pool temperature in March. I was losing 2 to 3 degrees at night but the idea was successful as I was still gaining heat. Since I didn't want to heat the pool past a certain point and I didn't want to have to manually control it, I needed a contoller. I was already  toying with my first Arduino (a Uno) so it was an obvious choice.

   I began to research temperature sensors and ran across the "Differduino" project. All I had to do was modify the hell out of it and I had my basic controller! I added an ethernet shield so that I could send data to an external site now known as Xively.

   The controller monitors the pool temperature and the panel temperature and turns the circulation pump on and off on a differential provided the pool temperature is below the setpoint. This part of the project has not changed, much....

The evolution begins...

   Then one day, I stumbled across the "Desert Home" page. Don't remember what I was looking for but this crazy fool was doing things I had thought about but hadn't figured out how to do practically. As he had put up all of his code and wanted people to see it and benefit from it, I decided to do so. Dave was (and still is) very helpful in getting things up and running and I soon had a Raspberry Pi to play with.

   The Ethernet interface on the pool controller was replaced with an XBEE radio and the data was being magically sent through the air to the RPI where it was being stored to do with as I chose. This led to a Web interface that can be seen at that allowed me to see the data in real time. I added a temperature and humidity sensor so I knew what was going on outside. Here's a picture of the controller about this time..

The house controller...

   The heart of the project has actually shifted from the pool controller to the house controller. This creation started out as Dave's, 100%! As it was written in Python, it was a learning curve. My programming experience was mostly C++. As I came to figure out more of Dave's code, it became more natural to read and much easier to learn from. Once again, Dave would prod me along rather than hand me the answers. Kudos to Dave for that...

   As I was collecting more data from the pool controller and have built a few other devices as well, data was getting tedious to process. I ran across a library called ArduinoJSON and spent a weekend in the woods figuring out how it best suited my needs. I'd like to think I turned Dave on to that little treasure but he may have been exploring JSON already. If you haven't looked at JSON, I suggest doing so. I learned quickly that only so much will fit on an Uno...


   I got hold of a Mega 2560 and loaded the code to it. I had a ton of memory now (and 3 extra hardware serial ports). The SoftwareSerial library I was using could now go away but I didn't do that until I realized that it didn't work well with two way communication on the Mega. I added and GPS module I scavenged from Streets and Trips. Now I had Dave's house clock as well so I could set up timers for the pool. A Timezone library even correctly handled the time change twice a year. This has come in handy on a few other devices. I intend to add a pH probe to monitor the pool and an acid pump to keep the pH at a certain point but I haven't done it yet. I have added two way communication with the pool controller and several things are now adjustable from the Web interface.

   The pool controller and all other devices I've built so far operate entirely on their own and continue to do their thing even if the house controller is offline. I recently had to replace my pool pump motor and chose to get a Hayward variable speed unit instead. Best decision possible in my opinion. Much quieter and the energy efficiency is a big benefit.  Electric bill went down almost $60! I'm now using the timer that I programmed to run the pool pump to run the chlorine generator and the timers on the pump to vary the pump speed. I let it run at a low speed overnight instead of turning it off.

   The house controller also now incorporates ZWAVE and controls several lights and doors. It's function grows almost every time I look at it. The power of these inexpensive machines is impressive.

What's next?

   The pH monitor and acid pump are still on the list. I need to get my panels finished up, right now I'm operating on just one, and I need to get them permanently mounted. I'm working on replacing my DHW controller with one that integrates into this system and I've got an LED sign that displays weather data and pool information all over the XBEE network.  I'm also looking into adding an FPH system from Hotspot. I'll do my own controller rather than using theirs but between it and the solar, I should be able to swim almost year round. We don't get much of a winter....

This is Dave again. Nice job Mike, and thanks for chiming in. See people, you're not the only one that does this kind of thing.

Have fun.


  1. I too made a pool automation controller, but I did it with a Synapse wireless module. The brains being an always on linux NAS box. The brains could be offloaded to a raspberry pi if needed. Anyways, the full chain of command is : synapse pool controller module (python coded) -> synapse gateway on linux NAS -> python "tornado" based web controller serving up jquery mobile javascript. I had to learn websockets, tornado, jquery mobile and Android webapps to get it all together. The tornado server has the time (since it's on the linux box with NIS) so it does the commands to the pump. I have it run my waterfall for 5 min every day to keep the algae from growing in it. I'm proud of that feature because I don't think commercial systems have such a feature. It also controls the pool LED so I can control the colors from my phone via the webapp.

    I have various other synapse modules. One for garage door automation. Another for controlling the ceiling fans. A third runs the cat food dispenser and water fountain (runs @ night).

    My future plans include pH automation as well since I too have a pH sensor (along with the unreliable ORP). I'd love to talk to my chlorine generator (pentair), but I'm too lazy to try to capture packets and decode the protocol. The cell just relies on the flow indicator to turn itself on and off.

    I should probably document it more, but I have such a hard time motivating myself to write it up. Here is my blog, but my last post was 1.5 years ago. :(

    My current stair remodel project (converting to hardwood everywhere) has sapped all my productivity for the past 6 months.

  2. I too have a Pentair salt system (IC-40) and have thought about being able to talk to it. Most likely just continue to control it by varying the time that it is allowed to run. Not familiar with the Synapse module but will be going over to check out your blog. I most likely lack the patience or the desire to blog this stuff but Dave may eventually inspire me to do so....

  3. Pool control is why I found this site, too. I couldn't stomach $1000+ for a name brand SWG, and got a $150 Intex instead. I didn't like their controller, so I replaced it with Arduino -
    Intex then changed their design and cut the chlorine production in half, which doubled the cost of cell replacement. When I started looking for replacement cells, I ended up getting a deal on Pentair IC transformer and cells. Been working OK so far by themselves, but when they annoy me enough, I'll modify them with a micro of my choice.

  4. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks... pool pump box

  5. great write up! did you every land on a PH probe setup?