In this codelab we will show you how to build and install an Open Thread Border Router on the esp32 development kits.
In this codelab, you will:
In this CodeLab we will build the Open Thread Border Router (ot_br) on an ESP32 development kit. We will then build and install the Thread Radio Co-processor (ot_rcp) on the ESP32-H2. This will allow us to create a border router between a Wifi and Thread Network. In doing so, we will learn how Border Routers work in Matter.
This set of Codelabs will use Ubuntu 22.04
on a Amd64 based architecture. If you are using Mac OS then you should follow the instructions directly from the Matter repo
You will need
Ubuntu 22.04
The total codelab will take approximately a Duration of 30 minuates
to complete.
We will be using the OpenThread Border Router Example application which is available on the Espressif ESP-IDF github repo for ot_br
First thing to do is sonnect the two SoCs via UART, below is an example setup with ESP32 DevKitC and ESP32-H2 DevKitC:
The pin outs are as follows:
ESP32 pin | ESP32-H2 pin |
GND | G |
GPIO4 | TX |
GPIO5 | RX |
Note: Once you have built this circuit I would suggest to disconnect the TX pin from the ESP32. I have found that leaving this connected prevents the flashing of the ESP32-H2 board.
We will be using the OpenThread Radio CoProcessor Example application which is available on the Espressif ESP-IDF github repo for ot_rcp
To run this example, a board with IEEE 802.15.4 module (for example ESP32-H2) is required. We will use the ESP32-H2.
ls /dev/ttyUSB*
Make note of this device.
cd ~/Projects/esp-idf #or where you located your esp-idf environment
source ./export.sh
cd examples/openthread/ot_rcp
idf.py set-target esp32h2
idf.py build
esp_ot_rcp.elf
in the build
directoryNote: if you run into any difficulties in can be useful to clean up the temporary build folder using rm -rf build
as this can often solve some build issues.
sudo usermod -a -G dialout $USER
idf.py -p /dev/ttyUSB0 erase_flash # replace the ttyUSB0 with the correct USB device from above
idf.py -p /dev/ttyUSB0 flash monitor
We will be using the OpenThread Border Router Example application which is available on the Espressif ESP-IDF github repo for ot_br
To run this example, an ESP32 series Wi-Fi SoC (ESP32, ESP32-C, ESP32-S, etc) is required. In this case, we will use an ESP32 development kit v4.
ls /dev/ttyUSB*
Make note of this device.
Note: if you have not already created the environment for connectedhomeip and esp-idf install then follow the steps on the previous page.
cd ~/Projects/esp-idf #or where you located your esp-idf environment
cd examples/openthread/ot_br
idf.py set-target esp32
idf.py build
esp_ot_br.elf
in the build
directoryNote: if you run into any difficulties in can be useful to clean up the temporary build folder using rm -rf build
as this can often solve some build issues.
idf.py -p /dev/ttyUSB1 erase_flash # replace the ttyUSB1 with the correct USB device from above
idf.py -p /dev/ttyUSB1 flash monitor
We will be using the OpenThread CLI Example application which is available on the Espressif ESP-IDF github repo for ot_cli
To run this example, an ESP32 series Wi-Fi SoC (ESP32, ESP32-C, ESP32-S, etc) is required. In this case, we will use a ESP32-C6.
ls /dev/ttyUSB*
Make note of this device.
Note: if you have not already created the environment for connectedhomeip and esp-idf install then follow the steps on the previous page.
cd ~/Projects/esp-idf #or where you located your esp-idf environment
cd examples/openthread/ot_cli
idf.py set-target esp32-c6
idf.py build
esp_ot_cli.elf
in the build
directoryNote: if you run into any difficulties in can be useful to clean up the temporary build folder using rm -rf build
as this can often solve some build issues.
idf.py -p /dev/ttyUSB2 erase_flash # replace the ttyUSB2 with the correct USB device from above
idf.py -p /dev/ttyUSB2 flash monitor
In this section of the codelab, we will check that we can communicate between our Thread network and the external IP network. Specifically, we will try to ping the Google DNS servers (which are on the public Internet)
factoryreset # the device will reboot
> dataset init new
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done
If everything has gone ok you should be able to see that this thread device has become a leader. This may take a few seconds.
> state
leader
Done
> ipaddr
fdde:ad00:beef:0:0:ff:fe00:fc00
fdde:ad00:beef:0:0:ff:fe00:8000
fdde:ad00:beef:0:a7c6:6311:9c8c:271b
fe80:0:0:0:5c27:a723:7115:c8f8
# Get the Active Dataset
> dataset active -x
0e080000000000010000000300001835060004001fffe00208fe7bb701f5f1125d0708fd75cbde7c6647bd0510b3914792d44f45b6c7d76eb9306eec94030f4f70656e5468726561642d35383332010258320410e35c581af5029b054fc904a24c2b27700c0402a0fff8
On the Terminal running the OT_BR example type the following command to join the OT border router to the Wifi Network
wifi connect -s myssid -p mypassword
If everything worked OK you should be able to see that the wifi is connected by using:
> wifi state
connected
Done
On the Terminal running the OT_BR example type the following command to join the OT border router to the Thread Network
> dataset set active 0e080000000000010000000300001835060004001fffe00208fe7bb701f5f1125d0708fd75cbde7c6647bd0510b3914792d44f45b6c7d76eb9306eec94030f4f70656e5468726561642d35383332010258320410e35c581af5029b054fc904a24c2b27700c0402a0fff8
> ifconfig up
Done
> thread start
Done
If everything worked OK you should be able to see that the border router is now a router (or child) on the Thread network:
> state
router # child is also a valid state
Done
In order to do a simple check between the Thread network and the IP network we will ping the Google DNS servers (i.e. 8.8.8.8 or 8.8.4.4) from the Thread device
On the Thread CLI device run the following command:
> ping 8.8.8.8
If everything worked successfully, you should see a response from the Google DNS servers thereby indicating that Thread network traffic has traversed the Border Router into the Wifi network and onwards to the external Internet.
Checkout the official documentation here: Espressif OpenThread Examples