I am trying to connect a flow meter YF-S201 to Raspberry Pi B+.
It has three wires --> Red -> 5V --> Blac -> Ground --> Yellow -> Signal
I have a doubt with the cicuit, The flow meter works in 5V but raspberry GPIO are 3V3, however I had test the output of the yellow wire and never exceds the 3V (in my tests)
Someone has used this flow meter ¿How should I connect it?
I have built two circuits:
SECOND (with a Voltage divider):
I have test both circuits but when I run my code It doesn work fine. The input pin (22 BCM) always is LOW, I cannot receive the pulses, I don know if I forgot something in my code. When I test with the multimeter I see how the voltage in the yellow wire change (It make me thing that the flow meter is working properly)
Please could someone help me? I have been searching a lot on the Internet but unfortunately I can not find the explanation of what is happening to me and I do not know if the problem is my code or the circuit
#!/usr/bin/python #flowsensor.py import RPi.GPIO as GPIO import time, sys FLOW_SENSOR = 22 GPIO.setmode(GPIO.BCM) GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down = GPIO.PUD_UP) global count count = 0 def countPulse(channel): global count if start_counter == 1: count = count+1 print count flow = count / (60 * 7.5) print(flow) GPIO.add_event_detect(FLOW_SENSOR, GPIO.FALLING, callback=countPulse) while True: try: start_counter = 1 time.sleep(1) start_counter = 0 flow = (count * 60 * 2.25 / 1000) print "The flow is: %.3f Liter/min" % (flow) count = 0 time.sleep(5) except KeyboardInterrupt: print '\ncaught keyboard interrupt!, bye' GPIO.cleanup() sys.exit()
Thanks in advance