arduino flow meter

 


 
If I recall correctly, but you can use any ground, the ground wire comes over here to one side of our voltage divider and this side. This side of the voltage divider also connects to the ground on our flow meter. Go through the resistor. This yellow wire goes back to the PI it’s our input to line 13 pin 13, and then it goes through our 4.7 cabe resistor and this yellow wire is the Hall effect switch on the sensor and that’s pretty much it from our divider let’s go look at Our plug our plug our pulse, our sensor has black, yellow and red wires and I’m. Using the same color scheme. The red wire is the 5 volts from the PI. The yellow wire is to the voltage divider and the black wire is just over here to the ground. So let’s follow this back over here. This is our flow sensor. It’S, the yff 201 it’s got a working range of 1 to 30 litres per minute and you can see the impeller inside there and it’s rather simple. It’S got an arrow on it, which tells you which way the water flows. Water comes in from the left. Side. Goes to the right side: spins the impeller there’s a little magnet on the impeller, the magnet triggers a Hall effect switch and that causes pulses to come back to the PI. We count the PI, we count the pulses. We take the time – and we know how many liters per minute and if we count the total number of pulses and, of course, to get the total liters.

Okay well, that’s it for the hardware setup, let’s, go look at the software and see how this works. Let’S. Look at the software behind this it’s, relatively simple it’s, just a couple screens of code and a lot of its comments. So Python 3 program for the yfs, 2, 0 1 flow meter and I’m going to use polling I’ve got another version that uses interrupts. This uses a nested, wiles I’ve, seen people use for loops and try to time it by using sleep and all that and yeah that that causes the program to change speed and you have to change constants and all that, depending on what your program is doing. So any little change you have to retune your program, which I don’t like that so I’m, going to use the clock. The internal clock instead input on 1013 pin 6 with ground 5 volts I’ve tried it on 3.3. It seems to work, but I get more noise. However, with 5 volts, you must use a voltage divider. This is a quick comment about the voltage. Divider I’ll show you that later and there’s a warning here, there’s no stop flow warning. So if you like, for example, these all these zeros indicate that the impeller is not turning, if you get all one, what I found is that you get erroneous readings. I’Ve tried many ways to stop it, but I can’t there’s a apparently a bug in the RPI code. I found something online about that: ok on where on word, import, the GPIO library.

Ok, we know about that. Import time insists we want sis for getting out of the program nicely and we want time. So we have a real time clock we’re going to use board numbering. I know a lot of people for the other bodies board numbering the input. Pin is going to be pin number 13 I’m going to assign that pin 13 as in these are some variables I need. This is the number of pulses per minute, so I’m, going to reset this. Every time I go around in the loop, this is the total number of pulses and I’m not going to reset that that’s, the total from the beginning of the program until the end total number of minutes, the program has been running. This is a constant, and this constant in my case is very approximate you to get good answer. You need to take your flow meter hook it up to some water run, the water into a say, a five gallon bucket and time with a stopwatch. How long it takes to fill that five gallon bucket and then you’ll have your constant, and this is a new time because I’m using I’m saving, the old and new time. So I can tell when one minute is passed and we’ll. Look at the code down here. Farther these are just comments to the user about what this is doing. This is water flow, it’s, approximate it’s, not accurate because of some of the issues.

We’Ve discussed, control c will exit nicely. We’Ll show you the code down here farther for that and let’s scroll down a couple more lines and here’s. The whole program really from here to here there’s, says two nested, while loops one here and one here and then a little bit of logic and some print out and that’s it. So this is just a loop forever statement, while true and the first thing I’m going to do is grab the time and we’re going to. We have to keep the old time of the new time. So we know that when one minute has elapsed and we’re going to use that down here in the second while loop, the rate counter we’re going to set to zero and that’s the one that we’re keeping pulses per minute. So we have to reset that every time we’re not resetting the total count, because we want to keep that as long as the program is running so here we’re checking to see if the old time the new time are different by more than a minute. If it’s more than a minute, it will go on to the next, it will jump out, come back up here and reset. So this is my 1 minute loop inside here. If you will, if the input is not equal to zero, in other words, it’s one I’m going to increment both of my counters, so the impellers gone by its triggered the hall effect, and I add one to each one – and here is a statement which all it Does is it prints these zeros and you’ll, see ones also when it’s running the zeros and ones just tell you that the impeller is turning, and so this all these zeros tell me the impeller has stopped and the Hall effect switch is not triggered at that point.

