esp-idf: ESP32-C6 Unable to join zigbee network (IDFGH-9286)

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.1-dev-3066-g236fa5e669

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-C6-DevKitC-1

Power Supply used.

USB

What is the expected behavior?

I have two boards, run HA_on_off_light and HA_on_off_switch respectively, and then I use zigbee sniffer to get their incoming packets, but I can’t get anything.

What is the actual behavior?

I can’t get the Beacon Request message when I use Ubiqua.

image

Steps to reproduce.

  1. cd examples/zigbee/light_sample/HA_on_off_switch
  2. idf.py --preview set-target esp32c6
  3. idf.py build
  4. idf.py flash
  5. cd examples/zigbee/light_sample/HA_on_off_light
  6. idf.py --preview set-target esp32c6
  7. idf.py build
  8. idf.py flash

Debug Logs.

Executing action: monitor
Running idf_monitor in directory /home/lewin/esp/esp-idf-v5.0/examples/zigbee/light_sample/HA_on_off_switch
Executing "/home/lewin/.espressif/python_env/idf5.1_py3.8_env/bin/python /home/lewin/esp/esp-idf-v5.0/tools/idf_monitor.py -p /dev/ttyUSB1 -b 115200 --toolchain-prefix riscv32-esp-elf- --target esp32c6 --decode-panic backtrace /home/lewin/esp/esp-idf-v5.0/examples/zigbee/light_sample/HA_on_off_switch/build/light_switch.elf -m '/home/lewin/.espressif/python_env/idf5.1_py3.8_env/bin/python' '/home/lewin/esp/esp-idf-v5.0/tools/idf.py' '-p' '/dev/ttyUSB1'"...
--- idf_monitor on /dev/ttyUSB1 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x4086c610,len:0xc98
load:0x4086e610,len:0x2a0c
load:0x40875720,len:0x17b0
entry 0x4086c610
I (23) boot: ESP-IDF v5.1-dev-3066-g236fa5e669 2nd stage bootloader
I (24) boot: compile time Jan 31 2023 15:42:51
I (24) boot: chip revision: v0.0
I (28) boot.esp32c6: SPI Speed      : 40MHz
I (33) boot.esp32c6: SPI Mode       : DIO
I (38) boot.esp32c6: SPI Flash Size : 2MB
I (42) boot: Enabling RNG early entropy source...
W (48) bootloader_random: bootloader_random_enable() has not been implemented yet
I (56) boot: Partition Table:
I (59) boot: ## Label            Usage          Type ST Offset   Length
I (67) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (74) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (82) boot:  2 factory          factory app      00 00 00010000 00089800
I (89) boot:  3 zb_storage       Unknown data     01 81 0009a000 00020000
I (97) boot:  4 zb_fct           Unknown data     01 81 000ba000 00000400
I (104) boot: End of partition table
I (108) esp_image: segment 0: paddr=00010020 vaddr=42060020 size=0a250h ( 41552) map
I (125) esp_image: segment 1: paddr=0001a278 vaddr=40800000 size=05da0h ( 23968) load
I (131) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=5cbb0h (379824) map
I (206) esp_image: segment 3: paddr=0007cbd8 vaddr=40805da0 size=06008h ( 24584) load
I (212) esp_image: segment 4: paddr=00082be8 vaddr=4080bdb0 size=01538h (  5432) load
I (217) boot: Loaded app from partition at offset 0x10000
I (218) boot: Disabling RNG early entropy source...
W (224) bootloader_random: bootloader_random_enable() has not been implemented yet
I (243) cpu_start: Pro cpu up.
W (252) clk: esp_perip_clk_init() has not been implemented yet
W (258) CACHE_ERR: esp_cache_err_int_init() has not been implemented yet
I (259) cpu_start: Pro cpu start user code
I (259) cpu_start: cpu freq: 160000000 Hz
I (264) cpu_start: Application information:
I (269) cpu_start: Project name:     light_switch
I (274) cpu_start: App version:      v5.1-dev-3066-g236fa5e669
I (281) cpu_start: Compile time:     Jan 31 2023 15:42:44
I (287) cpu_start: ELF file SHA256:  6a2fee3c1530ebe6...
I (293) cpu_start: ESP-IDF:          v5.1-dev-3066-g236fa5e669
I (299) cpu_start: Min chip rev:     v0.0
I (304) cpu_start: Max chip rev:     v0.99 
I (309) cpu_start: Chip rev:         v0.0
I (314) heap_init: Initializing. RAM available for dynamic allocation:
I (321) heap_init: At 40812E10 len 00069800 (422 KiB): D/IRAM
I (327) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DRAM
I (334) heap_init: At 50000010 len 00003FF0 (15 KiB): RTCRAM
I (341) spi_flash: detected chip: gd
I (345) spi_flash: flash io: dio
W (348) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (362) app_start: Starting scheduler on CPU0
I (367) main_task: Started on CPU0
I (367) main_task: Calling app_main()
I (377) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2 
I (377) phy_init: phy_version 101,587adde,Dec 20 2022,14:21:21
I (457) main_task: Returned from app_main()
I (467) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 23, status: -1
I (467) ESP_ZB_ON_OFF_SWITCH: Zigbee stack initialized
I (497) ESP_ZB_ON_OFF_SWITCH: Start network formation
I (42757) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (42757) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (43297) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (43297) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (44187) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (44187) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (44847) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (44847) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (45167) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (45167) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (45417) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (45417) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (45717) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (45717) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (45977) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (45977) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (46247) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (46247) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (46507) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (46507) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (46827) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (46827) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (48077) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (48077) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (50417) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (50417) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (50677) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (50677) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0
I (50937) ESP_ZB_ON_OFF_SWITCH: send 'on_off toggle' command
I (50937) ESP_ZB_ON_OFF_SWITCH: ZDO signal: 60, status: 0

More Information.

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 29

Most upvoted comments

@Tokn59 Within esp_zb_light.c of HA_on_off_light example, replace esp_zb_task function with the following code, that’s all.

char modelid[] = {13, 'E', 'S', 'P', '3', '2', 'C', '6', '.', 'L', 'i', 'g', 'h', 't'};
char manufname[] = {9, 'E', 's', 'p', 'r', 'e', 's', 's', 'i', 'f'};

static void esp_zb_task(void *pvParameters)
{
    /* initialize Zigbee stack with Zigbee end-device config */
    esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
    esp_zb_init(&zb_nwk_cfg);
    esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);

    /* set the on-off light device config */
    uint8_t test_attr, test_attr2;
 
    test_attr = 0;
    test_attr2 = 4;
    /* basic cluster create with fully customized */
    esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_BASIC);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, &test_attr);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, &test_attr2);
    esp_zb_cluster_update_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, &test_attr2);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]);
    /* identify cluster create with fully customized */
    esp_zb_attribute_list_t *esp_zb_identify_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY);
    esp_zb_identify_cluster_add_attr(esp_zb_identify_cluster, ESP_ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID, &test_attr);
    /* group cluster create with fully customized */
    esp_zb_attribute_list_t *esp_zb_groups_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_GROUPS);
    esp_zb_groups_cluster_add_attr(esp_zb_groups_cluster, ESP_ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID, &test_attr);
    /* scenes cluster create with standard cluster + customized */
    esp_zb_attribute_list_t *esp_zb_scenes_cluster = esp_zb_scenes_cluster_create(NULL);
    esp_zb_cluster_update_attr(esp_zb_scenes_cluster, ESP_ZB_ZCL_ATTR_SCENES_NAME_SUPPORT_ID, &test_attr);
    /* on-off cluster create with standard cluster config*/
    esp_zb_on_off_cluster_cfg_t on_off_cfg;
    on_off_cfg.on_off = ESP_ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE;
    esp_zb_attribute_list_t *esp_zb_on_off_cluster = esp_zb_on_off_cluster_create(&on_off_cfg);
    /* create cluster lists for this endpoint */
    esp_zb_cluster_list_t *esp_zb_cluster_list = esp_zb_zcl_cluster_list_create();
    esp_zb_cluster_list_add_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    /* update basic cluster in the existed cluster list */
    //esp_zb_cluster_list_update_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_identify_cluster(esp_zb_cluster_list, esp_zb_identify_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_groups_cluster(esp_zb_cluster_list, esp_zb_groups_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_scenes_cluster(esp_zb_cluster_list, esp_zb_scenes_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_on_off_cluster(esp_zb_cluster_list, esp_zb_on_off_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

    esp_zb_ep_list_t *esp_zb_ep_list = esp_zb_ep_list_create();
    /* add created endpoint (cluster_list) to endpoint list */
    esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_LIGHT_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID);
    esp_zb_device_register(esp_zb_ep_list);
    esp_zb_core_action_handler_register(zb_action_handler);
    ESP_ERROR_CHECK(esp_zb_start(false));
    esp_zb_main_loop_iteration();
}

