初识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地址:GitHub - espressif/esp-box: The ESP-BOX is a new generation AIoT development platform released by Espressif Systems.

克隆库: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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值