PDA

View Full Version : Reading The Flow Rate of your water cooling loop with an Arduino.



Oneslowz28
08-29-2010, 02:53 AM
This is part of a project I have been working on and I thought I would share it here. The flow meter I am using is the Water Flow Sensor (http://www.seeedstudio.com/depot/water-flow-sensor-p-635.html?cPath=6&zenid=594b89701c7a2015a13064b67aed4f44) found in the Seeed Studio Depo. It uses a simple rotating wheel that pulses a hall effect sensor. By reading these pulses and implementing a little math, we can read the liquids flow rate accurate to within 3%. The threads are simple G1/2 so finding barbed ends will not be that hard. I found some at lows for $1.89 each.


http://www.seeedstudio.com/depot/images/large/product/flowsensor_LRG.jpg

You will need
Seeeduino / Arduino
Water Flow Sensor
10K resistor

Wiring up the Water Flow Sensor is pretty simple. There are 3 wires: Black, Red, and Yellow.
Black to the Seeeduino's ground pin
Red to Seeeduino's 5v pin
The yellow wire will need to be connected to a 10k pull up resistor.and then to pin 2 on the Seeeduino.

Here is a fritzing diagram I made to show you how to wire it all up.

http://themakersworkbench.com/sites/default/files/images/water_flow.jpg

Once you have it wired up you will need to upload the following code to your Seeeduino. Once it is uploaded and you have some fluid flowing through the Water Flow Sensor, you can open the serial monitor and it will display the flow rate, refreshing every second.



// 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 sensors 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

initialised,
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
}



I hope this helps someone out! Thank's to Seeed Studio for hooking me up with a sensor so I could develop this tutorial.

Drum Thumper
08-29-2010, 10:58 AM
Find me a flow meter that can withstand at least 100C and you will have my curiosity seriously piqued...

x88x
08-29-2010, 03:55 PM
Find me a flow meter that can withstand at least 100C and you will have my curiosity seriously piqued...

:eek: 100C?!

Also, they're expensive, but I bet one of these would handle those temps:
http://www.surplussales.com/Switches/Flow.html

Oneslowz28
08-29-2010, 08:01 PM
The one I am using is good to 80c but I have seen some during my searches that can withstand 120c, they are a bit pricey though.

Konrad
09-04-2010, 03:58 AM
How can an efficient watercooling loop possibly reach 80C, let alone 100C?

Oneslowz28
09-04-2010, 07:38 AM
I think Drum Thumper is wanting to use this on his Automated Home Brewing system. I have been pestering him for months to use an arduino in the system when he finally builds it.

Konrad
09-04-2010, 08:17 AM
Automated Home Brewing System (AHBS 1.0).

That's awesome! Boggles the mind. Helluva lot more practical than uC logic light organs and weather stations.

jnew513
12-02-2010, 12:07 PM
I've been trying to modify/adapt this code to use with 2 of these flowmeters for use on a water storage tank, however I can't seem to figure out the syntax (or really anything at all) while trying to use 2 flowmeters (instead of just 1, as in the sample code above--which works great for one flowmeter btw).
My overall goal is to calculate the volume of water in a storage tank with a separate inlet and outlet. I have one flowmeter attached to the inlet, and one to the outlet. My (best?) plan now is to calculate each inlet or outlet volume by measuring each inlet and outlet flow rate (as in the sample code above) and then multiply each of these by the timestep between measurements to get each volume that has gone through the inlet and the outlet in that timestep, and then subtract the outflow volume from the inflow volume to get a net volume (in that timestep) that the tank is storing, and continuously adding up these net volumes (for each timestep) to get a continuous output of the total volume of water stored in the tank.
I feel like there might be a more straightforward way of doing this by bypassing the flowrates entirely and just using a counter to calculate each volume, but I'm really stuck either way on how to do this.
Any help (or even a sample code!!) is very appreciated. Thanks

Konrad
12-02-2010, 12:17 PM
Your logic seems right. The only way to simplify (that I can think of) would be to ensure that your flow pumps are equally matched; then you could simply subtract flows directly without any intermediate math.

You might be able to simplify by working in non-uniform units; each component might require some different measure, there is sometimes no need to do extra math/logic operations across the board.

