Water flow sensor connection to Uno Board with pull up resistor

Hi everybody.

I am a newbie to Arduino.
I am trying to get flow rate from the GEMS 173939-C flow sensor with my Arduino Uno board. (flow sensor datasheet: https://docs.rs-online.com/7c18/0900766b8023e8dd.pdf)

Some key facts about the sensor:
5-24VDC supply @ 8mA, frequency output max. 50mA (1k-2.2k pull-up resistor required)
flow range 1-15 L/min, 2200 pulses/L, frequency output 37-550Hz

I have connected the supply (red) and output (brown) cables with a 2.2k ohm resistor. (it was the only fitting resistor I had). The rest of the pin connections can be seen in the image "connections.jpg".

The input pin of the flow sensor is 3 and I have enabled the internal pull up. I am not sure whether this actually a) makes a difference because my serial output stays the same b) can replace the hardware pull up resistor from the datasheet?

The frequency I read with interrupts for falling edge (since pull-up). I then calculate the flow rate with following formula: flow rate [L/min] = (frequency [1/s] * 60) / 2200 [pulses/L]

I output the flow rate on the serial monitor. Currently, I am getting 0 the whole time. I do not know if this is because of a wrong hardware connection or a problem in my code. Perhaps, the 2.2k ohm is too high? The current of the output signal is 5V / 2200 ohm = 2mA... Any help appreciated!!

My whole code is below:

const int LED = 13;
const int interruptpin = 3;

volatile int count;
volatile int copy_count;

float flowrate;

unsigned long oldtime;

void flow()

void setup()

  pinMode(LED, OUTPUT);
  pinMode(interruptpin, INPUT); 
  digitalWrite(interruptpin, HIGH); // internal pull-up 

  count = 0;
  flowrate = 0;
  oldtime = 0;

  attachInterrupt(digitalPinToInterrupt(interruptpin), flow, FALLING);  

void loop()
  if((millis() - oldtime) > 1000)
    // detachInterrupt(digitalPinToInterrupt(interruptpin));
    copy_count = count;
    count = 0;
    flowrate = copy_count * 60 / 2200; // flowrate in L/min

    oldtime = millis();

    Serial.print("Flowrate : ");
    Serial.print(" \r\n");

Do you can monitor changes of "copy_count"?

copy_count is 0 all the time. Doesn't change

try this.

tried it. no change : ( still receiving 0 on copy_count

Take a cable one side connected to GND and simulate a sensor input at the interrupt pin.

I don't quite understand sorry. How would I simulate the sensor input?

Take a cable check
connect one side of cable to GND check
connect the other side to the interrupt pin (pin3) multiple check
monitor changes of the variable "copy_count" check

Okay, so I connected my interrupt pin with GND. Removing/inserting the cable ends into the pins causes a change in copy_count.

  • removing/inserting cable on interrupt pin --> copy_count changes by ca. 1-5 counts
  • removing/inserting cable on GND --> copy_count changes by ca. 1-15 counts

and now reconnect the sensor and test again

no change in copy_count.

I tried connecting a push-button. Every time the button is pushed, copy_count changes. I am guessing, that the hardware connection with the flow sensor is problematic. Maybe the 2.2k ohm resistor is too high? But 8mA is not that small when taken into account the fact, that the maximum current is supposed to be 50mA.

An external resisitor is not necessary due to the used pinMode.

removed the external resistor. sadly, still no change in copy_count

Do you have a flow through the sensor?
If yes and no changes of variable "copy_count" --> sensor defect.

It sounds like the actual wiring doesn't match the diagram you provided, or else (thinking out of the box) maybe there is no flow to measure.

Please post images of all the actual wiring.

The sensor output could drive an LED directly although dimly, sufficient to troubleshoot the sensor separately from the Arduino.

Thanks, that looks reasonable. What about flow through the sensor? I see an inert sensor sitting on a table.

Sorry, what do you exactly mean? :sweat_smile: The sensor on the table is the flow sensor... https://at.rs-online.com/web/p/durchflusssensoren/4468309/

blow into the sensor and see what happens, simply.