Page 1 of 1

Issues with using more than 7 Channels - Z-uno

Posted: 28 Jun 2020 03:28
by rommac100
So I have been trying to get a 16 port relay board working with the Z-Uno so that I can control my irrigation system using z-wave. I have already tested that all of GPIOs going to the relays work fine (which they do) but I have issues when I try to trigger the relay using the z-wave protocol. Specifically, I try to send a on command to any channel above 7 and it behaves weirdly. Specifically, Channel 8 does not work at all but Channel 9 through 15 (I only need 15 of the 16 relays) start triggering relays 1 through 8. I have already verified that homeseer and my Z-Troller are sending the correct commands. I also tried changing the order of the Channel declaration in my script and it still had similar issues. For clarification purposes, I am using the Arduino IDE 1.6.5, and the Z-Uno library version 2.1.5. My current script is attached. I would appreciate any assistance.

Code: Select all

/ RELAY PINS:
#define RELAY_PIN_1 0
#define RELAY_PIN_2 1
#define RELAY_PIN_3 17
#define RELAY_PIN_4 18
#define RELAY_PIN_5 19
#define RELAY_PIN_6 20
#define RELAY_PIN_7 21
#define RELAY_PIN_8 7
#define RELAY_PIN_9 8
#define RELAY_PIN_10 9
#define RELAY_PIN_11 10
#define RELAY_PIN_12 11
#define RELAY_PIN_13 14
#define RELAY_PIN_14 15
#define RELAY_PIN_15 16
//saved states

byte curr_relay_states[15];

ZUNO_SETUP_CHANNELS(
  ZUNO_SWITCH_BINARY(get_relay_1,set_relay_1),
  ZUNO_SWITCH_BINARY(get_relay_2,set_relay_2),
  ZUNO_SWITCH_BINARY(get_relay_3,set_relay_3),
  ZUNO_SWITCH_BINARY(get_relay_4,set_relay_4),
  ZUNO_SWITCH_BINARY(get_relay_5,set_relay_5),
  ZUNO_SWITCH_BINARY(get_relay_6,set_relay_6),
  ZUNO_SWITCH_BINARY(get_relay_7,set_relay_7),
  ZUNO_SWITCH_BINARY(get_relay_8,set_relay_8)
);

//zuno setup channels

void setup() {
  /** 
   * Effectively just set all GPIOs to output 
   */
  pinMode(RELAY_PIN_1, OUTPUT);
  pinMode(RELAY_PIN_2, OUTPUT);
  pinMode(RELAY_PIN_3, OUTPUT);
  pinMode(RELAY_PIN_4, OUTPUT);
  pinMode(RELAY_PIN_5, OUTPUT);
  pinMode(RELAY_PIN_6, OUTPUT);
  pinMode(RELAY_PIN_7, OUTPUT);
  pinMode(RELAY_PIN_8, OUTPUT);
  pinMode(RELAY_PIN_9, OUTPUT);
  pinMode(RELAY_PIN_10,OUTPUT);
  pinMode(RELAY_PIN_11,OUTPUT);
  pinMode(RELAY_PIN_12,OUTPUT);
  pinMode(RELAY_PIN_13,OUTPUT);
  pinMode(RELAY_PIN_14,OUTPUT);
  pinMode(RELAY_PIN_15,OUTPUT);
  set_relay_1(0);
  set_relay_2(0);
  set_relay_3(0);
  set_relay_4(0);
  set_relay_5(0);
  set_relay_6(0);
  set_relay_7(0);
  set_relay_8(0);
  set_relay_9(0);
  set_relay_10(0);
  set_relay_11(0);
  set_relay_12(0);
  set_relay_13(0);
  set_relay_14(0);
  set_relay_15(0);
}

void loop() {
  

}

// set state functions:

/*
 *  Set functions for the Z-Wave controller,
 *  Effectively, set HIGH  when it should be off, and set 1 or zero (in this case zero is used) when the relay should be on/closed
 */
void set_relay_1(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_1, LOW);
  else
    digitalWrite (RELAY_PIN_1, HIGH);
  curr_relay_states[0] = value;
}

