Generic Flow Meter not working

Hi Everyone, this is my first entry.
I’m setting up a grow booth with many sensors offcourse on mycodo platform…
I could not manage to have readings with generic flow meter. I’m using YF_S201 powered with 5v and used voltage divider as here Dropbox - Capture.JPG - Simplify your life for the signal. I used GPIO 26.
To test the sensor I used arduino uno and a code (working with interrupts ) . it worked fine.
I tried to power the sensor 3.3 V directly connect the signal cable to GPIO 26 it didnt work.
Any solution will be greatly appreciated … Thanks

1 Like

I use a similar generic flow meter, it appears to be open-drain output. Your connection seems unusual to me.

  1. The flow meter should be powered by 5V. This looks good.
  2. The flow meter’s output should be connected directly to the GPIO input, and both of those pulled up to 3.3V via a pull-up resistor (4.7K is fine).
  3. The 10K resistor to ground is not needed.

See this example: Liquid Flow Meter Raspberry Pi – Raspberry

2 Likes

Dookaloosy thanks for your reply,
ı tried the hook up as in your example link, (with the 10K as shown in the link not with 4.7 K though I don’t think that’s the issue ) . I forgot to mention on my previous hook up I monitored the sensor with an oscilloscope and could see the square waves. However the new hook up did not work either. I started thinking is there sth wrong on the software side. Like, do I have to pick "generic hall meter " from the input page, or is there sth wrong with my general pi settings maybe frequency of checking the GPIO I’m not even sure if there’s anything like that. .Finally could you pls tell me the sensor you are using may be I should give a try on that ( however mine is working on arduino with codes based on interrupt)
Any suggestion will be appreciated. And thanks a lot…

Hi again I strongly believe it on the softwware side with the last hook up as mentioned in your link I got nothing on mycodo however, I did get the numbers with this python code on the same setup

#!/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_UP)

global count
count = 0

def countPulse(channel):
   global count
   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:
        time.sleep(1)

    except KeyboardInterrupt:
        print '\ncaught keyboard interrupt!, bye'
        GPIO.cleanup()
        sys.exit()

I think I shouldn't be copying and pasting codes here like that , I know there is a more proper way to it just, I coudn't figure it out yet. Sorry for that.

I use similar flow meters like this.

All you need to do is to add the Generic Hall Flow Meter and make sure to set the “pulses per liter” field correctly. The correct value for your hardware can be obtained from its datasheet. Based on the data shown in this link, your flow meter outputs 450 pulses per liter.

1 Like

Thank you Dookaloosy;
I adjusted 450 p/L …
This is my system information page on mycodo check out the BCM numberings and GPIO names. Physical (board numberings) are ok as they are placed in Pi4 however the GPIO names doesn’t fit the Pi4 pinout. Does it makes sense ?

BCM numberings are OK. But the gpio names misfit. Like BCM 26 has to be GPIO26 but it is GPIO25 thats where the Flow meter is connected.

This is a problem with RPi – the pin numbering system is a mess.

I believe everything in Mycodo is using BCM numbering. Refer to the following chart from here to check your connections. In this case, GPIO26 (BCM!!!) is found at pin 37 of the 40-pin header.

1 Like

Excuse me for not being clear enough…
The pin layout for pi is ok… BCM numbering and board numbering differs that is clear and in the generic layout scheme you sent GPIO.26 > BCM 26 > Board numbering 37 that is OK.
How ever on mycodo system info page BCM 26 is matched with GPIO.25 (in the name column) that should be GPIO.26 and Physically on pin 37 ( board numbering and that is correct.)
Isn’t it weird ?

Also I checked on the hall_flow.py on github it seems to be operate on rising edge I think that might be the problem the code I used on the console which worked was using falling edge detection which worked for my sensor . I’m not so experienced on python . So can you tell me the sensor you’re using I 'll try to purchase the exact same sensor to see if it works ?

I already linked the sensor I use in a previous reply.

What’s the version of Mycodo you’re using? I’m not sure if your issues are due to use of an older version? As I recall, hall_flow.py had some issues and was recently fixed. I don’t know whether that fix has made it into the release version. Perhaps @KyleGabriel can answer.

The latest version of the input is released, I believe.

Thanks for the feed back . I couldn’t be quiet sure If mine ( yfs201) is open collector or not … Mostly they are …
I’m using version 8.11.0 I think it is the latest … @KyleGabriel Do I have to (or is there a way to ) upgrade the inputs only ? Because from the mycodo upgrade it tells me it’s the latest version. It is wierd that I can read the pulses via the code on the console that I posted earlier …
Thanks… .

I’m on 8.11.0 as well. It should work, if you can read the pulses via the console code. Doesn’t matter if it’s rising or falling edge.

Did you activate the Generic Hall Flow Meter input after setting it up? Can you check the Daemon Logs to see that the activation proceeded successfully?

2021-07-02 13:53:12,156 - INFO - mycodo.controllers.controller_input_80ae06df - Deactivated in 55.5 ms
2021-07-02 13:53:43,725 - INFO - mycodo.controllers.controller_input_80ae06df - Activated in 181.2 ms
2021-07-02 13:53:43,725 - DEBUG - mycodo.inputs.hall_flow_80ae06df - fLow: 0 l/min, pulses: 0, total pulses: 0, total volume: 0
2021-07-02 13:53:43,763 - DEBUG - mycodo.controllers.controller_input_80ae06df - Adding measurements to InfluxDB with ID 80ae06df-96cb-4ac5-b1d8-35da182705f5: {0: {'measurement': 'rate_volume', 'unit': 'l_min', 'value': 0.0, 'timestamp_utc': None}, 1: {'measurement': 'volume', 'unit': 'l', 'value': 0.0, 'timestamp_utc': None}}

Yes it seems that it’s activating properly how ever when I blow into to sensor no pulses.
I’m nearly sure there is nothing wrong with the sensor or wiring however I ordered another similar sensor just to check. Another option seems to be just reinstall operating system on pi and mycodo . And still wondering is there a setting on frequencies or sth like that to adjust on pi GPIO s. ı’m using 4B bye the way.
Thank you . Dookaloosy…

Dear Dookaloosy
I assume that you’ll be at least as happy as I am. It is over, pulses are now all over the place… :slight_smile:
I installed a fresh OS and mycodo and voila…
Thanks for all your support and effort … If you miss me you can always wirte :slight_smile:

2 Likes