Overview: This is a project to increase the reliability of controlling the flow of water to a stock tank that keeps our horses well watered (there is a “lead a horse to water” joke in here somewhere) using a microcontroller to sense water level and turn the water on/off. No AC power is available at these stock tanks, so using very low power techniques is required. The project uses an MSP430 MCU and a DC latching solenoid with a high quality sprinkler valve driven by an H-bridge device. Power is provided by a single 9v battery.
Problem: Having horses on the ranch means keeping a steady supply of water for these animals that can swallow a quart per gulp. Our stock tanks have water piped to them and we have used float valves to regulate the water level, but these float valves wear out often (twice a year), cost ~$30 to replace, and the failure mode results in lots of water in the pasture – good for the grass, but bad for the pocketbook (we don’t have well water). And water is a precious resource in Texas these days.
Solution: A few years ago we had irrigation plumbed to our greenhouse and the contractor used a regular sprinkler valve (Irritrol 205s) outfitted with a DC latching solenoid powered by a controller allowing you to set watering cycles as you would expect from a sprinkler controller, but powered from a single 9v battery. After reliable daily watering on a single 9v battery, it occurred to us that leveraging a similar setup would improve the stock tank problem.
So it was time to design some electronics to do the job! Last year we picked up some Launchpad boards from Texas Instruments for $4.30 (MSP430 – four three oh) and enjoyed how simple it was to program, test, and debug with the free Eclipse-based development environment (CCS) supplemented with other great inexpensive tools like the Saleae logic analyzer and a USB oscilloscope. We hacked together a prototype using a Launchpad and an H-bridge DRV8333 evaluation board working out the basics. Lot’s wires everywhere as prototypes go!
Our end goal was to house this controller in the valve box below ground level, so it had to be waterproof. We had never done a pcb before, but figured this would be the perfect time to learn how to design one, reflow it, and produce a neat, reliable device. We started down the Eagle tools route, but the commands weren’t intuitive – looked like a big learning curve ahead, yet it seems everyone uses Eagle. We searched to see if there was an alternative and landed on Diptrace. Much more intuitive to us and the tools are free, like Eagle, for the hobbyist. We are open sourcing this project, so hence the design files are Diptrace!
More on the design:
Hardware Choices: We decided to use the same DC latching solenoid (DIG-S305-DC) and the same valve (Irritrol 205S) that our sprinkler guy used, since he said it was very reliable. We started searching for an h-bridge and found the TI DRV8833 which has a power supply range of 2.7 V to 10.8 V. The coil impedance of the DC solenoid is 5 ohms and with a 9v battery, we needed the h-bridge to handle 1.8 amps. The DRV-8833 has two h-bridges each capable of 1.5 RMS amps or 2 amps peak and you can use them in parallel for 3 amps RMS or 4 amps peak so we decided to use them in parallel – could have probably used one channel but we didn’t need the second channel and two channels must be better than one!
We could have used a basic and less expensive MSP430F2012 for this project, but in case we wanted to add zigbee for remote monitoring/control, we decided to use the MSP430G2553 which has better UART and I2C capability and 16K of flash and 512 bytes of ram. We had used this part on several other projects as well. The MCU is programmed using headers that can be attached to the Launchpad – VDD must be driven by the Launchpad when programming so we provided a jumper on the board that must be in the appropriate position. Kerry Wong provides a nice writeup on using the Launchpad as a programmer here.
The solenoid specifies a 10 msec minimum pulse to engage/disengage . During prototyping, we observed a considerable sag in the voltage to the solenoid when the h-brigde was on – the 9 volts would drop to 4 volts – presumably due to the internal resistance of the battery. So we did a little math on the energy that needed to be dissipated in that 10 msec timeframe, and added a 4700 uF capacitor across the battery and that made things look better, although still sagging to a little over 5 volts. But the solenoid was happy.
To provide VDD for the MSP430G2553, we used a TPS76333 – by now you you may be thinking that we are biased towards TI parts, but they provide free samples, fast delivery, and no shipping charges — the path of least resistance!
Software: To conserve power and simplify the hardware, we used the Very-Low-Power Low-Frequency Oscillator (VLO) for the watchdog timer which is nominally 12 KHz and the default 1MHz DCO when the processor is active. The VLO can vary from 4 KHz to 20 KHz over the broad temperature range, but we intended for the controller to be in the valve box below ground so we wouldn’t see huge temperature swings and the sampling time of the float switch is by no means critical in this application.
Packaging
Weatherproof operation is required! The controller will be located below ground level and will fill up with water in a heavy rain. We selected a case from Polycase with a cable gland to seal where the wires to the solenoid and the float switch pass through. Great thing about the Polycase box, is it comes with a dxf template of the dimensions of the circuit board it can accommodate. We imported this to Diptrace and made some modifications so that it would fit in the 5 cm x 10 cm category for itead studio’s pcb service to reduce pcb costs.
PCB
As mentioned above, we settled on the Diptrace tools for our schematic capture and board layout. The tools work well and itead studio’s service is great – for both times we ordered (yes, we missed a few things on the first prototypes), we got back boards in just under three weeks. They advertise 8 pcs for the colored solder mask boards with 100% e-test and we got 12 boards back on the first run and 11 boards back on the second run. Very pleased with the quality and service.
Field Test
The installation required some plumbing This meant some digging and pvc cementing the valve in place.
For the float switch, we fashioned a simple bracket from 1” aluminum stock from the local home improvement store. After wiring the controller to the solenoid and float switch, the solenoid engaged after the expected delay and shut off when the float switch went open! However, for the next few mornings, the tank was below the float trigger level meaning something wasn’t working as we thought. After some pondering, we realized we had no hysteresis in the float switch sensing/triggering control software and
theorized it could be that trying to trigger the solenoid on soon after triggering it off, could have put too much demand on the 9v battery and reservoir capacitor. We added the logic in the software to prevent a retrigger within a period of time and this gave us reliability – no problems since then!
Next Steps
We don’t know how long the battery will last and we’ll post that when we know as we don’t (yet!) have a multimeter than can measure in the microamps range (millamp range shows zero). We also plan to test a tank with a flow meter plumbed inline to collect some statistics on water usage. There are already Zigbee temperature sensors in use around the ranch, so adding this to the network with information about on/off cycles and usage would be interesting.
Do you have a use for this?
All the design files and software are here.
Kits are available for purchase if you prefer:

Stock Tank Filler by Zephyr-Labs is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.