This documentation gives instructions on building and running the Matter light example on ESP32-H2.
The Topology:

This only needs to be done once:
$ git clone https://github.com/espressif/esp-matter
$ cd esp-matter/connectedhomeip/connectedhomeip
$ source scripts/bootstrap.sh
This needs to be done everytime a new terminal is opened:
$ cd /path/to/esp-idf
$ . export.sh
$ cd /path/to/esp-matter/
$ . export.sh
$ cd examples/light/
(This step is optional if you have other Thread Border Router solutions)
A Thread border router is required to provide the IP connectivity to the thread end device. A border router
solution shipped in ESP-IDF is composed of two parts: the Radio Co-Processor(RCP) running on ESP32-H2 and
the border router running on ESP32.

| ESP32 pin | ESP32-H2 pin |
|---|---|
| GND | G |
| GPIO4 | TX |
| GPIO5 | RX |
cd esp-idf/examples/openthread/ot_rcp
idf.py --preview set-target esp32h2
idf.py -p <port> build flash
cd esp-idf/examples/openthread/ot_br
idf.py set-target esp32
idf.py menuconfig
In the menuconfig, select Example Connection Configuration > connect using WiFi interface . Input thevWiFi SSID and password you’d like to connect to.
idf.py -p <port> flash monitor
The border router will be running on ESP32. It provides an interactive OpenThread shell:
> state
I(23374) OPENTHREAD:[INFO]-CLI-----: execute command: state
leader
Done
>
cd esp-matter/examples/light
idf.py --preview set-target esp32h2
idf.py -p <port> build flash monitor
Now the light app will be running on ESP32-H2.
( Note: If the version of esp32-h2 is displayed wrong when burning (h2 has two versions, date1 and date2). Please go to the menuconfig file to set the chip target to the version used.)
cd esp-matter/connectedhomeip/connectedhomeip
./scripts/build_python.sh -m platform
Your host machine shall be under the same WiFi as the Thread border router.
First enable ICMPv6 auto configuration on your host machine. Note to replace the interface name wlan0 with the real interface name on your machine.
sudo sysctl -w net/ipv6/conf/wlan0/accept_ra=2
sudo sysctl -w net/ipv6/conf/wlan0/accept_ra_rt_info_max_plen=128
Then on ot_br console, fetch the Thread active dataset to be sent to the device and the networkID to be used for enabling the Thread network :
> dataset active -x
I(111204) OPENTHREAD:[INFO]-CLI-----: execute command: dataset active -x
0e080000000000010000000300000f35060004001fffe00208dead00beef00cafe0708fd44b1f21b8ae77605100
Done
> extpanid
I(111205) OPENTHREAD:[INFO]-CLI-----: execute command: extpanid
dead00beef00cafe
Done
Now run chip-device-ctrl to pair the device:
esp-matter/connectedhomeip/connectedhomeip/out/python_env/bin/chip-device-ctrl
[1631175381.811277][824387:824387] CHIP:IN: local node id is 0x000000000001B669
[1631175381.812494][824387:824387] CHIP:DL: Avahi client registered
[1631175381.812898][824387:824387] CHIP:ZCL: Using ZAP configuration...
[1631175381.812920][824387:824387] CHIP:ZCL: deactivate report event
[1631175381.812926][824387:824387] CHIP:CTL: Getting operational keys
[1631175381.812987][824387:824387] CHIP:CTL: Getting root certificate for the controller fr
[1631175381.813176][824387:824387] CHIP:CTL: Generating operational certificate for the con
[1631175381.813325][824387:824387] CHIP:CTL: Getting intermediate CA certificate from the i
[1631175381.813361][824387:824387] CHIP:CTL: GetIntermediateCACertificate returned 0
[1631175381.813401][824387:824387] CHIP:CTL: Generating credentials
[1631175381.813460][824387:824387] CHIP:CTL: Loaded credentials successfully
[1631175381.815493][824387:824395] CHIP:DL: Platform main loop started.
Chip Device Controller Shell
chip-device-ctrl > connect -ble 3840 20202021 12344321
chip-device-ctrl > zcl NetworkCommissioning AddThreadNetwork 12344321 0 0 operationalDatase
chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 12344321 0 0 networkID=hex:dead00
chip-device-ctrl > close-ble
chip-device-ctrl > resolve 12344321
chip-device-ctrl > zcl OnOff Toggle 12344321 1 0