Не отображаются несколько датчиков движения в HC2 + Z-Uno

Данный раздел предназначен для русскоязычных пользователей. Если вы владеете английским, рекомендуем также просмотреть общую ветку обсуждений на английском.
Post Reply
Krash1991
Posts: 1
Joined: 18 Apr 2017 14:11

Не отображаются несколько датчиков движения в HC2 + Z-Uno

Post by Krash1991 »

За основу был взят скетч на добавление 10 устройств, https://z-uno.z-wave.me/examples/Certified10Channels/. Оставил лишь датчик движения и размножил их до 9 штук, при этом компиляция и загрузка на Z-Uno прошла успешно. Но при добавлении устройств к Fibaro HC2 отображается лишь 1 из 9 датчиков. Подскажите в чем может быть проблема?

Code: Select all

#define MotionPin1 7
#define MotionPin2 2
#define MotionPin3 1
#define MotionPin4 8
#define MotionPin5 9
#define MotionPin6 10
#define MotionPin7 11
#define MotionPin8 12
#define MotionPin9 17


#define SWITCH_ON 0xff
#define SWITCH_OFF 0

// Global variables to store data reported via getters
byte lastMotionValue1 = 0;
word relaxMotion1 = 0;
byte lastMotionValue2 = 0;
word relaxMotion2 = 0;
byte lastMotionValue3 = 0;
word relaxMotion3 = 0;
byte lastMotionValue4 = 0;
word relaxMotion4 = 0;
byte lastMotionValue5 = 0;
word relaxMotion5 = 0;
byte lastMotionValue6 = 0;
word relaxMotion6 = 0;
byte lastMotionValue7 = 0;
word relaxMotion7 = 0;
byte lastMotionValue8 = 0;
word relaxMotion8 = 0;
byte lastMotionValue9 = 0;
word relaxMotion9 = 0;

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);

ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE); // Send Basic Set to association group

// Set up 10 channels
ZUNO_SETUP_CHANNELS(
  ZUNO_SENSOR_BINARY_MOTION(getterMotion1),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion2),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion3),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion4),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion5),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion6),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion7),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion8),
  ZUNO_SENSOR_BINARY_MOTION(getterMotion9));
  

void setup() {
  // set up I/O pins. Analog and PWM will be automatically set up on analogRead/analogWrite functions call
 pinMode(MotionPin1, INPUT_PULLUP);
 pinMode(MotionPin2, INPUT_PULLUP);
 pinMode(MotionPin3, INPUT_PULLUP);
 pinMode(MotionPin4, INPUT_PULLUP);
 pinMode(MotionPin5, INPUT_PULLUP);
 pinMode(MotionPin6, INPUT_PULLUP);
 pinMode(MotionPin7, INPUT_PULLUP);
 pinMode(MotionPin8, INPUT_PULLUP);
 pinMode(MotionPin9, INPUT_PULLUP);
}

