SmartThings Community

Automated Pool Controller

(Lance) #41

Thank you @bscuderi13 for answering my questions. I’m about to embark on automating my pool and replacing my Hayward Pro Logic hopefully with something more flexible and modern. I however, have a two speed pump, so I need to figure that out. Initially I’m thinking of using the existing breakers and Relays in the Hayward and controlling them with the Proton until I feel comfortable moving that functionality over as well.

Would you mind sharing the innards of your controller? I would be interested to see how you have everything wired up.

I especially like what you’ve done with the lights. I have a similar setup in that my lights “cycle” through the colors (although a bit different order than yours), but I like the concept and plan to borrow that for sure! :slight_smile:

1 Like

(Lance) #42

@bscuderi13, I have copied all of your code from your variable pump.ino that applies to the light functions and created a device handler using your instructions and I now have the nice light control gui in Smartthings. Thank you for your support in all of this. I’m inching my way towards full pool automation, starting with Temperature monitoring (done), light control (now done) and working on valves next before tackling my two-speed 240v pumps!

Interestingly, my existing Particle code used “int” instead of “define” for the pins and it didn’t work that way. Any insight into that?

Also, I noticed that the “on/off” tile doesn’t change if the other buttons are used to turn the light on. Is there a way to have it know if the lights are on or off? Also, would it be possible to have it change background color to reflect the current light color?

1 Like

(Bscuderi13) #43

Sorry man I’ve been really busy lately so sorry for the slow response. I’d be happy to take a picture of the innards when I get home sometime later in the week. Im really happy someone is following suit and you were able to get this far in the project. As for the light updating the tile when you use a color button to turn it on I use webcore. Basically I have the particle publish in my photon code for when the pool light gets selected on. What you want to do is send a webhook to webcore when that particle publish occurs. I’m webcore all you want your piston to do is with pool light refresh. You could probably also use Stringify or any other third party to accomplish it as well. Problem was I don’t think there’s a way short of making a smart app or something to link the two. Which is why I did it this way. This way I am know it actually received the command and made the change. Rather than blindly having the device handler turn on the switch. The photon actually replies that it did it then the state changes. Hope this helps.


(Bscuderi13) #44

And as far as the webhook it’s easy to make. Login to the particle console. You’ll see intergrations. Make webhook. For your trigger select the publish name you want to trigger it In the address put the address url of your webcore piston where it says click here to activate piston. Now when your particle publishes the pool light on or whatever it was I called it the. It executes the webcore piston to turn on the pool light. Sorry not refresh as I might have innacueately stayed above.


(Lance) #45

Wow! Thanks for the detailed response. Can you give me a bit more detail on the Webhook? Do you use Get, Post, Put? Also, the code that is provided in the Webhook doesn’t appear to be in your firmware anywhere. I’m a bit lost. I can “execute” the WebCore piston and it will turn the lights on and update SmartThings, but I can’t seem to get the “on/off” to respond to turning on the other colors.

The result I get when I execute is:


(Lance) #46

bscuderi13, I’m curious why you don’t do the scheduling on the photon firmware vs using WebCoRE?

My biggest concern is losing internet and having my pool equipment not run it’s schedule. I’ve looked into the time functions on particle and it seems doable, but I would still want to be able to manually control things via ST (or some other method). Of course, I could be underestimating a limitation of the photon.


(Bscuderi13) #47

As far as the webhook I don’t reallt create the webhook in the firmware anywhere. I just send a particle.publish event like seen here anytime a change is made to the pool light.

Then you use the particle console website to make and create the webhook


(Bscuderi13) #48

And as far as using the particles functions to handle the pump schedule you absolutely could do this. But I’m order to change the schedule which I figured I might want to occasionally do especially seasonally it would require re flashing of the firmware to make any changes. Not that it’s difficult to reflash a particle but you have to do it from a computer as mobile devices suck on their coding website. The pro is obviously local execution but I went with webcore for simplicity of programming it since they have a phone app and it’s click to code not easy to screw up. Also this kept my code simple on the photon cause the photon doesn’t have any idea whether it’s a webcore schedule commanding the changes or me it just does the same thing. I thought carefully about a possible local schedule but for ease of editing I settled on this. My internet uptime has been damn near 100 percent and smartthings close to that too. To my knowledge it’s never not run so that has not prompted me to make any changes. With your equipment house and location that mind set could be different. For me no damage can be done the worst that could happen is the pump not run or not shut off which it’s capable of running 100 percent of the time so it’s impossible to do damage. And it hasn’t happened yet. Hope that makes sense why I chose this way.


(Lance) #49

