Note: This example is intended only to perform smoke tests of a Matter solution integrated with nRF Connect SDK platform. The example quality is not production ready and it may contain minor bugs or use not optimal configuration. It is not recommended to use this example as a basis for creating a market ready product.
For the production ready and optimized Matter samples, see nRF Connect SDK samples. The Matter samples in nRF Connect SDK use various additional software components and provide multiple optional features that improve the developer and user experience. To read more about it, see Matter support in nRF Connect SDK page. Using Matter samples from nRF Connect SDK allows you to get a full Nordic technical support via DevZone portal.
The nRF All Clusters Example Application implements various ZCL clusters populated on three endpoints. You can use this example as a reference for creating your own application.
The example is based on Matter and Nordic Semiconductor's nRF Connect SDK, and was created to facilitate testing and certification of a Matter device communicating over a low-power, 802.15.4 Thread network.
The example behaves as a Matter accessory, that is a device that can be paired into an existing Matter network and can be controlled by this network. The device works as a Thread Minimal End Device.
This example is running on the nRF Connect platform, which is based on Nordic Semiconductor‘s nRF Connect SDK and Zephyr RTOS. Visit Matter’s nRF Connect platform overview to read more about the platform structure and dependencies.
By default, the Matter accessory device has IPv6 networking disabled. You must pair it with the Matter controller over Bluetooth® LE to get the configuration from the controller to use the device within a Thread or Wi-Fi network. You have to make the device discoverable manually (for security reasons). See Bluetooth LE advertising to learn how to do this. The controller must get the commissioning information from the Matter accessory device and provision the device into the network.
You can test this application remotely over the Thread or the Wi-Fi protocol, which in either case requires more devices, including a Matter controller that you can configure either on a PC or a mobile device.
In this example, to commission the device onto a Matter network, it must be discoverable over Bluetooth LE. For security reasons, you must start Bluetooth LE advertising manually after powering up the device by pressing Button 4.
In this example, the commissioning procedure is done over Bluetooth LE between a Matter device and the Matter controller, where the controller has the commissioner role.
To start the rendezvous, the controller must get the commissioning information from the Matter device. The data payload is encoded within a QR code, printed to the UART console.
Last part of the rendezvous procedure, the provisioning operation involves sending the Thread network credentials from the Matter controller to the Matter device. As a result, device is able to join the Thread network and communicate with other Thread devices in the network.
The application requires a specific revision of the nRF Connect SDK to work correctly. See Setting up the environment for more information.
The example supports building and running on the following devices:
Hardware platform | Build target | Platform image |
---|---|---|
nRF52840 DK | nrf52840dk/nrf52840 | nRF52840 DK |
nRF5340 DK | nrf5340dk/nrf5340/cpuapp | nRF5340 DK |
nRF52840 Dongle | nrf52840dongle/nrf52840 | nRF52840 Dongle |
This section lists the User Interface elements that you can use to control and monitor the state of the device. These correspond to PCB components on the platform image.
Note:
The following Device UI elements are missing on the nRF52840 Dongle: Button 2, Button 3, Button 4, SEGGER J-Link USB port, and NFC port with antenna attached. You can collect logs from the nRF52840 Dongle using the nRF USB port instead of the SEGGER J-Link USB port. Functionalities associated with the remaining missing elements are inaccessible.
LED 1 shows the overall state of the device and its connectivity. The following states are possible:
Short Flash On (50 ms on/950 ms off) — The device is in the unprovisioned (unpaired) state and is waiting for a commissioning application to connect.
Rapid Even Flashing (100 ms on/100 ms off) — The device is in the unprovisioned state and a commissioning application is connected through Bluetooth LE.
Short Flash Off (950ms on/50ms off) — The device is fully provisioned, but does not yet have full connectivity for Thread or Wi-Fi network, or the related services.
Solid On — The device is fully provisioned and has full Thread network and service connectivity.
Button 1 can be used for the following purposes:
Button 4 — Pressing the button once starts Bluetooth LE advertising for the predefined period of time (15 minutes by default).
SEGGER J-Link USB port can be used to get logs from the device or communicate with it using the command line interface.
Before building the example, check out the Matter repository and sync submodules using the following command:
$ git submodule update --init
The example requires a specific revision of the nRF Connect SDK. You can either install it along with the related tools directly on your system or use a Docker image that has the tools pre-installed.
If you are a macOS user, you won't be able to use the Docker container to flash the application onto a Nordic development kit due to certain limitations of Docker for macOS. Use the native shell for building instead.
To use the Docker container for setup, complete the following steps:
If you do not have the nRF Connect SDK installed yet, create a directory for it by running the following command:
$ mkdir ~/nrfconnect
Download the latest version of the nRF Connect SDK Docker image by running the following command:
$ docker pull nordicsemi/nrfconnect-chip
Start Docker with the downloaded image by running the following command, customized to your needs as described below:
$ docker run --rm -it -e RUNAS=$(id -u) -v ~/nrfconnect:/var/ncs -v ~/connectedhomeip:/var/chip \ -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" nordicsemi/nrfconnect-chip
In this command:
Update the nRF Connect SDK to the most recent supported revision, by running the following command:
$ cd /var/chip $ python3 scripts/setup/nrfconnect/update_ncs.py --update
Now you can proceed with the Building instruction.
To use the native shell for setup, complete the following steps:
Download and install the following additional software:
If you do not have the nRF Connect SDK installed, follow the guide in the nRF Connect SDK documentation to install the latest stable nRF Connect SDK version. Since command-line tools will be used for building the example, installing SEGGER Embedded Studio is not required.
If you have the SDK already installed, continue to the next step and update the nRF Connect SDK after initializing environment variables.
Initialize environment variables referred to by the CHIP and the nRF Connect SDK build scripts. Replace nrfconnect-dir with the path to your nRF Connect SDK installation directory, and toolchain-dir with the path to GNU Arm Embedded Toolchain.
$ source nrfconnect-dir/zephyr/zephyr-env.sh $ export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb $ export GNUARMEMB_TOOLCHAIN_PATH=toolchain-dir
Update the nRF Connect SDK to the most recent supported revision by running the following command (replace matter-dir with the path to Matter repository directory):
$ cd matter-dir $ python3 scripts/setup/nrfconnect/update_ncs.py --update
Now you can proceed with the Building instruction.
Complete the following steps, regardless of the method used for setting up the environment:
Navigate to the example's directory:
$ cd examples/all-clusters-minimal-app/nrfconnect
Run the following command to build the example, with build-target replaced with the build target name of the Nordic Semiconductor's kit you own, for example nrf52840dk/nrf52840
:
$ west build -b build-target --sysbuild
You only need to specify the build target on the first build. See Requirements for the build target names of compatible kits.
The output zephyr.hex
file will be available in the build/nrfconnect/zephyr/
directory.
If you're planning to build the example for a different kit or make changes to the configuration, remove all build artifacts before building. To do so, use the following command:
$ rm -r build
To build the example with release configuration that disables the diagnostic features like logs and command-line interface, run the following command:
$ west build -b build-target --sysbuild -- -DFILE_SUFFIX=release
Remember to replace build-target with the build target name of the Nordic Semiconductor's kit you own.
Support for DFU using Matter OTA is disabled by default.
To build the example with configuration that supports DFU, run the following command with build-target replaced with the build target name of the Nordic Semiconductor kit you are using (for example nrf52840dk/nrf52840
):
$ west build -b build-target --sysbuild -- -DFILE_SUFFIX=dfu
Note:
There are two types of Device Firmware Upgrade modes: single-image DFU and multi-image DFU. Single-image mode supports upgrading only one firmware image, the application image, and should be used for single-core nRF52840 DK devices. Multi-image mode allows to upgrade more firmware images and is suitable for upgrading the application core and network core firmware in two-core nRF5340 DK devices.
Currently the multi-image mode is not available for the Matter OTA DFU.
To change the default MCUboot configuration, edit the prj.conf
file located in the sysbuild/mcuboot
directory.
In the default configuration, the MCUboot uses the Partition Manager to configure flash partitions used for the bootloader application image slot purposes. You can change these settings by defining static partitions. This example uses this option to define using an external flash.
To modify the flash settings of your board (that is, your build-target, for example nrf52840dk/nrf52840
), edit the pm_static_<build_target>.yml
file (for example pm_static_nrf52840dk_nrf52840.yml
), located in the main application directory.
The Zephyr ecosystem is based on Kconfig files and the settings can be modified using the menuconfig utility.
To open the menuconfig utility, run the following command from the example directory:
$ west build -b build-target --sysbuild -t menuconfig
Remember to replace build-target with the build target name of the Nordic Semiconductor's kit you own.
Changes done with menuconfig will be lost if the build
directory is deleted. To make them persistent, save the configuration options in the prj.conf
file.
The example uses different configuration files depending on the supported features. Configuration files are provided for different build types and they are located in the application root directory.
The prj.conf
file represents a debug build type. Other build types are covered by dedicated files with the build type added as a suffix to the prj part, as per the following list. For example, the release build type file name is prj_release.conf
. If a board has other configuration files, for example associated with partition layout or child image configuration, these follow the same pattern.
Before you start testing the application, you can select one of the build types supported by the sample. This sample supports the following build types, depending on the selected board:
For more information, see the Configuring nRF Connect SDK examples page.
The flashing and debugging procedure is different for the development kits and the nRF52840 Dongle.
To flash the application to the device, use the west tool and run the following command from the example directory:
$ west flash --erase
If you have multiple development kits connected, west will prompt you to pick the correct one.
To debug the application on target, run the following command from the example directory:
$ west debug
Visit Programming and Debugging nRF52840 Dongle to read more about flashing on the nRF52840 Dongle.
Check the CLI tutorial to learn how to use command-line interface of the application.
Read the CHIP Tool user guide to see how to use CHIP Tool for Linux or mac OS to commission and control the application within a Matter-enabled Thread network.
Read the Android commissioning guide to see how to use CHIPTool for Android smartphones to commission and control the application within a Matter-enabled Thread network.