Zigbee Lighting¶
Overview¶
This section of the documentation explains how to set up a basic Zigbee network composed of three devices:
- Zigbee Network coordinator demonstrates the Zigbee Coordinator role and supports only the network steering commissioning mechanism.
- Zigbee Light bulb demonstrates the Zigbee Router role and implements the Dimmable Light device specification, as defined in the Zigbee Home Automation public application profile.
- Zigbee Light switch demonstrates the Zigbee End Device role and implements the Dimmer Switch device specification, as defined in the Zigbee Home Automation public application profile. Once commissioned into the network, it looks for devices with the implemented Level Control and On/Off clusters and can control the one that answers first. The light switch also supports Multiprotocol Bluetooth LE extension which uses the Nordic UART Service (NUS) library to control the light bulb states over Bluetooth® LE in a Thread network.
Sniffing packets from a Zigbee network
You can use nRF Sniffer for 802.15.4 to capture and analyze packets exchanged on a Zigbee network.
Requirements¶
Before you start, check that you have the required hardware and software:
- 3x nRF52840 Connect Kit
- 3x USB-C Cable
- A smartphone or a tablet with nRF Toolbox installed
- A computer running macOS, Linux, or Windows 7 or newer
Building the sample¶
Before you start building, remember to set up the environment first.
Use the following steps to build the samples on the command line.
-
Open a terminal window.
-
Go to
my-workspace/ncs-playground
directory created in the Setting up the environment section. -
Build each sample using the
west
command, specifying the board (following the-b
option) asconnectkit_nrf52840
:Tip
The
-p always
option forces a pristine build, and is recommended for new users. Users may also use the-p auto
option, which will use heuristics to determine if a pristine build is required, such as when building another sample. -
After running the
west build
command, the build files can be found inbuild/zephyr
.
Flashing the firmware¶
The samples are designed to work with the UF2 Bootloader, so that you can easily flash each sample using the UF2 Bootloader. The firmware can be found in build/zephyr
with the name zephyr.uf2
.
To flash the firmware, complete the following steps:
-
Push and hold the USER button and plug your board into the USB port of your computer. Release the USER button after your board is connected. The RGB LED turns green.
-
It will mount as a Mass Storage Device called UF2BOOT.
-
Drag and drop
zephyr.uf2
onto the UF2BOOT volume. The RGB LED blinks red fast during flashing. -
Reset the board and the sample will start running.
-
Repeat the steps above to flash the Network coordinator, Light bulb and Light switch.
Testing¶
After flashing the Network coordinator, Light bulb and Light switch, complete the following steps to test the demo:
- Turn on the board that runs the Zigbee Network coordinator sample. When the RGB LED turns blue, this board has become the Coordinator of the Zigbee network and the network is established.
-
Turn on the board that runs the Zigbee Light bulb sample. When RGB LED turns blue, the light bulb has become a Router inside the network.
Note
If RGB LED on the light bulb does not turn blue, RESET the Coordinator to reopen the network.
-
Turn on the board that runs the Zigbee Light switch sample. When RGB LED turns blue, the light switch has become an End Device, connected directly to the Coordinator.
- Wait until Green LED on the light switch node turns on. This LED indicates that the light switch found a light bulb to control.
- Start the nRF Toolbox app, tap UART to open the UART application.
- Connect to the device with the name Zigbee_Switch discovered in the UART application.
-
Tap the blank buttons to create new commands. The following command assignments are configured with EOL set to LF :
- n - Turn on the Zigbee Light bulb.
- f - Turn off the Zigbee Light bulb.
- t - Toggle the Zigbee Light bulb on or off.
- i - Increase the brightness level of the Zigbee Light bulb.
- d - Decrease the brightness level of the Zigbee Light bulb.
-
In nRF Toolbox UART, tap the buttons you assigned:
- Tap the n and f command buttons to turn the LED on the Zigbee Light bulb node on and off, respectively.
- Tap the t command button to toggle the LED on the Zigbee Light bulb node on and off.
- Tap the i and d command buttons to make adjustments to the brightness level.