Measuring home water consumption with Raspberry Pi


Living in California during the mega drought is like watching the car in front of you throw their trash out the window everyday, forever. It's infuriating to watch other people's destructive behavior, but there's very little you can do about it. Throughout the Bay Area there are reminders to, "conserve water" on highway signs, business windows, and on the radio. This has led us to be hyper-vigilant of each others' behavior because we're constantly reminded how to act. However, without knowing how much water we're consuming ( in a more useful format than the monthly water bill ), it'll be very difficult to change our own behaviors or convince others they need to change. In other words we need more data. As Californians, we need to be mega nerds to get us through this mega drought.

I've always assumed it would be expensive to itemize water consumption in a house. Each water source would need a water flow rate sensor to get a measurement, which would add complexity and require plumping in most cases. However, a few days ago I suddenly had the realization that most of the time, I turn the water on full blast. All my sinks and showers have a single pull-style knob for on/off. The design makes it difficult to turn the water on minimally, so everyone opens it all the way. Therefore, I've made the assumption that all my sinks and faucets have a constant flow rate. All that's needed is to measure the flow rate once, figure out how long the faucet is open for, and multiply the two numbers together.

System Overview

For this project the electronics and software were more interesting to me than the mechanical components. The least amount of work possible was done on the mechanical parts to get it all minimally working. The switches I used were arcade buttons because they're inexpensive and I already had them.

Everything is based on a cloud database that the sensor data gets saved to. I use because I'm familiar with their API. They have documentation and example code for most platforms I'd use in the future too. It's really convenient to be able to swap out devices and components without the hassle of porting the data. Moreover, it's now trivial to visualize the data anywhere and on any device (e.g. the scatter plot below is made with d3.js ).

Temporary solution until the wireless performance is addressed

A Raspberry Pi runs Python scripts to mashup the technologies involved and get the system to work. The scripts sense button presses, listen for wireless data from the microcontrollers over XBee radios, calculate the water expended, and push the information to the Parse database. Instead of a Raspberry Pi for every room, a Propeller microcontroller is setup in the bathroom and wirelessly sends the data to the Raspberry Pi in the kitchen. This saves a bit of money and adds modularity. The layout I ended up with was largely governed by the poor performance of the XBee radios I'm experiencing. At this point my guess is that there's too much wifi interference, but this short distance works for now. The plan was to only have a R.Pi in the kitchen until I find a better solution. In the meantime, I've unplugged the kitchen sink sensor until this project receives more investment money and I purchase a second Raspberry Pi.

Kitchen Faucet

This three-minute build uses an arcade button zip-tied to the top half of the faucet with rubber pieces for added friction. The button remains pressed while faucet is closed and releases when the faucet is lifted. A large Jack in the Box cup was cut into a platform that the button presses against when closed. This solution isn't affected by the direction of the faucet or handle relative to each other and is doesn't require any changes in user behavior. It's virtually invisible.

Each faucet's flow rate needs to be measured and saved into system's programming. Once the button was installed and the Raspberry Pi could detect button presses, measuring the time in the 'open' state was trivial. Using a postage scale, I weighed the water and divided it by time it was on for. I did this a few times a determined the average flow rate to be 0.117 L/s for the kitchen faucet.


The button mount was designed and 3D printed in a couple hours. Hopefully others can use the 3D model too. It's split into two parts to minimize support material and save about 20 minutes of print time. I've also included a replacement end piece I made because my lever was rusted and broken. It's simply hot glued in place. Click the button to the right to download them.

The flusher's lever presses the yellow arcade button at the same time as it lifts the flap that's holding the water in the toilet's tank. A piece of foam glued to the button acts like a spring to compensate for alignment and travel distance differences.

The volume of water was calculated using a ruler and by measuring the change in water level. I assumed a rectangular volume ( width x length x height ) even though the corners are rounded and it's slightly tapered. The volume was calculated to be 5.6L. TODO: improve accuracy of this number.


Observations and Discussions

 A screen capture of the web server displaying the data.

Strange things happen when you're given progressively more data. You suddenly know very specific facts about your life. How much volume containers hold or the amount of water used to wash a salad. For example, I now know that I can only fill my water filter 1.4 L at a time. Rinsing your fingers after a quick snack from the fridge takes 250mL of water, the same as those small water bottles. Is this a wasteful quantity of water? I don't know yet.

Also, the system is an excellent timekeeper of when I poop... and also everyone else that comes to visit. This is going to be fun.

I had to move the only Raspberry Pi I had closer to the bathroom. This is why the small quantities of the kitchen faucet stop and large volumes from the toilet start.

Residential water use is dwarfed by agriculture and corporate water consumption in California. So why do go to the trouble of collecting this data at all? Even if all residential zones stopped 100% of their water use, it would barely make a difference. The short response is that this isn't really about the drought.

I like to think of this little water experiment as a way to guide my own behavior. That instantaneous and fine grain feedback is what's needed to make lasting changes to my water consumption and my overall life. Maybe someday our homes will work with us to be more efficient in not just water consumption but with power and other community related endeavors as well.

Next Steps and Long Term

I've made a list of every water output in my house and made plans to "make them smart" as well. For the appliances I can't easily measure (e.g. dish washer) I plan to use the overall water meter reading outside and the time of day to determine approximate consumption.

It would be relatively easy to add sensors to detect orientation of faucets and therefore if hot or cold water is running. I'd be interested to know how much water is wasted waiting for the shower to heat up or similar insights from my own day to day behaviors.

I recently watched Ex Machina and there's a scene that sticks out to me for summarizing the age we're entering. The scene is of the AI's creator describing his moment of insight when creating the first prototype. He explains that the data collected from people's internet searches were not a map of WHAT people were looking at, they were a map of HOW people were looking at things. What's interesting with all the data we're collecting is what lies beneath its surface. The more we start looking at what's right in front of us, the better chance we have at making a positive difference in the world.


Needed: A second Raspberry Pi + wifi module for kitchen

Support Project