pdf-icon

Product Guide

Real-Time AI Voice Assistant

Offline Voice Recognition

Thread

Module Gateway H2

IoT Tools

IoT Cloud

Ethernet Camera

Develop Tools

DIP Switch Usage Guide

Module GPS v2.0

Module GNSS

Module ExtPort For Core2

ESP Zigbee Gateway

This tutorial will guide you on how to run the ESP Zigbee Gateway example program using the Unit Gateway H2 paired with the CoreS3 controller. The ESP Zigbee Gateway is a gateway device based on the ESP32 series Wi-Fi SoC and the ESP32-H2 802.15.4 SoC. It connects Zigbee networks with Wi-Fi networks, enabling interoperability between smart home devices.

1. Preparation

ESP-IDF version
It is recommended to use ESP-IDF version v5.3.1 for compiling this example.
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git checkout v5.3.1 # recommend
./install.sh
. ./export.sh
  • 2. Use the Git command clone recursive to recursively clone the ESP-Zigbee-SDK repository:
git clone --recursive https://github.com/espressif/esp-zigbee-sdk.git
cd esp-zigbee-sdk

  • **4. The idf.py commands used in the subsequent tutorials depend on ESP-IDF. Before running the commands, you need to execute . ./export.sh in ESP-IDF to activate the relevant environment variables. For detailed instructions, please refer to the ESP-IDF - ESP32S3 Getting Started Tutorial .

2. Compile RCP Firmware

  • 1. Before compiling the Gateway firmware, you need to generate the RCP firmware first. Refer to the following commands to enter the corresponding RCP firmware directory and set the compilation target to esp32h2:
cd $IDF_PATH/examples/openthread/ot_rcp
idf.py set-target esp32h2
idf.py menuconfig
  • 2. Use idf.py menuconfig to enter the configuration page. In menuconfig, configure: Component config -> OpenThread RCP Example - Enable OPENTHREAD_NCP_VENDOR_HOOK.
Baud Rate Modification
Due to factors such as the pin drive capability of the chip, the serial port may not work properly when using a long connecting cable with the Unit. If this happens, you need to reduce the speed appropriately. Here, the default baud rate of 460800 is reduced to 230400.
  • 3. Modify the baud rate by opening main/esp_ot_config.h and changing line 43 .baud_rate = 460800; to .baud_rate = 230400;.
  • 4. After completing the configuration, execute the following command to compile the RCP firmware:
idf.py build
  • 5. Open the Unit Gateway H2 case, press the boot button, and then connect the USB power supply to put it into download mode. Execute the following command to flash the firmware:
idf.py flash

3. Compile Gateway Firmware

  • 1. Enter the esp_zigbee_gateway example program path and set the compilation target:
cd esp-zigbee-sdk/examples/esp_zigbee_gateway
idf.py set-target esp32s3
idf.py menuconfig
  • 2. Configure the correct communication pins in menuconfig. This pin configuration is for the CoreS3 controller. If you are using a different controller, modify it according to the actual situation:
- Board Configuration
  - Pin to RCP reset: -1
  - Pin to RCP boot: -1
  - Pin to RCP TX: 18
  - Pin to RCP RX: 17
  • 3. Gateway WiFi Connection Configuration:
- Example Connection Configuration
  - WiFi SSID
  - WiFi Password

Add the following functions and header files, and call and initialize them at the beginning of app_main to enable the Grove power supply output capability of CoreS3.

#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);
}

4. Compile and Flash

idf.py build
idf.py erase_flash
idf.py flash

5. Start Running

  • Connect the CoreS3 with the Unit Gateway H2.
  • Connect the CoreS3 to the computer.
  • Use idf.py monitor or other serial debugging tools to view the running logs at 115200bps.

Normal running log content:

  • RCP firmware version check
  • Wi-Fi connection successful
  • Zigbee network creation successful
  • Network open for device joining
On This Page