Homebrew automation with HomeAssistant and MQTT - Pentair Maxflow VS Automation pinout

billmi

Member
Apr 15, 2013
11
Florida's Spacecoast
In December, I finally implemented a system I'd been planing off and on since planning our pool build 2 years prior.

When we built our pool, the pool builder offered an Intelletouch automation system. I didn't feel it was worth the asking price, and found it lacking in a couple of key features. First, and most important to me, was although it offered mobile phone control, it used (or at least from what I could find online) a proprietary communication system, so I couldn't tie it into my home automation system for smart control (integrated control of other systems, not just remote control). I was already using Home Assistant, which is one of the more advanced home automation systems available - and free, so integrating it, was a key feature I was after. Also, it provided no valve position feedback, so if a valve actuator failed, and I was pumping my spa down, I'd have no way to know.

What we started with, was a Pentair Superflow VS pump running on its own timers, a manually controlled Pentair gas heater and an Intellechlor running on a mechanical timer in a Pentair load center, with manual valves. Features I looked for on the heater and pump were that they were both capable of digital control via dry contact connections - basically that they could be remotely controlled by the simple turning on and off of a switch, rather than some possibly proprietary command protocol.

After a year of operating and making notes of control goals as I went, my grand plans of what I wanted to do got a lot simpler. For the most part, the only thing that wasn't "set it and forget it" for my pool control over that year was switching between pool and spa operation (switching the position of drain and return manifold valves, turning on the pump and heater) or setting the pump to quick clean for vacuuming. I only changed pump timer values once during the year, and Intellichlor setting 3 or 4 times over the year. So I could do full pump control in my home automation system, it would only be for wow factor, and not really change anything for me.

Pool lights are switched in the house, so I'd already taken control of them with a Z-Wave light switch early on, with an automation in Home Assistant that will pulse the power to set colors as chosen in a drop down menu.

What it came down to for automation was needing to control 4 relays to operate 2 valve actuators in 2 directions, a relay to call the heater, and a relay to tell the Superflow to run at its "Quick Clean" speed setting. I also wanted to monitor temperature and pressure in the filter, so I could get alerts when the spa was warmed up, and if backpressure in the filter indicated it was time to clean.

My platform of choice for control was a NodeMCU (ESP8266 based dev board) because it's cheap, is programmable in the Arduino IDE and has wifi built in for cheap isolated networking (I would not be comfortable tying outside hardware into my house's Ethernet network via copper - we only use optic fiber for that at work due to lightning damage risk and that would add far more cost than I want).

The NodeMCU only has one analog input, and didn't have enough digital I/O to switch it between my pressure (generic, picked up on e-bay) and temperature (Pentair - paid through the nose for what it is, but it's in a very nice package to just strap onto the pipe) sensors. I'd started to consider what I'd need to add, then realized that since NodeMCU boards are only $3.50 a pop, it was cheaper and less hassle to just use two, and have them talk to each other as needed. A generic 8 relay board built for using with Arduinos was a quick grab on eBay (leaving me with a couple spare auxiliary relays for future expansion), then I started looking for enclosures... Sprinkler enclosures to start with, until my manager told me he'd just keep an eye out for an enclosure on the scrap pile (I work for an industrial control company) and a couple weeks later I got a nice sized lightning damaged enclosure with a backplane and some salvageable terminal and din-rail hardware. With a fair amount of scrubbing, some fresh paint, and most of its hardware going in the trash, it still smells faintly enough like smoke to make me hunger for roasted marshmallows, but it will do for home use.

I originally planned to build the circuit on perf board, soldering jumpers on the back for all the connections, but a friend turned my on to a PCB fabricator in China that does low volume production. Since it was a no-rush project, why not go a little further to look better? My first draft schematic was in Adobe Illustrator. I tried DesignSpark PCB (free cad software), and in a fraction of the time, had a better schematic that was much easier to edit. From there DesignSpark automatically designed a 2 layer PCB layout, that I ended up re-working quite a bit for better placement, allowing for a smaller board, and fattening up main power and ground bus lines. It was my first go at designing a printed circuit board, and it was far smoother and easier than I'd expected it would be. It also meant I could put some circuit board art in and feature Eddie Murphy as James Brown singing about my hot tub. Forty eight bucks and 5 days later I had 5 circuit boards (minimum order) in my hands.

