Stand-alone Liquid Flow Meter using Arduino
DIY Flow Meter
This guide uses a Sensirion liquid flow sensor, parts of the Arduino Starter Kit and the Sensirion Arduino sample code to build a simple stand-alone liquid flow meter.
- Sensirion liquid flow meter. An LG16-2000D (Article No. 1-100404-01) is being used in this example
- Flat ribbon cable (Article No. 1-100482-01) and screw headers (277-1275-ND, from www.digikey.com) to connect the sensor to your Arduino board
- Arduino Starter Kit (GKX00007, from www.arduino.cc): Arduino Uno, breadboard, 16x2 LCD, 10k ohm potentiometer, 220 ohm resistor, hook-up wires
- Sensirion’s Arduino Sample code
This guide is aimed at customers who have successfully set up their Arduino and connected their Sensirion liquid flow sensor (Arduino Interface for Liquid Flow Sensors). Please see the above Arduino Quick Start Guide for help in setting up your Arduino and liquid flow sensor.
In order to setup your Arduino on the hardware side, please follow the diagram below to connect your LCD, Arduino, and flow sensor.
Thanks to the straight forward integration of graphic LCDs into an Arduino project, only minor changes have to be made to example 3 of the sample code.
You can start your code with:
#include <LiquidCrystal.h> // first add the LCD library LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // then initialize the library with the numbers of the interface pins
This incorporates the LiquidCrystal.h library into your code and tells it what pins you have connected the LCD to.
Including the following into your void setup() will initiate the LCD and print the first line of text.
lcd.begin(16,2); // setup the LCD lcd.print("DIY Flow Meter "); // Writing the first line to the LCD:
In order to show the updated reading of the flow sensor on the LCD, a few lines have to be added to your void loop():
lcd.setCursor(0, 1); // move the LCD cursor to the second row lcd.print(sensor_reading); lcd.print(" ");lcd.print(dimension);lcd.print(unit);lcd.print("/");lcd.print(time_base);
After compiling and uploading your code, wait for your Arduino to restart. You can adjust the contrast settings using the potentiometer and start enjoying your Arduino-based liquid flow meter.
The entire code can be found at: Github