Water is cheap, but California is in one of the worst droughts ever right now. Let's face it: we can't fix the drought. However, some CA residents are actively running out of drinking water. At the municipal level it's difficult to enact immediate change, but we can change how we use our water at home. I decided it would be a good idea to focus my energies and the resources of my Artist Residency at Pier 9 towards something we can change: our habits. It's possible to dramatically change our behavior simply by making us aware, but we simply don't know where our water goes. A bill at the end of the month doesn't give you much useful information, and it gives you the information a month too late. So I set out to solve the problem of not knowing where our water goes on a realtime basis.
While searching for inspiration, I came across an awesome instructable by StaceyK, where you use a piezo sensor to listen to the water flowing out of a faucet or tap, and translate that vibration data to fluid flow. This gives you an accurate idea of how much water you are using with that specific device. It had a simple ambient display with LEDs that turned from green to red when you exceeded a specified water usage. I was inspired!
So I thought, why not place these all over your house? I didn't want to stop at one faucet, I wanted a usage breakdown of an entire house. The Internet Of Things is rapidly developing, up to speed with residential water usage. I found a cool small company called Pinoccio: they have low-cost mesh networking devices that can relay data across a network and broadcast that to the web. So I set out to make it easy to get this information.
This was my final project for the Artist In Residence program at Pier 9, and I am pleased to present my learnings. I started with zero knowledge of electronics and it turned into this, of which I am very proud. And I know it can be done better. Will you help me take this to the next level?
Table Of Contents:
1. Save The World One Drop At A Time, Part 1: Monitoring Water Flow - Plumbing Free - Using A Piezo And Pinoccio Mesh Networking
2. Save The World One Drop At A Time, Part 2: Monitoring Your Water Main (Plumbing Free)
3. Save The World One Drop At A Time, Part 3: Networking Your Sensors
4. Save The World One Drop At A Time, Part 4: Uploading The Arduino Sketch Code
5. Saving The World One Drop At A Time, Part 5: The Dashboard
Step 1: You Will Need
Step 2: Breadboarding
The first step involved breadboarding the circuit based on Stacey K's Instructable, with a few minor modifications. I tested it by plugging it into an arduino and reading the serial output. The circuit consists of an amplifier to increase the signal from the piezo, and a resistor tied to ground to regulate the voltage. There is a high-value resistor between the two inputs from the piezo, which acts as a pull-down resistor for the signal.
Step 3: Protoboarding
Once I verified the circuit worked, it was time to solder it up on the protoboard and migrate from the Arduino over to the Pinoccio. It turns out I wired this one incorrectly, so that the positive lead of the circuit was connected to the positive end of the piezo, which caused the circuit to complete every time I touched both the faucet and was holding my computer. This caused quite a lot of suffering, but I charged ahead and built a prototype anyways.
Step 4: Milling A Shaft Collar
So how do you get a flat surface to stop sitting tangent to the edge of your circle? Since a piezo sensor I was using was flat, but a pipe is round, I wanted to find a solution that wouldn't involve making a permanent mold of a pipe. I wanted the solution to be quickly connected to a pipe, so I bought a two-piece shaft collar and milled down a face of it to give a flat surface. It held the piezo neatly.
Step 5: Assembling Prototype 1
Once I had the protoboard and the milled surface, I decided to hook it up to a faucet for testing. It was a self-contained system that attached to the end of a faucet with an allen wrench. It, of course, didn't work, because my wiring was totally wrong. So it was back to the drawing board!
Step 6: Debugging & Optimizing The Circuit
Why didn't it just work?! I was in a very dark spot until I came across Amanda's Instructable on using the oscilloscope. It was time to debug my circuit. I took the oscilloscope home with me, and quickly found out what was wrong. This was easily tested by probing the voltage at various points and making sure the circuit behaved like I wanted it to. I also took home a bunch of resistors of different values, and swapped them out to verify that the circuit was giving me optimal amplification.
When I switched over from Arduino (5V) to Pinoccio (3.3V), I needed to compensate for the lower supply voltage. This meant removing the voltage divider from the original schematic to get the voltage to drop to a readable value in the analog sensor. Otherwise, you'll get a constant 1023 value in your serial output.
Note well: the Pinoccio has a max analog voltage input of about 1.65V!
Step 7: Choosing The Right Sensor
It turns out that some people make careers out of optimizing sensors. I experimented with many piezo sensors by trial and error: big ones, small ones, and everywhere in between. Finally, I settled on small 6.3kHz piezo buzzers we had tucked away in the electronics lab, and they turned out to be perfect. I only found this after milling out a shaft collar to house a raw sensor. This is not the best approach.
Piezo buzzers have quartz in the middle, so if you flex them, you shatter the buzzer. And that's a dead sensor for you. The buzzers I found came in a plastic enclosure and were therefore protected. You can buy these from Mouser Electronics. The smaller ones are capable of picking up more subtle vibrations, which comes in handy when you're listening to the flow of water.
Step 8: Building A PCB Shield Using 123D Circuits!
Once I had verified that I was getting correct readings from the breadboard, it was time to design a shield for the Pinoccio. I wanted a piece of drop-in hardware that anyone with a soldering iron could assemble. I had the opportunity to work with Rob Roberts of the 123D Circuits team and gain valuable insight into the world of PCB design. Together we came up with a very simple layout with screw terminals for connecting the piezo.
I actually chose the wrong op-amp component at first. The LM 741 is spec'ed to not run below 5V, so I chose the LM6132 op-amp instead. It unfortunately had a pinout that was different than the one in the layout, so I had to come up with a creative workaround. This involved lots of extra wires and fun solder joints.
Since I had ordered the boards and had them in-hand, I decided to make 4 creative workarounds. The next revision will be available on 123D circuits soon and have several modifications to make assembly even easier.
Step 9: Designing & 3D Printing An Enclosure
Since I had a compact board assembly, I decided to 3D print my first thing!
I designed it as a water droplet, or teardrop (glass half full or empty?). This was done in Inventor using the plastic parts feature, which is quite handy for this type of work.
I started by drawing a profile, revolving it 180 degrees, and extruding the back face to give it depth to house the pinoccio and shield. Once that's done, it's a fairly simple operation to turn the shape into a shell. You can then draw a part line and split the part into two solid bodies. You can then use the lip/groove feature to make it snap-fit.
I printed a test piece, and it worked! So then I printed two full scale ones. It turned out quite well. I made sure to include a hole at the bottom where you can fit a microUSB for charging, and also get your sensor wire out.
Step 10: Testing & Visualizing The Data
Once I had the setup installed on a sink, it was time to visualize the data. Eric Forman, another Artist In Residence here at Pier 9, had written a Processing script to plot data on a realtime basis. We made simple modifications to pull the values over in the script. The top row (green) shows the analog sensor value of the water, and the green is the standard deviation of that flow rate. You can visualize the flow of the faucet over time! It calculates analog values and maps the flow in a linear relationship between full flow and a trickle.
Step 11: So What Do You Do With This Information? Send It To The Cloud?
It's time to take advantage of the Pinoccio mesh networking capabilities and broadcast this information directly to the web. This requires a separate instructable of its own, as it turns out that getting the information up to the cloud isn't as simple as the picture included.
Please refer to "Save The World One Drop At A Time, Part 2"