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.
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). The network stays opened for 180 seconds after coordinator start-up. If you want to reopen the network, press button BSP_BUTTON_0 on the coordinator board.
By default, the light bulb controls the WS2812 LED chain (for example, the Adafruit NeoPixel Shield for Arduino), which can be connected to the P1.07 pin of the evaluation board. When connected, the LED chain lights simultaneously with BSP_LED_3. Not connecting the WS2812 does not affect operation of the example. Controlling the WS2812 LED chain can be also disabled by setting APP_BULB_USE_WS2812_LED_CHAIN
macro in sdk_config.h to 0.
The switch does support the Sleepy End Device behavior, meaning that the stack can make the CPU enter the sleep mode, which results in a significant conservation of energy and prolonged battery life. The device will automatically wake itself up on an event. Moreover, the CPU will wake itself from time to time to ensure the correct processing of stack internals.
Buttons are also used on the light switch node. Pressing BSP_BUTTON_1 after the successful commissioning (BSP_LED_2 state) turns off the light bulb (BSP_LED_3). Pressing BSP_BUTTON_0 turns 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 behavior.
You can find the source code and the makefiles in the following folders:
<InstallFolder>\examples\zigbee\light_control\light_coordinator
<InstallFolder>\examples\zigbee\light_control\light_switch
<InstallFolder>\examples\zigbee\light_control\light_bulb
To test the example:
The Zigbee light control example also incorporates a light switch with the 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.
The testing procedure is different when you use ZCL Groups, and you need at least five boards: