Tag Archives: rainwater harvesting

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: