PoolDuino - Automate my pool with Arduino

Hi folks,

I am planning to buy an inground pool and wants to use this opportunity to insert a few key elements to automate my pool as much as possible, leveraging the strength of an Arduino.

While the project will change throughout its execution, the following represents a list of feature I have in mind. I don't expect to implement all of them at first, but who knows where this is going to lead me.

-auto water leveling
-data logging: pH meter, salt, water temperature, air temperature, pump/heater/etc usage, etc.
-auto back wash
-in ground jet control for kids fun
-auto salt/pH control
-auto light control
-internet connected to alarm any unusual status

in the picture below you can see the various components I have so far:

-arduino duemilanove
-arduino sensor shield
-bunch of buttons with leds
-plastic case to put the project in
-liquidcrystal display, 16x2
-8 relay module 12v -breadboard
-servos (don't think i'll need them)
-usb cables to connect my arduino
-24v orbit water solenoid taken from a sprinkler system

Imgur

i've already ordered the following
-ph probe
-ph/orb adapter
-ethernet shield for arduino
-solid state relay to control 110v

I will post my code here and on google code. I will update this as my project moves along. We expect to buy the pool in the next few weeks, but since I need to put some pipes/cables/wires in the concrete I need to start this now.

If you have suggestion on some other stuff I could add to the project feel free to let me know!

You left out the barmaid serving drinks with umbrellas for when the kids are not around.

You left out chlorine moniter.
Backwash, doesn't that usually involve rotating a pretty hefty handle around, watching the effluent, then rotating it back?
(and refilling the filter if you have a diatomaceous earth filter)

Backwash, doesn't that usually involve rotating a pretty hefty handle around,

That's what I used to do, and the valve needed a huge amount of torque. But I suppose you could use 2 large solenoid valves instead.

One issue there is detecting that the valves actually open so you aren't pumping into the blocked pipe. This probably means a pressure sensor on the output of the pump.


Rob

Having just spent all morning repairing my stupid chlorinator, I'll point out a few things. The valves that are used on the plumbing controls are 24VAC and they can pull more amps than the arduino can provide. They are slow moving high torque devices that only use power when they are activated or you flip a switch on the bottom. They aren't cheap. Pools use large plumbing, mine uses 2" PVC pipe and thus, the valve are big too. By the way, the valves and actuators are two separate devices and the actuator mount on top of the valve with 4 stainless screws.

So, you're going to need a high current 24VAC transformer, mine is 10A and gets hot, however that could be because the chlorinator pulls 8A when it turns on.

PH sensors for the most part require replacement every year. Some of the very newest technology is better, but I don't know much about them. Same with the chlorine sensors. Since you mentioned salt, I'm assuming you're going to have a chlorinator. These things are often a lot of trouble to maintain, especially if you live where the water has a high mineral content. One thing they don't tell you at the dealer is that the chlorinators cause PH creep. That means the PH keeps going up over time and you have to keep adding acid to pull it back down. So, what you save on chlorine, you may wind up spending on acid. Also, calcium builds up on the plates inside the chlorinator and you have to clean them regularly. They don't tell you that either. The salt will actually cover the plate and the chlorinator will stop working. The manufacturers tell you to soak them in a dilute acid bath to clean them; DON'T DO THAT. The acid will accelerate the wear on the chlorinator and you'll need to replace that expensive item waaay too soon. We're talking from U$200 upwards to U$700 depending. Clean these things with a 1200psi power washer; you'll want one to clean the pool deck eventually anyway. The calcium buildup in the chlorinator will break off the plates and fly out into the pool causing a snow like residue on the bottom of the pool. If you have one of those pool sweeps that crawls around the bottom, it will pick it up for you. If you have one of the devices that swims, it'll just pile it up in the corners for you to scatter when you use the pool. If you have the jets in the bottom of the pool, same thing. They'll sweep the snow into the corners for you to come across later. This stuff will also plug up your filter so you have to clean it more often. If you keep the PH lower than recommended, you can mitigate this problem a lot. Try keeping it around 7.1 or so (I run mine at 7 most of the time. At 7.8 the pool will look like a snow bank in a few weeks.