void set_relay_2(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_2, LOW);
  else
    digitalWrite (RELAY_PIN_2, HIGH);
  curr_relay_states[1] = value;
}
void set_relay_3(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_3, LOW);
  else
    digitalWrite (RELAY_PIN_3, HIGH);
  curr_relay_states[2] = value;
}
void set_relay_4(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_4, LOW);
  else
    digitalWrite (RELAY_PIN_4, HIGH);
  curr_relay_states[3] = value;
}
void set_relay_5(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_5, LOW);
  else
    digitalWrite (RELAY_PIN_5, HIGH);
  curr_relay_states[4] = value;
}
void set_relay_6(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_6, LOW);
  else
    digitalWrite (RELAY_PIN_6, HIGH);
  curr_relay_states[5] = value;
}
void set_relay_7(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_7, LOW);
  else
    digitalWrite (RELAY_PIN_7, HIGH);
  curr_relay_states[6] = value;
}
void set_relay_8(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_8, LOW);
  else
    digitalWrite (RELAY_PIN_8, HIGH);
  curr_relay_states[7] = value;
}
void set_relay_9(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_9, LOW);
  else
    digitalWrite (RELAY_PIN_9, HIGH);
  curr_relay_states[8] = value;
}
void set_relay_10(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_10, LOW);
  else
    digitalWrite (RELAY_PIN_10, HIGH);
  curr_relay_states[9] = value;
}
void set_relay_11(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_11, LOW);
  else
    digitalWrite (RELAY_PIN_11, HIGH);
  curr_relay_states[10] = value;
}
void set_relay_12(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_12, LOW);
  else
    digitalWrite (RELAY_PIN_12, HIGH);
  curr_relay_states[11] = value;
}
void set_relay_13(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_13, LOW);
  else
    digitalWrite (RELAY_PIN_13, HIGH);
  curr_relay_states[12] = value;
}
void set_relay_14(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_14, LOW);
  else
    digitalWrite (RELAY_PIN_14, HIGH);
  curr_relay_states[13] = value;
}
void set_relay_15(byte value)
{
  if (value >0)
    digitalWrite (RELAY_PIN_15, LOW);
  else
    digitalWrite (RELAY_PIN_15, HIGH);
  curr_relay_states[14] = value;
}

// get state functions
/*
 * Just retreves the current state and returns it to the Z-Wave Controller.
 */
byte get_relay_1()  {return curr_relay_states[0];}
byte get_relay_2()  {return curr_relay_states[1];}
byte get_relay_3()  {return curr_relay_states[2];}
byte get_relay_4()  {return curr_relay_states[3];}
byte get_relay_5()  {return curr_relay_states[4];}
byte get_relay_6()  {return curr_relay_states[5];}
byte get_relay_7()  {return curr_relay_states[6];}
byte get_relay_8()  {return curr_relay_states[7];}
byte get_relay_9()  {return curr_relay_states[8];}
byte get_relay_10()   {return curr_relay_states[9];}
byte get_relay_11()   {return curr_relay_states[10];}
byte get_relay_12()   {return curr_relay_states[11];}
byte get_relay_13()   {return curr_relay_states[12];}
byte get_relay_14()   {return curr_relay_states[13];}
byte get_relay_15()   {return curr_relay_states[14];}

Re: Issues with using more than 7 Channels - Z-uno

Posted: 28 Jun 2020 23:12
by PoltoS
You have 15 getters and setters, but only 8 of them are exposed in ZUNO_SETUP_CHANNELS

Re: Issues with using more than 7 Channels - Z-uno

Posted: 29 Jun 2020 00:39
by rommac100
Oops I uploaded an older version of the code. But the problem still applies to the uploaded one. Instead for whatever reason the 8th Channel is present on the homeseer interface but does not activate any of the relays. I also tested this problem with 9 channels and I ended up having the eight channel not working and then the 9th channel looping back and activating the 1st channel. I also tested whether the problem still exists if I set half of the 15 channels to be Dimmers instead. When I do this I can get the eight channel to trigger but the rest of the channels trigger nothing.

Re: Issues with using more than 7 Channels - Z-uno

Posted: 29 Jun 2020 04:09
by Adbhatti
very useful code thanks :D

Re: Issues with using more than 7 Channels - Z-uno

Posted: 29 Jun 2020 10:53
by PoltoS
HS3 is known for mixing channels when there are many Z-Uno swithes. Please have a look on their forums and here. No idea how to overcome it since it is a HS3 bug

Re: Issues with using more than 7 Channels - Z-uno

Posted: 25 Jul 2020 21:16
by rommac100
Yup you were correct about it being homeseer's fault as I was able to use more than 7 channels on Home Assistant and I analyzed the packets that were being sent out from HS3 and they were being capped at channel 7 and looping back over to 1.