I would be interested to see more detail on how you physically wired up the laser sensor, etc. I have a similar sensor and am having a hard time getting it working correctly.


(Bscuderi13) #50

Lance I know this answers more than just your question but I’m trying to kill two birds with one stone as I have been asked about other wiring on facebook too.

Okay lots of people have asked about the wiring I’m not sure how to go about it so unless i drew a bunch of schematics and did it wire by wire there is no good way to show this but I am updating the original post to include a video showing the guts of each thing. I tried to kind of describe the wiring and parts conceptually with the video but this isn’t going to have every wire or anything as I’m sure it will be a mess and hard to tell or remember for that matter so I’ll just assume a basic understanding of electrical stuff and show what I did. But its important to realize that there isn’t a one size fits all approach to wiring since everyone’s pool equipment pad may be different. I’ll use this writing to kind of supplement the video.

The main pump controller I have a gfci outlet on my pool equipment pad. Downstream of this so everything is GFCI protected I added the three tap electrical chord. This has two things plugged into it 1) a 24 volt ac transformer to control the jandy valves. I send one leg of this to the relay first pig tailed so i can split it and send it to two relays one for open one for close if you have more jandy valves you obviously would have more in your pigtail. 2) a 12 volt one amp dc power supply I pigtail the positive leg of that 6 ways. One leg goes to my step down usb converter power supply thing (not a technical term) basically it takes the higher voltage ie 12 and steps it to five volts clean usb power supply to supply the photon I did this so I didn’t have to have yet another power supply plugged in. I found that board on amazon. The other 5 wires from my pigtail go to the relay board one for open of my 12volt valve and one for close of the 12 volt valve and the other 3 go to the relays for pump speed control. The pump speed control didn’t require 12 volts there was a whole acceptable range of power it could sense this is just what I used since I already had a 12 volt source. The 8th relay is my pool light the power source is 120 volts again from downstream of the gfci outlet so my pool light is also gfci protected. I don’t think I showed it in my video but the relay board itself is powered from the 5 volt pin from the photon. I also have the outside air temp probe on there I forgot to show but it is powered from one of the digital pins on my photon I cant remember which one you would have to refer to my code.

As far as the temp level sensor the laser distance sensor on mine is able to be powered with anything from i think 2.8 volts to 5 volts so I just power it again with a digital pin from my photon which is a 3.3 volt source. the temperature probe is also powered from one of the digital pins. The photon itself is powered from an 18650 battery that first it goes to a lithium charging board I got on amazon in a five pack for like 2 bucks. Its a simple circuit the only other things I added was a power switch to turn it on and off and the 4.7k resistor that is required for the temperature probe to function properly.

The water valves and flow sensor setup is powered from an 1860 lithium battery again so it can continue in a power outage and not leave valves open and water on. On the input side of that charger board I have a 5 volt dc power supply so it runs off mains power keeping the battery topped if their is power. Outflow from that is split up one side goes to a step up usb buck converter I have that takes the lower voltage output from the battery and steps it up to a clean 5 volt usb supply for the photon. The other side of that goes to the boost converter to step up the voltage to 12 volts for the valves. This is then switched at the relay to open and close valves. The relay board itself is powered off the 5v pins on the photon. The 5 volt pins on the photon also supply power to the flow sensors that require five volts to run.

Hope this helps!


(Lance) #51

Did I see in another topic that you are able to create a third position on the Jandy valves by using two relays?

I could use that functionality during freeze conditions to keep water flowing through all the pipes.


(Bscuderi13) #52

Yes you can create a third position or any number of positions you want. I used to use it But I don’t use the third position anymore so it’s not in my code. But yeah I just did it with timing. You always need two relays regardless one to go counterclockwise one to go clockwise you could just go til you hit the built in cam stops on the valve but I just track valve position in my code and activate the relays for the set time to get to the valve position you want. With this mindset you can have unlimited valve positions. It always moves the same speed so just time the valve and code it to activate the relay for that amount of time it works great and is always in perfect position when you do that. I kind of still do it I guess cause I haven’t readjusted my cams on the valve. I have one cam stop at the zero degree Position which is floor cleaners on and I also use the 90 degree position with timing which is just floor cleaners off but there isn’t a cam stop there. The other cam stop is at the 180 degree position but I removed any code relating to it so it won’t ever twist over to that cause I stopped using hat position. I could easily go out and reset my cams I suppose to be zero and 90 but that would require going out with tools and setting it where as this I was able to just use code to remove it.


(Lance) #53

Relating to the Jandy Actuators (or Intermatic in our case)…stupid question (I have a lot of them), but where does the other wire from the 24v transformer go? I’m assuming you put go NO on one relay and NC on the other, but is the other get grouped with grounds or somewhere else?