However, even with all it's faults, I recommend a salt pool. It feels great and you don't have to keep chlorine bottles around all the time. You do have to have acid storage though. Remember, anything solid that dissolves in the pool has solids (duh) in it. These solids will be in your pool forever or until you backwash out enough water to remove some of them. Nice clean rainwater is your friend in this respect.

Many states have caused the big retailers to lower the concentration of chlorine in the stuff you buy. It used to be over 30%, now it's less than 15%. This is because the methamphetamine cooks use this stuff and they wanted to thwart them. However, it just winds up costing us regular people more money. Look to pool supply places and ask them the concentration when you buy it.

So, you'll need a relay for every control you want as well as an actuator for every valve you want to mess with remotely. I have 4 actuators and a couple of the valves are manual only. That's because there's not much need for switching between the pool returns and the in-ground cleaning system or changing the rate on the skimmer.

My recommendation is to start really small. Have the people installing the pool provide the absolute minimum you can get away with. That usually means a mechanical timer for the motor and a really simple chlorinator control. Get the valves you want right up front because working with 2" plumbing is a real hassle. You absolutely can add them over time, but it will mean some digging and replumbing of whatever you have. Then, when you have worked with it a while, add something like remote lights so the kids can turn them on at night when you're skinny-dipping with a lady. Then you can automate a valve to get a feel for it. It's not that hard, but the adjustments can get annoying. For example if you want a fountain to run slow sometimes and fast others, that's two valves, not one. You'll see what I mean as you go along. Oh, at around U$50 a valve and over a hundred for the actuator, you'll soon limit your expectations and stretch the project over time.

Do not automate the backwash. This is too prone to error and you could easily backwash a bunch of dirt right back into the pool, or your bedroom. Take the time to stretch that hose out to where it actually needs to go and then turn the valve. This valve is expensive also, nasty expensive. I had a neighbor automate it and flood his back yard. The chemicals didn't really hurt anything, but it was a muddy mess for a while. Where I live we have to have water delivered for a pool and it was two truck loads to get him back to normal. Those two inch pipes and multi-horsepower pumps can move a lot of water in a small amount of time. I laughed a lot at his misfortune until I got black mold and it was his turn.

I haven't even started on solar heating and the perils of putting a few hundred pounds of pipe filled with water on your roof. Nor have I mentioned the calcium build up on waterfalls or other features that has to be cleaned off using acid and a stainless brush. Things like getting an accurate read on the actual salt level in your pool when the chlorinator control is telling you that there is 1900PPM when you know for a fact that there is over 3000ppm in there can be a challenge.

Scare you off yet?

When we had a pool as a kid (high school), there were no automated valves - it was all 2" plastic ball valves, all located by the pump.
We had 24'x52' inground pool, a manifold of about 7 valves so we pull water in from a lake thru the filter to fill the pool, turnoff the various skimmers & bottom drain for vacuuming, backwash the DE filter, Iforget what else, haven't seen that pool since '82 or '83 when my folks split up & moved out.
We spent several summers installing that and mixing cement for the deck around it.
And then pulling out frogs, mice, occasional snake, never any big animals tho.

My ongoing battle to automate my pool is because I live alone, and frankly, I got tired of checking the darn thing every day or two. It's kind of like I have a whiny kid in the yard that constantly needs attention. Sure, I could hire a pool company, but then I couldn't afford to automate the pool. What's the fun in that?

Oh, one thing I forgot to mention. Get a variable speed permanent magnet motor. These things can reduce your power bill for the pool by 75%. It turns out that you don't need to run a powerful motor much, just to vacuum the pool and prime the various things it connects to. These new pumps kick in hard to start and then cut back to practically nothing to do the routine stuff. I watched my pool expense slam through the floor when I invested in one.

Don't leave home without one.

Scare you off yet?

