Interruptor Gira + Z-Wave. Interruptor de radio de 4 botones basado en Z-Uno



Qué tareas resuelve el interruptor de radio:

  • En una habitación con una reparación lista, se movieron los muebles, se cerró el interruptor con un gabinete
  • En la etapa de reparación, no pensaron en un interruptor conveniente cerca de la cama
  • En una casa de madera, no es estético tirar del cableado externo, se requieren interruptores de radio, pero con un diseño específico
  • Integración con un sistema de automatización existente.

Actualmente, hay interruptores Z-Wave alimentados por batería, como el controlador de pared Z-Wave.Me , pero estos interruptores vienen con un diseño clave específico. Si desea utilizar los interruptores Legrand, Gira, etc., la placa Z-Wave Z-Uno viene al rescate.

Mostraré cómo hacer un interruptor de radio alimentado por batería desde un interruptor Gira que se puede instalar en cualquier lugar conveniente. El video del cambio al final del artículo.

Utilizo el mecanismo de interruptor Gira para persianas con 4 botones y un pestillo en el medio. Elegí el diseño de llave y cuadro de la serie System 55 solo porque la línea Z-Wave de interruptores alimentados por batería tiene cuadros con el mismo diseño.



La adición de nuevas funciones a Z-Uno está en curso, y en la última versión se agregó KeyScanner, que le permite procesar clics de 112 botones al mismo tiempo, me limitaré a leer 4 botones del interruptor.

En el siguiente dibujo, Z-Uno en modo de espera espera que se presione uno de los botones, después de presionar Z-Uno se activa y envía un comando de radio, después de lo cual se queda dormido inmediatamente para no consumir energía de la batería.



Boceto de interruptor de radio de 4 botones basado en Z-Uno
// KeyPad 1x4
#include <ZMEKeypad.h>
// Count of rows
#define ROWS  1
// Count of columns
#define COLS  4

// Set rows pins
BYTE rowPins[1] = {17};
// Set columns pins
BYTE columnPins[4] = {9, 10, 11, 12};

// Create object KeyPad
ZMEKeypad kpd = ZMEKeypad(columnPins, COLS, rowPins, ROWS);

#define CONTROL_GROUP1 1  // number of Association Group 
#define CONTROL_GROUP2 2  // number of Association Group
#define SWITCH_ON 0xff
#define SWITCH_OFF 0

// Start holding flags for 4 buttons
byte button_0_start_holding = TRUE;
byte button_1_start_holding = TRUE;
byte button_2_start_holding = TRUE;
byte button_3_start_holding = TRUE;

ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE_AND_DIM, ZUNO_ASSOCIATION_GROUP_SET_VALUE_AND_DIM); // Send Turn On/Off and Dim commands to associated devices
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_SLEEPING); // SLEEPING MODE

void setup() {
  zunoSetupKeyScannerWU(4); // turn INT1 wakeup into Key Scanner mode with two columns: pins 9 and 10
  // can also be called in any other place before zunoSendDeviceToSleep()
  kpd.begin();
  kpd.setHoldTime(50); // 100 ms for detect hold button, 10 = 100 ms
  kpd.setDebounceTime(2); // 20 ms debounce, 2 = 20 ms
}