So that’s all that print statements doing, except if you hit the control C, what will happen is this will exit nicely? It will do these po clean up. It will tell you it exiting nicely: it will do the gpio clean up it’ll, do the SIS exit and exit nicely. If you do not do that, it will come down here. It will increment the total number of minutes. It will print the litres per minute. The total leaders and the time and then we’ll start back up here again and do a new minute and keep the old totals and just keep rolling around and around and around forever let’s, take a look and see how it works. What I’m going to do is going to use this plastic tube and I’m going to blow into the to the center, because it’s not a good idea that for me to be running water in that TV room, my wife will have me shot. So I will cheat a little bit I’m going to do another cheap. Also, as I set the time, see that tent over there. It should be 60 for one minute, but I don’t want to sit here for one minute and watch this thing scroll by so I’ve cheated a little bit. It’S been set to 10 seconds, so we’ll get a new reading every 10 seconds, but in normal real life. I would change that 10 to a 60. Okay, let’s run it you can see.

The impeller is turning on blowing air into it, and the zero indicates that the impeller stops. So we got 12.1 litres per minute and a total of 12.1 liters. So this time we got 4 litres added onto the old one. We got 16 point one and it will just continue to do this. Okay. So this time we’ve got forty eight point: nine sixty five total third minute the date. This time, we’ve got nine point. Eight per minute: seventy four point: eight total we’re into the fourth minute, there’s the clock and so on, and so on.

 
 

arduino flow meter Video

 

 

 

 

 

 

arduino flow meter news

 

 

 

 

 

 

 

arduino flow meter Social

 

 

 

 

official.arduino
2019-10-02T19:32:52+0000

👋 Want to bring Tony Stark-like gesture control to your projects? Learn how with the BLE-enabled MKR WiFi 1010 and Nano 33 BLE Sense boards using the ArduinoBLE library.
safe image.php?d=AQDyi1ELcW4VGzhx&w=720&h=720&url=https%3A%2F%2Fhackster.imgix.net%2Fuploads%2Fattachments%2F997327%2Fblob dChOhNMmeF - arduino flow meter
official.arduino
2019-10-02T19:08:01+0000

Arduin-yo ho ho! A fairground favorite, the pirate ship is a fun way to explore the oscillation of a pendulum. How much fun, you ask? Access our Science Kit Physics Lab preview and see for yourself: http://bit.ly/2oC6L0Q

🔬 Now that you’ve gotten your feet wet, dive into the kit and enjoy all nine experiments. Order yours today: http://bit.ly/2MnQ7fr

70537898 550174072395145 8798850142103928832 n.jpg? nc cat=102& nc oc=AQmCfMPwMf1oPpYqFhzbxfnGdbrmsjZXrEEBy1ox5Z8EJtiYMADoFNZ5mnSNRgCCY74& nc ht=scontent - arduino flow meter

2016-04-15T14:35:45



 photo

2016-04-15T14:35:40



 photo

2016-04-15T14:35:36



 photo

 

 

(Visited 20 times, 1 visits today)

About The Author

You might be interested in

