智慧家庭教學展示板 HUSTKIT1 ZIGBEE_setup(20, 0x1111, 0x2222); Channel=20 /PAN ID=0x1111/ Address=0x2222 //------------Declare-CC2530------------------------------------------- #include SoftwareSerial myZigBee(A1, A2); // RX, TX //=================================================================== //智慧家庭教學展示板 HUSTKIT1 ZIGBEE_setup(20, 0x1111, 0x2222); //Channel=20 /PAN ID=0x1111/ Address=0x2222 //=================================================================== #define Kit1Channel 20 #define Kit1Panid 0x1111 #define Kit1Addr 0x2222 家電動作 Json 指令 myZigBee傳送指令 1.開大燈ON {"LIGHT1":100} myZigBee.print("{\"LIGHT1\":100}"); 2.關大燈OFF {"LIGHT1":0} myZigBee.print("{\"LIGHT1\":0}"); 3.開小燈1 ON {"LIGHT2":100} myZigBee.print("{\"LIGHT2\":100}"); 4.關小燈1 OFF {"LIGHT2":0} myZigBee.print("{\"LIGHT2\":0}"); 3.開小燈2 ON {"LIGHT3":100} myZigBee.print("{\"LIGHT3\":100}"); 4.關小燈2 OFF {"LIGHT3":0} myZigBee.print("{\"LIGHT3\":0}"); 5.插座1繼電器ON {"OUTP1":1} myZigBee.print("{\"OUTP1\":1}"); 6.插座1繼電器OFF {"OUTP1":0} myZigBee.print("{\"OUTP1\":0}"); 7.插座2繼電器ON {"OUTP2":1} myZigBee.print("{\"OUTP2\":1}"); 8.插座2繼電器OFF {"OUTP2":0} myZigBee.print("{\"OUTP2\":0}"); 9.小風扇ON {"FAN1":100} myZigBee.print("{\"FAN1\":100}"); 10.小風扇OFF {"FAN1":0} myZigBee.print("{\"FAN1\":0}"); 11.窗簾開 ON {"WIN1":1} myZigBee.print("{\"WIN 1\":1}"); 12.窗簾關 OFF {"WIN1":0} myZigBee.print("{\"WIN1\":0}"); 13.窗簾停 STOP {"WIN1":2} myZigBee.print("{\"WIN1\":2}"); 14.電鎖 ON {"ACCLOCK":1} myZigBee.print("{\"ACCLOCK \":1}"); 15.電鎖 OFF {"ACCLOCK":0} myZigBee.print("{\"ACCLOCK \":0}"); 16.電鎖 UNLOCK {"ACCLOCK":2} myZigBee.print("{\"ACCLOCK \":2}"); //------------------------------------------------------------------------------ void Zigbee_setup(uint8_t channel,uint16_t panid,uint16_t addr) { int i,len; // get Channel/PAN ID/Address myZigBee.write(0xAA); myZigBee.write(0xC7); myZigBee.write(0xBB); delay(30); // set Channel/PAN ID/Address myZigBee.write(0xAA); myZigBee.write(0xC7); myZigBee.write(0x5A); myZigBee.write(channel); myZigBee.write(panid>>8); myZigBee.write(panid&0xff); myZigBee.write(addr>>8); myZigBee.write(addr&0xff); myZigBee.write(0xBB); }