Z-uno o cómo agregar cualquier dispositivo a la red z-wave

De alguna manera instalé una casa inteligente para el cliente: la tarea era combinar todos los controles remotos en uno y este era el teléfono. Había tres controles remotos, dos de ellos con una señal infrarroja, pero el tercero, desde las cortinas, encendió la señal de radio. Puedo grabar y transmitir la señal usando el dispositivo ztx-120, pero no puedes grabar la señal de radio. Qué hacer en este caso, quiero decir en este artículo. Solo en el ejemplo no habrá control remoto por radio, sino un teléfono celular, el significado de esto no cambiará.

Para hacer esto, tomé la placa z-uno, cargué mi código usando un cable usb a través del programa arduino IDE 1.6.5 (cómo instalar arduino para z-uno en windows, leí en z-uno.z-wave.me/ instalar : las instrucciones están en inglés, pero todo está claro en las imágenes). Como no conozco el lenguaje C, tomé el código de una salida estándar, está en el programa arduino en forma de plantilla (llamado "SimpleSwitch") y lo multipliqué por los pines 13,14,15. A continuación se muestra el código que cargué en la placa z-uno.

ver código
/*
 * That is a Simple Sensor Multilevel example
 * It measures the value on the potentiometer
 * And sends report to the controller if changed
 */
 
// LED pin number
#define LED_PIN 13
#define LED_PINN 14
#define LED_PINNN 15

// Last saved LED value
byte currentLEDValue;
byte currentLEDValuee;
byte currentLEDValueee;

// next macro sets up the Z-Uno channels
// in this example we set up 1 switch binary channel
// you can read more on http://z-uno.z-wave.me/Reference/ZUNO_SWITCH_BINARY/
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(getter, setter),
                    ZUNO_SWITCH_BINARY(getterr, setterr),
                    ZUNO_SWITCH_BINARY(getterrr, setterrr));

// next macro sets up the Z-Uno frequency
ZUNO_SETUP_FREQUENCY(ZUNO_FREQ_RU);

void setup() {
  pinMode(LED_PIN, OUTPUT); // setup pin as output
  pinMode(LED_PINN, OUTPUT); // setup pin as output
  pinMode(LED_PINNN, OUTPUT); // setup pin as output
}

void loop() { 
  // loop is empty, because all the control comes over the Z-Wave
}

// function, which sets new relay state
// this function runs only once the controller sends new value
 void setter (byte value) {
  // value is a variable, holding a "new value"
  // which came from the controller or other Z-Wave device
  if (value > 0) {    // if greater then zero
    digitalWrite (LED_PIN, HIGH); //turn LED on
  } else {            // if equals zero
    digitalWrite(LED_PIN, LOW);   //turn LED off
  } 
  // let's save our value for the situation, when the controller will ask us about it
  currentLEDValue = value;
}

void setterr (byte valuee) {
  // value is a variable, holding a "new value"
  // which came from the controller or other Z-Wave device
  if (valuee > 0) {    // if greater then zero
    digitalWrite (LED_PINN, HIGH); //turn LED on
  } else {            // if equals zero
    digitalWrite(LED_PINN, LOW);   //turn LED off
  } 
  // let's save our value for the situation, when the controller will ask us about it
  currentLEDValuee = valuee;
}

void setterrr (byte valueee) {
  // value is a variable, holding a "new value"
  // which came from the controller or other Z-Wave device
  if (valueee > 0) {    // if greater then zero
    digitalWrite (LED_PINNN, HIGH); //turn LED on
  } else {            // if equals zero
    digitalWrite(LED_PINNN, LOW);   //turn LED off
  } 
  // let's save our value for the situation, when the controller will ask us about it
  currentLEDValueee = valueee;
}

// function, which returns the previously saved relay value
// this function runs only once the controller asks
byte getter (){
  return currentLEDValue;
}
byte getterr (){
  return currentLEDValuee;
}
byte getterrr (){
  return currentLEDValueee;
}


Al momento de escribir el artículo, no tenía una mano a mano, pero por ejemplo tomé mi viejo móvil con botones, desarmado y soldado a los botones "uno", "dos" y "restablecer". Luego decidí tomar toda la "tierra" de los botones del teléfono y torcerla en una, y dispersé a los profesionales en los pines 13, 14, 15.

Al mismo tiempo, nada funcionó para mí, ya que todos los botones estaban en el mismo circuito eléctrico, y cada botón debería tener el suyo.



Para tales casos, se utiliza un optoacoplador de transistor.

Para que sea más conveniente combinar todo esto, tomé una placa de prueba y la conecté con optoacopladores. Cabe señalar que hay un círculo en el optoacoplador o una muesca: este es el pie del optoacoplador donde se encuentra el más del diodo, respectivamente, conectaremos más de z-uno a estas patas, y tenemos los pines 13,14,15. Combinamos la "tierra" en los optoacopladores en el lado del diodo en la placa de pruebas en uno y los conectamos al puerto gnd en z-uno.



A continuación, adjuntamos a nuestro esquema los botones del teléfono móvil, donde habrá un punto a favor, y donde la "tierra" no importa, ya que los botones funcionan para cerrar. En la siguiente imagen puede ver el ensamblaje de la muestra de trabajo.



A continuación, agregue z-uno a la red z-wave y pruebe su operatividad. Como vemos, todo funciona.



Buena suerte con tus inventos. En el siguiente video puedes ver todo el proceso.

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


All Articles