Where to connect water meters outputs to z-uno shield

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

No problem.
The problem could be on the water meter pulse emitter and not on HC3.
To check that how can i simulate a water meter connected for example to the z-uno shield pin 7?
That way i can be sure that the code/configuration of the z-uno is correct. (on the serial monitor confirm that a pulse was received)

Please advice

Thank you
User avatar
PoltoS
Posts: 7594
Joined: 26 Jan 2011 19:36

Re: Where to connect water meters outputs to z-uno shield

Post by PoltoS »

Just connect pin 7 to ground and it will emulate a meter tick
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

Hi

Apparently the problem is on z-uno hardware or on the code I used.
Let me explain.
z-uno board is configured this way
https://z-uno.z-wave.me/shield/configur ... C&pin12=NC

So pin 7 and 8 should be ok.
To avoid more variables I changed on the example available the lines bellow
#define PIN_COLD 7
#define PIN_HOT 8

I Connected pin 7 to ground and nothing on the serial monitor
Tried the same with pin 8 and also nothing on the serial monitor.
Bellow the complete code I used this time. As you can confirm when there is a tick on pin 7 or 8 that information should be sent to the serial monitor.
Is my z-uno with some malfunction?. Is there a easy way to confirm it?.

Thank you

/*
* This is a simple 2 chennel meter example
* (c) Z-Wave.Me 2016
*/

#include <EEPROM.h>

// channel number
#define ZUNO_CHANNEL_NUMBER_COLD 1
#define ZUNO_CHANNEL_NUMBER_HOT 2

#define PIN_COLD 7
#define PIN_HOT 8

#define PIN_PULSE 13

#define EEPROM_ADDR 0x800
#define EEPROM_UPDATE_INTERVAL 120000

#define TICK_VALUE 1 // in liters


struct meter_data
{
unsigned long ticks_cold;
unsigned long ticks_hot;
byte crc8;
};

meter_data my_meter_data;

unsigned long last_update_millis = 0;
byte data_updated = FALSE;

#define DEBOUNCE_COUNT 3
byte cold_triggered = 0;
byte cold_debounce = DEBOUNCE_COUNT;
byte hot_triggered = 0;
byte hot_debounce = DEBOUNCE_COUNT;



// next macro sets up the Z-Uno channels
// in this example we set up 1 meter channel
// you can read more on http://z-uno.z-wave.me/Reference/ZUNO_S ... ULTILEVEL/
ZUNO_SETUP_CHANNELS(ZUNO_METER(ZUNO_METER_TYPE_WATER, METER_RESET_ENABLE, ZUNO_METER_WATER_SCALE_METERS3, METER_SIZE_FOUR_BYTES, METER_PRECISION_THREE_DECIMALS, getterCold, resetterCold),
ZUNO_METER(ZUNO_METER_TYPE_WATER, METER_RESET_ENABLE, ZUNO_METER_WATER_SCALE_METERS3, METER_SIZE_FOUR_BYTES, METER_PRECISION_THREE_DECIMALS, getterHot, resetterHot));


// For some cases use UART (Serial0/Serial1)
// It's a most comfortable way for debugging
// By default we use built-in USB CDC (Serial)
#define MY_SERIAL Serial

byte my_crc8(byte * data, byte count)
{
byte result = 0xDF;

while(count--)
{
result ^= *data;
data++;
}
return result;
}
void update_meter_data()
{
my_meter_data.crc8 = my_crc8((byte*)&my_meter_data, sizeof(meter_data) - 1);
EEPROM.put(EEPROM_ADDR, &my_meter_data, sizeof(meter_data));
}
void setup() {
MY_SERIAL.begin(9600);
MY_SERIAL.println("Starting Meter...");

// Dry contacts of meters connect to these pins
pinMode(PIN_COLD, INPUT_PULLUP);
pinMode(PIN_HOT, INPUT_PULLUP);

// Get last meter values from EEPROM
EEPROM.get(EEPROM_ADDR, &my_meter_data, sizeof(meter_data));
// Check data

if(my_crc8((byte*)&my_meter_data, sizeof(meter_data) - 1) != my_meter_data.crc8)
{
// Invalid data - reset all
MY_SERIAL.println("Bad eeprom crc8 - init meter data");
my_meter_data.ticks_cold = 0;
my_meter_data.ticks_hot = 0;
update_meter_data();

}

}



void loop() {

if(!digitalRead(PIN_COLD))
{
if(!cold_triggered)
{
cold_debounce--;
if(!cold_debounce)
{
my_meter_data.ticks_cold++;
data_updated = true;
cold_triggered = true;
MY_SERIAL.println("Cold++");
zunoSendReport(ZUNO_CHANNEL_NUMBER_COLD);
}
}
}
else
{
cold_debounce = DEBOUNCE_COUNT;
cold_triggered = false;

}
if(!digitalRead(PIN_HOT))
{
if(!hot_triggered)
{
hot_debounce--;
if(!hot_debounce)
{
my_meter_data.ticks_hot++;
data_updated = true;
hot_triggered = true;
MY_SERIAL.println("Hot++");
zunoSendReport(ZUNO_CHANNEL_NUMBER_HOT);
}
}

}
else
{
hot_debounce = DEBOUNCE_COUNT;
hot_triggered = false;

}
// To save EEPROM from a lot of r/w operation
// write it once in EEPROM_UPDATE_INTERVAL if data was updated
if(data_updated && ( millis() - last_update_millis ) > EEPROM_UPDATE_INTERVAL )
{
update_meter_data();
data_updated = false;
last_update_millis = millis();
MY_SERIAL.println("Updating EEPROM");
}
delay(100);

}


void resetterCold(byte v) {
my_meter_data.ticks_cold = 0;
update_meter_data();
MY_SERIAL.println("Cold meter was reset");
}
void resetterHot(byte v) {
my_meter_data.ticks_hot = 0;
update_meter_data();
MY_SERIAL.println("Hot meter was reset");
}

unsigned long getterCold(void) {
return my_meter_data.ticks_cold*TICK_VALUE;
}
unsigned long getterHot(void) {
return my_meter_data.ticks_hot*TICK_VALUE;
}
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

The z-uno configuration board link that I sent above is not ok. The correct one is the one you sent me. For some reason o tried to copy it but the results are different.
Thank you
User avatar
PoltoS
Posts: 7594
Joined: 26 Jan 2011 19:36

Re: Where to connect water meters outputs to z-uno shield

Post by PoltoS »

Please add MY_SERIAL.println(digitalRead(PIN_COLD)) in the beginning of the loop - will you see values?
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

Hi
The serial monitor is always sowing 1.
Connecting pin 7 to ground or not.
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

I done also the test with pin 8 same results
Of course I added instead the following line
MY_SERIAL.println(digitalRead(PIN_HOT))

To end I configured the board to use pin 11 and 12 (no jumpers on the board).
With the following change on the code.
#define PIN_COLD 11
#define PIN_HOT 12

Same results.
I don't understand what is happening.
The z-uno board is with a malfunction?
The problem is with z-uno?

Thank you
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

I took z-uno out of the board.
change the code to use pin 0 and 1.
connected ground to pin 0 and ground to pin 1 and is working just fine.
So the problem is when I connect z-uno to the board.

If the configuration that I have done on the board is correct and also the changes on the code why is not working?
What am I doing wrong?
Thank you
User avatar
PoltoS
Posts: 7594
Joined: 26 Jan 2011 19:36

Re: Where to connect water meters outputs to z-uno shield

Post by PoltoS »

So, withtout the Shield pins 7, 8, 11, 12 do not work, while without the Shield they do?
jadlr
Posts: 14
Joined: 24 Jul 2020 22:32

Re: Where to connect water meters outputs to z-uno shield

Post by jadlr »

Hi
Don't tested that.
With the Shield pins 7, 8, 11, 12 don't work
Without the shield i only tested pin 0 and 1 that worked perfectly (where the pin's that were used on the water meter example ).
Today i have no access to the shield but tomorrow i will do the test on z-uno without shield on pin 7,8,11 and 12 and i will report to you.
Thank you
Post Reply