Hi experts,
I am using a flow sensor to measure the flowrate of my pump. It does not give me consistent value and bounces intermittently. Is there anyway I can filter the bouncy values ?
this is my code:
volatile int noRisingEdgeTopsFan;
float flowLPM=0.00;
float flowOzM=0.00;
#define factorOz 33.814 //for litre to ounces.
#define sensorInput 2 // arduino pin
void rpmRW ()
{
noRisingEdgeTopsFan++;
}
void setup()
{
pinMode(sensorInput, INPUT);
Serial.begin(9600); // Keep the same value in Serial Monitor
attachInterrupt(0, rpmRW, RISING);
}
void loop ()
{
noRisingEdgeTopsFan = 0;
sei(); //interrupt enabled
delay (1000); //delay
cli(); // interrupt cleared
flowLPM = float(noRisingEdgeTopsFan)/11; // datasheet F= (11*Q)+/-3%
flowOzM = factorOz* float(flowLPM);
Serial.print("Pulses:");
Serial.print (noRisingEdgeTopsFan);
Serial.print("\t");
Serial.print (int(flowOzM));
Serial.print (" Oz/min\r\n");
}
and my Serial monitor