Sure did. Not that I ever considered putting in a pool. They were very popular here in Calif starting in the 50s and through the 70s, after that their popularity started to fall off and now you hardly ever see them anymore. Many people filled them in with dirt. Not sure as to the reason but high energy costs to heat the pool and of course on going maintenance costs are two possible reasons.

As I said I never considered adding one, although I did install a nice gas fired spa in one home I owned.

Lefty

wow that's a lot of good info! I'm surely scared, but nonetheless we'll have a pool before the end of the summer. I spent the last few days working on the logic for the water level component and i'm getting there. The water level filler will definitely be part of the initial deployment of my module. I've tested with a few switches and it's all working good.

I understand what you mean regarding the valves, but one thing I forgot to mention is that I don't plan to control each and every jet with a valve. I will have a single valve for my pool, one for the spa section within the pool, and one for the kids fountain. That gives me a total of 3 valves for the pool jets, 1 for the water level, and if I want to automate the backwash I would need another 3. Btw, I plan to put a permanent pipe to empty the pool in the sewer (We are allowed to do that here) so this will prevent any flooding in my backyard. Automating the backwash (which I won't do in the initial deployment) will need 3 valves opened/closed on a perfect timing, and some pressure probe to test whether valves were opened properly or not. I haven't figured out this one totally yet but plan to get on it later on.

Lastly, one VERY important component is the ethernet shield. I will fire emails on every specific activitites (water starting to fill in the pool, alarms, etc.) and I've also setup a few security net to prevent any problems (i.e. timer to limit amount of time we're filling the pool in case every water level probes fail).

I've builded a visio workflow to make sure I cover every aspect for each feature. I will share the visio and the initial code when I get a chance.

few problems I have so far: my liquidcrystal screen is limited in the amount of output. 16x2 is not a lot! I'm using an arduino duemilanove and i'm limited in the amount of input pins I have. Any input will be welcome if you guys know how I could do this.

Question for you draythromp, you mention actuator, what are you doing with them ??? moving some kind of ball valves with actuator???-

oh regarding powering 24V valves, I will use an external power supply with enough Watts and use solid state relay to control them.

Thanks a lot for your hints about chlorinator and salts, those are MUCH appreciated believe me! I'll keep you posted on how it goes.

Scare you off yet?

Reminds me of what a PITA a pool can be, glad I don't have one any more.

my liquidcrystal screen is limited in the amount of output. 16x2 is not a lot!

Simple, get a bigger one. Even better get a serial graphics LCD like the ones from 4D Systems, they have touch panels as well so you don't need buttons.

limited in the amount of input pins I have

Either move up to a Mega or use a MUX (like the 4051 or 4067) to get more inputs.


Rob

Pool valve actuator:

Pool valve:

You've probably seen these before. The actuator, when power is applied to a specific wire pair, will turn until a switch opens and then stop. When you put power to a different wire pair, it turns back until a different switch opens. This is a good thing since it uses no power at all to stay in place unlike a solenoid valve. Solenoid valves use power all the time they are activated except for a few that have catches to hold them and never seem to be used for pools. The actuator bolts to the top of most of the valves and work nicely for a very long time. There are various manufacturers of the valves and solenoids and most of them work nicely with each other. You can go to a pool shop, compare them and how they work, then order them online to save money. Most of us folk with pools use this technique. Additionally, check ebay to buy them, save yourself a bunch of money over the usual suppliers.

For my purposes, a simple mechanical float works fine to keep the pool filled. I check it twice a year to make sure there is no corrosion or calcium build up and never, ever have a problem with it. My problem is getting water OUT of the pool when the rain raises the level a couple of inches. I have one of those pools with a lip over the pool and I don't want water getting behind it so I have to watch the upper level. This will be a project for this fall, I'm all tied up with an acid injector right now.

