Water Flow

So I found a sketch that calculates the flow of water posted here on this forum. Pretty simple , +to red lead - to black lead and the yellow wire goes to Digital pin 2, there is a 10K pull-up resistor between +
and pin 2 .I believe my circuit is correct but for some reason and again maybe its my circuit , the serial always outputs some sort of reading weather there is water flow or not. Also is there a way to convert this to gallons and compile it to a total usage ? I would like to just reset it after I get usage like say for a week to a month.Thanks below is the sketch I have downloaded :

// reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com
// Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com
// http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com

volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;
int hallsensor = 2; //The pin location of the sensor

void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensor signal

}
// 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 initilised

attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
// 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 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
}

Also just to note that what I am using is a model YF-B5 3/4" water flow sensor,thanks

Try connecting this up to ensure the module is working...

Flow Pulse: F= 6.6 *Q(L/min)

So for say ~10L/min...a "typical" tap on full...

F = 6.6 * 10 =~ 70Hz (top end human sight frequency).

Have you therefore tried to put say a red LED and a 220 ohm resistor between pin 2 and the pin 2 or the arduino to have a visual indicator?

Output pin of Sensor------>100-1kohm resistor ------> Red LED (~1.8V drop) -----> Arduino pin 2

What do you see?

Larryfos:
So I found a sketch that calculates the flow of water posted here on this forum. Pretty simple , +to red lead - to black lead and the yellow wire goes to Digital pin 2, there is a 10K pull-up resistor between +
and pin 2 .I believe my circuit is correct

I don't believe it is. These circuits usually have a 1k series resistor, not a pull-up. The code looks about right. You will find something similar here.

Just press the reset button when you are ready to reset.

Hi,
Can you post a link to your flow sensor please?

Thanks.. Tom... :slight_smile:

PS: Many hall sensors "sink" current.

So with my idea of the LED:

Try putting the LED and resistor between the 5V in to the sensor and with the anode (+ve) of the LED going in to the sensor "output" pin.

Remember the 1k ish ohm resistor.

Slowly turn the water on...do you actually get a square wave output from the hall sensor? Or is this a analog out hall sensor (which would not support the datasheets claims).

Sorry really a newbie here , don't know code, trying to learn ,got a book C++ for dummies but maybe I am just ignorant ,not understanding this at all. Don't understand how to relate code to program ,can do the electrical. Will try the lerd and get back to you on it,don't know where to put that math in the code properly
Try connecting this up to ensure the module is working...

Flow Pulse: F= 6.6 *Q(L/min)

So for say ~10L/min...a "typical" tap on full...

F = 6.6 * 10 =~ 70Hz (top end human sight frequency).

Have you therefore tried to put say a red LED and a 220 ohm resistor between pin 2 and the pin 2 or the arduino to have a visual indicator?

Output pin of Sensor------>100-1kohm resistor ------> Red LED (~1.8V drop) -----> Arduino pin 2

What do you see?
ssue there but the code writing and how it applies is killing me. anyways bacck to what you suggest

Sorry johnny1010 not quite understanding what you suggest on the resistor, currently ther is a 10K resistor in the circuit between the output of the water sensor and the +5v .So if I understand you , you suggest to add an LED as a visual and leaving the water sensor connected .

Just figured it out, had an issue with Arduino, no +5 vdc present , resolved that issue and now the sensor works it reads 0/L with no water flow. Feel stupid, should have checked for presence of voltage before I sent out a cry for help. Still would like to know how to change it from metric Liters to gallons though.

1 Gallon = 4.54609 Litres...

Simply dividing your value by 4.54609 will give L/Min as Gal/Min

TomGeorge:
Hi,
Can you post a link to your flow sensor please?

Thanks.. Tom... :slight_smile:

I think this is the one he is using, Tom!
http://www.hobbytronics.co.uk/yf-s201-water-flow-meter

For a US gallon the constant is 3.7854

Allan

allanhurst:
For a US gallon the constant is 3.7854

Allan

:wink:

Mars Climate Orbiter

Whoops!

Allan

ps - the SI system makes a clear distinction between mass and force - 1kg mass exerts a force of 9.81 newtons on the earth's surface. ( G = 9.81 m/s/s)

the old imperial system doesn't - when I speak of 1 - lb force, what do I mean ? The force exerted by 1 lb mass at the earth's surface, or the force required to make it accelerate at 1 ft/s/s .....?

To clear this up, at school we were taught to use the term 'poundal' for this second unit.

I don't think it caught on.

allanhurst:
Whoops!

Allan

ps - the SI system makes a clear distinction between mass and force - 1kg mass exerts a force of 9.81 newtons on the earth's surface. ( G = 9.81 m/s/s)

Well yes and no.

1kg is defined as an amount of matter ("stuff" in laymans).
1N is defined as the force require to accelerate 1kg of matter (stuff) by 1 metre per second per second.

1N of force is the same on Mars as Earth. Just that the constant G is not.

Quite.

But the potential ambiguity of the imperial system remains, for example in rating the specific impulse of a rocket fuel/oxidiser combination in 'seconds'....

Allan.