Measure Water Flow in literes using Arduino Mega 2560 Board and Water Flow Sensor

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a water flow sensor with Arduino Megs 2560 board. I am trying to conceptualize the concept to calculate amount of water getting dispensed esp. in 1,2,3,4 and 5 liters quantity.

The Water flow sensors generate pulses/sec when water is flowing through it. In my case it is 4.5 pluses per sec as per specification. I would connect the sensor input to any pin from 22-53 pin.

Suppose I connect to ping 23 so in my setup() function I would add:

    attachInterrupt(23, pulseCounter, FALLING);

where pulseCounter is an interrupt function triggered on each signal generated from sensor and increments a variable

   void pulseCounter()
    {
      // Increment the pulse counter
      pulseCount++;
    }

Now how do I calculate the flowrate and water dispensed in milliliters using this information? I am not sure but I understand that I first need to calculate flowrate first, if so is the below formula correct:

    flowrate = pulseCount / 4.5;

and to measure amount of litres have dispensed is

    flowMilliLitres = (flowRate / 60) * 1000;

as we keep adding flowMilliLitres oto a global variable:

totalMilliLitres += flowMilliLitres;

Please correct my understanding if I am proceeding in wright direction.

 

This topic has a solution.
Last Edited: Fri. Nov 14, 2014 - 06:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you provide a link to your flow sensor please? Pulses per second make no sense alone... you need to know the relationship between the volume of water passed and the pulses. That relationship should be stated in the sensor datasheet.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I may be wrong - it would be pulses per volume:

 

http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf

 

But then it varies from freqz of the MCU unit. How do I know the freqz of the MCU and I would assume that counting that much pulses then would mean that a liter of water has been dispensed?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK Prakash. The datasheet says in two places that it produces approximately 8 pulses for each litre of water that flows through it. The graph is wrong (compare the figure for 480 litres per hour with the printed values. Someone plotted the wrong values).

 

So your MCU must simply measure the number of pulses received in a known period of time, eg how many pulses are counted in one second. If you count 8 pulses in one second (8Hz), that means that 1 litre of water has flowed through in that one second. The frequency of your MCU (eg 16MHz) is not important except for being able to measure 1 second.

 

So...

 

Volume in litres = 0.125 * (number of pulses)/(number of seconds of counting)

 

... therefore 16 pulses counted during 2 seconds is 1 litre of water measured.

 

Hope that helps you.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
The datasheet says in two places that it produces approximately 8 pulses for each litre of water that flows through it.

So time is irrelevant?

 

Quote:
therefore 16 pulses counted during 2 seconds is 1 litre of water measured.

Surely, 16 pulses counted in any period of time is two litres of water?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah OK... just count pulses and divide by 8 and call the result litres.  I'll go back to sleep now... cheeky

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No no no, wrong, sorry.

 

8 Hz means one liter per minute... doesn't mean that each 8 pulses one liter went through.

If ONE LITER per MINUTE creates 8Hz, than each 60 seconds of 8Hz, 480 pulses, means one liter.

 

In other words, each 8 pulses means 16.6ml, or each pulse means 2.08ml (2.08 cubic centimeter of water).

 

So, you can yes, multiply pulses times 0.00208 and obtain "liters".

 

 

 

In this link below, you can read 7.5Hz per liter/minute, or, 450 pulses per liter, same as my calculations above.

 

http://www.hobbytronics.co.uk/yf-s201-water-flow-meter

 

 

Wagner Lipnharski
Orlando Florida USA

Last Edited: Fri. Mar 11, 2016 - 07:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, your program should be;

 

 void pulseCounter()
    {
      // Increment the pulse counter
      pulseCount++;
      if(pulseCount > 47)
         {
         pulseCount -= 48;
         totalMilliLitres += 100;
         }
      end if         

Wagner Lipnharski
Orlando Florida USA

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice to see you around Wagner but the thread is 1.5 years old. wink

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:

Nice to see you around Wagner but the thread is 1.5 years old. wink

 

Hey John, I still orbiting...

I like to dig and fix old wrong information... looks like ourselves... laugh old and wiser... 

Wagner Lipnharski
Orlando Florida USA

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wagnerlip wrote:

No no no, wrong, sorry.

 

8 Hz means one liter per minute... doesn't mean that each 8 pulses one liter went through.

If ONE LITER per MINUTE creates 8Hz, than each 60 seconds of 8Hz, 480 pulses, means one liter.

 

In other words, each 8 pulses means 16.6ml, or each pulse means 2.08ml (2.08 cubic centimeter of water).

 

So, you can yes, multiply pulses times 0.00208 and obtain "liters".

 

 

 

In this link below, you can read 7.5Hz per liter/minute, or, 450 pulses per liter, same as my calculations above.

 

http://www.hobbytronics.co.uk/yf-s201-water-flow-meter

 

 

 

How can i measure volume when pulse is not stable?

(when see actual water flow its not stable flow rate or stable pulse. in that case how can i calculate liquid volume that flows through the sensor during specific time period(eg:1hour)) 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I said in post #6... count the number of pulses and when you reach 8 that means 1 litre has passed. How many times have you counted to 8 in your one hour... irrespective of stability or not.

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

but that's not what wagnerlip  said in #7 -  which veno  quoted to re-resurrect this old thread again in #11.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep. Correction. Count 480 pulses equals 1 litre.

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The OP seems to produce some confusion when use the expression "flowrate" but not correlated to time, and also, did not used the concept of "volume" when time is not involved.

We need to be careful, since it can leads to wrong assumptions. 

 

Flowrate is always "some volume" by "some time".

 

In this specific case, the weblink states approximately 2.25mL per pulse, so, 8 pulses means only volume of liquid (18mL), but 8Hz means frequency in time, and it means 18mL per second, it can not be translated to 1.08 liter per minute, since you can not ensure stability of such reading during the next 59 seconds.  As an instantaneous sample of just one second, you can say that 8Hz could represent an assumption of 1.08 liter per minute.

 

One should never confuse things.  The uC calculation should multiply pulses per second (Hz) by 135 in order to obtain milliLiters per minute, but again, that is an assumption.  If the liquid flow was zero during 900ms and produced 8 pulses in the last 100ms, it would means absolutely bullsh*t, and the assumption of 1.08 LPM would be wrong.

The only valid information would be accumulating pulses to represent volume in multiples of 2.25mL.  Based on that accumulated pulses and the time, one could assume a more reliable LPM.

 

Wagner Lipnharski
Orlando Florida USA

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all the details - I remember being able to resolve the issue close to your approach.