Zigbee: Light bulb

This sample demonstrates a simple light bulb whose brightness can be adjusted by another device.

You can use this sample with the Zigbee Network coordinator and Zigbee Light switch samples to set up a basic Zigbee network.

As a proof of concept, the sample also supports the optional Matter extension, which lets the same firmware start as a Zigbee Router and migrate to a Matter Dimmable Light after Matter commissioning. This combined Matter build also enables Touchlink target support, so it can be commissioned by a nearby Touchlink initiator without a Zigbee Coordinator on the network.

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Board target

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

nRF54L10 emulation on the nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l10/cpuapp

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp

nRF54LM20 DK

PCA10184

nrf54lm20dk

nrf54lm20dk/nrf54lm20a/cpuapp

To test this sample, you also need to program the following samples:

Overview

The Zigbee light bulb sample takes the Zigbee Router role and implements the Dimmable Light device specification, as defined in the Zigbee Home Automation public application profile. This profile allows changing the brightness level of the light bulb’s LED.

Matter extension

This optional extension is a proof of concept of a combined Matter and Zigbee build on a single SoC, sharing the 802.15.4 radio between the ZBOSS stack and OpenThread (used by Matter). For Thread networking in Matter mode, the light bulb acts as an OpenThread Full Thread Device (FTD). It is supported only on the nrf54lm20dk/nrf54lm20a/cpuapp board target.

The sample-specific behavior is:

  • On first boot, the device is a standard Zigbee Router exposing the Dimmable Light device, while the Matter stack advertises for commissioning over Bluetooth LE (CHIPoBLE).

  • After successful Matter commissioning, the device is converted to a Matter Dimmable Light endpoint that serves the On/Off and Level Control clusters and drives the same LED through PWM. It can then be controlled by any device on the Matter fabric bound to it (for example, the Zigbee: Light switch built with the Matter extension).

  • On subsequent boots, the device starts directly as a Matter Dimmable Light. A Matter factory reset reverts it to a fresh Zigbee Router.

The radio hand-over, persistent protocol state, factory-reset behavior and onboarding-data generation are common to both combined samples and are described in detail in the Matter extension section of the Light switch sample.

Matter extension limitations

As a proof of concept, the Matter extension has the following limitations:

  • The 802.15.4 radio is time-shared, never concurrent: once the device is provisioned to Matter, Zigbee is torn down, and returning to Zigbee requires a Matter factory reset (which also wipes Matter storage).

  • The Matter extension cannot be combined with the Multiprotocol Bluetooth LE extension (overlay-multiprotocol_ble.conf) or with the Zigbee-only FOTA build (FILE_SUFFIX=fota).

  • The Matter shell (CONFIG_CHIP_LIB_SHELL) and the Matter test shell are disabled to avoid option-parsing conflicts with the Zigbee shell.

  • The memory footprint is tuned empirically for nrf54lm20dk/nrf54lm20a/cpuapp; porting to other targets requires revisiting the libc heap, ZBOSS thread, system work queue and partition sizes used by prj_matter_fota.conf.

Configuration

See Configuring and building in the nRF Connect SDK documentation for information about how to permanently or temporarily change the configuration.

Configuration files for sample extensions

To activate the Matter extension, build the sample with FILE_SUFFIX=matter_fota. This selects the prj_matter_fota.conf configuration, which enables Matter (CONFIG_CHIP), the CONFIG_ZIGBEE_MATTER_COEXISTENCE orchestration layer, and the matching static partition layout.

west build samples/light_bulb -b nrf54lm20dk/nrf54lm20a/cpuapp -- -DFILE_SUFFIX=matter_fota

To produce a size-optimized release build (no logging, console or shell), add matter_fota_release.conf as an extra overlay:

west build samples/light_bulb -b nrf54lm20dk/nrf54lm20a/cpuapp -- -DFILE_SUFFIX=matter_fota -DEXTRA_CONF_FILE='matter_fota_release.conf'

See Matter extension limitations for supported board targets and incompatible options.

User interface

LED 0:

Blinks to indicate that the main application thread is running.

LED 1:

Indicates the dimmable light option, that is changes to the light bulb brightness. It can be controlled by another Zigbee device in the network, for example a light switch. Blinks when the light bulb is in Identify mode.

LED 2:

Turns on when the light bulb joins the network.

Button 3:

Depending on how long the button is pressed:

  • If pressed for less than five seconds, it starts or cancels the Identify mode.

  • If pressed for five seconds, it initiates the factory reset of the device. The length of the button press can be edited using the CONFIG_FACTORY_RESET_PRESS_TIME_SECONDS Kconfig option from Zigbee application utilities. Releasing the button within this time does not trigger the factory reset procedure.

