This information applies to the following SoCs: nRF52833 and nRF52840.
The Zigbee light control example demonstrates a basic Zigbee network. It provides a minimal implementation of the following devices:
- Light coordinator – demonstrates the Zigbee Coordinator role, which supports only the network steering commissioning mechanism.
- Light switch – demonstrates the Zigbee End Device role, implementing the Dimmer Light Switch profile.
- Light bulb – demonstrates the Zigbee Router role, implementing the Dimmable Light profile.
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 through on-board buttons.
Setup
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
The light switch can be used with the CLI Agent example to establish control with a light bulb. The light switch also shows an additional way of reducing current consumption when the sleepy behavior is enabled.
LED and button assignments
All devices use LED assignments as described in Zigbee BSP LED and button reference for the following LEDs:
- LED3 – Used to inform about the network connection state.
- For coordinator, indicates whether the network is open or closed.
- For other devices, indicates whether the device is connected to a Zigbee network.
Moreover, the following LEDs reserved for user application purposes are assigned in this example:
- (Light switch) LED4 – Used to indicate that the light switch has found a light bulb to control.
- (Light bulb) LED4 – Used for the dimmable light option.
The following buttons reserved for user application purposes are assigned in this example:
- (Coordinator) Button 1 – Used to reopen the network.
- (Light switch) Button 1
- When the light bulb has been turned off, pressing this button once turns it back on.
- When pressed for a longer period of time, increases the brightness of the light bulb.
- (Light switch) Button 2
- After the successful commissioning (LED3 state), pressing this button once turns off the light bulb (LED4).
- When pressed for a longer period of time, decreases the brightness of the light bulb.
- (Light switch) Button 3 – When pressed while resetting the board, enables the Sleepy End Device behavior.
- (Light switch) Button 4 – When pressed, toggles the Finding & Binding mode on the local endpoint on or off.
- Note
- If you decrease the brightness level to the minimum, the effect of turning on the light bulb might not be noticeable.
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 up simultaneously with LED4. Not connecting the WS2812 does not affect the 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.
- Note
- When you use the light bulb or light coordinator on the nRF52840 Dongle (PCA10059), it is the LED3 that informs about the successful network joining.
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.
Testing
- Precondition
- To test the Zigbee light control example, prepare at least three boards.
- Note
- The network stays opened for 180 seconds after the coordinator start-up. Use Button 1 on the coordinator node to reopen the network if needed.
To test the example:
- Build the example according to the instructions in Building examples.
- Program one board for each example: Light coordinator, Light switch, and Light bulb.
- Turn on the Light coordinator node. LED3 turns on. The node becomes the Coordinator of the network.
- Turn on the Light bulb node. LED3 turns on. The node becomes a Router inside the network.
- Turn on the Light switch node. LED3 turns on. The node becomes an End Device, connected directly to the Coordinator.
- Wait until LED4 on the light switch node turns on. This LED indicates that the switch found a light bulb to control.
You can now use buttons on the board to control the light bulb, as described in LED and button assignments.
Testing Zigbee Light Switch with ZCL Groups
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:
- Build the example according to the instructions in Building examples.
- Program one board for each example: Light coordinator and Light switch with ZCL Groups.
- Program three boards with the Light bulb example.
- Turn on the Light coordinator node. LED3 turns on. The node becomes the Coordinator of the network.
- Turn on all the Light bulb nodes. LED3 turns on on each of them. The nodes become Routers inside the network.
- Turn on the Light switch with ZCL Groups node. LED3 turns on. The node becomes an End Device, connected directly to the Coordinator.
- Wait until LED4 on the light switch node turns on. This LED indicates that the switch found at least one light bulb to control.
You can now use buttons on the board to control the light bulb, as described in LED and button assignments.