Author Archives: Dave

Rain gauge

Setting an Arduino Up to Read a Tipping Bucket Rain Gauge

This post is part of a series I’m doing on the automatic first flush system we use on our rainwater harvesting set-up. The tipping bucket rain gauge is the key external input that allows the system to do its job. Tipping bucket rain gauges use a funnel to direct water onto a see-saw of two side-by-side buckets. The buckets are sized so that a certain amount of water causes the see-saw to tip (usually .01 inches of precipitation collected by the funnel, an 8 inch diameter funnel collects about 8.2 mL of water per tip).

Tipping Bucket

When the see-saw tips, a magnet swings along with it and past a magnetic switch that closes as the magnet passes over. When the switch closes it briefly completes the circuit and a pulse is sent down the output wire. The unpredictable, short nature of the pulse being sent down the wire makes it a bit hard to measure with an arduino that is doing lots of other things. What if the pulse comes and the arduino is busy doing something else? To solve this problem, I hooked the output of the tipping bucket gauge up to a flip-flop, a very simple combination of logic gates housed inside of an integrated circut (you can get one from radio shack for less than $1). The flip flop captures the pulse from the gauge, and in effect holds on to it by setting its own output high (to 5 volts). Even when the pulse from the rain gauge stops, the flip flop’s output remains high. This buys the arduino some time to check on the rain gauge when it gets around to it. The arduino sketch (program) is set to check the flip flop each cycle. If the line is high, it records that .01 inches of rain as fallen, adds that amount to the storm total, and then sends a pulse to the reset pin on the flip flop. When the reset pin on the flip flop is set high, it effectively lets go of the last tip and is then ready to record a new one. If we don’t want to miss any tips, we have to be sure the rest of our arduino sketch doesn’t take longer than the minimum time between tips. On most tipping bucket gauges, they don’t tip much faster than once per second. As long as your sketch loops faster than that, you should get a fairly accurate count from your gauge.

System diagram

The basics of how the tipping bucket, flip flop, and arduino are hooked up

Here is the rain gauge reading subroutine from the sketch:

void rainTip () { 
if (digitalRead(rain_Gauge) == HIGH) { //if the flip flop has a tip recorded
timeOfLastTip = now(); //timestamp the latest tip so we can calculate dry-times ++rainCountTips; //add to the storm total 
rainCountIn = rainCountTips * .01; //convert from tips to inches 
digitalWrite(rain_GaugeReset, HIGH); //send a pulse to reset the flip flop 
delay(600); //hold it for long enough to actually work 
digitalWrite(rain_GaugeReset, LOW); //set the reset pin low 
} // END of if
} // END of subroutine

Arduino Powered, Rainwater Harvesting First Flush System

 Project Introduction

If you’ve done much reading about rainwater harvesting, you’ve likely heard of a first-flush system. I worked as an installer and designer on a number of systems during graduate school, and every one had some kind of first flush system installed.

If you’ve never heard of a first flush system, the concept is simple and really important to understand – especially if you’re planning on doing a system where the water will be used indoors, and double especially if you’re going to do a potable system.

The end goal of installing a first flush system is to divert the first bit of water that is collected by your roof during a rain storm. The reasoning behind this is sound: after a few days with no rain, dust, insects, and bird droppings accumulate on your collection surface (AKA your roof). The first flush of water that falls during a rainstorm contains the vast majority of particulates and organic material that head down the gutters during a storm – this stuff has to be filtered out later to ensure the water is clear and safe to drink so its best to just not let it into your tanks in the first place.

By diverting this first surge of dirty water away from your collection tanks, you keep your tanks and system much cleaner, and potentially safter, too. The state of Texas has a great explanation on how much water to divert in their rainwater harvesting manual. Huge thanks to the TWDB for putting such a great manual together.

“…One rule of thumb for first-flush diversion is to divert a minimum of 10
gallons for every 1,000 square feet of collection surface. However, first-flush
volumes vary with the amount of dust on the roof surface, which is a function of
the number of dry days, the amount and type of debris, tree overhang, and