Building and running

Make sure to configure the Zigbee stack before building and testing this sample. See Configuring Zigbee R23 add-on for more information.

This sample can be found under samples/light_bulb in the Zigbee R23 add-on folder structure.

To build the sample, follow the instructions in Building an application in the nRF Connect SDK documentation for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the Zigbee R23 add-on which is an SDK repository, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

Testing

After programming the sample to your development kits, complete the following steps to test it:

  1. Turn on the development kit that runs the Network coordinator sample.

    When LED 2 turns on, this development kit has become the Coordinator of the Zigbee network and the network is established.

  2. Turn on the development kit that runs the Light bulb sample.

    When LED 2 turns on, the light bulb has become a Router inside the network.

    Note

    If LED 2 does not turn on, press Button 0 on the Coordinator to reopen the network.

  3. Turn on the development kit that runs the Light switch sample.

    When LED 2 turns on, the light switch has become an End Device, connected directly to the Coordinator.

  4. Wait until LED 3 on the development kit that runs the Light switch sample turns on.

    This LED indicates that the switch found a light bulb to control.

  5. Use the buttons on the development kit that runs the Zigbee: Light switch sample to control the light bulb.

    The result of using the buttons is reflected on the light bulb’s LED 1.

You can now use buttons on the light switch to control the light bulb, as described in the User interface section of the Light switch sample page.

Testing the Matter extension

See Matter extension for the runtime behavior driving the steps below.

To test the extension, you need:

  • A light bulb built with the Matter extension (see Configuration files for sample extensions).

  • A Zigbee test setup to verify Zigbee operation before Matter commissioning. You can use either the standard setup (a Network coordinator and a Zigbee light switch) or, alternatively, only a Touchlink-capable light switch (for example, the Zigbee: Light switch built with the Matter extension), in which case the Zigbee Coordinator is not needed.

  • A Matter controller that can commission a Thread device over Bluetooth LE, for example CHIP Tool or an ecosystem app (Apple Home, Google Home, Amazon Alexa).

  • A Thread Border Router reachable by the Matter fabric.

  • Optionally, a Matter switch on the same Thread fabric to be bound to the light bulb (for example, the Zigbee: Light switch built with the Matter extension).

Complete the following steps to exercise the full Zigbee-to-Matter flow:

  1. Verify Zigbee operation in one of the following ways:

    • Follow the standard Testing procedure with a Zigbee Network coordinator and a Zigbee light switch.

    • Or, skip the Zigbee Coordinator and pair the light bulb directly with a Touchlink-capable light switch:

      1. Power the light bulb (Touchlink target).

      2. Power the light switch and press its Touchlink button (see Touchlink commissioning). The two devices form a distributed-security Zigbee network without a Zigbee Coordinator, and the light switch finds and controls the light bulb.

    While the device is still a Zigbee Router, it also advertises for Matter commissioning over Bluetooth LE.

  2. Commission the device using the onboarding payload produced by the Matter factory data build (QR code or manual pairing code). After the Matter CASE session is established, the light bulb hands the radio over to Thread and stops participating in the Zigbee network.

  3. Drive the light bulb from a Matter peer:

    • From the controller directly, with chip-tool onoff toggle or chip-tool levelcontrol move-to-level .

    • Or by binding a Matter switch to the light bulb and using the switch’s dimmer button.

  4. To return the device to Zigbee operation, trigger a Matter factory reset from the controller (for example, chip-tool pairing unpair ). The device reboots as a fresh Zigbee Router with Matter Bluetooth LE advertising active again.

Dependencies

This sample uses the following nRF Connect SDK libraries:

It uses the ZBOSS stack:

In addition, it uses the following Zephyr libraries:

If you are using the optional Matter extension, this sample requires the following dependencies:

  • The Matter stack (CONFIG_CHIP) shipped with the nRF Connect SDK, including the On/Off, Level Control and Identify clusters and the Matter factory data module.

  • OpenThread (used by Matter on 802.15.4) and the SoftDevice Controller (used for CHIPoBLE commissioning).

  • The zigbee_matter_coexistence and zigbee_matter_protocol_state libraries, which orchestrate the 802.15.4 radio hand-over and persist the selected protocol.

  • The nrf_802154_callbacks_dispatcher (CONFIG_NRF_802154_CALLBACKS_DISPATCHER) with runtime re-init (CONFIG_NRF_802154_DRV_REINIT_ENABLED).