Automated Pool Controller [NEEDS UPDATING: ALL GROOVY CODE IS OBSOLETE]

I got around to posting some code up on github as per your request and linked it in the original post. Be gentle I am not a programmer this is literally my first custom project. I also added a screenshot of my pool light controller version 2.0 in smarthings. That allows buttons to select specific colors more easily all in one device.

I have no room to criticize on code, I’m just as new as you. I will check out the light controller as well. Thank you!

I finally got good enough internet and saw the video, answering some of the questions I had. I was concerned about current ratings for the pump, but since it is just those three relay for selecting speed, since it is always hot, there really isn’t any load on the relays. I have a single speed pump in the meantime and was thinking I would put another higher rated relay on the output of one the relays on the 8 relay board, so that the board never sees that 10-13 amp current.

Pertaining to your solenoid valves for adding water to the pool, do you have a model number for them, as they look similar to valves I was considering for shutting off my well and water heater in the even of a leak. They look like Chinese ones from Aliexpress.
The plan is, with a leak on the water heater, I would have the shutoff turn off water, and turn off power to the water heater to prevent burning out the heating elements.

Yes you would definitely need a larger solid state relay or something isolated that is designed to switch the load as well as dissipate the heat if you are going to switch a single speed 240 volt pool pump. It definitely can be done but this relay board definitely wouldn’t handle that it on its own. You are right with my setup I’m not using the relays to control the load of my pump but rather to send signals to my pump to select speed. I have to step up the signals to a high enough that it can read it as the 3.3 volts from the photon is too low so I am sending 12vdc through 3 of the 8 relays. The other slots are for the pool light and valves.

As far as the light I just got one from amazon that cycled colors when it was switched on and off quickly this allowed me to program colors.

The valves on my garden hose that you asked about are just these


They have 3/4 and 1/2 inch versions for whatever you need with your piping. They work really good they just have 3 wires and run on 12 volts dc. One wire is the negative the other two are positive. one wire opens the valve if 12 volts is applied the other wire closes if 12 volts is applied. This valve fails in its last position so depending upon whats important to you consider some of the other options out there as they also have fail closed or fail open models. For me those valves are battery backed up so even if the power goes out I can still send a close signal to them (smarttings and router are on a UPS). If the pool filler turns on the valve it also will locally shutoff when the flow sensor reaches the desired volume so no internet is required.

The Hall effect flow sensors, what model did they happen to be. How reliable have they been for you?

They are reliable and accurate. I just got them from amazon for I think four bucks a piece. I’ve only noticed that they don’t work if the flow rate is super super slow as they aren’t sensitive enough for that but are plenty accurate at norlmal flow rates. For example my patio misters use so little flowing water when they are on that it does t really detect them. That is covered in their spec sheets though as a minimum flow rate of 1.5 liters per minute to work.
uxcell G3/4" Thread Hall Effect Liquid Water Flow Sensor Flowmeter Fluidmeter 2-45L/min https://www.amazon.com/dp/B01LW1MSV0/ref=cm_sw_r_cp_tai_KJ7EAbZDKQF82

Just a heads up to anyone following. I have updated the device type and changed the screenshots above to represent the new more polished look…

Here is something I found that incorporates the Atlas Scientific pH and ORP for pool monitoring. I’m checking if I can have one photon run the relays AND monitor the pool at the same time.

1 Like

What did you use for the laser window for the pool level VL530L0X? I see a rubber bushing, but is there a window or something in that bushing?

There isn’t. I just put a rubber grommet to maybe help so water can’t run down the sides and get inside. But the unit sits high enough above the water line that I havent had any issues or water get in it since the hole is on the bottom. I toyed with the idea of some Plastic wrap or glass or plastic window I’m not sure what I would need to not interfere with the lidar Sensor. But if you find something or have insights I am all ears. But that sensor has been out there for a bit now serveral rain storms etc and all myinspections show that no water has gotten in.

Funny thing is, this is exactly how I was planning to do mine with Particle, Smarthings and Raspberry PI. I knew someone would beat me to it!

1 Like

Hi, I’ve been adding some automation to my pool too, I’m using Linknode R8, which is basically an ESP8266 with 8 relays.

I’m stuck with pool light though, using webcore, the relay is flashing On and Off very slowly and light is not changing color because of that, how did you accomplish the fast on/off/on with your project?

1 Like

Ghassan_Jankeel Basically I did the same thing as you at first with webcore and found webcore to be too slow or unreliable to sequence the relay precisely as needed for the color. Therefore I programmed that ability directly into my micro controller so that all the relay sequencing and delays are handled locally once a cloud request comes in for a color change. So basically my device handler in smartthings sends a color change request to the particle cloud. Then the photon after receiving the request cycles the relay as required.

so is that something I need to implement in the custom firmware? also can u share the code or the part where it does that? I want to see if I will be able to make it work with changes for my ESP8266

All my code is linked to the github mentioned in the bottom at the original post. Basically the sections that pertain I’ve taken screenshots. Not of every color but it should give you the idea… particle has cloud functions you can call on that basically From smartthings I send a colorchange request and a value. 2 = red 3 = green etc… that then changes a flag variable that I use in my loop to actually do the color change. I do this cause with particle and smartthings it sends a request and waits for a response. With all the delays and such in the color change code it can make smartthings timeout cause it didn’t receive a response quickly. This avoids that problem as the response is received instsntenously and then it completes the change. You may also notice with my color change code i first read the pin for the relay state, low is on high is off, I do this to easily and lazily code the color change so that if it’s already on and on a different color to shut off the light for long enough for it to reset so it’s the same cycles to the color. Otherwise I would haven’t track the current color and code the cycles between to get to the new color.

Cloud function to link to smartthings and set a flag in the loop to avoid the timeout
image

Loop code calls the appropriate color function
image

Color functions.
image

Thanks for the detailed reply… yeah the webcore is def not the way to go, even when using flash on/off instead of turn on and off still does not work all the time.
I’ll try to implement the On/Off sequences for all the colors in the device handler and then simply call them from web core, or just add all the buttons to the Sonoff device handler as well.

1 Like

Awesome project! It inspired me to automate my pool equipment too. I am getting started and your example helps me a lot, but I had a couple of questions.

  1. Could you provide example code about how you used WebCore to schedule your pool pump and valves?

  2. How did you actually control the Jandy valves with the Particle Photon? I did not see that code in your GitHub (maybe I missed it).

Thanks for sharing your project and experience with the community.

1 Like

Okay This is just a screenshot of the start of my webcore piston but you get the idea I just use it to turn on and off valves and set speeds at various times of the day or whatever you want to trigger them. Turning on the pump just sets full blast and the button presses represent the other speeds. I couldn’t get the whole snapshot thing to work probably cause I’m on my iPad but it gave a piston ID of hxzed that you could try if you are Interested in the whole thing.

The code for the valves I refer to them as aerator on and off and cleaners on and off. Here’s all the bits that control them. I use the same principle I discussed above with the last question about the pool Light where I basically have the cloud control set a flag in the regular loop to avoid the timeout on smartthings after it sends the request.

Register them and also the loop portion that calls the actual functions if the flag is true.

The actual functions to control the valves.

The cloud portion to receive commands from smartthings and set the flags to run them from the loop.

1 Like

Thank you. This will help me a lot.

@bscuderi13 have you considered the concept of a “service mode” that enables you to manually override the timers, etc? My current controller has that functionality and it really comes in handy when I want to do activities outside of their regularly scheduled service.

1 Like

@Exit2studios I basically do have a service mode. If you look at my pool pump controller screenshot or code you see I have the auto mode or manual mode virtual switch. The switch itself does nothing other than keep the webcore automatic schedule from running if in manual mode. If I’m in auto then the regular timed functions work. I also have the chemical mode virtual switch that if engages does a full blast stir for 15 minutes then shutoff if I add some chemicals.