The following examples demonstrate different features of a Zigbee stack running on the nRF52840 or the nRF52833 device.
Before running the examples, see Running precompiled examples.
To control Zigbee network and devices using Python language, you can use the Zigbee CLI Agent example and a Python CLI wrapper library.
- Device support breakdown
- Not all Zigbee examples support both the nRF52840 or the nRF52833 devices. See both sections for more information.
- SoftDevice usage
- Zigbee examples do not use the SoftDevice, with the exception of multiprotocol examples.
- Zigbee example parameters
- All Zigbee examples use the following parameters: For production firmware or for use with 3rd party devices, such as Amazon Echo Plus, it is strongly advised to set the IEEE_CHANNEL_MASK (located in files named
main.c
of each example) to cover multiple channels. For example, set IEEE_CHANNEL_MASK to 0x07fff800U, in order to use all 802.15.4 defined channels.
Testing
You can find the source code and the project file of the examples in the following folder: <InstallFolder>/examples/zigbee
Use the following steps to test the Zigbee examples:
- Build the example according to the instructions in Building examples.
- Use nrfjprog (from nRF5x Command Line Tools v9.2.0 or newer) to program the hex file that was created in the
_build
folder to the board.
- Use an UART viewer to see the log messages produced by the application. All Zigbee examples use 1 000 000 baud rate.
Zigbee BSP LED and button reference
All Zigbee examples use the same LED assignments:
- LED1 (
BSP_LED_0
or BSP_BOARD_LED_0
) and LED2 (BSP_LED_1
or BSP_BOARD_LED_1
) – Used only inside multiprotocol examples to indicate the BLE status.
- Blinking – BLE advertising.
- Slow blinking (period of 200 ms when on, period of 800 ms when off) – Node is not connecting to a Zigbee mesh network.
- Rapid blinking (period of 100 ms) – Node is connecting to a Zigbee mesh network.
- Solid – Connected over BLE.
- Note
- Zigbee Multi Sensor with FreeRTOS Example is an exception, as it uses LED1 (BSP_LED_0 or
BSP_BOARD_LED_0
) as a simple blinking-alive indicator. This example is not multiprotocol.
- LED3 (
BSP_LED_2
or BSP_BOARD_LED_2
) – Used to indicate the Zigbee network connection state.
- Disabled – Node is disconnected or is currently connecting to a Zigbee mesh network. The node is not commissioned.
- Solid – Node is connected to a Zigbee mesh network. The node is commissioned.
- Reserved for user application purposes:
- LED2 (
BSP_LED_1
or BSP_BOARD_LED_1
)
- LED4 (
BSP_LED_3
or BSP_BOARD_LED_3
)
All buttons are reserved for user application purposes. The following buttons are available:
- Button 1 (
BSP_BUTTON_0
or BSP_BOARD_BUTTON_0
)
- Button 2 (BSP_BUTTON_1 or
BSP_BOARD_BUTTON_1
)
- Button 3 (BSP_BUTTON_2 or
BSP_BOARD_BUTTON_2
)
- Button 4 (BSP_BUTTON_3 or
BSP_BOARD_BUTTON_3
)
See example pages for assignments related to each example.
Persistent storage erase method
All Zigbee examples have a method to erase the Zigbee persistent storage at boot. When using an nRF52 Development Kit, short the pin 1.09 to the ground. This pin is configurable in the zigbee_helpers.c
file.
- Warning
- This feature clears all the NVRAM used by the Zigbee stack, including the NWK frame counter. This has severe consequences in the production. For clearing all the network information data except the frame counter, use the
zb_nvram_clear
function.
Power consumption measurements
For devices in which low power consumption is critical, especially battery-powered devices that implement the end device role, the current consumption must be verified during the development process.
There are different ways in which you can measure the current, for example by using the ampere-meter. For more information, see Measuring current for nRF52840 DK.
When measuring the power consumption for Zigbee examples, take into account the following information:
- You should start measuring the power consumption after the device is initialized and has joined the network. Do not start measurement before the device has joined the network, as this can result in higher power consumption.
- If the device you are measuring the power consumption for is an End Device, but not Sleepy End Device, enable the sleepy behavior to get the lowest power consumption possible.
- Note
- The sleepy behavior is not set by default for most of the Zigbee examples. For example, the light switch example requires pressing one of the buttons during startup to enable the sleepy behavior. If the sleepy behavior is not set by default, you can enable it by calling
zb_set_rx_on_when_idle(0)
. However, if the example uses a button to enable the behavior, sleepy_device_setup()
is called while booting.