Comment (49)

    1. The constant REALLY depends on your code. In theory you can just use your setup to fill a bucket of water and time it. Then use the flow per time info from that to make your constant. That constant will depend on your code.
      You can start with the data I put in the description as a baseline.

    2. Thank you for your response. I am basically doing this project to measure consumption on my kitchen sink tap and i did as you suggested and it seem to have worked for the first test but when i open the tap and have water running at the different speed than the one i used to get the constant then i get wrong results. My thoughts are that the pressure or the speed of water affects the time it takes to fill a bucket of water to get the constant, so my question is: is there no way of getting the constant at runtime based on the speed the water is running? forgive me am still new at this.

    1. I have not tried that yet, I’ve seen people who have. It looks like something that’s in the “moderately difficult” category.

  1. Hi, I have everything needed (electronics and hardware) and I tried to copy the program as you have it written but I’m getting a syntax error at “if GPIO.input(input)!= 0 #Look for pulses”. It highlights everything after that red and won’t let me begin the program. Is there any way I could download your copy of this program so I can be sure there are no mistakes?

    1. Since I wrote this comment I have been able to make some progress. I took your code and modified it to suit my needs. I am in need of some extra help though. I have even gone to my local tech school to find someone who knows python and GPIO but am having a really hard time finding the help I need.

      What I am trying to do is use a flow meter and solenoid to automatically dispense 5 gallons of fluid from a pressurized source (PVC pipe) upon a button press. I also need a button to interrupt flow as an emergency stop (shut the solenoid to resting position.

      I have the elctronics hooked up and pieced together including sensor, solenoid, resistors, transistors, 12v relay etc. The code is currently scattered among different programs. One program is able to open the solenoid upon start (run) program and stay open until the total count reaches a certain number and then shut. Another program will open the solenoid at a button press and stay open but it’s not reading impulses the way i would like it to (technically its not reading the input at all). I am having a hard time bringing these features together into one program.

      I would really like to get this project done and am looking for some help from someone who is much more experienced in python coding than myself. Is there any way we can begin a correspondence with each other via email, phone or email? Assuming you are willing and have time to help an enthusiastic novice such as myself. I would so greatly appreciate it.

      Ill leave my email here if you are willing to help. Daren@kingind.net . Thank you!

    2. @Daren Lorenzo I need to point out that this meter is only for water, it concerns me when you wrote about pressurized fluid, because this meter is not for any other fluid, especially not something flammable. This is just a hobby for me, and was geared more for someone who wants to measure water use in their drip system or similar. I don’t know your application, but phrases like “emergency stop” seem to hint this might be something that requires a professional programmer / electrical engineer.

  2. Hi, I know this is a water flow sensor but I would like to use it for air, do you know if that’s possible? It’s just to get an idea of a relationship so it doesn’t need to be that accurate. Thanks 🙂

    1. I don’t think it will work. Air would cause it to go WAY past it’s design speed. It is very easy to make it start under-counting by a lot. I think in the gas business they use pressure and a fixed opening to measure the amount of flow of a gas. I googled “digital air flow meter” and there are such things.

  3. I’m not sure if this has been mentioned before, but I figured out how to solve the getting 1’s as inputs even when the impeller is stationary. If the impeller has been turning in the opposite direction as it does when air flows through in the correct direction, it shows 1. If you blow through in the correct direction before running the programme it corrects itself and goes back to 0. Not sure if this will help anyone but just thought I’d mention what I found.

  4. Good day

    I need help with the code.

    I want the flow meter to count 500ml and then then the relay must close?

    How can i do that

    1. I put a lot of info in the description. It will be different for each model of flow meter. 500 ml per what time? This meter has minimum and maximum flows. Outside of those it does not work well. Also the accuracy is only ±10% and the range is 1-30 Lpm. Hope that helps.

  5. Im having issues with line 37, what is the complete code? I have used the following;
    print(‘Time (min & clock) ‘, minutes, ‘\t’, time.asctime(time))

    1. Sorry, got cut off. This is copy and pasted from the program:
      print(‘Time (min & clock) ‘, minutes, ‘\t’, time.asctime(time.localtime(time.time())),’\n’)
      It’s also now in the description.

  6. I want to use it for my water pump on off. Can i use it without adruino. Does it give supply when water is not flowing? I want it should not give supply while water is not flowing. Please answer me

    1. No, this measures amount of water (liters, gallons). It requires a computer. I think you want a solenoid water valve.

  7. my flow sensor is not reading it when i wrote the pgm and ran like this….cant understand whats wrong…its urgent can u help?

    1. I included the YF-S201 specs in the description so you can compare to others. You should also consider that the electrical requirements may be different.

    1. Yes I said that in the video. The problem is that impeller is spinning very fast giving wrong measurements. This was made to measure a relatively viscous fluid (water). Also the specs show it has limits on upper and lower impeller speeds. This was just for demonstration purposes.

  8. I think you can calculate the constant by spec (450 pulse per liter). Just divide the number of pulses between 450 and multiply by the time unit you are measuring (e.g. 60 secs to get Lt/min). However I used the wiring and was OK!! Thanks!

    1. That sounds correct. But you must consider the speed of the computer as well, if you are just running a small program that will work, but as the program grows in complexity, the polling / interrupts don’t always happen as timed.

    1. The specs are in the description. The manufacturer lists a maximum, but not a minimum. I think gravity would work fine as long as the flow rate is within specs.

    1. @eko yulianto It uses a magnet and Hall effect sensor. The magnet triggers the sensor creating a pulse (or pulses) per revolution. The raspberry pi counts the pulses. Data is in the description.

LEAVE YOUR COMMENT

Your email address will not be published. Required fields are marked *