I only needed one board but that was minimum order and it was good that I had spares. I "wisely" soldered all the components on the board straight away before discovering that the sockets I'd bought were for round hole pins and wouldn't accept the NodeMCU boards. Larger sockets, and the second board was the one that went into service. I also, unsurprisingly, discovered that since I hadn't built up the whole circuit on a breadboard and tested it first, some of the individual circuits that tested out fine on the breadboard ran into problems if they were in use when the NodeMCU booted, or had issues with cross-talk. So... there are some cut traces and jumpers on the board, but even folks I know who do board design for a living usually find stuff to fix on their first revision, so I won't feel bad for that. A little 3D printer magic later, I had mounting hardware to DIN rail mount the circuit boards.

Writing, testing and debugging software spread over a couple of days. Telemetry and commands communicated between the controller to Home Assistant via the MQTT protocol over WiFi. After picking up a pair of Intermatic valve actuators, installation of the box and electrical one afternoon, the valves, control circuits, and analog sensors another, at which point the system worked - as long as I manually flipped the switches I'd wired up to simulate valve position. The next afternoon I added waterproof magnetic reed switches on the valve actuators to give position feedback and it's been doing its thing since, aside from pressure feedback.

The pressure value is not changing when the pressure changes, though it did on my test bench. I haven't jumped on debugging that yet, since I care far more about temperature, but I still do like the idea of getting an alert if the pressure goes high, or fails to change daily, indicating the pump did't run through it's timed cycle. I'll get to it eventually, but the important part is there - I can say "Alexa, turn on the Pool Spa" and some 20-30 minutes later, the lights above the kitchen counter start dancing in a rainbow animation to let me know the spa has hit 100 degrees. More importantly, when my wife and I get out of the hot tub, I don't have to walk around the side of the house in the dark and sometimes cold and rain to fumble with valves and buttons when we are done.

Future work includes getting the pressure reading functional and adding control for the spa blower. If I can find a drop in Z-Wave or Wifi switch that will handle that load, that will be a quick and easy answer, but I suspect it may be a solid state relay going in the load center switched by one of my two auxiliary relays. That route has more circuit isolation hurdles to jump.

For anyone else looking to control a a Maxflow VS - Pentair sells a cable to do dry contact control, but at $50 retail, that's a $15 connector with what seems like less than $35 worth of wire connected to it. The connector is a Switchcraft EN3C8FX round female connector. The Superflow manual explains how to use it for dry contact or +5v control, but they don't give the pinouts of the connector - only the color code of the $35 piece of wire they sell with the connector. I probed the connector with a voltmeter, and then a resistor (to avoid a straight up short of power to ground) and found the following pinout.

Facing the pump (looking into the male connector in the pump, or the back of the female connector) numbering the pins clockwise starting at the first pin after the registration notch:
Pin 1 - Quick Clean
Pin 2 - Stage 3
Pin 3 - Stage 2
Pin 4 - Stage 1
Pin 6 - Gnd (-5v potential from pin 7, +3v to others)
Pin 8 - +5VDC (+5 potential to pin 6, +8 to others)
 

Attachments

  • Like
Reactions: rowiac and manfacro

Bama Rambler

Mod Squad
TFP Expert
Bronze Supporter
LifeTime Supporter
Jun 22, 2009
23,674
SouthWest Alabama
Uh, WOW! Great job. :goodjob:
I really like the idea of the valve position feedback.

I'm sure you'll get inquires to build some of those for people. or at least provide the documentation for them. :)
 
  • Like
Reactions: billmi

jonpcar

Bronze Supporter
Jun 1, 2016
423
Gilbert, AZ
Love it! Everything looks thought out and professional. I am doing a similar project but I haven’t yet downscaled from the Cadillac version and have gotten bogged down in some details...and the lack of time to plow through them. Like yourself, I am not in a huge rush.

What manufacturer did you use for the pcb? I hate to add another task to the queue (pcb design), but it sure looks clean and I am sure you will benefit with more reliability than wire jumping.

The costs add up, but still are dwarfed by the cost of what an out-of-box system would be. Unfortunately for me, the costs are also dwarfed by the “value” of time that I have spent on the project, luckily the fun/learning aspect kicks in to make up for that.

