pdf-icon

Product Guide

Real-Time AI Voice Assistant

Offline Voice Recognition

Thread

Module Gateway H2

IoT Tools

IoT Cloud

Ethernet Camera

Develop Tools

DIP Switch Usage Guide

Module GPS v2.0

Module GNSS

Module ExtPort For Core2

ESP Thread Border Router

The Unit Gateway H2 supports running the ESP Thread Border Router SDK with the ESP32 series Wi-Fi SoC. This SDK is built based on ESP-IDF and OpenThread, running the Thread network on the H2, which communicates with the main processor via a serial port.

1. Preparation

ESP-IDF version
It is recommended to use ESP-IDF version v5.3.1 for compiling this example.
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git checkout v5.3.1 # recommend
./install.sh
. ./export.sh

  • 3.The idf.py commands used in the subsequent tutorials depend on ESP-IDF. Before running the commands, you need to execute . ./export.sh in ESP-IDF to activate the relevant environment variables. For detailed instructions, please refer to the ESP-IDF - ESP32S3 Getting Started Guide .

2. Compile RCP Firmware

  • 1.Before compiling the Thread Border Router firmware, you need to generate the RCP firmware first. Refer to the following instructions to enter the corresponding RCP firmware directory and set the compilation target to esp32h2.
Baud Rate Modification
Due to factors such as the pin drive capability of the chip, the serial port may not work properly when using a long connecting cable with the Unit. If this happens, you need to reduce the speed appropriately. Here, the default baud rate of 460800 is reduced to 230400.
  • 2.Modify the baud rate by opening main/esp_ot_config.h and changing line 43 .baud_rate = 460800; to .baud_rate = 230400;.
cd examples/openthread/ot_rcp
vim main/esp_ot_config.h
# line 43 .baud_rate = 460800; change to .baud_rate = 230400;
  • 3.After completing the configuration, execute the following commands to compile the RCP firmware.
cd $IDF_PATH/examples/openthread/ot_rcp
idf.py set-target esp32h2
idf.py build
  • 3.Open the Unit Gateway H2 case, hold down the boot button, and then connect the USB power supply to enter download mode. Execute the following commands to flash the firmware.
idf.py flash

3. Compile ESP Thread BR Firmware

  • 1.Pull the project.
git clone https://github.com/Ocean-lhy/esp-thread-br.git
Using Unit Gateway H2 as RCP to implement ESP Thread Border Router requires disabling RCP flashing, modifying the baud rate, and changing the serial port pins. The corresponding code branches have been modified and can be directly switched for use.
  • 2.Switch to the corresponding branch based on the main control device used.
# coreS3
git checkout demo_for_unit_coreS3
cd examples/thread_border_router_credential_sharing
idf.py set-target esp32s3
# core2 v1.0 and v1.1 have different power management chips, AXP192 and AXP2101 respectively, which need to be configured in menuconfig
git checkout demo_for_unit_core2
cd examples/thread_border_router_credential_sharing
idf.py set-target esp32
# core
git checkout demo_for_unit_core
cd examples/thread_border_router_credential_sharing
idf.py set-target esp32
  • 3.Use idf.py menuconfig to enter the configuration page. Configure WiFi information in menuconfig: Component config -> Example Connection Configuration
idf.py menuconfig
  • 4.Compile and flash the ESP Thread BR firmware
idf.py build
idf.py erase_flash
idf.py flash

4. Start Running

  • 1.Connect the Unit Gateway H2 to the main control device PORT.C, and wait for the device to connect to Wi-Fi and the Thread network. After the device initialization is complete, the following information will be displayed:

  • generate epskc button

  • factoryreset button

  • Border router web server URL

  • 2.Click the generate epskc button, and the device will generate an epskc, which will be displayed on the screen and can be used for quick network access.
  • 3.Within the local network, use a browser to access the Border router web server URL to view Thread network information.
  • 4.If you want to modify the connected WIFI, you can use the serial port command interface to input the command wifi -s SSID -p PASSWORD, and then restart the device.

5. Testing

Use Unit Gateway H2 (ESP32-H2) or NanoC6 (ESP32-C6), refer to the example program to flash the OpenThread SimpleCLI example, connect to the Thread network, and view Thread network information.

  1. In the ThreadBorderRouter background, input networkkey, panid, channel to obtain the Thread network's network key, panid, and channel.

  2. In the SimpleCLI example, input configuration commands and start the Thread network

networkkey <networkkey>
panid <panid>
channel <channel>
ifconfig up
thread start
  1. In the SimpleCLI serial interaction, input state to view the Thread network status. If connected as a child/router, the Thread network connection is successful. If established as a leader, the configuration may be incorrect.
  2. In the SimpleCLI serial interaction, input parent to view the Thread network's parent node; input extaddr to view the extended address of this node.
  3. In the ThreadBorderRouter serial interaction, input extaddr to view the extended address of this node, which should match the parent extaddr in the SimpleCLI example.
  4. In the ThreadBorderRouter serial interaction, input neighbor table to view the Thread network's neighbor nodes, which should include the node from the SimpleCLI example.
On This Page