(Bscuderi13) #54

I’m using the actuator from intermatic. There is 3 wires red white and black. The black is like the common and the motor turns on and goes clockwise or counterclockwise depending on which of the other wires is active the red or the white and will go til it hits the limit switch. It runs off 24 volt alternating current. Since it’s alternating current there is technically no ground. However If it’s easier to to think of it having ground that’s fine. So the power supply has two wires coming off of it. It doesn’t matter which one since it’s alternating current and there technically is no ground but pick one of them any one of them it doesn’t matter which one and that is kinda like the ground and goes to the common wire on the valves aka the black. Your second wire pigtail it and send it to the common port of 2 different relays. Then hook the red wire to the first relays NO spot and the white wire to the second relays NO spot. Now if relay one is activated the cuircuit is completed and tells the motor rotate clockwise it whatever and then vise versa is relay two is activated it goes the other way. In my code you notice I don’t allow one relay to turn on without turning off the other first. That way you aren’t trying to run the valve in forward and reverse at the same time burning it out.


(Bscuderi13) #55

And I suppose technically you could use just one relay instead of two if you use the built in cam stop limit switches on the actuators. Basically hooking say the red up to NO and the the White up to NC but this would eliminate the ability to stop at intermittent valve positions and you could only achieve the two different positions because if the relay was on it would go Say clockwise all the way to the stop and if it was turned off it would go counterclockwise all the way to the other stop. Hopefully this helps you see my theory and why I used two relays. I guess not necessary but made it more versatile.


(Lance) #56

Brilliant! Thank you for the detailed response. I am also using the Intermatics, as they are much cheaper than the Pentair and Haywards when I replace them (that being said, the Pentairs and Haywards are a bit nicer…they’re easier to adjust and they rotate more quickly- just FYI).

I always figured there had to be a way to stop them at any point and your explanation is actually easier than what I thought. I have four actuators, so that is a lot of relays, but honestly, they’re so cheap, it doesn’t really matter.

I may need to figure out how to use a i2c port expander if I keep adding relays, or just run multiple photons.

Thanks again. I’m inching my way to a working product (although I may move away from ST for control).


(Bscuderi13) #57

Well even with four actuators it would take a lot of things you want to control before you need a second photon. Not that a second photon isn’t an option. Especially since you can use the analog pins as digital pins you have 14 possible pins that i count and maybe a couple of the others can be used I’m not sure about the function of a couple of the pins. Especially if you use only one relay on the actuators that you only need two Positions. I can’t imagine every actuator needs intermittent positions but for the ones that might benefit use multiple relays. I’ve seen relay modules as high as 16 relays. I’m not sure if the photon can handle that many powering the board from the 5v pin so if you went more than 8 I’d say just get a seperate 5 volt supply for your relay board or power directly from your five volt source with a beefier supply instead of running it off of the vin pin from the photon like I am. It handles the 8 relay board just fine however anymore is unkonownyou would have to heck the specs.


(Nick) #58

As an update to what I had planned. I am looking at another pump the Jandy JEP2.0 and it speaks RS-485 to a local controller. but I suspect that Hayward would be the same, that you could snoop the RS-485 commands and then cut out the proprietary controller altogether, using the photon to send ANY speed you want to the pump and still receive the power usage information. By any speed, anything from 0-100%. I am researching what work has been done with the Jandy Aqualink protocol to avoid duplicating work.

1 Like

(Bscuderi13) #59

@rx78ntalex dude thanks for the update. That is freaking awesome and definitely way above my head. Which is why I chose the pump that I did. Lol I figured I would easily be able to control it through the three relays so I was this pump or bust. Which is definitely limiting if you can find a deal on another. If you get this working though I’d love to see how you did it. Mainly because I have a stand-alone spa that is like a 2004 sweetwater spa. The control panel itself connects to the topside controller with an rj45 jack. I’d love to automate the hottub and keep all the currently working hardware all working. If I could put raspberry pi or photon as a man in the middle for communications that would be the best possible way to automate it in my opinion. Although all my reading on sniffing and spectrum analyzers clock speeds etc left me more than confused and I pushed it to the back burner. But I would love to resurrect my idea with the right help.


(Nick) #60

From your description, it sounds like you have a Hayward, or Hayward-clone pump, as they had the 3 relay setup, which is really nice and how I planned on going, but either pump, Hayward or Jandy does speak RS-485, so you may be able to retrofit this to that pump. My job in industrial instrumentation has gifted me with a USB to RS-485 modem to try it out but bear with me, I have so many brands in the fire, this may be a while. If anyone wants to help, I’m all ears.