Zigbee quick start guide

This guide demonstrates some of the basic concepts of the Zigbee network using the nRF Connect SDK and the nRF Connect for Visual Studio Code extension. It guides you through the installation of the required tools and programming of the required samples.

Overview

As part of this guide, we are going to program three Zigbee samples onto three different development kits in order to set up a basic Zigbee network composed of three devices, or nodes. A node is “a testable implementation of a Zigbee application on a single stack with a single network address, and on a single network”.

Zigbee star topology setup for this guide

Zigbee star topology setup for this guide

The figure shows the Zigbee network star topology we are going to set up. In this topology, the nodes have the following responsibilities:

  • Zigbee Coordinator initiates and maintains the devices on the network. It also chooses the key network parameters. The coordinator’s radio is continuously listening for frames.

  • Zigbee Router extends the range of the network. For this reason, the router has the radio enabled at all times. However, in the star topology it is not moving packets through the network.

  • Zigbee End Device receives messages from the parent device, in this case the coordinator.

Each of the samples we are going to use for forming the network is based on the single-chip, single-protocol architecture, uses the default configuration (that is without any additional sample extensions enabled) and has a clearly defined role:

  • Zigbee network coordinator demonstrates the Zigbee Coordinator role and supports only the network steering commissioning mechanism.

  • Zigbee light bulb demonstrates the Zigbee Router role and implements the Dimmable Light device specification, as defined in the Zigbee Home Automation public application profile.

  • Zigbee light switch demonstrates the Zigbee End Device role and implements the Dimmer Switch device specification, as defined in the Zigbee Home Automation public application profile. Once commissioned into the network, it looks for devices with the implemented Level Control and On/Off clusters and can control the one that answers first.

All these samples also implement the Basic and Identify clusters, which are the basic Zigbee clusters.

Zigbee topologies

Depending on the available device types and their number, Zigbee supports the following network topologies:

  • Star topology - where the coordinator communicates directly with the end devices and no routers are actively present, meaning they are either not present or not routing packets within the network.

  • Tree topology - where routers are located beyond their mutual radio range and are not able to communicate with each other. However, unlike in the star topology, the routers continue to move packets through the network.

  • Mesh topology - which allows full peer-to-peer communication.

Zigbee topology types

Zigbee topology types

In every Zigbee topology, each router and end device that joins the Zigbee network after its creation by the coordinator needs a parent device. When a device wants to join the network, it sends a beacon request to scan for available devices. The devices that can route the packets respond with beacons. Based on different factors of responses, such as signal strength, the new device selects the parent.

For end devices, the parent device, either a coordinator or a router, can store information meant for them. This is required because the end devices do not receive packets directly from other devices. Each packet meant for an end device needs to go through its parent, and the end devices need to regularly request and respond to packets from the parents. For example, in the nRF Connect SDK the Zigbee light switch device requests packets from the parent every three seconds. The end device does not route packets. It can also disable its radio to reduce the power consumption between the regular packet requests if the Sleepy End Device behavior is enabled.

Detailed reading

If you want to learn more about Zigbee topics and terminology mentioned in this guide, read the following pages:

Requirements

For this quick start guide, you need three development kits of the following types:

Hardware platforms

PCA

Board name

Build target

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF52833 DK

PCA10100

nrf52833dk_nrf52833

nrf52833dk_nrf52833

nRF5340 DK

PCA10095

nrf5340dk_nrf5340

nrf5340dk_nrf5340_cpuapp

nRF21540 DK

PCA10112

nrf21540dk_nrf52840

nrf21540dk_nrf52840

You can mix different development kits.

Software requirements

For this quick start guide, we will install the following software:

  • Toolchain Manager - An application for installing the full nRF Connect SDK toolchain.

  • Visual Studio Code (VS Code) - The recommended IDE for the nRF Connect SDK.

  • nRF Connect for Visual Studio Code - Extension for VS Code that allows you to develop applications for the nRF Connect SDK.

  • nRF Command Line Tools - A set of mandatory tools for working with the nRF Connect SDK.

  • SEGGER J-Link - Tool for handling the serial connection.

Set up the software

The following steps are a simplified version of the nRF Connect SDK’s Installing automatically procedure.

