Easiest way to read a hall effect flow meter - Page 1
Forum section: electronics / beginners

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 16, 2023, 12:45:21 am
content: Hi,I have a flow sensor, what is the easiest way to get useful readings out of this thing 24/7 without having to resort to programming?Thanks!Richard

author: SmallCog
author_rank: Frequent Contributor
timestamp: March 16, 2023, 01:39:38 am
content: If you want to go with off the shelf modules and no programming you could use a totalising counter to know what volume has flowed through the deviceHopefully the pulse outputs are relative to a nice simple unit (eg 1 pulse = 1 litre) to save you needing to multiply pulses by an uncomfortable number to get a reading. This volume/pulse number isn't obvious at first glance in the specifications of the unit (it appears to come with a display normally) so you may need to experiment counting pulses as you pass a known volume of liquid through it.If you're after instantaneous flow rather than accumulated then use a frequency counter but you'll probably have to come up with a bit of a chart to put next to the display (eg 100Hz = 1Litre/Second, 120Hz = 1.5L/Sec etc)You will probably find that it's only accurate when the pipe is full of water, consider mounting it in a low point in your plumbing so that it's always full, eg:_________ ____________________ \______ _________/ ___________\_______[FLOW METER]__________/

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 16, 2023, 01:43:23 am
content: Thanks, it's to monitor pool circulation, so it would be a litres per minute number I'd be after?Apparently the equation for calculating flow rate is very simple: Hz * rate scale factor = flow.The rate scale factor is calculated using 60/K-factor.The “K-Factor” is defines as the number of pulses per volume of fluid. For a 40mm pn10 saddle, the K-factor is 16.561 pulses per liter.The rate scale factor for a 40mm pn10 saddle = 60/16.561 = 3.622Thus, if the DC square wave frequency is 48 Hz, then 48*3.622 = 173.856 liters per minute.Flow total can be calculated using: 1/K=totalSo is there something off the shelf that can do this, I've asked the manufacturer if they sell an aftermarket LCD.If I could get the DC square wave frequency on to the LAN using MQTT then I could probably figure out how to calculate the flow on node-red, maybe using function nodes?

author: SmallCog
author_rank: Frequent Contributor
timestamp: March 16, 2023, 05:25:40 am
content: Quote from: rthorntn on March 16, 2023, 01:43:23 amMy googling lead me to belive that the module is normally sold with a display, so hopefully a spare display can be obtained at a resonable price (or keep your sensor for a spare and buy a full set)Simplest cheapest option otherwise is a panel mount meter that will measure and display the frequency with a laminated chart next to it showing the conversions. I've not seen a cheap meter that has the ability to add a scaling factor (but they may exist in more expensive meters).You could even get an analogue needle meter and print up a new backing that shows typical flow so that abnormally high or low flow is evident at a glance. EG like this person has done to make a clock but with a Hz meter from your sensorhttps://www.instructables.com/Analog-VU-meter-and-Clock-Arduino-Powered/Otherwise this is trivial for something like an arduino to doAn ESP based board would be my tip for this, it can read the pulses, do the math, and drive an LCD or whatever to display it onThe built in WiFi would give you the ability to later on have a website hosted on it for remote monitoring and/or to pass the numbers off to another system using your preferred push or poll protocol.

author: james_s
author_rank: Super Contributor
timestamp: March 16, 2023, 05:29:37 am
content: An integrator connected to an analog meter ought to do what you need. This can be as simple as a R-C low pass filter, the more often the pulses come, the higher the meter will read.https://www.electronics-tutorials.ws/opamp/opamp_6.html

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 16, 2023, 05:50:54 am
content: Thanks!Let's say I'm going to use a Teensy 4.1 with ethernet as wifi is flakey in that area.What's the relationship between input supply voltage and signal output?I should probably use a small external PSU >=6VDC to feed the input supply voltage, say I use 9V, does that make the signal output 9V pulses?Like most hobbyist MCU's the Teensy wants no more than 5V on its pins right?So what's the easiest way to put a 9V pulse on a <=5V tolerant pin, a voltage divider circuit, to half it to 4.5V?This library looks promising:https://www.pjrc.com/teensy/td_libs_FreqMeasure.htmlSo would the cabling be as simple as connecting the flow meters signal output to the Teensy?

author: james_s
author_rank: Super Contributor
timestamp: March 16, 2023, 06:55:25 am
content: The fact that it's recommending a pullup resistor suggests that the output is open collector and gets pulled down to ground when active and floats up to whatever voltage it's pulled up to the rest of the time but you should test that before connecting it to a microcontroller. If it is indeed open collector then you can just pull it up to the 5V rail on the microcontroller board. You might even get away with just using the built in pullup resistor that every modern microcontroller has for each of the IO pins.If it turns out that you do need to scale down the voltage you can use a divider made of a pair of resistors to drop it down as far as you want.

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 16, 2023, 08:11:34 am
content: Quote from: james_s on March 16, 2023, 06:55:25 amWhat would be the easiest way to test this?

author: james_s
author_rank: Super Contributor
timestamp: March 16, 2023, 05:08:38 pm
content: Wire it up on the bench. Connect a power source such as a 9V battery to the power wires and then measure the voltage at the output pin and spin the sensor. If you get a low or no reading then it's an open collector output. You could also read the datasheet if you can find one, it should say.

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 17, 2023, 02:56:00 am
content: Thanks!So I connect 9v DC power to red (voltage input) and black (gnd) - checkAnd I measure the voltage, I assume you mean with a DMM or do you mean an oscilloscope, I have access to both, if a DMM is OK then where do I put the probes, + on the bare (signal output) wire and - on black?

author: james_s
author_rank: Super Contributor
timestamp: March 17, 2023, 03:25:48 am
content: A dmm is fine, if you want to play with a scope that will work too, anything that shows you what the voltage is doing.

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 17, 2023, 04:18:37 am
content: Thanks.I've no idea what I'm doing.Hooking it all up, my Agilent DMM (set to measure volts) gives no clue that anything is going on when I move the magnet on the little paddle to the sensor.

author: james_s
author_rank: Super Contributor
timestamp: March 17, 2023, 06:23:59 am
content: That suggests that the sensor has an open collector output. Try connecting a resistor, value not critical, say 1k-10k between the red wire and the output wire then repeat the measurement.

author: rthorntn
author_rank: Frequent Contributor
timestamp: March 18, 2023, 01:01:18 am
content: Thanks (I learned quite a bit), yes, a 2.2K resistor connected as you describe proves it's open collector, the multimeter shows my DC voltage until I move the magnet near to the sensor where it drops to 0v.How can I confirm it will work with the Teensy 4.1 internal pull-up (3.3V?), the Teensy documentationhttps://www.pjrc.com/teensy/td_digital.htmlmentions a delay?"A brief delay may be needed between pinMode() configuring INPUT_PULLUP mode and digitalRead() reporting the unconnected pin as HIGH. The pullup resistor raises the voltage slowly, depending on capacitance of any circuitry attached, plus the capacitance of the pin and breadboard or wires. Usually delayMicroseconds(10) is plenty."I think it could read my signal at ~100Hz, I think thats a pulse every 10000 microsecond and 10 microseconds per pulse seems insignificant.Also I set my bench PSU to 5.00v and 50ma and it all seems to work fine, maybe the 6v recommendation is for longer cable runs or for powering the LCD display.

author: james_s
author_rank: Super Contributor
timestamp: March 20, 2023, 07:17:43 pm
content: It will work. If interference or cable capacitance or whatever is an issue you can always add an external pullup resistor.The delay you mention is not relevant for your purpose. That comes into play when a pin has multiple functions and you are enabling and disabling the pullup dynamically. In this case you will just enable the pullup at the beginning and leave it on. Monitoring a 100Hz pulse stream with a microcontroller is trivial, even if you were using a 25 year old 8 bit MCU the period between pulses is an eternity from the microcontroller's perspective.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: March 21, 2023, 02:28:16 pm
content: One way is to build a simple frequency meter and count the pulses in some fixed gate time, but you will need quite a bunch of logic IC's for this, but there exist IC's for frequency measuerement. But it's probably not going to be simpler then programming a simple uC.Another way is to first do some pulse shaping. With for example an NE555 you can create a fixed width pulse on each falling flank of the sensor, and then put that signal through an RC filter. Then you have an analog voltage that is proportional to the rotation speed of the magnet. It does not work without the NE555 pulse shaping, because then you will have a fixed duty cycle, and this will always result in the same average voltage, regardless of the amount of water flowing.Also:TLDR, but how did you get from "not wanting to program" to a Teensy 4.1?