Ever wanted to measure liquid flowing through a pipe / container? Wanted to create a control system based on the water flow rate or quantity ? For example while gardening, to measure the amount of water used to water your plants , to prevent wastage , etc. If yes, then this very easy DIY project is for you. Here, step by step instructions are given on how to measure water flow rate and quantity using an arduino flow rate sensor.
A flow sensor is a device for sensing the rate of fluid flow. Typically a flow sensor is the sensing element used in a flow meter, or flow logger, to record the flow of fluids.
Step 1: Components Requires
1. Arduino Uno
2. Flow Sensor
3. Connecting wires
4. LCD Display
5. 1K Ohm Resistor
Step 2: Circuit and Its Connections
Flow sensor Yellow Wire is output and it gives pulses in proportion with flow
Step 3: Programming the Arduino
Code:
/* This tutorial Demonstrates the use of Flow Sensor Web: blog.circuits4you.com
The circuit: Flow Sensor Connections Yellow --- Pin 6 Red --- +5V Black --- GND LCD Connections * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 6 * LCD D5 pin to digital pin 5 * LCD D6 pin to digital pin 4 * LCD D7 pin to digital pin 3 * LCD R/W pin to ground * 1K resistor: * One end to ground * Another end to LCD VO pin (pin 3) This example code is in the public domain. */ // include the library code: #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 6, 5, 4, 3); volatile int FlowPulse; //measuring the rising edges of the signal int Calc; int flowsensor = 2; //The pin location of the sensor void setup() { pinMode(flowsensor, INPUT); //initializes digital pin 2 as an input Serial.begin(9600); //This is the setup function where the serial port is initialised, attachInterrupt(0, rpm, RISING); //and the interrupt is attached // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.setCursor(0, 1); lcd.print("Flow Meter"); } void loop() { FlowPulse = 0; //Set NbTops to 0 ready for calculations sei(); //Enables interrupts delay (1000); //Wait 1 second cli(); //Disable interrupts Calc = (FlowPulse * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour Serial.print (Calc, DEC); //Prints the number calculated above Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 2); lcd.print(Calc,DEC); // print the Flow Rate lcd.print(" L/hour"); } void rpm () //This is the function that the interupt calls { FlowPulse++; //This function measures the rising and falling edge of the hall effect sensors signal }
Step 4: Testing and Results
1. Blow air or allow water flow through the sensor
2. Observe the reading on LCD or Serial Monitor
3. Readings get updated at every 1 Sec
beautiful good job
ReplyDeleteI cant get a read out for PIN 6 at all
ReplyDeleteCheck connections
Deletereading is constantly shhowing 8 L/hr.
Deletei only get 8 L/hour every time... why?
ReplyDeleteavrdude: stk500_getsync(): not in sync: resp=0x00
ReplyDeleteI cant read out for PIN 6
ReplyDeleteOkay so for everyone that wants to run this on pin six, this code can only work on pin 2 and 3. Those are the only pins on the uno that accepts external interrupts, sooooo when you call "attachInterrupt(0, rpm, RISING);" you are attaching an interrupt to digital pin 2, when you call "attachInterrupt(1, rpm, RISING);" you are attaching an interrupt to digital pin 3!
ReplyDeleteI do not know how the OP got this to work but only pin 2 and 3 can work (according to me :P )
i need library file of this program can you help me with that
ReplyDeletei need a library for the same please at anthonykarimi44@gmail.com
ReplyDeletei need a code exactly like this but using a lcd keypad! Somebody can help me?
ReplyDeleteYou can get some help on keypad interfacing, If you tell complete project Idea I will make it and publish here.
Deletehttp://circuits4you.com/2016/05/15/keypad-interfacing-arduino/
'Calc' gives the value of flow rate in liter per hour which is Q(flow rate). So how come there is a Q in the denominator
ReplyDeleteCalc = (FlowPulse * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour