Pulse Water Meter

Hi guys.

I am wanting to measure the pulse from a water meter such as the one attached.

This will correspond to a liter used which I can report on.

Thought this would have been done multiple times but struggling to find an example. Would the two wires simply be connected to a ground and digital input and then just measure the state of the pin multiple times.

Thanks in advance

water meter.jpg

A photo of a water meter is of little use for answering your question. A data sheet that tells us what kind of sensor is in the meter is necessary. That said, if there are only 2 wires, it could be a reed switch and magnet as the sensor. Then the connection would be one wire to ground and the other to an input set to pinMode(INPUT_PULLUP). You will need to debounce the switch in software.

But you need a data sheet to be sure.

Coincidentally I just bought a DAE MJ-50 turbine flow meter that looks similar to yours. http://daecontrols.com/downloads/MJ%20datasheet-1.3us.pdf

Firstly check that the model you are intending to use gives the resolution you need. Different models position the sensor over different dials to give a pulse every 0.1, 1, 10 or 100 gallons (378 litres).

The picture you provided shows the sensor over the 1 gallon dial which has 10 divisions and therefore will give a pulse every 10 gallons (37.8 litres). Is this resolution good enough for your needs? Check that the product image actually matches the model number which in turn will tell you the volume delivered per pulse.

On the DAE MJ-50 the sensor is a reed switch with 2 wires and is read the same way as you would read a mechanical switch using a pull up resistor and a digital input. If yours also uses a reed switch then pick a resistor value that limits the current to a few milliamps. Connecting 5v and ground directly to the 2 wires will destroy the switch.

Note that at very low flow rates the meter will not register any flow at all. You need a minimum flow rate to overcome the internal friction of the components.

Thanks guys, yes it is a reed switch water meter.

Any chance of seeing your code for your project mikb55.

Thanks Brad

Here is the code I have come up with, just tested from pin2 to ground before attaching the water meter. Now just have to upload this through the Ethernet hat to a ip address as a csv file.

// Water Meter repetition counter

int pulse1 = 2;
int counter1 = 0;
long lastDebounce1 = 0;
long debounceDelay = 500;   // Ignore bounces under 1/2 second, need to calibrate with water meter

void setup() {
  pinMode(pulse1, INPUT_PULLUP); //Pullup internal resister
  digitalWrite(pulse1, HIGH);
  attachInterrupt(0, trigger1, FALLING);
  Serial.println("Water Pulse");

void loop() {
  // Count and total pulses

void trigger1() {
  if ( (millis() - lastDebounce1) > debounceDelay) {
    Serial.print(" ");
    lastDebounce1 = millis();

Have a look at the StateChange example in Arduino>Files>Examples>Digital It works quite well with your sort of application (I use it with water and gas flow meters) You might also look at interrupts - examples in textbook Practical Arduino, pulse counting in Arduino Cookbook or Nick Gammon's articles (Gammon.au) on interrupts. Reed switches will need some form of debouncing in software or in hardware (CR filter and Schmitt trigger) - the Practical Arduino example takes you through exactly what you want. Your code looks as though you are heading in the right direction. Another source of information is OpenEnergy.org who deal with meter pulse counting

Thanks Guys, one more enhancement.

The current output is

1 2 3 4 5 6 7 8 9

How would I change this just to show the max value, ie 9 in this case and then 10.

Also is there a limit to the number it can count to?


bradhnz: Also is there a limit to the number it can count to?

Yes: 32,767 (after which it goes to -32,768 and continues to count up). For higher numbers: make it an unsigned int (up to 65,535) or unsigned long (up to 4,294,967,295). You can never have negative numbers in this counter, so it's good practice to make it an unsigned type to begin with. If you will never count past 255, you can use a byte instead, and save a byte of memory.

Thanks wvmarle, I will need to change that to assigned long I think as will be counting around 40,000 pulse per day or 40 thousand liters.

Any ideas on modifying current output

1 2 3 4 5 6 7 8 9

to just to show the max value, ie 9 in this case. This will be writing a csv file every 10 minutes to the sd card with just the max value?


Don't print any values until you know you have a maximum or it's time to log?

Its a rolling total so it needs to replicate this line to csv every 10 minutes

//-->2018-03-15 20:16:00;P01:5000

next 10 minutes

//-->2018-03-15 20:16:10;P01:5500

so in this case I know I have used 500 pulses or 500 litres in the last 10 minutes.

Thanks Brad

Well, then it's easy. Just print the value every 10 minutes. If you use an unsigned int it will simply roll over to 0 when you reach 65535, nothing you have to do about that other than make whatever software is processing the csv file aware of the possibility.