Scamperbaby
Posts: 2
Joined: Sat Nov 02, 2019 6:39 pm

Flow meter question

Sat Nov 02, 2019 7:17 pm

I'm hoping to get some validation on connecting a flow meter to a Raspberry Pi 3 A+. The software is no problem but I'm pretty new to electronics side of things so I want to make sure I'm not screwing something up.

Here is the data sheet for the flow meter:
https://jlcinternational.com/wp-content ... _Meter.pdf

If I'm reading it correctly, I should be doing the following (using board GPIO numbering):
  • connecting power to pin 4 (5v)
  • ground to pin 6
  • input to pin 3
  • In code, setting the input GPIO as pull-up
  • Every 5375 pulses equates to 1 gallon
Is that all sound correct?

User avatar
joan
Posts: 15122
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Flow meter question

Sat Nov 02, 2019 8:52 pm

Sounds right. Generally the output of the flow meters are open collector. That means they normally float up to an external voltage and are pulled down to zero to signal a pulse. That means they should safely work with devices with 3V3 GPIO like the Pi as well as with devices with 5V GPIO such as most Arduinos.

Pin 3 (GPIO 2) and pin 5 (GPIO 3) have external pulls to 3V3 fitted. I'd suggest you use another GPIO if you can.

Scamperbaby
Posts: 2
Joined: Sat Nov 02, 2019 6:39 pm

Re: Flow meter question

Sat Nov 02, 2019 10:04 pm

joan wrote:
Sat Nov 02, 2019 8:52 pm
Sounds right. Generally the output of the flow meters are open collector. That means they normally float up to an external voltage and are pulled down to zero to signal a pulse. That means they should safely work with devices with 3V3 GPIO like the Pi as well as with devices with 5V GPIO such as most Arduinos.

Pin 3 (GPIO 2) and pin 5 (GPIO 3) have external pulls to 3V3 fitted. I'd suggest you use another GPIO if you can.
Thanks!

JohnsUPS
Posts: 189
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Flow meter question

Sun Nov 03, 2019 12:21 am

I looked at the data sheet for the flow meter, and there is a 10k pullup on the open collector output to the V+ pin. Because the data sheet lists the working voltage as 5 - 24 VDC, the data line will be pulled up very close to 5V (if the meter is powered from 5V). The GPIO pins cannot tolerate more than 3.3V, so you will have to level shift the output of the flow meter before connecting it to the Pi.
A voltage divider circuit would be the most simple. About 19.1K from the data pin to ground (in series with the internal 10k with the internal Pi pullup turned off) would yield just under 3.3V with the transistor off.

Correction - glanced at the data sheet too quick - output is open collector, don't know how I missed that.....no internal pullup in this case...
Last edited by JohnsUPS on Sun Nov 03, 2019 8:10 pm, edited 1 time in total.

User avatar
Burngate
Posts: 6374
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Flow meter question

Sun Nov 03, 2019 10:37 am

Flowmeter4.jpg
Flowmeter4.jpg (20.68 KiB) Viewed 825 times
According to the data sheet, the output is OC, and the pull-up resistor isn't integral, so there's no problem powering the flowmeter with 5v (it may not be happy at lower than that) while pulling up the output to 3v3.

My understanding is that 10k is just an example value for the pull-up - as it says, "Reesistor value depending on external device", so the 1k8 pull-up on GPIOs 2 & 3 should be no problem (a couple of mA shouldn't be beyond even a no-name transistor)
You may, however, find the internal 50k pull-up that's applied by the Pi via "code" is too weak, if you use long cables or your environment is electrically noisy.

So go with your original design!

Return to “Automation, sensing and robotics”