Water flow Sensor.

Very new to Arduino and currently undertaking a project in water flow measurement. I know my Arduino uno chip is more the capable carrying such a task but I have become somewhat confused with the coding and connections involved with setting up the water flow measurement device.

My components I have chosen to use are
G1/2 water flow sensor
16X2 Lcd shield

I would like for the G1/2 water flow sensor output to be printed on the 16x 2 Lcd screen but some of the connections between components overlap on the board such as the D5 D6 D7. I was hoping someone may be able to supply me with alternative set up diagram so that both may run properly.

I believe my code to be in working however would love to hear of any improvements.

#include <LiquidCrystal.h>

volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;                               
int hallsensor = 2;    //The pin location of the sensor
 LiquidCrystal lcd (12, 11, 10, 5, 4, 3, 2);
void rpm ()     //This is the function that the interupt calls 
{ 
  NbTopsFan++;  //This function measures the rising and falling edge of the 
 


} 
// The setup() method runs once, when the sketch starts

void setup() //
{ 
  pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
  Serial.begin(9600); //This is the setup function where the serial port is 
 

  attachInterrupt(0, rpm, RISING); //and the interrupt is attached
   lcd.begin(16,2);
  lcd.setCursor(1,0); 
  lcd.print("WATER FLOW METER");
  lcd.clear();
 
  
} 
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()    
{
  NbTopsFan = 0;   //Set NbTops to 0 ready for calculations
  sei();      //Enables interrupts
  delay (1000);   //Wait 1 second
  cli();      //Disable interrupts
  Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate 

 lcd.print(Calc,DEC);
lcd.print("L/hour\r\n");
lcd.setCursor(0,1);

lcd.print("Pounds/hour\r\n");
  Serial.print (Calc, DEC); //Prints the number calculated above
  Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line

Thank you

This flow sensor ? http://www.seeedstudio.com/depot/G12-Water-Flow-Sensor-p-635.html

Do you have a 10k pullup resistor as is shown in the wiki ?

The Arduino Uno has an interrupt at pin 2, so lets keep the sensor attached to pin 2.

The LCD display can use any pin. Now you have : 12, 11, 10, 5, 4, 3, 2
Could you use another pin for pin 2 ?
You can use 6...9 and even an analog pin A0...A5.

Was the display working without the sensor ?
Test the display again, when an other pin is used.
Only after the display is okay, try to make the sensor work.

Thanks for the response,

The water flow sensor is connected to the Arduino with 10k resistor and seems to be giving out correct readings.

The LCD screen on the other hand does not seem to be responding or printing the incoming measurement. the shield I am using lays on top of the Arduino and connected at all the inputs on the board it does however have a replacement inputs on top of it.

LCD :http://www.maplin.co.uk/p/16x2-lcd-shield-for-arduino-n07dh

When I upload the code onto the Arduino the display does not even run, it turns on but does not print any of the values from my code. Cannot find any clear tutorials online, and need help getting the display operational

I believe all these sensors are pretty much the same, the 1/2 simply means it has a 1/2" BSP thread, and the only variation is the pulses per litre factor. This is often marked on the side of the sensor.

You might get some value from the water flow project by Freetronics and /or Jaycar. I find the rate display is pretty useless but the total flow is very accurate once some calibration is made.

In the light of the total flow accuracy, I believe the rate can be made to work by getting an avarege over several readings, or simply using a longer time window.

The LCD is a shield but the usual 16x2 tutorials are for a bare display. Therefore the pin call is probably wrong. The shields may vary, but try 8,9,4,5,6,7. You should able to see the PCB traces to check this

I agree with Nick_Pyner.
You have a real "shield" that is attached to the Arduino, with fixed pins for the LCD.
I think you need this : LiquidCrystal lcd ( 8, 9, 4, 5, 6, 7 ) ;
Analog input A0 is used for the buttons.

This is a tutorial for the display : http://www.arduino.cc/en/Tutorial/LiquidCrystal
Try that with the sensor not connected.

Does the display work without the sensor connected? Have you written a basic sketch to simply print "I'm working" to the display?

You might have to adjust the pot in the upper left of the LCD shield to be able to see output on the display. It should be a small grey or blue box with a brass screw in the top or side. You can adjust this with a jeweler's screwdriver, just be gentle and don't turn it too far.

Just wanted to provide some screenshots of various LCDs as the pot doesn't always look the same and isn't always in the same place. These are a few examples I found of LCDs that do have this potentiometer on them. There also seem to be quite a few that don't have one at all. I hope this is helpful.