This example is built on Matter and the NXP RW612 SDK, supporting remote access and control of a light bulb over Wi-Fi with OpenThread Border Router (OTBR).
The Matter FRDM-RW612 Light Switch Combo example demonstrates a dual-endpoint application. Endpoint 1 represents a Light Device (bulb), while Endpoint 2 functions as a Light Switch device.Buttons are used to either turn the local light bulb (Endpoint 1) on and off or control other bound lights via Endpoint 2, which acts as a switch. This example serves as a reference for developing your own Matter-based applications.
It operates as a Matter accessory, meaning it can be paired with an existing Matter network and controlled through that network.
- Software
- Hardware
- Setup
- Flashing and debugging
- Matter cli mode
- Demo with NXP chip-tool APP
- Support
- Release Notes
In order to build the Project CHIP example, we recommend using a Linux distribution.
The build system has been tested on the following Operating Systems:
- macOS 10.15
- Debian 11 (64 bit required)
- Ubuntu 22.04 LTS
- Windows 10 (experimental)
The Matter build system has the following features:
- Very fast and small footprint
- Cross-platform handling: Linux, Darwin, Embedded Arm, among others
- Multiple toolchains & cross toolchain dependencies
- Integrates automated testing framework:
ninja check
- Introspection:
gn desc
- Automatic formatting:
gn format
The following board is required:
- Make sure that below prerequisites are correctly installed .
sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev \
libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev \
python3-pip unzip libgirepository1.0-dev libcairo2-dev libreadline-dev
- Step 1: Clone Matter repo:
$ git clone -b v1.4.0.0 https://github.com/NXP/matter.git && pushd . && cd matter && scripts/checkout_submodules.py --shallow --platform nxp --recursive &&source ./scripts/activate.sh && ./third_party/nxp/nxp_matter_support/scripts/update_nxp_sdk.py --platform common && popd
- Step 2: Clone and overwrite the files
$ git clone https://github.com/nxp-appcodehub/ap-frdm-rw612-light-switch-otbr-combo.git && cp -r -f ap-frdm-rw612-light-switch-otbr-combo/examples matter/.
- Step 3: Activate local environment
$ cd matter
$ source ./scripts/activate.sh
- Step 4: Build Matter with Border Router configuration with BLE commissioning (ble-wifi)
$ cd examples/light-switch-combo-app/nxp/rt/rw61x
# Create the project
$ gn gen --args='chip_enable_wifi=true chip_enable_openthread=true nxp_enable_matter_cli=true board_version="frdm" nxp_use_factory_data=false chip_enable_ota_requestor=false no_mcuboot=true' out/debug
$ ninja -C out/debug
The application binary can be found in out/debug/chip-rw61x-light-switch-combo-example
Optional GN options that can be added when building an application:
- To enable the
matter CLI,
the argument
nxp_enable_matter_cli=true
must be added to the gn gen command. - By default, the
NXP RD-RW612-BGA
board revision will be chosen. To switch toNXP FRDM-RW612
board revision, the argumentboard_version=\"frdm\"
must be added to the gn gen command. - To build the application in debug mode, the argument
is_debug=true optimize_debug=false
must be added to the gn gen command. - To build with the option to have Matter certificates/keys pre-loaded in a
specific flash area the argument
chip_with_factory_data=1
can be added to the gn gen command. (for more information see Guide for writing manufacturing data on NXP devices. - To build the application with the OTA Requestor enabled, the arguments
chip_enable_ota_requestor=true no_mcuboot=false
must be added to the gn gen command. (More information about the OTA Requestor feature in OTA Requestor README
There 2 ways to flash the application image to FRDK-RW612, Jlink, and MCUXpresso. The first way to flash the application on FRDM-RW612 is using the Jlink tool.
-
Install JLink_Windows
-
The original application file name is
chip-rw61x-light-switch-combo-example.hex
. change the file extension form “.hex ” to “.srec ”, after the file name: chip-rw61x-light-switch-combo-example.srec -
Create a txt file -
commands_script
and with the following content (change the application name accordingly):
reset
halt
loadfile chip-rw61x-light-switch-combo-example.srec
reset
go
quit
- Copy the application and commands_script in the folder where the JLink executable is placed. Execute:
$ jlink -device RW612 -if SWD -speed 4000 -autoconnect 1 -CommanderScript commands_script
After the flash success, start the application on the RW612 FRDM.
In order to flash the application we recommended using MCUXpresso IDE (version >= 11.6.0).
- Import the previously downloaded NXP SDK into MCUXpresso IDE. (link)
Right click the empty space in the MCUXpresso IDE "Installed SDKs" tab to show the menu, select the "Import archive" (or "Import folder" if a folder is used) menu item.
- Import the connectedhomeip repo in MCUXpresso IDE as Makefile Project. Use none as Toolchain for Indexer Settings:
File -> Import -> C/C++ -> Existing Code as Makefile Project
- Configure MCU Settings:
Right click on the Project -> Properties -> C/C++ Build -> MCU Settings -> Select RW612 -> Apply & Close
- Configure the toolchain editor:
Right click on the Project -> C/C++ Build-> Tool Chain Editor -> NXP MCU Tools -> Apply & Close
- Create a debug configuration :
Right click on the Project -> Debug -> As->SEGGER JLink probes -> OK -> Select elf file
- Debug using the newly created configuration file.
CHIP Tool is a Matter controller which can be used to commission a Matter device into the network. For more information regarding how to use the CHIP Tool controller, please refer to the CHIP Tool guide.
To know how to commission a device over BLE, follow the instructions from chip-tool's README.md 'Commission a device over BLE'.
To know how to commissioning a device over IP, follow the instructions from chip-tool's README.md 'Pair a device over IP'
The Matter CLI can be enabled with the chip-rw61x-light-switch-combo-example application.
For more information about the Matter CLI default commands, you can refer to the dedicated ReadMe.
The chip-rw61x-light-switch-combo-example application supports additional commands :
> help
[...]
mattercommissioning Open/close the commissioning window. Usage : mattercommissioning [on|off]
matterfactoryreset Perform a factory reset on the device
matterreset Reset the device
matterfactoryreset
command erases the file system completely (all Matter settings are erased). Or You can hold SW2 for 3 seconds for the device factoryreset.matterreset
enables the device to reboot without erasing the settings.
Here are described steps to use the light-switch-combo-app with the Matter CLI enabled
-
Prepare the board with the flashed
chip-rw61x-light-switch-combo-example
(as shown above). -
The matter CLI is accessible in
MCU-Link
. For that, start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:- Baud rate: 115200
- 8 data bits
- 1 stop bit
- No parity
- No flow control
-
On the client side, start sending commands using the chip-tool application as it is described here.
This chapter provides a demo tutorial on how to use the FRDM-RW612 with NXP’s Chip-Tool app for pairing and basic control operations.
For more detailed information, please refer to the following link:
UG10178 Quick Start to the Matter Demo NXP CHIP Tool app, FRDM-RW612 and FRDMMCU W71
-
Using the Android phone, go to the Google Play Store
-
Search “NXP Matter Chip-tool”
Configure a externet AP as shown below.
- If the AP supports the IPv6 DHCP server, it must be
disabled
. - WPA3 is not supported in the Matter demo binary for FRDM-RW612(OTBR). The AP must be configured in
WPA2 mode
.
Connect your android phone to the Access Point first .The Android phone and FRDM-RW612(OTBR) must be connected to an Access Point and able to reach each other via its IPv6 address.
Please ensure that your phone is connected to the correct AP and that Bluetooth is turned on. And make sure your device has been factory reset. You can enter the Matter CLI mode to run #matter factoryreset
, or press and hold SW2 for 3 seconds to reset the device to its factory settings.
Step1 . Open the Chip-tool app and tap Pair New Device (WiFi Device).
Step2 . Select input manually , not scan QRcode.
Step3 . Enter the discriminator and PIN code (default values: 3840 and 20202021, respectively).
Step4 . Enter your Wi-Fi SSID and password. Once pairing is successful, assign a name to your device.
Note : If there is still an error, wait a moment and repeat the step.
Step5 . Once the device is successfully paired, you can control the switch.
When the FRDM-RW612 firmware startup, the OTBR will be automatically brought up.
Get the OTBR table list as shown in the following example:
>otcli dataset active
Active Timestamp: 1
Channel: 17
Channel Mask: 0x07fff800
Ext PAN ID: 1111111122222222
Mesh Local Prefix: fdca:a943:242e:b986::/64
Network Key: 00112233445566778899aabbccddeeff
Network Name: OpenThread-b04c
PAN ID: 0x1234
PSKc: 8d4874b9ac7e0ad605179fc71af9a1c8
Security Policy: 672 onrc 0
Done
If you need to create a new thread netwrok , for Matter with OpenThread Border Router support, the matter CLI can be used to start/join the Thread network, using the following ot-cli commands .
> otcli dataset init new
Done
> otcli dataset
Active Timestamp: 1
Channel: 25
Channel Mask: 0x07fff800
Ext PAN ID: 42af793f623aab54
Mesh Local Prefix: fd6e:c358:7078:5a8d::/64
Network Key: f824658f79d8ca033fbb85ecc3ca91cc
Network Name: OpenThread-b870
PAN ID: 0xb870
PSKc: f438a194a5e968cc43cc4b3a6f560ca4
Security Policy: 672 onrc 0
Done
> otcli dataset panid 0xabcd
Done
> otcli dataset channel 25
Done
> otcli dataset commit active
Done
> otcli ifconfig up
Done
> otcli thread start
Done
> otcli state
leader
Done
To enable Thread Border Router support see the build section.
The complete Border Router guide is located here.
UG10178 Quick Start to the Matter Demo NXP CHIP Tool app, FRDM-RW612 and FRDMMCU W71
Open Thread CLI Command Reference link
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.
Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
Version | Description / Update | Date |
---|---|---|
1.0 | Initial release on Application Code Hub | February 20th 2025 |
NXP, the NXP logo, NXP SECURE CONNECTIONS FOR A SMARTER WORLD, Airfast, Altivec, ByLink, CodeWarrior, ColdFire, ColdFire+, CoolFlux, CoolFlux DSP, DESFire, EdgeLock, EdgeScale, EdgeVerse, elQ, Embrace, Freescale, GreenChip, HITAG, ICODE and I-CODE, Immersiv3D, I2C-bus logo , JCOP, Kinetis, Layerscape, MagniV, Mantis, MCCI, MIFARE, MIFARE Classic, MIFARE FleX, MIFARE4Mobile, MIFARE Plus, MIFARE Ultralight, MiGLO, MOBILEGT, NTAG, PEG, Plus X, POR, PowerQUICC, Processor Expert, QorIQ, QorIQ Qonverge, RoadLink wordmark and logo, SafeAssure, SafeAssure logo , SmartLX, SmartMX, StarCore, Symphony, Tower, TriMedia, Trimension, UCODE, VortiQa, Vybrid are trademarks of NXP B.V. All other product or service names are the property of their respective owners. © 2021 NXP B.V.