A preliminary study by Rain Water Harvesting and Waste Water Systems
Pty Ltd., a rainwater harvesting component vendor in Australia, recommends that between 13 and 49 gallons be diverted per 1,000 square feet. The primary reason for the wide variation in estimates is that there is no exact calculation to determine how much initial water needs to be diverted because there are many variables that would
determine the effectiveness of washing the contaminants off the collection surface, just as there are many variables determining the make up of the contaminants themselves. For example, the slope and smoothness of the collection surface, the intensity of the rain event, the length of time between events (which adds to the amount of accumulated contaminants), and the nature of the contaminants themselves add to the difficulty of determining just how much rain should be diverted during first flush. In order to effectively wash a collection surface, a rain intensity of one-tenth of an inch of rain per hour is needed to wash a sloped roof. A flat or near-flat collection surface requires 0.18 inches of rain per hour for an effective washing of the surface…

Basically, there’s a lot to think about when trying to maximize the effectiveness of your first flush system.

When I worked as a rainwater system installer, I became very frustrated with the current state-of-the-art in first flush systems. The primary system used on residential installations centers on a floating ball valve and a teeny tiny hole.

The idea is that you create a diversion chamber with a bouyant ball inside. This chamber is installed downstream of the gutters, but upstream of the collection tank(s). The first surge of water fills the chamber, floating the ball up to the top until it seals against the top of the chamber. At this point, any additional water from the roof continues downstream to the collection tanks. You can choose to place a chamber at each downspout, or a single, much larger one on the trunk-line enroute to the collection tank.

Now, you’re left with one or multiple first flush chambers full of dirty water. A clean-out valve would be great, except that you’d have to remember to drain your collection chambers after every rainstorm. To combat this unrealistic expectation, most systems use a small drain hole to slowly empty the chamber. Anyone see a problem with using a tiny hole to drain water filled with lots of particulate matter? Talk about clogging quickly! Manufacturers have installed filters in these systems, but they also clog and require service. Service usually entails getting watery sludge shot all over you, which is never pleasant!

The proverbial holy-grail of first flushingness would be to divert the first flush of water, and have it bypass your system completely. But as you read in the TWDB excerpt above, there’s a lot of logic that goes into determining exactly how much water you should flush.

The Crucible

We are lucky enough to have some land in our family, located in the Texas Hill Country, a beautiful place with crystal clear spring-fed rivers that are lined with bald-cypress trees. The water is clear and pure, but LOADED with calcium carbonate. The nice lady at the county water authority told us that our well water was so hard she was surprised it didn’t bounce right off – a good line for sure.

Sure enough, the water (even after softening) was so hard that it ruined appliances, left water spots on everything, and after a shower your hair was left feeling like dried hay. It wasn’t great to drink, either. They could drill a deeper well to try and find “sweet-water”, or use a similar amount of water to set up a rainwater harvesting system. I lobbied for the latter :).

They are set up ideally for a potable rainwater harvesting system. They have three large collection surfaces with metal roofs totaling right at 9,000 sq feet: the house (1,900 sq feet of roof), the garage/workshop (1,500 square feet of roof), and a large barn (5,600 sq feet of roof). A 1-inch rainfall in this system would produce over 5,000 gallons of rainwater!

We spent a few months drawing the system out, getting gutters and downspouts installed, and prepping for the install. They’d be using four, 10,000 gallon plastic tanks…enough water for a full year of mildly conservative use in the house, and the entire tank-battery could be completely filled on only 8 – 10 inches of rainfall.

We hit a huge roadblock when we came to the first flush system. There are over 10 downspouts spread over 4 acres…who wants to keep up with cleaning/draining those all the time? Using a single first-flush container would require a tank somewhere from 90 to 500 gallons in size, and again you have the issues of cleaning/draining the dirty water. They spend large amounts of time away from the ranch, so the system realistically couldn’t be babied all of the time. I had just started messing around with an arduino, and thought “hey, this thing has a lot of potential to do the thinking for us”.

The system concept

The arduino board is able to listen to a variety of inputs, and act on those inputs according to the logic you program into it’s memory. We would provide it with inputs of rainfall (from a tipping-bucket rain gauge like this one) and water-levels in the tanks (from an ultra-sonic range-finder like this one). In turn, it would control a series of actuated (motorized) first-flush valves. These valves would go downstream of the gutters, but upstream of the collection tanks, just like any other first-flush system. The basic idea was this: the arduino keeps an eye on how much its rained recently and decides if it the system should divert and flush any subsequent rain, or let it into the tanks. The beauty is that the flush lines can just be plumbed into the overflow for the system, and the dirty water never gets into your tanks!

I’ll be doing a series of posts on the nuts and bolts of this system, should make it easier to digest and understand.

Series Links:

Reading a rain gauge with an arduino

System Images:

Here are a few system images:

Automatic Door

