Spoiler alert: I wrote this blog post before realizing that the solenoid valve was normally open, when I expected it to be normally closed. The electronics were made specifically for one function and I cannot use them with a normally open valve. I will make new (and better!) control circuitry and create a new post about it. This post goes through everything I worked on to get the original design to where it is now. Look forward to Part 2 for details on the final working product.
This project, in essence, only had to do one thing -- open and close the solenoid valve to let water flow. It has two mechanisms to open the valve, a MSP430-powered relay with a countdown timer program or a manual on-off switch to control exactly when the water flows or stops. I modified one of my PCBs from my MSP430 Reaction Game project as a display to set how much time the valve will stay open for. I used a basic light switch to control the manual operation of the valve. There is also an indicator that lights when the valve is open, regardless if the manual switch or timer program opened it.
I used a Thomas & Betts E987NR Junction Box as the enclosure for this project. Getting everything to fit inside was tough, but this box is very easy to drill and cut out holes so I would definitely use it for any other of my projects that could use an enclosure. This box was previously used, so it already had some holes in it. Luckily, I was able to reuse some holes that we already drilled in it and I only had to patch one of them.
|Junction box cover|
I started this project off by modifying and installing my MSP430 Reaction Game PCB to the cover of the junction box. I was able to mount the majority of the components as I normally would if I was using it for its intended purpose, but I did make some simple adjustments. I had to mount the electrolytic capacitor on the backside of the board because it was too tall to fit the other way. I also mounted the programming headers facing this way so I could program the MSP430 once the PCB was mounted to the lid. I used longer pushbuttons so they could be reached through the lid. I added a wire to P1.2 on the MSP430 that will be used to switch the relay that controls the valve and light an indicator LED that the valve is open. I also modified the power input because it will be running from a power supply I made and not a 9V battery with a power switch. I had to cut off a portion of the board so that I could mount a different potentiometer than I normally use. The potentiometer was mounted to the lid and had wires running from it to the PCB. I also drilled holes so the PCB could be mounted to the lid.
|Bottom of PCB with programming header|
and capacitor along with holes for LEDs, etc
|Top of PCB showing longer buttons,|
potentiometer connections, and modifications to
cover so board would fit snug
I used red light in the first position and green lights for the other LEDs. The red LED signifies that the valve is open because of the program, and not because of the manual switch. The green LEDs are controlled through the potentiometer to adjust the time that the valve would be on. The first LED opens the valve for one hour, and each LED in between that is lit adds 20 minutes to the time, with the last LED opening the valve for three hours. Once the start button is pressed, all of the LEDs will light up and act as a countdown until the valve closed. Each of the LEDs in this mode signifies 1/7 of the total time left. As the timer counts down, the LEDs go out as each 1/7 of the time is passed.
Once I was happy that the PCB's operation was sufficient, I connected the lights through the PCB and soldered them in. Unfortunately, soldering in the LEDs locks the PCB to the cover, so I hope I never have to made any modifications for the PCB in the future.
My first step of working with the electric system was installing the light switch to the side of the junction box. I chose a cheap rocker switch for this application because I felt it looked the best. I used a Dremel to cut a precisely-sized hole so that the switch would stay in place just by popping it into the hole. The mounting tabs of the switch were slightly larger than the box, so I bent them backwards and was able to use them, at a right angle of their original position, to mount the switch to the box. My choice of an inexpensive light switch came back to bite me as I was tightening a screw and completely stripped it with a hand screwdriver. I have never seen a screw strip with such a small amount of effort. I replaced the screw with another and the switch was complete.
|Switch in hole|
I used a Opto 22 120D3 DC Control Solid State Relay so the 3.3V MSP430 microcontroller could switch the 120VAC solenoid valve I was using. It was simply mounted in a free space of the junction box using a couple small bolts. It's location makes it difficult to mount and use, but once in place it is out of the way.
|Solid state relay|
The final piece of the project was to build a power supply to power the micrcontroller. I used a step down transformer and diodes assembled as a full bridge wave rectifier along with a 100uF capacitor to get the 120VAC voltage into a small DC voltage which then runs into the voltage regulator located on the MSP430 Reaction Game PCB to supply 3.3V DC to the microcontroller. The power supply was mounted to a PCB that is mounted on the side opposite of the relay via some metal standoffs for an optimal fit.
|Step down transformer and rectification|
All that was left to do was connect the all of the wiring inside the box. It's like a puzzle in there and all the pieces need to be put together in a specific order or it's impossible to tighten some of the screws. First the light switch is mounted, then the relay is installed, then the power supply is mounted, and then the indicator light. I mounted an indicator light to the top of the box through a small hole. The light is in series with the solenoid and turns on at the same time as the solenoid. After all these are connected, the lid can be installed.
Since this box was used before, there was one hole that needed to be filled. I used JB Weld and a piece that I removed to install the light switch to fix the hole. I carefully shaped the new insert with a Dremel so that it would fit very snug and only a small amount of JB Weld would be needed. It turned out better than I expected.
Once it was complete, I took it to my girlfriend's house to install it and connect the fittings. For the water lines, I went from the spigot to a tee that then split into another spigot or the solenoid. Since the distance to the secondary spigot is so much shorter and below the line for the solenoid, the water comes out at a high pressure even if the solenoid is open.
Another thing I had to do was convert the power outlets in the garage from 2 prong to 3 prong. After shutting off the power to the garage (which I luckily got on the first breaker I flipped), I took the cover plate off and checked to make sure the box was grounded. Thankfully it was and I only had to get a grounding wire and connect the new power outlet up. It had a very nice design where the wires slipped in and then a screw tightened it down unlike many others I wired where you had to wrap the wire around the screw to make a connection.
|Installing the power outlet|
|Finally some grounded outlets|
Here's the worst part. As I mentioned in the introduction of this post, it turned out that the solenoid valve that I have is a normally open model. Although, I researched the part number before, I could not find any solid information on my particular valve. Without much though, I assumed is was normally closed because that's what I'd expect most valves to be. I tried testing it before but was unable to due to the fact that water must be running through it at at least 5 PSI for the solenoid to switch. I used some tricks while wiring this up that would only work for a normally closed valve. Because of this, I'm going to redo the controller. This doesn't bother me too much because I was unhappy with the looks of the MSP430 controller. For the next controller, I plan on using a PIC chip and a 16x2 character LCD to display information.
This is the latest revision of my code and schematics for this project on my github. From here on out, my github code will be for the PIC-based model. I'll post some more pictures of the project below. Stay tuned for the final version of this project! Thanks for reading.
|A look inside the mess|
|Some pictures of the garden this year|