nRF5 SDK for Thread and Zigbee v2.0.0
BLE UART and Zigbee Light Switch Example
This example requires the following SoftDevice: S140

Important: Before you run this example, make sure to program the SoftDevice.

This dynamic multiprotocol example application is based on the UART/Serial Port Emulation over BLE example available in nRF5 SDK v15.2.0. It has been extended to support dynamic switching between two protocols, BLE and Zigbee, at the same time (concurrently). From the Zigbee protocol perspective, this example implements dimmable light switch, as described in the Light switch example.

To support both protocols at the same time, the Zigbee stack uses the 802.15.4 radio during the Bluetooth low energy radio's inactive time (using Timeslot API). Depending on the Bluetooth low energy connection interval, the nRF52840 SoC can spend up to 99% of the radio time on the Zigbee protocol. This is the same mechanism as the one used inside Thread Dynamic multiprotocol examples. For more information on multiprotocol operation, refer to the Multiprotocol support support section.

Note
Transmitting and receiving data does not break connections from any of the used radio protocols (BLE or Zigbee).

This BLE-Zigbee multiprotocol example requires running two other examples containing Zigbee coordinator and Zigbee light bulb. You can find these examples in Zigbee Light Control example.

LED assignments:

Button assignments:

Pressing BSP_BUTTON_1 after successful commissioning (BSP_LED_3 state) turns off the Zigbee light bulb. 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 behaviour.

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

BLE UART command assignments:

Setup

You can find the source code in the following folder: <InstallFolder>\examples\multiprotocol\ble_zigbee\ble_zigbee_dynamic_light_switch_nus

Testing

Precondition
To test this example, prepare three nRF52840 Preview Development Kits and a smartphone (Android or iOS).
  1. On the smartphone, install nRF Toolbox for BLE.
  2. Run the following commands to flash the Zigbee coordinator example to one of the boards:
    $ cd <InstallFolder>/examples/zigbee/light_control/light_coordinator/hex
    $ nrfjprog -f nrf52 -r --program nrf52840_xxaa.hex --chiperase
  3. Run the following commands to flash the Zigbee dimmable light bulb example to another board:
    $ cd <InstallFolder>/examples/zigbee/light_control/light_bulb/hex
    $ nrfjprog -f nrf52 -r --program nrf52840_xxaa.hex --chiperase
  4. Build the example according to the instructions in Building examples.
  5. Flash SoftDevice and the example according to the instructions in Running examples.
  6. Start all boards as described in Zigbee Light Control example and wait until BSP_LED_3 on the multiprotocol node turns on.
  7. You can toggle BSP_LED_3 on the light bulb board in the network by pressing BSP_BUTTON_0 and BSP_BUTTON_1 on the light switch board.
  8. Open nRF Toolbox and choose the UART application.
    nrftoolbox_dynamic_zigbee_uart_1.png
    nRF Toolbox - UART application
  9. Tap EDIT and configure five application buttons.
    • Enter command "n" (EOL = LF)
    • Enter command "f" (EOL = LF)
    • Enter command "t" (EOL = LF)
    • Enter command "i" (EOL = LF)
    • Enter command "d" (EOL = LF)
      nrftoolbox_dynamic_zigbee_uart_2.png
      nRF Toolbox - UART application - Configure button
  10. After all buttons are configured, tap DONE.
  11. Tap CONNECT and select the Zigbee_UART device.
    nrftoolbox_dynamic_zigbee_uart_3.png
    nRF Toolbox - UART application after establishing the connection
  12. Observe that BSP_LED_0 on the multiprotocol light switch board is turned on, which indicates that a BLE connection has been established.
  13. You can control BSP_LED_3 on the Zigbee light bulb node by pressing the left ("n" - command), middle ("t" - command) and right ("f" - command) button from your smartphone.
  14. You can also adjust the brightness level by pressing the top ("i" - command) and bottom ("d" - command) button from your smartphone.
  15. If you want to test the delayed toggle command, you may add another button with the numeric command or create a separate configuration (screen).
    nrftoolbox_dynamic_zigbee_uart_4.png
    nRF Toolbox - Add configuration
  16. For example, you may add buttons to toggle the light bulb after 1 ("1" - command), 3 ("3" - command), and 9 ("9" - command) seconds.
    nrftoolbox_dynamic_zigbee_uart_5.png
    nRF Toolbox - Delayed toggle commands

Documentation feedback | Developer Zone | Subscribe | Updated