To set up the required software, complete the following steps:

  1. Install the Toolchain Manager app:

    1. Download nRF Connect for Desktop for your operating system.

    2. Install and run the tool on your machine.

    3. In the APPS section, click Install next to Toolchain Manager.

    The app is installed on your machine, and the Install button changes to Open.

  2. Open the Toolchain Manager in nRF Connect for Desktop.

  3. Click Settings in the navigation bar to specify where you want to install the nRF Connect SDK. Then, in SDK Environments, click the Install button next to the nRF Connect SDK version that you want to install. The nRF Connect SDK version of your choice is installed on your machine.

  4. Click the Open VS Code button. The installation wizard checks whether you have the following software installed:

    • VS Code

    • nRF Connect for Visual Studio Code extension

    • nRF Command Line Tools (with SEGGER J-Link)

    If any of these items is missing, you are taken to its installation page to complete the setup. At the end of the process, the VS Code main window opens.

Program the samples

To program the samples, complete the following steps:

  1. In VS Code, open the nRF Connect extension by clicking its icon or pressing Ctrl + Alt + N.

  2. Add the network coordinator application:

    1. In the Welcome panel or on the Welcome page, click Create a new application from sample.

      nRF Connect for Visual Studio Code - Welcome panel
    2. Select the Freestanding application type, which uses the preinstalled version of the nRF Connect SDK.

    3. Enter a custom application location and name. For example, Zigbee_coordinator.

    4. Keep the default settings for nRF Connect SDK and nRF Connect Toolchain.

    5. In the Application template, click Browse and search for the Zigbee network coordinator sample. The path for the application template is nrf/samples/zigbee/network_coordinator.

    6. Click Select and then click Create Application.

      nRF Connect for Visual Studio Code - Create Application panel
    7. If needed, click Yes when prompted if you trust the authors of the files.

  3. Generate the network coordinator application:

    1. In the Applications panel, click the No build configuration - Click to create one button.

    2. In the configuration options on the Add Build Configuration screen, select the board onto which you want to program the sample. See the Requirements section for the list of available build target names. For the purpose of this quick start guide, leave the default values for other options.

      nRF Connect for Visual Studio Code - Generate Configuration panel
    3. Click Build Configuration. When the process starts, a Zigbee Coordinator panel appears under the Applications panel. The generation process takes some time and you can observe its progress in the nRF Connect terminal.

      nRF Connect for Visual Studio Code - building process in progress
  4. Program the application to the board:

    1. Connect your development kit using the serial port.

    2. In the Connected Devices panel, click Refresh Connected Devices. Your development kit appears on the list.

    3. In the Actions panel, click Flash.

      nRF Connect for Visual Studio Code - Refresh Connected Devices and Flash buttons

    When the programming is done, the LED 3 on the development kit turns on to indicate that the Zigbee network is open. After some time, it turns off and the Zigbee network needs to be reopened.

  5. Add the light switch application. Repeat steps 2 to 4 using a custom application location and name, for example Zigbee_light_switch. The path for the application template is nrf/samples/zigbee/light_switch.

  6. Add the light bulb application. Repeat steps 2 to 4 using a custom application location and name, for example Zigbee_light_bulb. The path for the application template is nrf/samples/zigbee/light_bulb. The LED 4 turns on when the application is started.

  7. Press Button 1 on the development kit programmed with the network coordinator sample to reopen the Zigbee network. After some time, the devices join the Zigbee network. On the development kit programmed with the light bulb sample, LED 3 turns on when the light bulb joins the network. On the development kit programmed with the light switch sample, LED 3 turns on when the device joins the network and LED 4 turns on when the light switch finds a light bulb to control.

Test the network

After forming the Zigbee network, test the interaction between the devices:

  1. Press Button 2 once on the development kit programmed with the light switch sample to turn off the light bulb’s LED 4.

  2. Press Button 1 once on the development kit programmed with the light switch sample to turn on the light bulb’s LED 4.

  3. Press and hold Button 2 on the development kit programmed with the light switch sample to decrease the light bulb’s LED 4 brightness.

  4. Press and hold Button 1 on the development kit programmed with the light switch sample to increase the light bulb’s LED 4 brightness.

What to do next

After you complete this quick start guide, we recommend that you get familiar with the following topics: