• ESP Matter on ESP32H2


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

    Supported ESP-IDF and connectedhomeip versions

    • For Wi-Fi devices (ESP32, ESP32-C3, ESP32-S3), ESP-IDF v4.4.1 release is required.
    • For Thread devices (ESP32-H2), ESP-IDF master branch at commit 047903c should be used.

    Hardware Required


    • Ubuntu 20.04 PC, with BLE dongle installed
    • 1x ESP32 DevkitC
    • 2x ESP32-H2 DevKitC
    • Phone (Optional, only required if you want to try the matter phone app)

    The Topology:
    在这里插入图片描述

    Step 1. Getting the Repositories


    This only needs to be done once:

    $ git clone https://github.com/espressif/esp-matter
    $ cd esp-matter/connectedhomeip/connectedhomeip
    $ source scripts/bootstrap.sh
    
    • 1
    • 2
    • 3

    Step 2. Configuring the environment


    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/
    
    • 1
    • 2
    • 3
    • 4
    • 5

    Step 3. Setup the Thread Border Router (ESP32 + ESP32-H2)


    (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.

    Hardware connection:

    在这里插入图片描述

    ESP32 pinESP32-H2 pin
    GNDG
    GPIO4TX
    GPIO5RX

    Build and flash the RCP (ESP32-H2)

    cd esp-idf/examples/openthread/ot_rcp
    idf.py --preview set-target esp32h2
    idf.py -p <port> build flash
    
    • 1
    • 2
    • 3

    Build and flash the border router (ESP32)

    cd esp-idf/examples/openthread/ot_br
    idf.py set-target esp32
    idf.py menuconfig
    
    • 1
    • 2
    • 3

    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
    
    • 1

    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
    >
    
    • 1
    • 2
    • 3
    • 4
    • 5

    Step 4. Setup Thread End Device (ESP32-H2)


    cd esp-matter/examples/light
    idf.py --preview set-target esp32h2
    idf.py -p <port> build flash monitor
    
    • 1
    • 2
    • 3

    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.)

    Step 5. Build Matter command line control tool


    cd esp-matter/connectedhomeip/connectedhomeip
    ./scripts/build_python.sh -m platform
    
    • 1
    • 2

    Step 6. Pair and control the light end device


    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
    
    • 1
    • 2

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
  • 相关阅读:
    7月SCI/SSCI期刊变动,警惕这5本被剔除
    【面试题】公平锁和非公平锁/可重入锁
    C语言:给定两个数,求这两个数的最大公约数(新思路:辗转相除法)
    C++类和对象的声明、解析、使用(构造、析构函数、友元、命名空间)
    Redis命令和Redisson对象匹配列表
    MySQL常用指令整理
    PyPy+Cython对Python进行加速,以及乱码问题
    Android系统10 RK3399 init进程启动(四十) 开机自启动脚本init.rc执行逻辑框架
    Python和Java二选一该学啥?
    小红书账号怎么做起来的呢?干货!快收藏起来!
  • 原文地址:https://blog.csdn.net/Marchtwentytwo/article/details/126254696