A Better Automatic Chicken Coop Door

For those who have chickens in their yards, a reliable automatic coop door is the holy grail. The end of constant fighting over who will go outside to close the coop…the end to dreading that you’ll forget to close the coop and inadvertently fatten a local raccoon while traumatizing (and downsizing) your flock.

After about a year of having our chickens in a tractor-style coop (they are always enclosed in the coop, but you move it around), we decided to just let them free-range. Thus, the coop-closing issue was born. Soon after I decided to take a look around at the state of the art, see what other chicken keepers had used to solve this problem. Reading forums and watching videos, it seemed like the market was full of expensive solutions or garage-built ones. I wanted simple, effective, and less than $200.

I’ll skip the gory details, but it was a disaster. It often was stuck open, and just never worked right…even after significant re-design. The winding-a-string method of moving the door coupled with trying to slide a door in a simple notch left lots of room for malfunctions.

After a year of fiddling with the off-the-shelf door, I was determined to make something better. Something more reliable, where you’d never have to worry about the door getting stuck, where the door was actively held down when closed so nothing could pry it up and get in.

I ended up with the design you see in the pictures. I recently installed it into a new coop. Instead of a motor winding a string, I used a linear actuator. The improvement here is that you’re still using a motor, but that linear actuators can have a static loading capacity. This basically means that when the actuator stops, it holds whatever its attached to in place (so raccoons can’t just slide it up, for example). Linear actuators, in addition, often have position-limiting circuitry built right in…no more hodge-podge limit switches exposed to the elements.

WARNING: if you make a similar door, make sure you pick an actuator that is both slow (1.5 inches per second or slower), and relatively weak (15lbs force or less). We don’t want to create a chicken guillotine!

The second breakthrough was the use of a cheap drawer-slider to aid in reducing friction of the movement of the door. The sliders act as a track, keeping the door in place horizontally, and the wheels on the track allow for very little friction as the door moves up and down. I used the simplest (and cheapest) type of track-slider, the ones with small nylon wheels in them…I was afraid that the bearings in more expensive models would get fouled (no pun intended) by being outdoors and exposed to the dust/dirt.

I’ve got a video walk-through of the door installed on my old coop:

The control circuitry is based on a couple of wildlife feeder timers that I happened to have on hand already. These are designed for remote (solar) installations, so they are very low power. They simply trip an internal relay for a user-settable duration at up to 6 times per day. They have four wires, two connect to the power source, and two go to the device to be controlled by the timer.

Usually these timers just control a simple motor that spins in one direction. With this linear actuator, however, we need to spin the motor in both directions: one way to open the door, the opposite way to close the door. With motors, reversing them is as simple as reversing the polarity of the power-source, but achieving this with these off-the-shelf timers requires some external circuitry. Below is a diagram (while it looks complex, it really is quite simple).

Control circuitry

The single-pull double-throw (SPDT) relays control the polarity going to the actuator based on which timer is activated.

Here are the key parts:

  • Timer units (2 @ $30.00)
  • 12V actuator (1 @ $110.00 – the actuator I used is discontinued, this one is equivalent)
  • Actuator mounting brackets (2 @ $10.00 – these seem expensive for what they are, feel free to experiment and DIY)
  • 18 inch drawer slider ($7.50 – also available at hardware store)
  • Perf board for control circuit (5-pack for $7.00, you can get singles at Radio Shack)
  • SPDT relays (5-pack for $6.00 – also available at Radio Shack)
  • Wire terminals (5-pack for $6.00 – also available at Radio Shack)
  • Solar Panel and Charge Controller ($35.00 – only if you’re going to use solar to charge a battery-powered install)
  • A 12V battery. A car battery is expensive and is probably overkill unless you live in an area where solar power will be unreliable. I use a lawnmower battery that I had from a previous project, but you could use an even smaller one.

So, all tolled up this is more in the $250 range, however, I did already have the timers and the battery on hand so I slid in at less than $200 in new expenditures  The increase in reliability is well worth the extra effort. The door has never failed, caught a chicken, or gotten stuck. I find that I have to adjust the timers for changing daylight once every couple of months, which lets me check on the battery charge level at the same time (the timers show battery voltage).

Coopsicle, Austin Style


In the 6 or so years that I’ve had chickens, we’ve moved three times (such is the life of a student). Now that we’re paying a mortgage, I wanted to build a coop that was well thought out, comfortable for the birds, and that actually could be counted as an improvement to our backyard.

