Interfacing Water Flow Sensor with Raspberry Pi 3 ๐ฟ
๐ฏ Objective
To measure the flow rate of water using a Water Flow Sensor (YF-S201) and Raspberry Pi 3. Useful in smart irrigation and water management systems.
๐งฐ Components Required
Component | Quantity |
Raspberry Pi 3 | 1 |
YF-S201 Water Flow Sensor | 1 |
10K Pull-down Resistor | 1 |
Jumper Wires | As required |
Breadboard | 1 |
⚡ Circuit Connections
Sensor Pin | Connect To |
Red (VCC) | 5V (Raspberry Pi) |
Black (GND) | GND (Raspberry Pi) |
Yellow (Pulse Out) | GPIO18 (Pin 12) with pull-down resistor |
๐ง Python Code
import RPi.GPIO as GPIO
import time
FLOW_SENSOR = 18
pulse_count = 0
def countPulse(channel):
global pulse_count
pulse_count += 1
GPIO.setmode(GPIO.BCM)
GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(FLOW_SENSOR, GPIO.FALLING, callback=countPulse)
try:
while True:
pulse_count = 0
time.sleep(1)
flow_rate = (pulse_count / 7.5) # for YF-S201
print(f"๐ฟ Flow Rate: {flow_rate:.2f} L/min")
except KeyboardInterrupt:
GPIO.cleanup()
๐ Output
- Shows live flow rate of water in liters per minute.
- Pulse count is converted to flow using the sensor's spec.
๐ก Applications
- Smart irrigation systems
- Water conservation projects
- Leak detection and usage monitoring
๐ฏ เคเคฆ्เคฆिเคท्เค
เคตॉเคเคฐ เคซ्เคฒो เคธेเคจ्เคธเคฐ เคตाเคชเคฐूเคจ เคชाเคฃ्เคฏाเคा เคช्เคฐเคตाเคน เคฆเคฐ เคฎोเคเคฃे เคเคฃि Raspberry Pi 3 เคตเคฐ เคค्เคฏाเคे เคฎाเคชเคจ เคเคฐเคฃे.
๐งฐ เคฒाเคเคฃाเคฐे เคธाเคนिเคค्เคฏ
เคเคเค | เคธंเค्เคฏा |
Raspberry Pi 3 | 1 |
YF-S201 เคตॉเคเคฐ เคซ्เคฒो เคธेเคจ्เคธเคฐ | 1 |
10K เคชुเคฒ-เคกाเคเคจ เคฐेเคिเคธ्เคเคฐ | 1 |
เคंเคชเคฐ เคตाเคฏเคฐ्เคธ | เคเคฐเคेเคจुเคธाเคฐ |
เคฌ्เคฐेเคกเคฌोเคฐ्เคก | 1 |
⚡ เคธเคฐ्เคिเค เคเคจेเค्เคถเคจ
เคธेเคจ्เคธเคฐ เคชिเคจ | เคोเคกเคฃी |
Red (VCC) | 5V (Raspberry Pi) |
Black (GND) | GND (Raspberry Pi) |
Yellow (Pulse Out) | GPIO18 (Pin 12) เคชुเคฒ-เคกाเคเคจ เคฐेเคिเคธ्เคเคฐเคธเคน |
๐ง เคชाเคเคฅเคจ เคोเคก
import RPi.GPIO as GPIO
import time
FLOW_SENSOR = 18
pulse_count = 0
def countPulse(channel):
global pulse_count
pulse_count += 1
GPIO.setmode(GPIO.BCM)
GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(FLOW_SENSOR, GPIO.FALLING, callback=countPulse)
try:
while True:
pulse_count = 0
time.sleep(1)
flow_rate = (pulse_count / 7.5)
print(f"๐ฟ เคช्เคฐเคตाเคน เคฆเคฐ: {flow_rate:.2f} เคฒी./เคฎिเคจिเค")
except KeyboardInterrupt:
GPIO.cleanup()
๐ เคเคเคเคชुเค
- เคชाเคฃ्เคฏाเคा เคช्เคฐเคตाเคน เคฆเคฐ เคฒीเคเคฐ/เคฎिเคจिเคเคฎเคง्เคฏे เคฆเคฐ्เคถเคตเคคो.
- เคชเคฒ्เคธ เคाเคंเค เคตाเคชเคฐूเคจ เคฆเคฐाเคे เคฐूเคชांเคคเคฐเคฃ เคนोเคคे.
๐ก เคเคชเคฏोเค
- เคธ्เคฎाเคฐ्เค เคธिंเคเคจ เคฏंเคค्เคฐเคฃा
- เคชाเคฃी เคฌเคเคคीเคธाเค ी เคช्เคฐเคฃाเคฒी
- เคฒीเค เคกिเคेเค्เคถเคจ เคต เคชाเคฃी เคตाเคชเคฐ เค्เคฐॅเคिंเค
Comments