void loop() {
 byte currentMotionValue1;
 byte currentMotionValue2;
 byte currentMotionValue3;
 byte currentMotionValue4;
 byte currentMotionValue5;
 byte currentMotionValue6;
 byte currentMotionValue7;
 byte currentMotionValue8;
 byte currentMotionValue9;
  // Trigger motion and wait for relax (about 5 sec) before report idle
  
  // 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  
  currentMotionValue1 = !digitalRead(MotionPin1);
  if (currentMotionValue1) {
    if (relaxMotion1 == 0) {
      lastMotionValue1 = 1;
      zunoSendReport(1);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion1 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue1 == 1 && relaxMotion1 == 0) {
    lastMotionValue1 = 0; 
    zunoSendReport(1);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion1) relaxMotion1--;

 // 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
  
  currentMotionValue2 = !digitalRead(MotionPin2);
  if (currentMotionValue2) {
    if (relaxMotion2 == 0) {
      lastMotionValue2 = 1;
      zunoSendReport(2);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion2 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue2 == 1 && relaxMotion2 == 0) {
    lastMotionValue2 = 0; 
    zunoSendReport(2);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion2) relaxMotion2--;

//3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

  currentMotionValue3 = !digitalRead(MotionPin3);
  if (currentMotionValue3) {
    if (relaxMotion3 == 0) {
      lastMotionValue3 = 1;
      zunoSendReport(3);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion3 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue3 == 1 && relaxMotion3 == 0) {
    lastMotionValue3 = 0; 
    zunoSendReport(3);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion3) relaxMotion3--;

//4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 

  currentMotionValue4 = !digitalRead(MotionPin4);
  if (currentMotionValue4) {
    if (relaxMotion4 == 0) {
      lastMotionValue4 = 1;
      zunoSendReport(4);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion4 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue4 == 1 && relaxMotion4 == 0) {
    lastMotionValue4 = 0; 
    zunoSendReport(4);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion4) relaxMotion4--;

//5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5

  currentMotionValue5 = !digitalRead(MotionPin5);
  if (currentMotionValue5) {
    if (relaxMotion5 == 0) {
      lastMotionValue5 = 1;
      zunoSendReport(5);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion5= 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue5 == 1 && relaxMotion5 == 0) {
    lastMotionValue5 = 0; 
    zunoSendReport(1);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion5) relaxMotion5--;

//6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

  currentMotionValue6 = !digitalRead(MotionPin6);
  if (currentMotionValue6) {
    if (relaxMotion6 == 0) {
      lastMotionValue6 = 1;
      zunoSendReport(6);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion6 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue6 == 1 && relaxMotion6 == 0) {
    lastMotionValue6 = 0; 
    zunoSendReport(6);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion6) relaxMotion6--;

//7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
  currentMotionValue7 = !digitalRead(MotionPin7);
  if (currentMotionValue7) {
    if (relaxMotion7 == 0) {
      lastMotionValue7 = 1;
      zunoSendReport(7);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion7 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue7 == 1 && relaxMotion7 == 0) {
    lastMotionValue7 = 0; 
    zunoSendReport(7);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion7) relaxMotion7--;

//8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8

  currentMotionValue8 = !digitalRead(MotionPin8);
  if (currentMotionValue8) {
    if (relaxMotion8 == 0) {
      lastMotionValue8 = 1;
      zunoSendReport(8);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion8 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue8 == 1 && relaxMotion8 == 0) {
    lastMotionValue8 = 0; 
    zunoSendReport(8);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion8) relaxMotion8--;

//9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 
 
  currentMotionValue9 = !digitalRead(MotionPin9);
  if (currentMotionValue9) {
    if (relaxMotion9 == 0) {
      lastMotionValue9 = 1;
      zunoSendReport(9);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion9 = 1900; // impirical for ~5 sec relax time
  }
  if (lastMotionValue9 == 1 && relaxMotion9 == 0) {
    lastMotionValue9 = 0; 
    zunoSendReport(9);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion9) relaxMotion9--;
 
}

// Getters and setters


byte getterMotion1(void) {
  return lastMotionValue1 ? 0xff : 0;
}

byte getterMotion2(void) {
  return lastMotionValue2 ? 0xff : 0;
}
byte getterMotion3(void) {
  return lastMotionValue3 ? 0xff : 0;
}
byte getterMotion4(void) {
  return lastMotionValue4 ? 0xff : 0;
}
byte getterMotion5(void) {
  return lastMotionValue5 ? 0xff : 0;
}
byte getterMotion6(void) {
  return lastMotionValue6 ? 0xff : 0;
}
byte getterMotion7(void) {
  return lastMotionValue7 ? 0xff : 0;
}
byte getterMotion8(void) {
  return lastMotionValue8 ? 0xff : 0;
}
byte getterMotion9(void) {
  return lastMotionValue9 ? 0xff : 0;
}
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Не отображаются несколько датчиков движения в HC2 + Z-Un

Post by PoltoS »

Попробуйте свежую прошивку HC2
Post Reply