DIY automation build

foobert

0
LifeTime Supporter
Jul 19, 2013
142
Bay Area, CA
And, so begins the build of my automation system. Intended features:

  • Valve control for intake, returns, sweep, and solar.
  • Pump control of the 4 programmable speed presets.
  • Solar temperature controller
  • Heater control and temperature modulation.
  • Mobile friendly web-enabled control w/manual overrides (ala, kick on spa for 45 minutes at 100˚).
  • Salt-water generator run-time control through FC sample data input.
  • PH control via acid pump controlled through PH sample data input.
  • Water chemistry history record and at-a-glance problem identification.
  • Filter pressure monitoring to identify back-flushing time.
  • Lighting control

This will be based off a Raspberry PI (happens to be an older Rev 2 version). It has plenty of GPIO handle this. Best of all, it can easily be a web-server, run a database back-end, and can be programmed through just about whatever programming language you want. This will be a mix of PHP for the web-interface, python for the guts of the logical control. Sample history, temperature data, and run states will be stored in mysql database.

I know I'm not the first to do this. But, I haven't seen a DIY job that ties all this together in an moderately easy to use open source package (am I missing it?). I will share full code and want to streamline the setup for any others that want to duplicate this.

Let's get started. A quick floor plan layout of the hardware in the enclosure.
IMG_2492-20160910.jpg


The major parts list:

Excluding the valve actuators, the hardware for this is quite simple and cheep.

I'm choosing not to automate the sensing (ala, ORP + PH). It's certainly technically feasible, but, seems more trouble than it's worth from a cost/benefit/maintenance standpoint.

This will be a phased approach. First part is basic pump control, chlorination, valves, and heater. Second phase will be the web-UI. Pressure monitoring will happen later. Solar control once I have solar panels installed to bother with. Acid injection when I get tired of pouring acid in :roll:
 
Sounds interesting, do keep us posted on how this develops, I am wondering if you have a plan for sealing the Dallas Semi 1-wire serial temperature sensors against moisture, as I recall they can be effected by physical strain on the packaging, so mounting them in a blob of epoxy is out.
 
