4.7.1 Zigbee Application Demo: Light Control and Monitoring Using Combined Interface
WBZ451 Curiosity Board
Device: PIC32CX1012BZ25048 (MCU) on WBZ451 Module
On-Board: RGB LED, User Button and UART-USB Converter
Introduction
GitHub Repository
.hex
, and accompanying readme.md
file
for the application can be found in the GitHub repository Hardware Requirement
Tool | Quantity |
---|---|
WBZ451 Curiosity Boards | 2 |
Micro USB cable | 2 |
Personal Computer | 1 |
SDK Setup
Software Requirement
Programming the Precompiled Hex File or Application Example
This demo needs two devices. One is the Combined Interface and the other is extended color light.
-
One of the WBZ451 Curiosity boards is programmed with Combined Interface which can act as Zigbee Gateway/Coordinator. Program the CI pre-compiled hex image by following the steps mentioned in the “Programming the precompiled hex file or Application Example” section of the Zigbee Centralized Network Formation by Combined Interface application on one curiosity board.
-
Another WBZ451 Curiosity board is programmed with Extended Lights application which can act as Zigbee Router. Follow the below step for programming Extended Lights application on another curiosity board.
Programming the .hex
File using MPLAB X IPE
- Import and program the
Precompiled
.hex
file is located in"<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\zigbee\ext_light\hex"
folder - For more details on the steps, go
to Programming a DeviceNote: Users must choose the correct device and tool information
Programming the Application using MPLAB X IDE
-
Follow steps mentioned in the Running a Precompiled Example section
- Open and program the application
example “
ext_light.X
” located in “<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\zigbee\ext_light\firmware"
using MPLAB X IDEFor more details on finding the Harmony content path, refer to Installing the MCC Plugin
Demo Description
The demo application demonstrates the Zigbee protocol functionality of the PIC32CXBZ/WBZ family of devices and modules. It consists of a ZigBee 3.0 Coordinator and Router implemented as shown below :
Application | Zigbee Logical Device Type | Functionality |
---|---|---|
Combined Interface | Coordinator | Device capable of controlling and monitoring other devices. It is typically a mains-powered device like a personal computer |
Extended Lights | Router | Is a lighting device that can be switched ON/OFF, brightness and color of the light can be adjusted via the color commands. |
Zigbee Device Commissioning:
-
The Zigbee router, in other words, Extended Lights can be commissioned and brought to the existing Zigbee network formed by Zigbee coordinator in other words, Combined Interface or can create new Zigbee Distributed network (if there is no nearby network).
Zigbee Light Control:
-
Extended light RGB LED can be controlled from Zigbee Gateway of the same network.
-
When the light status is changed the light change report will be sent to Zigbee Gateway through Zigbee communication.
Demo Steps:
The Zigbee light can be connected to any Zigbee network.
Joining Light with the WBZ451 Combined Interface (CI) Coordinator
Hardware and Software Setup
- Supply power to the WBZ451 Curiosity board consisting of the Combined Interface application by connecting a USB cable. Power Supply (PS) Green LED will turn ON when connected to the PC.
- The application activity is shown
in "Console Log" through on board UART-USB converter
- Open TeraTerm and
configure as mentioned below:Terminal Settings
- Baud Rate/Speed – 115200 (as configured in SERCOM configuration)
- Parity – None
- Data Bits – 8
- Stop Bits – 1
- Flow Control – None
For more details on how to set the “Serial Port” and “Speed”, refer to COM Port Setup
- Additionally, local echo and sending line ends with line feeds can be enabled in the PC serial terminal application.
- Open TeraTerm and
configure as mentioned below:
Network Formation (Coordinator - Combined Interface)
Follow the steps explained in the Network Formation (Coordinator - (Combined Interface)) section to open up the network in CI.Commissioning (Router - Extended Light)
The Extended Lights can be connected to any Zigbee Gateway (Combined interface running on the WBZ451 Curiosity Board in the previous step).-
Supply power to another WBZ451 Curiosity board programmed with “
Extended Light.X
” by connecting a USB cable. Power Supply (PS) Green LED will turn ON when connected to PC. -
Follow step 2 in "Hardware and Software Setup" for UART terminal Setup.
- Input command:
resetToFN
and look for the below logs for successful joining with CI - Success logs : When extended light is successfully commissioned with Combined Interface below log will be seen.
Light Control
RGB LED on the WBZ451 Curiosity board is tied with Zigbee functionality. The LED color and brightness can be changed through Zigbee network.- The RGB color can be controlled from Combined Interface through console commands.
- RGB color is changed from Combined Interface, will be reflected in next received light attribute report in combined Interface
- The network address of the light is needed to send light control commands to light.
- This network address can be obtained from Combined Interface console log while commissioning is done. Refer to the above success log for light network address.
- Another way to get the network
address from light is executing the below command in light side.
Command: getNetworkAddress Response: f088
-
The table below describes few commands for light control (ON/OFF, brightness, hue and saturation). For more details on the different parameters of the commands, refer to the Zigbee Console Commands section.
Table 4-14. Control Command Command Type Commands Parameter Details RGB LED ON onOff 0x0 0xf088 0x23 -on
0x23
Zigbee end-point number used for LightRGB LED OFF onOff 0x0 0xf088 0x23 -off
0x23
Zigbee end-point number used for LightRGB LED brightness change moveToLevel 0x0 0xf088 0x23 0x45 0x0 0x1 0x0 0x0
0x45
is the configurable brightness valueRGB LED color change moveToHueAndSaturation 0x0 0xf088 0x23 0x45 0x67 0x0 0x0 0x0
0x45
and0x67
are the configurable Hue and Saturation values
-
On-board button actions:
-
When the on-board "User Button (SW2)" is pressed for more than 10sec, it deletes all the networking information and brings the device to factory default state. This functionality is available in both Combined Interface and Light devices.
-
-
Persistent Data Storage (PDS):
- The RGB light status (ON/OFF) and brightness values are stored in non-volatile memory called PDS. So, power OFF/ON of extended light, these values persist and RGB LED will reflect accordingly. This PDS storage is tied to Zigbee network.
- The light ON/OFF status, colour and light brightness is being stored in non-volatile memory in this case. So, power OFF/ON, the LED will be updated with light ON/OFF, color and brightness values retrieved from previous transaction.
Creating Application Device Types From Scratch using MCC
For developing Combined Interface from scratch, refer to the “Creating Application Device Types From Scratch Using MCC” section of Zigbee Centralized Network Formation by Combined Interface
For developing extended light from scratch, refer to the “Creating Application Device Types From Scratch Using MCC” section of Zigbee Application Demo: Light Control and Monitoring using Alexa Echo Plus