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):

#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()
void loop()
 while (millis()-startflow<duration)
 //read the input on analog pin 0:
 int sensorValueNew=analogRead(A0);
 //software Debouncing
 if (sensorValueNew>=200)
 sensorValueNew=analogRead (A0);

//Print Velocity to Monitor

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,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".