I agree with Dave, the position feedback on the valves was a great idea, especially since you didn’t tie the pump/pump schedule into the project. Do you change those only manually or do they have any sort of scheduling involved?

Finally, did you have to install an external antenna for your wifi connectivity?
 
  • Like
Reactions: MyAZPool and billmi

ogdento

Bronze Supporter
Mar 30, 2015
376
Chico, CA
Hey this is very well done, really great work! Clever use of reed switches for the valve feedback. Are those mobile screenshots from the Home Assistant app, or is that a UI of your own design?
 

billmi

Member
Apr 15, 2013
11
Florida's Spacecoast
Thanks,

I used PCBWay.com for the PCBs. Their web site has an easy to use quoting system to give the price up front, then once you place the initial order they review it to give the final price quote for approval and payment (making sure there isn't an issue with the design files that would require extra work and money for them to fix). There are a dozen or so fab houses in China using the same engine, and I even ran across a site that aggregates several of them so you can put in your data and get a price comparisons in a grid. I found a couple a few dollars lower, but stuck with PCBWay based on my friend's experience with them being trouble free.

In the long run, I probably could have done it faster on perfboard, but I figure the time spent on the PCB wasn't just for the PCB, it was also learning a new skill. I can't say enough good about Design Spark PCB. There are loads of tutorials for it on YouTube. There is a plugin for it that allows components in a standard format used by multiple CAD platforms. That's well worth adding, there are free online libraries of components, and I found what I needed save for a NodeMCU that was a different version. The pins were all the right dimensions. But labeled different, so a re-label and resave and I was in business.

Yes, if I'd billed myself for the hours, especially at the blue sky planning or learning Design Spark levels, it would not have been such a bargain :)

For the valves, I wrote up a valve schedule and then logic rules from that. What I change manually via Home Assistant (or Alexa commanding Home Assistant) is the mode command to be in pool or spa mode and that is saved in flash memory, so if a power dip resets the controller, it comes back in the same mode.

The valve controller logic looks at the command and the status feedback.

  • If the command is spa, and there is not a feedback that the Return valve is in the spa position it sends power to move the return valve to spa.
  • If the command is spa and there is a feedback that the return valve is in the spa position and no feedback that the drain valve is in the spa position, it sends power to move the drain valve to spa.
  • If the command is spa and there is feedback that both valves are in the spa position, the pump and heater calls are sent.
There is a similar set of rules for if the mode is pool, or if the Quick Clean command is given (it calls the pump if both valves are in the pool position). By doing the logic from the perspective of rules applied to each device, rather than executing a sequence of events, there are no problems if the sequence is interrupted, or if the valves are manually moved to a different position and the controller is rebooted. Each device's controller logic just acts based on the current conditions.

I didn't write in any manual override control for the valves. I kept it simple, so if I ever do need to run the pump with the return pool mode and the drain manifold in spa mode, I'll have to shut it down and manually move the valves with their handles, and use the button on the pump.

I don't think I'll intentionally want to pump the water out of the spa, though. I might someday want to blow a bunch of propane to heat the whole pool. If I ever do that, I'll need to add a pool heat mode to the controller or jumper the relay, because there is no way to manually run the heater when its fireman's switch circuit is not closed.

I didn't need an internal antenna for the WiFi, which also helped make it a practical choice. My pool hardware is on the outside wall of my home office, so I placed my office WiFi router near that wall. There's about 2 feet of air, a cinderblock, and the fiberglass cabinet and aluminum backplane between the router and the PCB antennas on the NodeMCUs, so they have a very robust signal to work with.
 
  • Like
Reactions: ogdento and jonpcar

jonpcar

Bronze Supporter
Jun 1, 2016
423
Gilbert, AZ
Bill(?)...thanks for the answers...do you plan on posting any of your work on github or other sites? The good thing about that is that there is automatic version controlling and recovery built in. The tougher thing is figuring out how to do it initially. The code is view-able by all (public) unless you pay for an upgrade to make it private (could be considered a good or bad thing, I suppose). I am going to post my code once it gets to a usable state.

I have glanced through many of those pool projects posted (at github and Hackster) to get ideas for mine. It's a nice resource. I am going to add for a second time...great idea on the valve status! I didn't see that on ANY of the pool projects I have examined. I think Pentair's intellivalve will have that type of status available eventually, but it's not clear to me that any of their controllers have YET implemented it.
 
Last edited:

billmi

Member
Apr 15, 2013
11
Florida's Spacecoast
Thank you,

Github is a great tool for releasing code, but I wasn't planning to release mine. Aside from not being keen on the liability potential I'd need to jump through some hoops at work to get it waived from my noncompete.

Yes, the Intellivalves look pretty cool. As far as I can tell though, they are using a proprietary protocol. It surprised me when I started looking into this that feedback wasn't a thing. It's pretty standard on industrial valve controllers to either have extra contacts on the limit switches for feedback, or to have an analog position feedback signal.
 

sevans01

Member
Mar 31, 2018
6
deltona/FL
I love this guy!
I have the same Pentair equip and basically did the same project with different components. I used a 1st gen Raspberry Pi I had laying around to control a 16 channel relay board to switch the pump speeds (built my own cable too, I stumbled on the connector at surplus electronics shop for a couple bucks), control the valve actuators and cycle the heater on/off for the target temperature.
To control the pool lights, spa blower, and manual override for Intellichlor - the relays switch 24v AC to control contactors that switch the 120/240v lines.
For temp monitoring I used 1-wire digital sensors
I also use Home Assistant for the automation - using the Generic Thermostat to control the spa heat temp.
I left all the switches exposed on Home Assistant so I can manually control the valve relays if needed

The latest add on was a solar system with the automation for it in Home Assistant. When the rules show conditions are right for solar heat it switches a valve to the panels and sets the desires pump speed.

Still working out ideas for a water level sensor

Love the idea for the valve position feedback
 
  • Like
Reactions: billmi

jonpcar

Bronze Supporter
Jun 1, 2016
423
Gilbert, AZ
Hey sevans , nice project. Are you controlling the pump using the rs485 bus, or with the speed selector inputs (not sure if Pentair has those or not). I just “discovered” those one wire temp sensors the other day and haven’t decided whether or not to replace my standard ones (which need a resistor and analog channel input). Do you have a picture or description for how you installed those on your piping? Check out the “Milone etape” for possible water level measurement...several pool projects have used them.

Bill, the pentair intellivalves are interesting and I am sure it won’t be long before someone decides the protocol to control them once pentair releases firmware that does. However, from my experiments with my actuators (and on my system), anything other than the first few “clicks” on both ends of a valve don’t have much impact on the flow through them. I’m hoping the intellivalves implement a finer level of control, rather than those like an actuator.
 
Last edited:

sevans01

Member
Mar 31, 2018
6
deltona/FL
The easiest way I found to mount the 1-wire sensors was to cut my pipe and glue in a tee. In the tee I glued in a 2" slip to 3/4" threaded reducer. I used a 3/4" threaded PVC plug, drilled a hole the sized of the sensor then glued the sensor in with JB Weld. The threaded plug will make it very easy to replace if/when a sensor dies.

My pump is the Superflo VS which doesn't have the rs485 interface. I just probed which connector pin controlled each speed and the relay shorts 5v onto that pin
 

jonpcar

Bronze Supporter
Jun 1, 2016
423
Gilbert, AZ
Sevans thanks for the details on the 1-wire sensors...I am leaning towards ordering a few because they look so simple and I am thinking of using multiple. Are you happy with the accuracy of yours and if you don’t mind, can you point me to the one you actually bought?
 

sevans01

Member
Mar 31, 2018
6
deltona/FL
They are rated for accuracy of +/- .9F and the few times I checked against a Thermapen they matched.
I got these but there are countless waterproof DS18B20 sensors listed, I think they are all the same, just different sellers

I started with just running them off a GPIO pin with a 4.7k pullup resistor, and for short distances it worked great.
When I added solar, I added 2 sensors about 120ft away and they would drop offline. I switched over to using a Maxim DS9490R USB to 1-wire interface to better drive them, but still had trouble with 2 sensors at that distance. Cutting back to 1 remote sensor and 2 close up and everything is stable

What I have found is 1-wire is tricky over long distances, wire capacitance and signal back reflections start coming into play. There are very detailed white-papers to deal with improving results, but I didn't need the second remote sensor, so I'm happy with the setup as it is.
And if the solar panels could have gone on the roof, distance wouldn't have been an issue.
 
  • Like
Reactions: billmi

jonpcar

Bronze Supporter
Jun 1, 2016
423
Gilbert, AZ
Sevans, thanks...I suspect that you are right about many of those amazon sensors being from the same manufacturer and simply imported by different sellers. I just wasn’t sure if there was a name brand version that might perform better. Sounds like you have had luck with those so I will do the same.

I am not planning any long distance ones yet (solar may be in my future), but thanks for the details on the issues with that. Because only one pin is needed and these are cheap!, I will now use at least 3: ambient, pool water, -new- buried chlorine tank temp, for the heck of it to see if there are any trends if and when I get everything up and running.

By the way have you documented your system anywhere on the web?...I’ve looked over many, but don’t think I have run into yours. Thanks again to the op (billmi) and yourself for the inspiration!

Don’t know if you looked at the Milone etapes for water level control. I am planning on two: one for my chlorine tank and one for my yet-to-be-installed acid tank. My originally installed “toilet water leveler” has worked great for 25 years with a couple replacements in that time.
 

billmi

Member
Apr 15, 2013
11
Florida's Spacecoast
I love this guy!
I have the same Pentair equip and basically did the same project with different components...
Sounds like an awesome setup! I totally hadn't considered controlling temperature, but it would be easy to do - just set the heater's thermostat to its maximum and turn it on and off as needed to hit the target temperature - that's great!

I've been toying with the idea of building a water level sensor into the lid of my skimmer, with either a couple of sealed magnetic float switches (one for high level and one for low level) or sonar, and a battery with solar panel built into the lid. I'm dubious of anything but something fully sealed surviving in that environment for long, which makes me think low-cost sonar is not the right tool, and industrial sonar level sensors are more than I want to spend. Since I don't need to know the level by the minute, I'd be OK with a long sleep cycle and only waking to report the level at night to both reduce power consumption and since the skimmer is normally not running at night, so the pump wouldn't be drawing down the level then. Key is I want the whole thing to be non-obtrusive and self contained.
 
  • Like
Reactions: MyAZPool

billmi

Member
Apr 15, 2013
11
Florida's Spacecoast
Bill, the pentair intellivalves are interesting and I am sure it won’t be long before someone decides the protocol to control them once pentair releases firmware that does...
Yes, it won't surprise me if those get reverse engineered. For what I'm doing so far, it's overkill, since I am just running them to their limits, but they would be nice for something like my fan jets, where the in-between positions matter for trying to get a specific flow rate.
 

sevans01

Member
Mar 31, 2018
6
deltona/FL
jonpcar - no, nothing published for my system, still very much a work in progress. Just last night I added a control to shut off the solar heat when the pool gets too warm as it got up to 89F yesterday.

the Milone tapes look interesting, my trouble for level sensing is that being able to get readings, but not having a wire run across the deck. I even toyed with the idea of laser mounted near the pool for time of flight measurement, but it looks like laser readings on clear water from that distance would be difficult at best

Other idea is a low power wireless micro controller in a sealed container, mounted under the skimmer lid, then battery run time would be the issue since I don't think there would be enough sun there for a solar recharge
 
  • Like
Reactions: billmi

MyAZPool

Gold Supporter
Jul 3, 2018
994
Arizona
jonpcar
Looking through the information contained in those hyper-links is sooooo impressive (and so above my pay-grade :mrgreen:). I only wish I had the skill sets necessary to do this type of work. My hat is off to anyone this creative (and just plain SMART). :salut:
r.
 

jonpcar

Bronze Supporter
Jun 1, 2016
423
Gilbert, AZ
r, I think most of these projects are tackled by people who just love to tinker. Many, but not all, have a background in either software or electronics hardware, sometimes both (I envy those, haha). As talked about early in the thread, the “hardware” is always cheaper, but the time commitment is what usually disqualifies those who pursue these: many of these projects fail to reach launch.

Lots of other issues besides cost/time should be considered as well: safety, reliability, transferability (house sale) are among those. So, despite costs and limitations of commercial systems, they are the ONLY real option for 99% of pool owners who want/need advanced automation. And, as demonstrated by your Intellicenter experimentations, some of those commercial solutions still allow almost unlimited room for fun and tinkering!