Z-uno或如何将任何设备添加到z-wave网络

我以某种方式为客户端安装了智能家居:任务是将所有遥控器组合成一个,这就是电话。有三个遥控器,其中两个带有红外信号,但是第三个-从窗帘上打开了无线电信号。我可以使用ztx-120设备记录和传输信号,但是您不能记录无线电信号。在这种情况下,我想在这篇文章中讲述。仅在该示例中,将没有无线电遥控器,而是一部手机,其含义将不会改变。

为此,我拿起z-uno板,通过arduino IDE 1.6.5程序使用usb电缆将代码上传到其中(如何在Windows上为z-uno安装arduino,我在z-uno.z-wave.me/阅读安装 -说明为英文,但图片中的内容都清晰可见)。由于我不懂C语言,因此我从标准插座中获取了代码,它以模板(称为“ SimpleSwitch”)的形式存在于arduino程序中,并与针脚13,14,15相乘。以下是我上传到z-uno板上的代码。

查看代码
/*
 * 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;
}


在撰写本文时,我手头没有,但是举个例子,我拿起带按钮的旧手机,拆开并焊接到“一个”,“两个”和“重置”按钮上。然后,我决定从电话按钮中取出所有“地线”,并将其扭成一体,然后将专业人士分散到针脚13,14,15中。

同时,对我来说什么也没有用,因为所有按钮都在同一电路中,每个按钮都应该有自己的按钮。



在这种情况下,使用晶体管光耦合器。

为了更方便地组合所有这些功能,我拿了一块面包板,并将其与光耦合器连接。应该注意的是,光耦合器上有一个圆圈或一个凹口-这是光耦合器的脚,分别是二极管正脚所在的位置,我们将z-uno的正脚附加到这些支脚上,并且有13、14、15引脚。我们将面包板上的二极管一侧的光耦合器上的“地”组合在一起,并将它们连接到z-uno的gnd端口。



接下来,我们将移动电话的按钮连接到我们的方案,在该按钮上将有一个加号,在哪里“接地”-没关系,因为按钮可以关闭。在下面的图片中,您可以看到正在工作的样品组件。



接下来,将z-uno添加到z-wave网络,并测试其可操作性。如我们所见,一切正常。



祝您的发明好运。在下面的视频中,您可以观看整个过程。

Source: https://habr.com/ru/post/zh-CN395907/


All Articles