I have 3 that I epoxy blobbed several years ago and they have since been in service outdoors. Still work great and appear to have held accuracy just fine (although I haven't checked calibration since they were deployed).

For measuring the pool temps, they'll be inside a thermowell, so, I don't need them to be submersible.
 
After posting that I went and did some digging, it appears that the earlier designs of the Dallas Semi temperature sensor (up until about 2001) suffered from a design flaw that caused mechanical pressure on the housing to translate to a change in temperature, the later ones used a self compensating design which greatly lowered this effect.
 
I'm a bit annoyed at the relay board. At a glance, it has all the right features: opto-isolation, buffered drivers for the relays, and indicating LED's for on/off status. With all that, I figured they must have wired it together intelligently w/ solid principles and flexible input voltages.

Sadly, they force 5V down your throat by hard-wiring the opto-isolators to an on board 5V supply (LDO driven from 12V input). The Pi is a 3.3 volt device. It's bad form to force the clamping diodes on the Pi's IO buffer to absorb the over-voltage from directly wiring the GPIO to this relay input.

But, the real kicker is that the input to the relay board is inverse logic -- hold the pin to ground to energize the relay. Since the Pi's GPIO defaults to hi-impedance input at boot up, this isn't such a big deal. However, the default state of the output is '0'. Since I don't want to glitch the output from low-to-high when transitioning to output mode, I'm going the extra mile an using an inverting buffer circuit to drive the relay board. If the relay board had been designed better, this would be completely unnecessary. Ohh well, I have it now...

sainsmart_driver.png


For the electronically less-inclined, the NPN transistor (Q1) passes current when the base (middle connection) is at a "high" voltage. When Q1 passes current, that lights the LED inside the opto-isolator (U1), which then energizes the rest of the relay circuit. Resistor R2 is needed to hold the transistor base at low voltage while the Pi's GPIO is in high-impedance input mode (ala, when the Pi is off, or booting up). R3 limits the source current from the Pi to <1mA (its rated for 20mA, so, this is very conservative).

Tonight, I'll do a quick breadboard sanity check, just to be sure.

Then, I'll make up a connecting board to bridge between the Pi and the relay board. It'll have 16 copies of the above. The board will have the added benefit of giving me a place to mount the I2C analog-to-digial converter for the pressure transducer, as well as some 1-wire interface headers.
 
I thought about doing something similar, so definitely keeping an eye on this. Are you worried about operating temperature at all on the Pi? I know you have much milder weather than I do in the desert, but in an enclosed box it's always a concern
 
I've had this Pi in a much small sealed box, outside in partial sun for the last 2 years -- hasn't been a problem. I will admit, now that I have all new pump pad equipment, I plan to put a roof over it all to keep the sun and weather off.
 

Enjoying this content?

Support TFP with a donation.

Give Support
Ya remember this project? Yeah, I hardly do either :confused:

Quite a few moons ago, I hand-wired a board with 16 copies of the above circuit, and actually had it all working! Alas, as I was taking things apart after that test, an alligator clip got away from me and shorted something out which fried my older model Raspberry Pi. The older Pi has a different pin-out than the newer ones. Yeah, I probably could have found and purchased and older Pi to match, but, I really wasn't happy with how the hand-wired bridge board looked. For a host of other reason, I just decided to spin my own PCB:
pool_bridge_pcb.png


~$30 later, I have a stack of a dozen boards sitting on my desk. Going to try to build one out in the nearish future and get this project going again...
 
Too bad you don't have a pick & place tool as well as a reflow furnace...makes building a board so much faster!! Nice board design!

Good luck.
 
It's not a big deal to do by hand -- except for the I2C A-D converter, it's mostly 0805 packages, which are quite easy to place by hand. Cut a solder mask on the vinyl cutter, place the parts, and reflow it on a hot plate. Easy peasy for a couple of boards :)
 
By coincidence, I just decided I want to add some DIY automation to my pool and spa. They have completely separate pump/heater/control systems, so would be pretty costly to buy an off the shelf system for both.

Probably going to tackle spa first.

Wondering if you ever shared your code?

Might be interested in a bare PCB too, if you want to sell one.

Really want to tie into my existing domoticz system, will be looking into that too.

Randy
 
I don't have any code to share yet, but, it will one day be posted when it's in a state that is self contained enough to make sense of. Once I have validated the PCB, yes, I'd be happy to get rid of the extras :)
 
Let us know how this turns out. You might want to even change the computer to a Pi -Zero W as they are cheaper and sufficient CPU wise as they are about the same speed as the original RPi that you started with.

I started a similar project a few years ago that I called PoolPi. My plan was to have a floating pool monitoring computer in my pool sealed in a tupperware-like container. It would have a solar panel on the top to charge batteries to power the pi. The pool water should also help to moderate the temperatures. I had a temperature sensor and was hoping to use a pH sensor as well - but those are expensive. I was also going to add a motion sensor so this could work as a pool occupancy alarm. And I was also thinking about putting a Pi camera in it so that I could get a live video feed, or at least snapshots, of my pool (live video would such too much power). V1 got shorted out by my salty pool water but I hope to get back to this in the future.
 
I installed a T with a 3/4" pipe thread as the "T port" and thread a stainless steel thermowell into that. You can get them on amazon for <$15. I soldered the wires onto the DS18B20 and dipped it in epoxy for weather proofing. Once cured, slide it into the bottom of the thermowell and stuff the opening with some wadding (paper towel) to insulate from the outside air.

For best results, positioned the T so that it faces down slightly so any water that finds it's way to the opening drains out.
 

Enjoying this content?

Support TFP with a donation.

Give Support
Thread Status
Hello , This thread has been inactive for over 60 days. New postings here are unlikely to be seen or responded to by other members. For better visibility, consider Starting A New Thread.