I am doing a project where I will use a flow sensor to measure the fuel consumption of an engine. However, I am only doing a test setup for now and the liquid I am using is just water. I am using a flow sensor with the following specifications:
I am using a code I found from a blog (see Flow Sensor code. Although the person is using a different flow sensor from mine.
I am actually getting a value but when I compare the value using the volumetric method (I collect the water and record the volume from a predetermined time of 10 secs). The value I am getting from the Arduino code is smaller compared to the volumetric method. For example, when I get 24 L/h from the code, my calculated flow rate using the volumetric method is 115 L/h. It's too big of a margin.
I already tried configuring the code a little bit by changing the "7.5" to 9. I obtained the value 9 from the specs of the flow sensor (180 Hz / 20 L/min = 9). Although I have no idea if that is correct.
I'd like to ask for advice in order to properly calibrate the values I am getting from the sensor.
Thank you!
Code:
/*
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: www.hobbytronics.co.uk
*/
volatile int flow_frequency; // Measures flow sensor pulsesunsigned
int l_hour; // Calculated litres/hour
unsigned char flowsensor = 2; // Sensor Input
unsigned long currentTime;
unsigned long cloopTime;
void flow () // Interrupt function
{
flow_frequency++;
}
void setup()
{
pinMode(flowsensor, INPUT);
digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
Serial.begin(9600);
attachInterrupt(0, flow, RISING); // Setup Interrupt
sei(); // Enable interrupts
currentTime = millis();
cloopTime = currentTime;
}
void loop ()
{
currentTime = millis();
// Every second, calculate and print litres/hour
if(currentTime >= (cloopTime + 1000))
{
cloopTime = currentTime; // Updates cloopTime
// Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
l_hour = (flow_frequency * 60 /7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
flow_frequency = 0; // Reset Counter
Serial.print(l_hour, DEC); // Print litres/hour
Serial.println(" L/hour");
}
}
I once installed a flow sensor to the petrol line into the carburettor in the car.
One important piece of data was the diagram showing pulses versus flow rate. That sensor was highly none linear.
Can You provide those data for that sensor?
Unfortunately, the datasheet of the sensor does not provide the diagram showing the pulses versus flow rate. I am still trying to contact the manufacturer for the said diagram. For now, I only have this kind of diagram to show:
From rough calcs the sensor output is non-linear, and the flow rate/frequency output is determined by the output plumbing sizing.
You would need to do testing of measureing the freq out at various flow rates to apply the Kfactor into the formula,utilizing the pipe sizing of the final application.
The charting is indicating flow rate in gallons per minute , therefore you need to determine if it is US gal. or Imperial and convert to Litres.
The non-linear output could be applied into the Multi Map function to provide an accurate output off L/min.
Bit of work faffing around but quite doable.........HTH.