Water flow vane type sensor use

For my requirements I found that the most suitable sensor for my project would be a regular vane / impeller / propeller type liquid flow sensor (FS-200 type) that detects the minimal amount of flow in my pipe system

My question is not about detecting the pulses from the sensor but to compute a function with an Arduino when a pulse/pulses is/are detected

What I would like to ask is for your suggestions about the following. When the sensor starts giving pulses to one of the Arduino inputs, one of the Arduino digital outputs goes HIGH for say 2 seconds and then goes LOW even if pulses from the flow sensor at the input are still present

When the flow stops and there are no more pulses, the Arduino starts the cycle again, awaiting indefinitely for the next pulse or set of pulses from the flow sensor in order to switch again to HIGH the digital output for 2 seconds and then LOW again

Can someone please guide me to which sketch example I could build upon to perform the above operation ?

Thank you in advance

I can't think of any of the example sketches that are close to what you want. But the sketch should not be too difficult. Main complication is how often the pulses come from the sensor, and how long after the last pulse comes to you decide that it was the last?

Take a look at blink without delay - it will illustrate how to use millis for timing, which you're going to need I suspect.

Also, what's the fastest rate the pulses will come and the shortest the pulses will ever be?

The link to your suggested sensor has this: "
it is a contact switch. Meaning it will operate on any voltage or as a continuity switch with no voltage.".

So you would need a program that tests for a switch closure. Examples in the IDE example programs. That also means the switch can stay "on" if the flow happens to stop at the correct point.


Hi gents, and thanks for your ideas

Just to answer some of your questions, the flow sensor gives a maximum output of 100Hz with max water flow rate and the duty cycle is around 40/60

As for the duration of the input pulses to the arduino it depends on how much time the water tap is left open by the user, so can't consider to include such an unknown time frame in my sketch

To be honest I was more inclined to the idea of a one-shot trigger type of function that just starts a timer for 2 seconds on and then goes off even if the triggering pulses are still present at the input

Is there such a function in Arduino language ?

...even if the triggering pulses are still present at the input

But what does "still present" mean? You will need to decide on a "timeout" where if no more pulses (or edges) are received, the flow is deemed to have stopped.

Is there such a function in Arduino language ?

No language would have such a specific function. If they did, every language would need a million functions for such specific things. Languages have much more general functions. But if used correctly, they will do what you need.

My question is not about detecting the pulses from the sensor but to compute a function with an Arduino when a pulse/pulses is/are detected

That is rather hard to read. At a guess all you want to do is make a pin high for two seconds, and the only condition is that it is triggered by water flow. That cannot possibly be hard, particularly if your timing loop is two seconds. I only want to point out that, if you are working with domestic water supply, you might be amazed at the amount of water movement in the system that does not constitute "flow" and this would be be about the only good reason for using a flow meter instead of a flow switch.

IF you can be sure of the minimum flow rate when the tap is on, all you need to do is come to terms with detecting pulses from the sensor and use a standard flow rate programme, but with a two second timer window, that will turn the pin high when the flow rate is say half the above minimum AND it was less than that on the previous cycle. You may find the "less" may actually be "quite a lot less". This is because, although the quantity of water passed over a long period is very accurate, these sensors can be quite erratic when measuring rate over short intervals.

Consider the very possible situation where you only get a single pulse. How long do you wait for the second pulse? Or is the second pulse really the start of a rapid series of pulses?