Waterflow detection using Hall Effect sensor

Jeds

New Member
Hi,
Humbly hoping someone can suggest how I can solve this one ..
I have a simple water flow sensor that uses a hall effect sensor that generates a square wave signal, powered from a 5v power supply.
I have the signal hooked up to a Raspberry Pi so it can alert me if it detects water flowing for longer than x mins (I've had garden hose break in the past resulting in water gushing out for hours!).
Anyways .. problem is .. the signal can come to rest at low or high state since it's a rotary magnet that doesn't always stop in a certain position.
But the Pi is expecting either a constant and predictable High or Low state to determine if water is flowing or not.

If was thinking of using a 555 Timer to detect the square wave .. but not sure how I can convert the presence (or lack of) the square wave (ie water flowing) into a constant +5v or 0v signal for the Pi to make use of.
Or could do this an entirely different way to plug into the Pi (without a 555 timer) .. just looking for some kind suggestions.

Any help or suggestions would be very much appreciated,

thanks folks,
Jeds
 
Why not just use the PI to check for the square wave?, pretty pointless adding an extra un-needed 555.

Basically what you want is a 'missing pulse' detector - but used backwards, to detect pulses rather than missing ones.

It would be absolutely trivial to do using a PIC (many of which even include suitable hardware to do the detection).

Essentially just check for a change in level on the pin (PIC's even have hardware to do that - Interrupt On Change On Pin), easily done in a simple software loop, once a change is detected start a counter counting up (or down), and if another change occurs in X seconds (a time you decide on) then a leak is occurring, however if another change doesn't occur in time, then reset the counter and wait for another change to initiate the process again.

I've never played with PI's much, but it should be a trivial task on any processor.
 
Depending on the counter setup you can use a passive solution with a series C and pull-up R. 33nF 330k and add a current limit protecting series R after it. The Pi may not need it with ESD protection, but I'd not want to take the chance of latch-up.

use the Vdd on board, not 5V. But if you can fix the code, go for it. Counters should always be edge-sensitive anyhow.
 
I don't know which hall effect sensor you're using. You can try KY-024 hall sensor module. It gives digital output. The output is either LOW or HIGH. So, you can always read the output with a Raspberry Pi. It's straightforward.
 
Many thanks all for your kind advice, time and replies. Being no more than a very entry level enthusiast .. tbh a lot of these went over my head.

The KY-024 idea is interesting ... I bought one on Amazon and will try adapt the flow sensor to make use of it as one simple option ... but I was hoping to try learn how to build a circuit or design a Pi solution to handle this as well .. so ..
I'll have another go at using the Pi's PWM detection capabilities (first attempt was a miserable failure) ...

You'd all have a good laugh at me ... I had a crack at trying to design a circuit to detect both 0v and 5v rest state of Hall effect sensor .. using an OR, NOR and AND gates .. the idea seemed logical enough to me (no pun intended) ... and while the logic gates did seem to detect rest state as I imagined in my head while designing it all ... it had zero luck detecting flowing water state and remained stubbornly (and infuriatingly) in the OFF state (with very inexplicable random occasional blips of ON state which I put down to line noise from dodgey breadboard connections .. LoL)

I'll update with the outcome once I have a crack at both the Pi edge detection coding and the KY-024 ...

Again .. thanks all for your kind time and suggestions .. although apologies ...some of them were a bit over my head :-(
 
I presume you have a standard flow sensor?, like the one used here:


I've used them to measure the flow rate (in litres per second and cubic metres per hour) of water from a tap.

As I said in post #2, it's trivial to do what you want - detect when there's water flowing - easily done with simple software loops.
 
ok ... solution found (sheepish laugh) ...
turns out .. RTFM applies when working with the Pi ...
My original attempt at code (which looked very elegant if I do say so myself) ... and all subsequent attempts after noticing it wasn't working (and the attempts at designing logic boards to detect square waves) .. was in fact ... a case of PEBKAC ... :-(

Embarrassed to say ... I overlooked using the 3.3v supply pin on the Pi .. and accidentally was using a 5v supply pin to trigger Pi. .. As soon as I realised my mistake and connected it to the 3.3v supply pin, the original code started working beautifully!

Sorry folks .. but thought I'd share my embarrassment here for other newbie's to possibly learn from

Thank You again to everyone for helping with suggestions.
I still have a KY-024 on the way so will probably still tinker with that anyway
 
yep .. the Hall effect sensor is built into the water flow sensor ... and in my mind .. the problem (before I actually figured out my mistake) .. was that I was using an analogue signal producing a square wave output on a digital input ..
The KY-024 contains the circuitry to convert that to digital output from the hall effect sensor .. would've made it very convenient to plug that into the Pi.

I was planning to de-solder the sensor from the KY board and fit it to the water flow sensor and re-connect it with some thin wiring so it fits within the existing casing of the water flow sensor I have.

VERY clunky and ugly ... but it was just for personal home use .. and tbh .. more about just tinkering with kit to try and make it work. good fun if completely amateurish! LoL
 
Interesting idea, replace what you have with something that works exactly the same, and make it ugly at the same time

Your 'mistake' really was confusing analogue and digital, the output of the flow sensor is a digital one, and quite possibly uses something very similar to the KY-024.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…