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.
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 Parse.com 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 ).
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.
Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!