@likunqiao097304 It works! ! !

Make two suggestions:

  1. The light device should be used as a router (this should follow the device specification, it would be better)
  2. When the device initiates network steering, it should initiate a Beacon Request to the primary channel and the secondary channel in sequence. (These should follow the bdb specification)

I tested the code with esp-idf 5.1.2(esp-zigbee-lib: 0.9.5, esp-zboss-lib: 0.7.2). No problem! The device are set to that right model id and manufacturer name on zigbee2mqtt.

2023년 11월 30일 (목) 오후 8:46, pcurt @.***>님이 작성:

Does someone test this following code with the last esp-idf version (ESP-IDF) 5.1.2 ?

… char modelid[] = {13, ‘E’, ‘S’, ‘P’, ‘3’, ‘2’, ‘C’, ‘6’, ‘.’, ‘L’, ‘i’, ‘g’, ‘h’, ‘t’}; char manufname[] = {9, ‘E’, ‘s’, ‘p’, ‘r’, ‘e’, ‘s’, ‘s’, ‘i’, ‘f’}; … esp_zb_init(&zb_nwk_cfg); esp_zb_set_network_channel(23); … esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]); esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]); …

It uses the following versions for zigbee and zboss libraries

esp-zigbee-lib: “0.9.0” esp-zboss-lib: “0.7.0”

With 5.1.2 esp-idf, Zigbee model and manufacturer name are set to ‘undefined’ It was working with previous version 5.1.1 (esp-zigbee-lib: 0.7.0, espressif/esp-zboss-lib: 0.5.0) So I don’t know who to set model and manufacturer with last esp-idf.

— Reply to this email directly, view it on GitHub https://github.com/espressif/esp-idf/issues/10662#issuecomment-1833609270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANLS2RQYTO37WBBAOOX32DYHBWYNAVCNFSM6AAAAAAUMDAKYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZTGYYDSMRXGA . You are receiving this because you were mentioned.Message ID: @.***>

@likunqiao097304 Thank you!

After setting the channel number, I could make the device to be registered to home assistant via zigbee2mqtt addon with zigbee 3.0 usb dongle.

I used HA_on_off_switch example that was modified to include manufname and modelid attributes in basic cluster, refered by this custom example.

...
char modelid[] = {13, 'E', 'S', 'P', '3', '2', 'C', '6', '.', 'L', 'i', 'g', 'h', 't'};
char manufname[] = {9, 'E', 's', 'p', 'r', 'e', 's', 's', 'i', 'f'};
...
    esp_zb_init(&zb_nwk_cfg);
    esp_zb_set_network_channel(23);
...
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]);
...

Then, I added the following switch converter to HA repository as to this procedure.

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    zigbeeModel: ['ESP32C6.Light'],
    model: 'ESP32C6.Light',
    vendor: 'Espressif',
    description: 'light_bulb',
    fromZigbee: [fz.on_off],
    toZigbee: [tz.on_off],
    exposes: [e.switch()],
    // The configure method below is needed to make the device reports on/off state changes
    // when the device is controlled manually through the button on it.
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint);
    },
};

module.exports = definition;

screenshot of z2m device list on HA. ha_z2m_esp32c6_1 screenshot of z2m dashboard on HA. ha_z2m_esp32c6_2

@momo1 It is recommended that you buy a zigbee sniffer, which can capture zigbee data packets, making it easier to locate problems.

@lbuque the default channel is 13. If you want to change to different one, please refer to the esp_zigbee_core.h: esp_zb_set_network_channel(uint8_t channel); BTW, it seems like on-off switch didn’t formed network successfully. Try to erase the NVRAM first, before flash the code. Please refer to the README.md under HA_on_off_switch.