Water meter with 4 pulses pr. litre connect to Arduino

Hi,

I have played around with 3 wire hall sensors, but now i am aiming for a better and more expensive water meter.

I want to count how many litres that have passed on each session.

For this purpose i have purchased a WMT030C1D0 water meter with pulse-output. There are 2 wires (black and red).

Since my Hall sensor program doesn't count pulses, i need to make a new program.

How do i connect the wires, and how do i make a simple pulse counter?

How do i connect the wires

What do you want to connect them to? Post a link to the device you want to connect to the Arduino (and not some useless e-bay advertisement).

If there are only 2 wires, it is likely that one is ground and the other is digital or analog (HIGH or LOW when a pulse happens, or ramping up and down quickly around the pulse).

PaulS:
What do you want to connect them to? Post a link to the device you want to connect to the Arduino (and not some useless e-bay advertisement).

I want to connect it directly to a Arduino Mega or Uno.

I agree that it would be simple to assume that the wires should connect to +5v and a Digital pin, but i need a little more help please.

Just as long as i can get a reading, i can construct the rest of the program around it myself.

but i need a little more help please.

Then you need to post a link to the device. I am not going to tell you to connect the red wire to pin 7 and the black wire to ground, and then have you complain about all the smoke and sparks, without seeing just what it is you want to connect, and what the voltage and amperage are likely to be.

xelot:
Since my Hall sensor program doesn't count pulses,

Really? I wonder what it did do.

Nick_Pyner:
Really? I wonder what it did do.

I've never seen a hall effect sensor that could COUNT pulses. DETECTing magnets is a different story. The Arduino should do the counting.

Just being pedantic because I'm bored.

Here's the datasheet:

http://www.reciprotor.com/files/varer/seko/new-seko-water-meters-catalogue.pdf

The model i want to use is WMT030C1D0

xelot:
Here's the datasheet:

That is not the sort of datasheet that we need. It does not explain the electrical characteristics of the device or whether it can be connected to any microprocessor or if it needs a specialized proprietary reading device.

...R

Hi,
Is there anything written on the housing or where the two wires that come out of it to identify what they are?

Thanks.. Tom.. :slight_smile:

xelot:
For this purpose i have purchased a WMT030C1D0 water meter with pulse-output. There are 2 wires (black and red).

Since you have purchased it, hopefully you have done so with more knowledge than is given on the datasheet you have given us. By two wires, I guess the meter has a reed switch, as I understand they are common for this. I don't suppose there is any point in asking what the hall sensor programme you are currently using does, but you may possibly find that it is adaptable with no more than changing the count factor to suit. All you need is a better understanding of it.

Nick_Pyner:
Since you have purchased it, hopefully you have done so with more knowledge than is given on the datasheet you have given us.

Not really, i figured it was a simple counter of a LOW/HIGH on a digital pin.

Nick_Pyner:
By two wires, I guess the meter has a reed switch, as I understand they are common for this. I don't suppose there is any point in asking what the hall sensor programme you are currently using does, but you may possibly find that it is adaptable with no more than changing the count factor to suit. All you need is a better understanding of it.

My meaning is to measure how many litres that have been collected for each use.

Here's a couple of images

Google Photos

Google Photos

Have you tested the two wires with a multi meter to see if it is indeed a reed switch like Nick_Pyner suggests. That would be my guess as well.

PaulS:
Just being pedantic because I'm bored.

I was never sure before today!

If it has 2 wires and isn’t self-powered then you can guess at what voltage and current it needs. Start low…

I look at the Seko site and they really want you to buy their controller. I’ve seen this kind of thing before.

OK, so i found out that this is indeed a Reed sensor. When i blow through the meter with a multimeter on it, there is 4 pulses per litre.

So now i have written a small program:

//Detect how much water has passed the meter. 
//Reed sensor water meter with red wire (+) and black (-)
//Connected to Arduino uno pin 2 and pin 6


#define give 2
#define recieve 6
int counter=0;
int val=0;
int liter=0;


void setup() {
pinMode(give, OUTPUT);
//pinMode(recieve, INPUT);
Serial.begin(9600);
digitalWrite(give, HIGH);

Serial.println("Ready for data");
}

void loop() {

  val=digitalRead(recieve);

  // put your main code here, to run repeatedly:
  if(val==1){
  counter++;

  }
liter=counter/4;
if(counter %4 ==0){
Serial.print(liter);
Serial.println(" liter");
}
delay(500);

}

I need something in my program to check if the reed sensor is moving. If i start the system, and the reed sensor is side by side to the magnet, it will count on and on. Is there a "onchange" state i can use ?

Your code needs to check that there is a LOW before recognizing and counting a HIGH.

Something like this

prevVal = val;
val = digitalRead(receive);
if (val != prevVal && val == HIGH) {
  counter ++;
}

...R

xelot:
I need something in my program to check if the reed sensor is moving. If i start the system, and the reed sensor is side by side to the magnet, it will count on and on. Is there a “onchange” state i can use ?

You want to detect and track change in pin state over time rather than “always now” pin state.

I use 1 byte per pin. For the no-bounce reed switch I only need 2 bits to track current and previous states as a number I can make a switch-case statement for.

#include “Arduino.h”

const byte switchPin = 7; // these could be arrays to loop through many pins.
byte switchState = 3; // starts as current and previous states are HIGH, with pins moded INPUT_PULLUP, is no press.

void loop()
{

switchState = switchState & 1; // all the bits except bit 0, last read’s current state bit, get cleared.
switchState = switchState << 1; // shifts the bits in switchState up 1. Last current state in moved into previous state bit.
switchState += digitalRead( switchPin ); // and now bit 0 is current read and bit 1 is previous read

switch ( switchState )
{
case 0 : // current and previous states are LOW — no change, switch closed
// code
break;
case 1 : // current state is HIGH and previous state is LOW — change detected, switch opened
// code
break;
case 2 : // current state is LOW and previous state is HIGH — change detected, switch closed
// code
break;
case 3 : // current and previous states are HIGH — no change, switch open
// code
break;
}

}

I only need 1 variable for 2 states and I can compare them by the value they make.

If you get into bit logic you can work with many bits together very fast. An unsigned long will let you work 32 T/F values at once.
http://playground.arduino.cc/Code/BitMath

Robin2:
Your code needs to check that there is a LOW before recognizing and counting a HIGH.

Something like this

prevVal = val;

val = digitalRead(receive);
if (val != prevVal && val == HIGH) {
  counter ++;
}




...R

Works great, but when the sensor is side by side to the magnet, it just counts on and on. My first thought was to time how many millis(); the pin is HIGH, and then somehow prevent more counts until the pin has changed. But i cant seem to figure it out.

Tried this, but with no luck

void loop() {

prevVal=val;
val=digitalRead(recieve);


  if(val != prevVal  && val==1){
    while(val==1){
    val=digitalRead(recieve);
    }
    
    counter++; 

  }

Any suggestions ?

If val is zero, you will increment counter on every pass through loop. You need to increment it only when val becomes one. Look at the state change example or try:

void loop() {

prevVal=val;
val=digitalRead(recieve);


  if(val != prevVal  && val==1)
    {
    counter++; 
    }
    

  }