tscodeler
Posts: 5
Joined: Sat Aug 15, 2015 6:47 pm

How to use water flow sensor on Raspberry?

Sat Aug 15, 2015 8:11 pm

I'm trying to use this water flow sensor with raspberry:

https://www.adafruit.com/products/828

I'm using this python code to read the pulses:

!/usr/bin/env python

import RPi.GPIO as GPIO import time, sys

FLOW_SENSOR = 23

GPIO.setmode(GPIO.BCM) GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

global count count = 0

def countPulse(channel): global count count = count+1 print count

GPIO.add_event_detect(FLOW_SENSOR, GPIO.RISING, callback=countPulse)

while True: try: time.sleep(1) except KeyboardInterrupt: print '\ncaught keyboard interrupt!, bye' GPIO.cleanup() sys.exit()

Unfortunately, this code is not working properly and as I'm new with raspberry I don't know how to solve the problem.

I would like to know if is necessary to use another component in raspberry, like MCP3008 or another one.

If possible, send me how to wire the sensor cables is raspberry too.

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: How to use water flow sensor on Raspberry?

Sun Aug 16, 2015 9:22 am

Please do not duplicate posts across different forums.
I'm locking this one and moving the other to the python forum.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “Beginners”