One day while browsing a google image search for “chicken coop”, I stumbled upon a really cool looking coop:


Turns out this is the Coopsicle design from a book by Kevin McElroy called Reinventing the Chicken Coop (Kindle version). I read some reviews and downloaded it to take a look.

Setting the coop on a single post lets you easily put this coop on uneven ground, and we don’t need a fenced in run since we let our hens free-range in the backyard. Last weekend I sat down and really thought about how I could modify this coop for our set-up. Here’s the result:

Coopsicle, Austin StyleThe original coopsicle was located in northern California, where the summers are more mild than ours here in Austin. As such, their use of two re-used windows in either end makes a lot of sense and looks great…but we would need more airflow. I replaced the windows with 1/2 inch hardware cloth. I didn’t have any that would have spanned the entire 36″ x 36″ opening, so there are two panels with a divider. I’ll probably get a couple of plexi-glass panels to cover the openings during the winter months.

The end panels aren’t structural to the coop, so I made both of them removable to make cleaning the coop easier. They attach by sliding over two 5/16″ carriage bolts (one on each side) and are held in place with wing-nuts. In the picture you can see the recessed nut that lets the door sit flush when it slides over the bolt.

I kept one of the doors as designed, which allows access to the nest-boxes and the food. The other door I replaced with my previously built automatic coop door. Luckily this coop design is tall enough to accomodate the existing linear actuator I used, so it was pretty much a plug and play install. Check out the post on the door opener for more details, its been working great for over a year now, and is much more secure against predators than string-based designs. I chose to put the automatic door on the side of the coop you can easily see from the house so you can check on it with a quick glance. On the other side of the coop is a pop-open panel that gives easy access to the wildlife timers that set the opening and closing times

I put the coop lower on the post than the design called for in the book, and I used a 4×6 pressure-treated post instead of the 4×4 post they use (both modifications they recommended for increased stability). I really wanted to use a 6×6 cedar post, but I couldn’t procure one in time. The coop is still high enough to let me hang the 3-gallon fonts. Hanging them seems to keep the trough more full than sitting them on the ground. We use 2 just to be sure the girls have water when we go out of town for a few days.

In the book, Kevin calls for a thin-gauge aluminum roof. I kind of like the look of rusted steel, so I opted for 16 gauge steel instead. 16 gauge is a bit thicker than most roofing metal, but it is thick enough so that it won’t bend under it’s own weight. It should also rust nicely while staying structural and straight. I chose to make the roof overhang a bit further than the design in the book calls for. There were a couple of ramifications to that decision. My 6″ overhangs meant that I had to get two pieces of steel to do the whole roof (sheet metal only comes 48″ wide where I buy it). I chose to get 2, 26″ x 84″ pieces and join them at the peak of the roof with outdoor caulk. If I had a welder I would like to have welded them up, but I don’t so I didn’t. We’ll see how the caulk turns out.

The last change was that I didn’t do the circular stairs like they do in the book. My automatic door would have been difficult to turn into a floor-opening, and having a solid floor makes clean-up a bit easier (in my opinion). I put a jump-up platform under the door, and built a ramp to help them get used the the new digs. Its a bit high for our oldest hen, so I’m going to have to lower the platform if I want to remove the ramp eventually.

I’m really happy with how it turned out, and I’m thankful for the inspiration Matt and Kevin provided in their book.

Mission Statement

One of the primary lessons I learned in business school was the power a thoughtfully crafted mission statement can have in a business. Used correctly, a mission statement gives every employee direction in their daily activities, it empowers them to make their own decisions because they know what’s important to the business.

Whole Foods has a great example of a mission statement, and they’ve done it as a list of core values:

  • We sell the highest quality natural and organic products available
  • We satisfy, delight, and nourish our customers
  • We support team member excellence and happiness
  • We create wealth through profits and growth
  • We serve and support our local and global communities
  • We practice and advance environmental stewardship
  • We create ongoing win-win partnerships with our suppliers
  • We promote the health of our stakeholders through healthy eating education

I’ve tried to blog before, but I’ve often lost focus and abandoned the blog after a few months. To help combat this, and to give myself guidance going forward, I’m going to try and capture my desires for this site in a mission statement….here goes.

This site exists to:

  • Share things I’ve built and done on the web so that others might stand on my shoulders and build something better.
  • Create a record of the things that I’m proud of accomplishing.
  • Force me to slow down and document what I’m doing and where I’m going.

Alright, with that on paper, lets go.