Measure water flow with the Raspberry Pi. This is an advanced version of an earlier RPi experiment using the YF-S201 flow meter. This one is based on polling and triggers on TIME. It also ensures that a stopped impeller does not lead to bad data.
NOTE: The pi is not a real time computer (for example like the Arduino) and its ability to react to polling or interrupts is dependent on other code being executed. As a result, at higher input rates, the pi will begin to miss inputs and the results will be less and less accurate. You can put in factors based on assumptions (as in this example) to get reasonable approximations.
Good demo of measuring and controlling water flows - home watering use, irrigation water use tracking, livestock water tanks, etc.
The sensor is inline and uses an impeller with an embedded magnet. The magnet triggers a Hall effect switch sending a pulse 6x per revolution.
There are 3 wires, red (power, 2-24 volts, but I've gotten it to work at 3 volts), black (ground) and yellow (Hall effect output).
From the spec sheet:
16 Hz = 2 L/min = 120 L/hr
32.5 Hz = 4 L/min = 240 L/hr
49.3 Hz = 6 L/min = 360 L/hr
65.5 Hz = 8 L/min = 480 L/hr
82 Hz = 10 L/min = 600 L/hr
etc. Max 30 L/min
Frequency (Hz) = 7.5 * Flow rate (L/min)
Pulses per Liter: 450
Model: YF-S201
Sensor Type: Hall effect
Working Voltage: 3.5 to 24V DC (min tested voltage 3.3V)
Max current draw: 15mA @ 5volts
Output Type: 5volt TTL
Working Flow Rate: 1 to 30 Liters/Minute
Accuracy: ±10%
Maximum water pressure: 2.0 MPa
Operating Temperature: ≤80℃
Liquid Temperature: ≤120℃
Output duty cycle: 50% ±10%
Output rise time: 0.04us
Output fall time: 0.18us
Min Durability: 300,000 cycles
Cable length: 15cm
1/2" nominal pipe connections, 0.78" outer diameter, 1/2" of thread
Size: 2.5" x 1.4" x 1.4"
Notes:
YOU NEED A VOLTAGE DIVIDER WHEN OPERATING ABOVE 3.3 VOLTS!!!
MATERIALS
Raspberry Pi (and Pi power supply)
Breadboard
YF-S201 Water meter / sensor
Jumpers
Resistor (yellow purple red 4700 ohms)
Resistor (brown black orange 10k ohms)
WARNING: Warning: mis-wiring or mis-programming your Pi or miswiring of accessories can ruin the Pi and accessories.
Information/drawings offered as is. Use at your own risk. If you don't know, learn first.