SXRguyinMA
12-02-2010, 12:24 PM
or you could use/make a float type device that's hooked to a potentiometer to read the physical level in the tank, then make the Arduino do some basic math for the tank's size and have it display the current stored volume on an LCD display, and update it every second or as needed :D

I'm currently working on a project to do just this, but with my oil tank for my heat. The tank already has a float gauge, but it requires me to go to the basement every time I want to check my oil level. I plan to attach a lever to the float gauge, then to a potentiometer, and calibrate it so the arduino will wirelessly (or wired, not sure yet) transmit the data to either a webpage or some kind of LCD panel mounted somewhere in my apartment

jnew513
12-02-2010, 01:13 PM
I had thought about doing a float type device, but it's actually a flexible water bladder, not a rigid tank (sorry for the lack of clarification), so measuring volume just using the height of the liquid would be pretty much impossible/very difficult.

The main issue i'm having with this is getting my arduino to read both flowmeters simultaneously. I can't seem to figure out how to adapt the code in this thread to work with two flowmeters

SXRguyinMA
12-02-2010, 02:13 PM
ahhh well that makes sense to do it your way then.

maybe do something similar to my above idea, but use a scale of some sort to move the potentiometer, and calibrate it to the weight of the assembly. weigh it empty and full, and set that at the min/max :think:

as fara s reading both meter at the same time, I have no idea lol

x88x
12-02-2010, 03:04 PM
I haven't looked at the code, so I can't offer any help there atm, but I did notice a potential problem with the concept...the monitor you describe would only measure the delta, not the actual capacity. So, unless every time you start it the res is empty, you won't get a valid value. One workaround would be to incorporate some sort of persistent data storage, and just make sure the monitor is on when you initially fill your loop.

Konrad
12-02-2010, 03:23 PM
If a float sensor in the bag isn't an option, then perhaps a weight sensor?

crenn
12-02-2010, 04:07 PM
To measure 2 flowmeters, you'll need to attach another set of external interrupts on pin 3.

If you wish for more information, I can provide it.

If you wish to do this, you'll either have to have a known amount of water in the bag or have it empty on startup. Will this also be controlling pumps?

jnew513
12-02-2010, 05:15 PM
crenn,

The water bladder will be empty upon startup. If you could provide me with some information on how to convert the flowmeter flowrate readings to a volume, or on how to directly convert the flowmeter readings to a volume, that would be great.

The arduino will be controlling a peristaltic pump to inject liquid disinfectant into the water bladder, and it will also be controlling a motor driving an impeller that mixes the water and disinfectant. I have both the pump and the impeller hooked up to a simple relay to go on/off for some amount of time. The pump has a fixed flow, so the the volume of disinfectant added to the water bladder will solely be a function of the time that the pump is on for, so after the pump has been calibrated/tested, I will know how many seconds of the pump being on equals how much volume of disinfectant that is, etc. The motor running the impeller can just run for some pre-defined constant time, since all it is doing is mixing. The volume of disinfectant to be added will be calculated by knowing the required concentration of disinfectant in water, and thus I need to know the total volume of water in the tank.

I hope this was clear let me know if you have any other questions. Thanks

x88x
12-02-2010, 05:53 PM
OOC, what's the application for this? I, and I'm guessing most everyone else, have been assuming it was a PC liquid cooling system (thus the assumption that the bladder would be full on start)...but it doesn't sound like it from your explanation.

jnew513
12-02-2010, 08:20 PM
Sorry for the lack of clarification throughout---it is not part of a PC cooling system. It is for a university project that I am working on, in which the overall goal is to automate the addition of the correct amount of a disinfectant into water storage bladder for long term storage (like when you fill up a water bottle and let it sit around for a couple days, and it starts too smell is what we're trying to eliminate) and also to indicate how much water is currently in the water bladder

Oneslowz28
12-03-2010, 01:24 AM
To read from 2 flow meters at once you would need to attach a second interrupt to another sense pin on the atmega. You will not be able to read them both at the exact same time though. One will have to be offset from the other. As for fluid level, you couldn't use something like a fuel level sending unit? They are fairly cheap... I bet you could find some micro liquid level sending units online somewhere. Or maybe you could use some sort of thermostatic strip that was attached to the outside of the bladder and it could tell the water level by reading the temperature difference at the water line.