Go Down

Topic: Reading Flowmeter Pulse Output (Read 224 times) previous topic - next topic


I have used Arduino Uno, Mega and D1 to read the pressure sensor analogue output with no problem. These sensors have 3 wires and require power from the Arduino board.
Now, I have a flowmeter that only has two wires. It is one for analogue output and one for GND (I guess). The device voltage output shows fine on this data logger which shows voltage of 0.06v and 1.43v when the flowmeter working (each voltage change means 10 Lit).

Data logger that shows the voltage right:

This is the flowmeter that creates pulse output or simply two voltage value when some flow observed.


Now when I connect the flowmeter to A0 and GND (which works fine on the above datalogger) I get varying values which doesnt mean much.

This is one sample code I use that works fine with pressure sensor:
Code: [Select]


  Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

unsigned long duration;
unsigned long timeR;
unsigned long timeOld;
float voltageOld = 0;
int frequency=0;
int sensorValue;
float voltage=0;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(A0, INPUT);

// the loop routine runs over and over again forever:
void loop() {

  // print out the value you read:
    //duration = pulseIn(A0, LOW);
          //Calculate pulse
            // read the input on analog pin 0:
            sensorValue = analogRead(A0);
            // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
            voltage = sensorValue * (500 / 1023.0);
            timeR = millis();
            if((voltage-voltageOld)<-20) {
              } else {
                 frequency = frequency+timeR-timeOld;
            voltageOld = voltage;
            timeOld = timeR;


Try adding a 10k pull up resistor from +5v to A0.

(The sensor is probably a reed switch that alternates between open circuit and shorted to ground.)


It is not an analog value, using analogRead is meaningless.

The two wires connect to a reed switch that closes when the impeller wheel moves a magnet close to the switch. Change the input setup to be "pinMode(A0, INPUT_PULLUP);" and you do not need an external resistor*. Wire the switch to A0 and GND. You then read the frequency of the digital input which is the flow rate. You can use this to get started:


*- you may need 2 to 5k external resistor, it depends on how far away the flowmeter is from the Arduino. The internal pullup is fine for testing.
Vacuum tube guy in a solid state world


@mikb55 It works perfectly. Thanks


The data sheet mentions indeed that there's a MTKD-N version of the meter which has a reed switch as output. Most like that's the one you have. Enabling the internal pull-up should do the job.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


yes, it is just a magnet sitting on top of handle. Its fairly simple setup


Simple yet efficient :-)
For low power setups also much better than those power hungry hall effect sensors...
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up