Introduction: Save the World One Drop at a Time, Part 2: Monitoring Your Water Main (Plumbing Free)
In order to get a comprehensive idea of where your water goes, I thought it would be a good idea to monitor it both at the outlets and the inlet. I came across a great instructable by Gregory0. It takes a hall effect sensor and picks up delicate magnetic field changes when your register spins. By counting the number of revolutions you can directly correlate that to how much water has flowed through your main.
By cross referencing that data with the information you get from your outlets, you can get an accurate idea of where your water is going.
Step 1: Breadboarding
I used plain white tape to affix the sensor to the side of the meter. I built off Gregory0's instructable to get a basic proof of concept on breadboard. Initially my circuit wasn't tuned correctly, so I drilled a hole into the side of the meter to get closer to the register. This proved to be unnecessary once I got the circuit dialed in correctly.
These were my early learnings. To catch up on the theory behind the circuit, read Gregory0's Instructable
When you start to breadboard this yourself, please refer to Part 4
Step 2: Downsizing From Arduino (It's Never As Simple As You Think)
Once I had a working circuit on the arduino, I needed to downsize to the 3.3V for Pinoccio. I found what I thought was an elegant solution: a Honeywell SS451A. It was rated down to 3V and had an amplifier circuit already built into it! I put a low value resistor between the positive and signal inputs, and had a beautifully digitized signal.
However, I didn't read the important part. I chose a latching sensor, that only triggered at 35 gauss. I was able to pick up a reading from the water main, but only after I ripped off the register and put it directly on the face of the impeller. While it was a simple solution, it was not scalable. I needed something that could be put on the side of the water main, without having to break anything. (We are forbidden by law from tampering with the water main, but the law never said anything about taping things to the side!)
Step 3: Testing, Failing, & Picking the Right Component
It didn't work. This was before I learned to spec my components properly! I chose a hall effect sensor that digitized the output and only triggered when the field reached 35 gauss. So I took to the curb and it didn't work. Back to the lab!
What's you need is a non-latching linear hall effect sensor. I went back and bought the Honeywell SS494B, because it's sensitive enough to pick up around 1 gauss. Just as a frame of reference, a neodymium magnet is in the thousands of gauss, and earth's magnetic field is ~.5 gauss.
A good test to see if you can use this on your water main will be to hold a compass next to it when water is flowing through your main. If it spins, there's a good chance you'll be able to use this circuit to pick up
Step 4: It Worked! Sort Of...
Once I picked the right sensor, I was able to get conclusive results on the oscilloscope. Since I don't recommend squatting on the street in Oakland with a laptop and a bunch of electronics and test this, I bought a water meter.
I chose the Neptune T-10 industrial version because it's the beefiest version out there, and one of the most common water mains out there. I figured that if I could read it on this, you'll be able to read signal on anything. It's got a lot more copper and plastic to go through, which make it hard to pick up a signal. You can see the pulse readings on the oscilloscope.
Step 5: What's That Potentiometer Doing There?
The potentiometer lets you dial in the sensitivity of the circuit. It is the DC offset, and you need to have the voltage sitting in the middle of your supply voltage. If you've got a 5V power supply, you will need to use an oscilloscope or multimeter to adjust the base voltage at that pin to 2.5V. Otherwise the signal will stick to either side of the op-amp's rails.
The value of the potentiometer isn't all that important. You can use a 20k, 50k, or even a 100k potentiometer. As you go higher in value, the sensitivity gets rougher, so a 20k is recommended but not necessary. I used a 100k for prototyping purposes, because it was on hand in the electronics lab.
Step 6: Supply Voltage Woes
So now that I had my circuit built, I still had to get my power to it. I couldn't find a linear non latching hall effect sensor that was sensitive enough to pick up the 1 gauss necessary, and also run off 3V from the Pinoccio Scout. There were two battles here: If I powered my circuit with 5V, the voltage would oscillate between 0 and 5V, which is too much for the pinoccio!
1. Getting 5V power to the circuit:
Since AC power from a USB cable proved to have too much noise and ruin the amplifier signal, and the lab supply wasn't a scalable solution, I decided to use a battery pack. 4 AAA batteries at 1.5v gave me a solid 6V battery with 1000 mA-h. I wired this into my power supply and gave everything a common ground.
2. Getting 3.3V or less out from a 5V circuit:
The digital pins of the Pinoccio have a maximum input voltage of 3.6V, and I didn't want to fry my board. It turns out that most boards have a cool feature called 'pull up resistors'. You can designate a pin as a pull-up resistor, and add a transistor to the circuit (2N222). Please refer to the hand-drawn diagram. The base acts as your signal out from the circuit (with a 4.7K resistor), the collector goes to common ground, and the emitter goes to your pin designated as a 'pull up resistor' This way your input voltage will never exceed 3.6V to your Pinoccio.
Be sure to verify that the pinout is the same from your transistor.
Note: The Pinoccio, the collector pin of the transistor, and the circuit all need to share a common ground!
Step 7: Enclosing the Board
Once I resolved the supply voltage troubles, it was time to enclose the circuit. I bought a $10 waterproof enclosure box from Adafruit and put the circuit inside. I made sure to give it an external switch for the sensor circuit, and a quick disconnect for the hall effect sensor. Everything nestled snugly inside.
Step 8: Calibrating the Device
Once I had a robust sensor circuit hooked up into the Pinoccio Scout and giving me what I needed, it was time to calibrate the device. Since I had the water main detached, I hooked up a homemade funnel with a bicycle tube and poured one gallon through. The neptune T-10 (5/8in) meter gave me 60 pulses per gallon. Once you figure that into your code, it will give you accurate measurements of your flow.
Your water main will likely be still attached to your plumbing. To calibrate yours, you'll need to turn off all water-consuming appliances in your home, turn the sensor on, and go and fill a gallon with a sink.
Step 9: Proceed to Part 3
Now that you're calibrated, it's time to start linking up the code.
I'll now hand you off to my friend Jonathan's Instructable titled "Save The World One Drop At A Time, Part 3: Networking Your Sensors". This is where he'll teach you to tie it all together.