This example is based on the M5Stack CoreS3 and leverages its touchscreen to demonstrate the Credential Sharing feature in Thread 1.4 release, in addition to basic Thread BR functionality.
The ePSKc can be generated via the touchscreen and is used to establish a DTLS session with a Thread Commissioner. Thread credentials can then be retrieved or configured through the secure session.
This example requires the M5Stack Thread Border Router, a ready-to-use Thread Border Router solution built with the M5Stack CoreS3 (ESP32-S3) and the ESP32-H2 Thread/Zigbee Gateway Module.
This example requires IDF v5.5.5. It may not be compatible with older or newer versions of IDF.
ESP32-S3 is the SoC on M5Stack CoreS3, so set target to esp32s3:
idf.py set-target esp32s3The example is pre-configured via sdkconfig.defaults, and most configurations do not need to be modified using idf.py menuconfig. You can modify the following parameters as needed:
- Initial OpenThread dataset, such as the
networkkeyandchannel. - Lifetime and port of the Ephemeral Key, which can be configured via
menuconfig -> ESP Thread Border Router M5Stack Example.
First build the ot_rcp example in IDF. In the building process, the built RCP image will be automatically packed into the Border Router firmware.
Build the project and flash it to the board, then run monitor tool to view serial output:
idf.py build
idf.py -p PORT erase-flash flash monitor
Follow the steps below to set up the Thread Border Router:
-
First Boot: On first boot, the device will start in SoftAP mode and provide a Wi-Fi configuration WEB service.
-
Configure Wi-Fi:
- Join the SoftAP network (SSID:
ESP-ThreadBR-xxx) from your phone or PC - Visit
http://192.168.4.1to configure Wi-Fi SSID and password
- Join the SoftAP network (SSID:
-
Connect and Form Network: Once configured, the device will:
- Connect to the configured Wi-Fi network
- Form a Thread network
- Act as a Thread Border Router
Once completed, the device will display the WEB server URL on its screen (see ESP Thread BR WEB GUI).
The Share Thread Network Credential button is used to generate an OpenThread ephemeral key and advertise the meshcop-e service on the Wi-Fi network. This ephemeral key enables the Thread Commissioner to establish a secure session with the Thread Border Router, allowing the Commissioner to retrieve or configure the network credential on the Border Router.
For more usage instructions and Thread Border Router features, refer to ESP Thread BR CodeLab.
The above configuration process is intended for use with the Module Gateway H2. If you are using the Unit Gateway H2:
Please follow the steps below:
- Hardware Setup: Prepare a Unit Gateway H2 flashed with
ot_rcpand connect it to the M5Stack viaPORT.C. - Build Configuration:
- Enable the
RADIO_CO_PROCESSOR_UNIT_H2feature via menuconfig. - Disable the
AUTO_UPDATE_RCPfeature via menuconfig. - Set
PIN_TO_RCP_TXto18andPIN_TO_RCP_RXto17via menuconfig.
- Enable the
After that, build and flash as usual. The example will then operate using the Unit Gateway H2.