void loop() {
  byte actions[4]; // Array that return all actions from keypad (hold, release, press, double press, etc.)
  byte go_to_sleep = FALSE; // go to sleep after button released;
  
  // Default value for buttons - inactive, then read real states
  byte button_0_active = FALSE;
  byte button_1_active = FALSE;
  byte button_2_active = FALSE;
  byte button_3_active = FALSE;

  byte num_touched_keys = kpd.scanKeys(actions);
  if (num_touched_keys) {
    bool hold = KEYPAD_IS_HOLDING(actions[0]);
    switch (KEYPAD_KEYINDEX(actions[0])) {
      case 0: // Button Left Down
        button_0_active = TRUE;
        if (hold && button_0_start_holding) { // If button 0 start holding
          button_0_start_holding = FALSE;
          zunoSendToGroupDimmingCommand(CONTROL_GROUP1, TRUE, TRUE); // start dimming down (group, direction, start_stop)
        }
        if (!hold) { // If button 0 not holding
          go_to_sleep = TRUE;
          zunoSendToGroupSetValueCommand(CONTROL_GROUP1, SWITCH_OFF);  
        }
        break;
      case 1: // Button Left Up
        button_1_active = TRUE;
        if (hold && button_1_start_holding) { // If button 1 start holding
          button_1_start_holding = FALSE;
          zunoSendToGroupDimmingCommand(CONTROL_GROUP1, FALSE, TRUE); // start dimming up (group, direction, start_stop)
        }
        if (!hold) { // If button 1 not holding
          go_to_sleep = TRUE;
          zunoSendToGroupSetValueCommand(CONTROL_GROUP1, SWITCH_ON);
        }
        break;
      case 2: // Button Right Down
        button_2_active = TRUE;
        if (hold && button_2_start_holding) { // If button 2 start holding
          button_2_start_holding = FALSE;
          zunoSendToGroupDimmingCommand(CONTROL_GROUP2, TRUE, TRUE); // start dimming down (group, direction, start_stop)
        }
        if (!hold) { // If button 2 not holding
          go_to_sleep = TRUE;
          zunoSendToGroupSetValueCommand(CONTROL_GROUP2, SWITCH_OFF);
        }
        break;
      case 3: // Button Right Up
        button_3_active = TRUE;
        if (hold && button_3_start_holding) { // If button 3 start holding
          button_3_start_holding = FALSE;
          zunoSendToGroupDimmingCommand(CONTROL_GROUP2, FALSE, TRUE); // start dimming down (group, direction, start_stop)
        }
        if (!hold) { // If button 3 not holding
          go_to_sleep = TRUE;
          zunoSendToGroupSetValueCommand(CONTROL_GROUP2, SWITCH_ON);
        }
        break;
    }
  }

  if(!button_0_start_holding && !button_0_active) { // If button 0 release holding
    button_0_start_holding = TRUE;
    zunoSendToGroupDimmingCommand(CONTROL_GROUP1, TRUE, FALSE); // stop dimming down (group, direction, start_stop)
  }
   if(!button_1_start_holding && !button_1_active) { // If button 1 release holding
    button_1_start_holding = TRUE;
    zunoSendToGroupDimmingCommand(CONTROL_GROUP1, FALSE, FALSE); // stop dimming up (group, direction, start_stop)
  }
   if(!button_2_start_holding && !button_2_active) { // If button 2 release holding
    button_2_start_holding = TRUE;
    zunoSendToGroupDimmingCommand(CONTROL_GROUP2, TRUE, FALSE); // stop dimming down (group, direction, start_stop)
  }
   if(!button_3_start_holding && !button_3_active) { // If button 3 release holding
    button_3_start_holding = TRUE;
    zunoSendToGroupDimmingCommand(CONTROL_GROUP2, FALSE, FALSE); // stop dimming up (group, direction, start_stop)
  }

  // if all buttons released
  if (kpd.isIdled()) {
    go_to_sleep = TRUE;
  }

  if (go_to_sleep) {
    zunoSendDeviceToSleep();  
  }
}
//        Z-Uno 2.0.6    /Volumes/Files/user/Library/Arduino15/packages/Z-Uno/hardware/zw8051/2.0.6/libraries/ZMEKeypad/ZMEKeypad.h  "BYTE isIdled(){return mon_keys == 0;};"   55 


El receptor del comando de radio se configura en cada uno de los 4 botones con la ayuda de asociaciones, puede ser un relé , un atenuador , una cinta RGBW , una lámpara LED u otro actuador. En el boceto, creo 2 grupos de asociaciones para controlar 2 dispositivos, los botones superiores envían comandos de encendido, los botones inferiores envían comandos de encendido.



Conectamos el mecanismo del interruptor GIRA a los pines de Z-Uno 1,2,3,4. El Z-Uno viene con un enchufe, lo solde al compartimento de la batería 1/2 AA y lo enchufé al conector de la batería. La batería 1 / 2AA (ER14250) tiene una capacidad compacta de 3.6 V, pero puede usar 2 baterías AA, también encajan perfectamente en el zócalo.

Z-Uno tiene 2 convertidores CC-CC, no son necesarios para el funcionamiento con batería, por lo tanto, pueden excluirse del circuito de suministro de energía soldando el puente R12. Al mismo tiempo, el consumo de energía de Z-Uno en modo de suspensión se reduce en 143 veces, de 1 mA a 7 μA.

Recomiendo 60 mm de profundidad para los enchufes, es más conveniente trabajar con ellos, es difícil empujar el Z-Uno con una batería, cables y el interruptor en un enchufe de 40 mm, ¡pero puedes!





2 botones derechos controlan el tomacorriente, envían comandos ON y OFF al tomacorriente Z-Wave.Me .

2 botones izquierdos controlan el atenuador, con una pulsación breve se envían los comandos ON y OFF, con una pulsación larga ARRIBA o ABAJO, los comandos de atenuación se envían al atenuador Z-Wave.Me .

Como puede ver el dispositivo alimentado por batería, leer el estado de los botones usando Z-Uno es muy simple, y de esta manera puede conectar un teclado completo a Z-Uno, donde cada botón realizará una función útil de su hogar inteligente.


Video del interruptor de batería basado en Z-Uno. Dimmer y control de relé.

Source: https://habr.com/ru/post/es396839/


All Articles