In the previous water meter Blogs we used a cheap flow meter to give us a measure of water flowrate and total water used. The flow meters are cheap and the spec sheet can be misleading, this code is used to get a real world value of number of pulses per L of water delivered.

 

>Connect the water meter in-line, and prime system

>Turn tap off

>Start Arduino

>Turn tap on to fill up a known volume

Clicks per L= Volume/Pulse Count   [Volume must be in L]

We can use this value in our previous code to get really accurate readings

 

LCD Shiled that it will work with:

 

LCD

 

Pinout [Solder onto LCD shiled is preferred ] :

 

pinout

 

Ignore external pull up, we are doing that in software instead

 

 

Header 1

/* This script is used to make sense of the output from a hall effect water flow meter for calibration

Calibrating Water Meters:

>Load Calibration Code

>Connect the water meter in-line, and prime system

>Turn tap off

>Start Arduino

>Turn tap on to fill up a known volume

Clicks per L= Volume/Pulse Count   [Volume must be in L]

We can use this value in our previous code to get really accurate readings

 

Michael Ratcliffe  Mike@MichaelRatcliffe.com

  

    This program is free software: you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation, either version 3 of the License, or

    (at your option) any later version.

 

 

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.

 

 

    You should have received a copy of the GNU General Public License

    along with this program.  If not, see <http://www.gnu.org/licenses/>.

  

   

    Components:

    See main folder for sensor data sheets, required liabaries and extra information: [can be downloaded via www.michaelratcliffe.com]

  

    All power systems should be powerd of DC voltage of below 48v for safter [water is around] 12v is prefferable and cheapest. As always this is a DIY project and done at your own risk.

  

  

    >Arduino Uno

    >Hall Effect Water Flow Meter 5v

    >LCD button Shield [Hobby tronix]

 

*/

// including some libraries for interfacing with harware

#include <LiquidCrystal.h> //Standard LCD Lbrary

 

 

#define Water_pin 2

#define Relay A2

 

 

 

 

//*********************8* Setting up LCD ************************//

// select the pins used on the LCD panel

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

 

 

//***************************** End Of User Defined Variables **************************************************//

 

 

unsigned long PulseCount=0;  //counter for water meter pulses

 

 

 

 

//**************************** Setup Routine , Runs Once and Sets used pins to correct value *******************//

void setup() {

//Stoping noise from being a problem, pin is high untill hall sensor pulls it low

pinMode(Water_pin, INPUT);

digitalWrite(Water_pin, HIGH);// saves having an external pullup

    

//External Interrupts: This is what the watr meter pulse count is collected from     

attachInterrupt(0, WaterCounter, FALLING);  //watermeter pulse output connected to pin2

lcd.begin(16, 2);              // start the library

                      lcd.setCursor(0,0);

                      lcd.print("                ");

                      delay(3);

                      lcd.setCursor(1,1);

                      lcd.print("                    ");

 

 

 

 

 

 

 

 

};

 

//************************************** Main Loop that will continualy run ******************************************//

void loop(){

 

 

                      lcd.setCursor(0,0);

                      lcd.print("Pulse_Count:   ");

                    

                      lcd.setCursor(0,1);

                      lcd.print(PulseCount);

                       

delay(300); //just a short delay to let things settle

};

 

 

 

 

//*************Interupt routine for water meter readings - Runs everytime sensor has a pulse *************//

 

 

void WaterCounter() {

 

   // Increment the pulse counter

  PulseCount++;

 

};