There's a couple of things you can do with the 16x2 display. First, look at a serial converter; these little thing drop you down to using only one pin for data saving a whole bunch of them for around U$15. I use this one: http://shop.moderndevice.com/products/lcd117-kit. I am a complete convert to the serial display for just presenting data. You can use one of these with the SoftwareSerial library and have the normal serial port available for debugging. I have used two of these serial converters and still had the serial port on the arduino available for testing and stuff. The other thing you can do is rotate the display. This means show the temperature for 2 seconds, then the level, then the salt, then the whatever you want. I do this for a couple of things and even show debugging info like memory remaining, timers to fire in the future, etc. This way I can display virtually unlimited data. You can even hook a switch to it and have the switch step through the items. I have a house monitor that works this way illustrated on my blog. Kinda cool and growing in capabilities every couple of weeks. Really primitive code, but it works.

Or, as suggested, get a bigger display. Or combine the techniques and have the coolest display on the block.

For the time being, avoid the mega2560. I don't personally know about the mega1280. The 2560 has a couple of bugs in the bootloader (check the other threads in the forum) that make it a bad choice right now. The watchdog doesn't work right and your code can cause the bootloader to fail insidiously. I have hit both of these on the 2560.

As to what I'm doing with the actuators, I use them for all the functions that require the water flow to change and I want them to be automated somehow. I turn on and off a waterfall, fountain, solar heater and a vacuum break on the roof. These things are totally cool and easy to set up. When you look at the valves and actuators, you'll see what I mean. the actuators could be used for a lot of other projects if they were cheaper. They have high torque and don't use power when not moving. Pretty nice actually. You could probably use one of these on the backflow valve, but I have never looked at that.

A warning on the ethernet shield. I and many others have had trouble with the shields long term. In my case, the shields just stop talking and stay that way until the arduino is rebooted. Additionally, the older boards had to have the power cycled before they would reset properly. There are many articles on this around the web. The new boards reset properly, but there are some other problems with establishing a reliable connection and recovering from a failed internet connection. I have worked our a few techniques to handle this, but your mileage may vary so experiment a lot. This is one reason why I encountered the watchdog timer bug on the 2560, I tried a watchdog timer to help with ethernet hangups and then hung the arduino board. Sigh....

There are ways around this stuff, so just ask when you get to that point.

Guys
I'm curious about the PH meter/probes you have been using.
Any links to them. I have been asked for another type of project and the cost is quite high, so I'm looking for any leads.

Re Valves
I'm curious if you can use a 2'' version Gate Valve and have a stepper instead of the handle.?

I'm also wondering if some of the irrigation suppliers can source 2" valves at a lower cost. Here in NZ they aren't cheap.

Many years ago I knew someone who used a saturated chlorine solution, and just poured the liquid in, which I guess left all the solids out of the pool...His pool was gin clear, so maybe it was a good idea.

We have a smaller pool that the wife wanted, so its her job to do the cleaning, chlorine, etc....far easier for me.

I do like your VFD for the pump though, there was an article in Silicon Chip (Australina Electronics mag) about a similar device.
You had to manually choose what your were doing, and it included a few preset times, but a simple Arduino controlling a basic VFD would work just as well.

Mark

I honestly don't know if the valve you show can be used with a stepper motor. The problem I see is that the valve in the picture is a gate valve which is usually multi turn and that could be a problem. My experience has been that the valves have too high a resistance and require too much torque for most devices. Maybe one of the folks that deal with motor control can comment on that. Also, brass on the valves of a pool can be a bad idea with the various chemicals involved, but there are a lot of plastic ones to choose from.

I have used a regular ball valve with the actuator I showed in the picture, but it took making an adapter to go from the female socket on the actuator to the valve stem on the valve. It has been working for a couple of years with no problem however. The reason I did this was because I was automating a fountain valve which was 3/4 inch and I couldn't find a swimming pool valve for that size pipe. So something along those lines may be possible.

On another note, the prices on the actuators seems to be coming down, albeit slowly, so maybe you can find a bargain on one of them. Also, since I haven't needed many of them and have spread the purchases over a few years, I haven't been too motivated to find a cheaper method. If you figure out how to control a two inch water line cheaply, be sure to post it. You'll become an immediate hero because these things are darn expensive. They have to set out in the weather with freezing cold and scorching heat for years at a time and that's tough to do.

Regarding PH, I haven't tried them yet, but this place http://atlas-scientific.com/ has a pretty compelling array of devices. I plan on getting one of these http://atlas-scientific.com/Details.cfm?ProdID=32&category= in a few months to experiment with. Don't let the U$25 price fool you though, they need a probe (http://atlas-scientific.com/Details.cfm?ProdID=35&category=) and it costs U$55 so the whole package is U$80, but that's less than one designed for a pool by one of the big names. Additionally, the documentation indicates that we can tweak the code to correct for calibration drift over time and get several years out of a single probe. My only concern is that the company goes out of business or gets bought out by one of the big companies after I have become accustomed to using their products.

I suspect that before I get done with this I'll have a complete pool controller running. The one thing that will take some serious experimentation is building a chlorinator from parts available around town. I've got a good hint from those things they make to split water into H and O to (supposedly) increase gas mileage. That's exactly what a chlorinator does and I should be able to leverage that somehow. Sign, I'll never, ever run out of projects.

@draythomp

Hey thanks very much for the link. $55US is far cheaper than some of the other scary prices.
Re the valve, I was wondering if brass was an issue, and the steeper may need a gearbox.
I brought one of these suckers earlier, and its already geared down, so stopping it at 5v is nearly impossible.
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=126

I agree with you, I have so many projects that if I live to 150 I think I'll ony get half done.

Mark

hi,

draythomp I wish you were leaving next to my house so I can pick your brain!!!

I got the following to monitor the ph:

adapter to read the probe:

cheapest probe I could find.
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=120636420084

I'm working on a custom "skimmer" that I'll use to install all my probes (ph, thermometer, water level, water input...). I'll install the skimmer in the shed and have some pipe in between. I need to draw a plan for the person who'll make it (made of inox) so I'll post it here when done.

I have a few things I need to post here which i'm hoping to do by Tuesday as i'm still in vacation. this includes a call flows for the water leveler, the preliminary code for my arduino and the initial plan for the skimmer, pool and kids fountain.

I know this projects sounds a lot, but considering the amount of money i'm about to spend I'm confident i'll get far enough to at least get a success/failure and not just an unfinished project.

Draythomp, question for you. Which pump brand/model have you bought? Do you control the speed of it with your arduino? Do you have some pictures of your finish project? How do you control the variable speed pump?

markB I don't think this stepper motor would be strong enough to turn a ball valve. If so PLEASE LET US KNOW!! This would be a great and cheap mecanism.

I'm going to use this for the kids fountain and the water leveler input: http://www.orbitonline.com/products/Valves/02/16/01/218/

this us not good enough for the backwash but should be fine for my current usage. I will have to use those actuator later on though.

any of you were able to interface with the chorinator??

thank you guys!

i'll keep you guys posted!

The valve for the fountain and filling system look fine, but keep in mind that they draw power the entire time they are on. I'm a bit of a nut about saving power anywhere I can. In your situation, power may not be a problem at all. The PH probe is actually pretty cool, I'm wondering how well the calibration holds up and how long the probe actually lasts though. The problem with these things is that they sometimes need to be calibrated a lot to keep a reasonable accuracy.

My filling system is a simple little well with a float in it. Very simple and totally problem free for years now. The same kind of thing they use on an evaporative cooler. An automated one should work fine, but remember, when it fails it could die with the water on.

I have a Hayward pump: EcoStar | Pumps | In Ground Pool Pumps - Hayward Pool Products. This little jewel pulls around 2800 watts at high speed and as low as 150W at low speed. I have to run it around 1800 rpm to get enough head pressure to operate the chlorinator and the solar heater and that pulls around 325 watts. These little jewels (well, not real little) can save you around 75% on pool power usage if you currently have a single speed pump and run it during peak periods. Currently I'm only using two speeds, low and high (I can set each of these to any rpm) and my controller handles that for me. However, take a look at the manual, there is an easy way to get 4 preset speeds out of the pump. Needs 4 relays to do it, but that part is easy.

As for pictures of some of the stuff, check out my blog under 'swimming pool'. http://draythomp.blogspot.com/

markB I don't think this stepper motor would be strong enough to turn a ball valve. If so PLEASE LET US KNOW!! This would be a great and cheap mecanism.

I agree. You would need a gearbox, and then you may as well use an actuator, unless your're a mechanical wizz.
I looked at automating a 1 inch ball valve and it got too hard, thats why I started on the gate valve idea.
Sorry no cheap solution...

Those pumps look like a great idea. Far better than adding a VFD.

Thanks for the PH probe link, they do seem a little cheap, but maybe they work fine for a year or more.

Mark

regarding my water leveler failing, since i'm using this sprinkler solenoid, if we loose electricity while it fills the pool, the water will stop! that's what's cool about it.

Ok so a few things. Those are not pretty, just basic drawing I'm doing to help myself understand where I'm going with this. again, basic!

First diagram is the logical flows for the water level. I want to make sure I cover every states of the software, to prevent any failure. I'm hoping to have more success with the ethernet shield since you pointed out some of them are failing.

Imgur

second picture is something i'm still not sure about. I'd like to come up with some sump tank where I could put all my equipments. If you're familiar with salt water aquarium tank, that's what we use (sump tank) for the monitoring/filtering stuff. This small tank would probably be a cylinder with a radius of 6-8 inches, 2-3 foot tall, and have a pipe (3-4 inches) to connect it to the pool. The pipe would need some angle to prevent water staying in during winter. I would also get some portion of the water output from the pump in the tank to get a fresh read on every probe. The temperature would be higher than the rest of the pool, but that's alright if you know and can take this into consideration.

Imgur

Dave, I saw on your website that you're logging the water temperature. Which probe do you use? I was planning to use a/some LM35DZ and encapsulate them like this guy did:

talk to you later!

This is the temperature sensor. I've had three of these in service for five years and they don't seem to fail.....ever. The one problem with them is that they are black and heat up in the direct sun. That can easily be fixed with a piece of metal tape over the part that is exposed. Of course, if you want the temperature of the ambient air don't cover them. They can be purchased for far less than the picture shows if you look around. http://www.amazon.com/dp/B004S3KCLC/ref=asc_df_B004S3KCLC1605341?
smid=A3J45EP2ZLXHOW&tag=nextagusmp0395406-20&linkCode=asn&creative=395105&creativeASIN=B004S3KCLC
However, waterproofing one of the temperature sensors we use with the arduino is a piece of cake, you only have to protect the wires coming out the bottom of the sensor and you can do that with epoxy or polymorph or a plastic straw filled with silicone caulk.

The way I've seen samples taken is to drill directly into the 2 inch pipe and just stuff the sensor in there. This is done on both my solar and pool temperature probes. For ph, you can put a piece of 6 inch pipe in the plumbing somewhere and create a water filled area to insert the probe. Other folks may have better suggestions in this area, check some of the swimming pool forums for tips on this kind of thing. That's where I got the acid injector idea.

I don't see anything wrong with your logic for the pool water leveling. Just remember to watch it carefully for the first few days to be sure nothing bad happens. Try turning the feed line down to a dribble to be sure you don't go too far with it.

Guys
How about these
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=151

When I was repairing spa controllers, they used a stainless sleeve into the filter housing, and a cable gland that sealed against the sleeve.
If you do it that way, use a bit of heat transfer paste (white stuff used between a transistor and the heatsink) to improve the thermal transfer.

mark

I am Soooooo going to get one of those temperature sensors. I can hook one of those to an XBee inside and thread the thing outside to measure air temperature. It will be the next sensor I use for testing the hot water in my solar water heater. Thanks a lot for the link. I should have known Terry would have something cool like that.