Need Project Help: Using a mechanical flow meter with Arduino

Hello! I am attempting to count revolutions of a mechanical flow meter (a Gurley Price 622) using a script I augmented from another study (the study is linked below and the script is found on the last few pages. I tried to copy and paste it here but the formatting is lost, my apologies). The flow meter I am using completes a circuit each rotation, so I have 3.3v powering it from my Arduino Uno and I am reading when the circuit is complete with the A0 analog pin. I am able to read when a revolution is complete via the serial monitor but I am only getting a value of 0.2 for any given revolution instead of an actual velocity (the faster the flow meter spins a value of 0.2 is given more frequently). The script I augmented was written for use with this flow meter but with additional instrumentation. I would like to have a velocity value instead of simply noting when a revolution has occurred; how might I go about doing that? My end goal is to hook up a Adalogger feather to my Uno and have revolution data as well as time written to the SD card on the Adalogger. I am a complete Arduino noob so I would appreciate any tips on integrating a Adalogger feather as well. Thank you for any tips or advice your willing to share!

Study I got script from (script on last 4 pages):
https://scholars.unh.edu/cgi/viewcontent.cgi?article=1147&context=honors

#include <SoftwareSerial.h>
#include <stdlib.h>

unsigned int flowcount=0;     //revolutions counter
float revs=0.0;     //revolutions per second
float velocity=0.0;   //calculated velocity in feet per second
unsigned long startflow = 0;  //loop counter
unsigned int flow=HIGH;  //sets the flow reader to HIGH to avoid incorrect readings
int duration=12000;   //run counter for 12 seconds
void setup()
{
 duration=(duration/1000);
Serial.begin(9600);
}
void loop()
{
 startflow=millis();
 while (millis()-startflow<duration)
{
 //read the input on analog pin 0:
 int sensorValueNew=analogRead(A0);
 //software Debouncing
 if (sensorValueNew>=200)
{
 delay(50);
 sensorValueNew=analogRead (A0);
 if(sensorValueNew<=200)
 {
   flowcount++;
 }
}
}

if(flowcount==0)
{
 revs=0;
 velocity=0;
}
else
{
 revs=(float)flowcount/(float)duration;
 velocity=2.2048*(revs)+0.0178;
}
//Print Velocity to Monitor
Serial.print("velocity=");
Serial.println(velocity);
{
flowcount=0;
}
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Use a digital input for the digital signal (1 pulse/rev). See the StateChangeDetection example for code ready to count the revs.

3.3V will be detected reliably as HIGH on a digitalRead(). But why using 3.3V instead of 5V for that?

For speed, measure the time passed between two (or more) rising edges of the detector. Each rising edge is exactly one rotation.

Thank you for your replies! I have decided to go a different route and use a change detection example script to count the interval between when the switch is open. I have been getting some good results, I will post my script on here soon (its on my laptop). I am using this flow meter to measure discharge rates of a tile drain pipe, so if anyone has a similar project I would be happy to help!

That meter looks like an anemometer for water instead of wind with a break-beam photo detector, click the search icon at top of page searchIcon.png and type "anemometer".
https://datasheets.globalspec.com/ps/1562/gurley/653BC88E-2ED6-4D2A-A429-70BA2FA417B8

searchIcon.png