初识Matter——esp-box控制两盏灯
初识Matter
一、效果展示
esp-matter
二、准备
1.ubuntu系统/Mac系统电脑
2.安装esp-idf及esp-matter环境
3.esp-box设备
4.两块esp32
5.两个led灯或使用板载灯
三、烧录固件(esp-box)
下载esp-box例程
克隆库:git clone GitHub - espressif/esp-box: The ESP-BOX is a new generation AIoT development platform released by Espressif Systems.
移动到matter_switch例程目录
给终端配置esp-idf和esp- matter环境
source /Users/xxxx/esp/esp-idf/export.sh
source /Users/xxxx/esp/esp-matter/export.sh
export IDF_CCACHE_ENABLE=1
设置目标设备并编译环境
idf.py set-target esp32s3 build
烧录固件到设备
cd build
esptool.py -p /dev/ttyACM0 write_flash 0 demo_box_s3_box_switch.bin
cd ../
idf.py -p /dev/ttyACM0 monitor
新建终端,配置环境
cd esp-idf; source ./export.sh; cd ..
cd esp-matter; source ./export.sh; cd ..
export IDF_CCACHE_ENABLE=1
chip-tool interactive start
设备配网
chip-tool pairing ble-wifi ${NODE_ID_TO_ASSIGN} ${SSID} ${PASSWORD} 20202021 3840
where:
- ${NODE_ID_TO_ASSIGN} (which must be a decimal number or a 0x-prefixed hex number) is the node id to assign to the node being commissioned.
- ${SSID} is the Wi-Fi SSID either as a string, or in the form hex:XXXXXXXX where the bytes of the SSID are encoded as two-digit hex numbers.
- ${PASSWORD} is the Wi-Fi password, again either as a string or as hex data
pairing ble-wifi 0x7283 Printer_Server 1234567890 20202021 3840
如果使用虚拟机或蓝牙不可用的情况,也可以直接进行设备配网
在设备终端
matter wifi connect ssid password
使用chip-tool 连接设备
chip-tool pairing onnetwork 0x7283 20202021
配网成功后esp-box屏幕会亮起
四、烧录light固件(esp32)
原始例程中led 控制引脚为gpio5。可自行配置
打开终端到esp-matter库的light例程
配置编译环境
source /Users/xxxxx/esp/esp-idf/export.sh
source /Users/xxxxx/esp/esp-matter/export.sh
设置目标设备
idf.py set-target esp32
烧录设备并打开串口,注意选择对应的串口
idf.py erase_flash
idf.py flash monitor
设备配网及id
pairing ble-wifi 0x5164 Printer_Server 1234567890 20202021 3840
另一盏灯操作也如此? id为0x5163
pairing ble-wifi 0x5163 Printer_Server 1234567890 20202021 3840
控制0x5164 灯状态
onoff toggle 0x5164 0x1
五、绑定设备
将两盏灯分别绑定在esp-box的light按钮和switch按钮
更新0x5164灯的acl属性
accesscontrol write acl '[{"privilege": 5, "authMode": 2, "subjects": [ 112233, 29315 ], "targets": null}]' 0x5164 0x0
更新0x5163灯的acl属性
accesscontrol write acl '[{"privilege": 5, "authMode": 2, "subjects": [ 112233, 29315 ], "targets": null}]' 0x5163 0x0
将灯绑定到esp-box
将0x5164绑定到light按钮
binding write binding '[{"node":20836, "endpoint":1, "cluster":6}]' 0x7283 0x1
将0x5163绑定到switch开关
binding write binding '[{"node":20835, "endpoint":1, "cluster":6}]' 0x7283 0x3
至此esp-box已经可以控制两盏灯了
如果中间有步骤配置错误可以恢复出厂设置
恢复出厂设置
matter device factoryreset
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!