nRF5 SDK for Thread and Zigbee v2.0.0
Zigbee Light Control example

The Zigbee light control example demonstrates a basic Zigbee network. It provides a minimal implementation of the following devices:

The coordinator establishes the network and commissions the light bulb and light switch. Once the light switch is successfully commissioned, it sends a broadcast message to find any device with implemented Level Control and On/Off clusters. It remembers the device network address from the first response and is controlled via on-board buttons.

Description

All devices indicate the Zigbee stack state using LEDs, as defined in Thread BSP LED reference. The dimmable light option is available from BSP_LED_3 on the light bulb. On the coordinator node, BSP_LED_2 informs if the network is opened for new devices (BSP_LED_2 is turned on) or closed (BSP_LED_2 is turned off). Currently there is no option to reopen the network, so it is recommended to power up all devices while BSP_LED_2 is on. The network stays opened for 180 seconds after coordinator start-up.

Note
If using the light bulb or light coordinator on the nRF52840 Dongle (PCA10059), it is the LED1 which informs about the successful network joining.

The switch does support the Sleepy End Device behaviour, meaning that the stack can make the CPU enter the sleep mode, resulting in a significant conserving of energy and prolonged battery life as a result. The device shall automatically wake itself up on an event. Besides, the CPU will wake itself from time to time to ensure the correct processing of stack internals.

Buttons are used only on the light switch node. Pressing BSP_BUTTON_1 after successful commissioning (BSP_LED_2 state) turns off the light bulb (BSP_LED_3). Pressing BSP_BUTTON_0 will turn it back on. Using a long press adjusts the brightness level of the light bulb. BSP_BUTTON_1 decreases the brightness and BSP_BUTTON_0 increases the brightness. Hold the BSP_BUTTON_2 pressed while resetting the board to enable the Sleepy End Device behaviour.

Note
If the user decreases the brightness level to the minimum, the effect of turning on the light bulb might not be noticeable.

Setup

You can find the source code and the makefiles in the following folders:

Testing

  1. Build the example according to the instructions in Building examples.
  2. Program one board for each example: Light coordinator, Light switch, and Light bulb.
  3. Turn on the Light coordinator node. BSP_LED_2 turns on. The node will become the Coordinator of the network.
  4. Turn on the Light bulb node and wait until BSP_LED_2 turns on. The node will become a Router inside the network.
  5. Turn on the Light switch node and wait until BSP_LED_2 turns on. The node will become an End Device, connected directly to the Coordinator.
  6. Wait until BSP_LED_3 on the light switch node turns on. This LED indicates that the switch found a light bulb to control.
  7. You can control BSP_LED_3 on the light bulb node by pressing BSP_BUTTON_0 and BSP_BUTTON_1 on the light switch node.
  8. Pressing BSP_BUTTON_0 or BSP_BUTTON_1 turns the light bulb on or off.
  9. Press and hold BSP_BUTTON_0 or BSP_BUTTON_1 to increase or decrease the brightness level of the light bulb.

Zigbee Light Switch with ZCL Groups

The Zigbee light control example also incorporates a Light switch with ZCL Groups functionality. Such switch sends a broadcast message to find the devices with implemented Level Control and On/Off clusters, but instead of controlling the first discovered light bulb, it creates a group out of all the suitable devices and controls them at once.

Therefore, in this case the testing procedure may be altered:

  1. Build the example according to the instructions in Building examples.
  2. Program one board for each example: Light coordinator and Light switch with ZCL Groups.
  3. Program three boards with the Light bulb example.
  4. Turn on the Light coordinator node. BSP_LED_2 should turn on. The node will become the Coordinator of the network.
  5. Turn on all the Light bulb nodes and wait until BSP_LED_2 turns on on each of them. The nodes will become Routers inside the network.
  6. Turn on the Light switch with ZCL Groups node and wait until BSP_LED_2 turns on. The node will become an End Device, connected directly to the Coordinator.
  7. Wait until BSP_LED_3 on the light switch node turns on. This LED indicates that the switch found at least one light bulb to control.
  8. You can control BSP_LED_3 on all of the light bulb nodes by pressing BSP_BUTTON_0 and BSP_BUTTON_1 on the light switch node.
  9. Pressing BSP_BUTTON_0 or BSP_BUTTON_1 turns the light bulbs on or off.
  10. Press and hold BSP_BUTTON_0 or BSP_BUTTON_1 to increase or decrease the brightness level of the light bulbs.

Documentation feedback | Developer Zone | Subscribe | Updated