本教程将介绍如何使用Unit Gateway H2搭配CoreS3主控运行ESP Zigbee Host/NCP案例程序。ESP Zigbee NCP (Network Co-Processor) 是一种网络协处理器模式,它将 Zigbee 协议栈运行在一个独立的处理器上,通过串口与主处理器通信。这种架构可以让主处理器专注于应用层逻辑,而将 Zigbee 网络相关的处理交给协处理器处理。参考下方教程为Unit Gateway H2烧录ESP Zigbee NCP固件, 为CoreS3烧录ESP Zigbee Host固件, 实现创建Coordinator节点。
v5.3.1
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git checkout v5.3.1 # recommend
./install.sh
. ./export.sh
clone recursive
递归克隆ESP-Zigbee-SDK仓库git clone --recursive https://github.com/espressif/esp-zigbee-sdk.git
cd esp-zigbee-sdk
. ./export.sh
用于激活相关的环境变量。详细说明请参考
ESP-IDF - ESP32S3上手教程
。esp32h2
。cd examples/esp_zigbee_ncp
idf.py set-target esp32h2
idf.py menuconfig
idf.py menuconfig
进入配置页面。在menuconfig中配置设备的引脚信息:Component config
-> Zigbee Network Co-processor
- Component config → Zigbee Network Co-processor
- UART RX Pin: 23
- UART TX Pin: 24
- Component config → ESP Zigbee → Configure the Zigbee device type
- Zigbee Coordinator or Router device # or Zigbee End Device
idf.py build
idf.py erase_flash
进行擦除。idf.py erase_flash
idf.py flash
esp32s3
。cd examples/esp_zigbee_host
idf.py set-target esp32s3 # 使用 CoreS3
idf.py menuconfig
idf.py menuconfig
进入配置页面。在menuconfig中配置设备的引脚信息:Component config
-> Zigbee NCP Host
- Component config → Zigbee NCP Host
- UART RX Pin: 18
- UART TX Pin: 17
添加以下函数与头文件, 并添加到app_main中开头进行调用初始化,打开CoreS3的Grove供电输出能力。
#include "driver/i2c.h"
void fix_aw9523_p0_pull_up(void)
{
/* AW9523 P0 is in push-pull mode */
const i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_12,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_io_num = GPIO_NUM_11,
.scl_pullup_en = GPIO_PULLUP_DISABLE,
.master.clk_speed = 400000
};
i2c_param_config(I2C_NUM_1, &i2c_conf);
i2c_driver_install(I2C_NUM_1, i2c_conf.mode, 0, 0, 0);
uint8_t data[2];
data[0] = 0x11;
data[1] = 0x10;
i2c_master_write_to_device(I2C_NUM_1, 0x58, data, sizeof(data), 1000 / portTICK_PERIOD_MS);
i2c_driver_delete(I2C_NUM_1);
}
idf.py build
idf.py flash
idf.py monitor
或其他的串口调试工具在115200bps配置下查看运行日志。正常运行日志内容: