Skip to content

ESP crashes when trying to connect to zigbee network #11354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
vatsake opened this issue May 13, 2025 · 3 comments
Open
1 task done

ESP crashes when trying to connect to zigbee network #11354

vatsake opened this issue May 13, 2025 · 3 comments
Assignees
Labels
Area: Zigbee Issues and Feature Request about Zigbee

Comments

@vatsake
Copy link

vatsake commented May 13, 2025

Board

ESP32-H2-MINI-1

Device Description

Plain module

Hardware Configuration

No, just USB-C.

Version

latest stable Release (if not listed below)

IDE Name

Arduino IDE

Operating System

Win 11

Flash frequency

64Mhz

PSRAM enabled

yes

Upload speed

115200

Description

I've created a zigbee network with Aruba APs.
Using the scan networks example, it finds the network.
09:36:32.411 -> Nr | PAN ID | CH | Permit Joining | Router Capacity | End Device Capacity | Extended PAN ID
09:36:32.411 -> 1 | 0xa177 | 13 | Yes | Yes | Yes | 28:de:65...
09:36:32.411 -> 2 | 0xa177 | 11 | Yes | Yes | Yes | 28:de:65...
09:36:32.450 -> 3 | 0xa177 | 19 | Yes | Yes | Yes | 28:de:65...
09:36:32.450 -> 4 | 0xa177 | 11 | Yes | Yes | Yes | 28:de:65...
09:36:32.450 -> 5 | 0xa177 | 14 | Yes | Yes | Yes | 28:de:65...
09:36:32.450 -> 6 | 0xa177 | 20 | Yes | Yes | Yes | 28:de:65...

Sketch

// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @brief This example demonstrates Zigbee temperature sensor.
 *
 * The example demonstrates how to use Zigbee library to create a end device temperature sensor.
 * The temperature sensor is a Zigbee end device, which is controlled by a Zigbee coordinator.
 *
 * Proper Zigbee mode must be selected in Tools->Zigbee mode
 * and also the correct partition scheme must be selected in Tools->Partition Scheme.
 *
 * Please check the README.md for instructions and more detailed description.
 *
 * Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
 */

#ifndef ZIGBEE_MODE_ED
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif

#include "Zigbee.h"

/* Zigbee temperature sensor configuration */
#define TEMP_SENSOR_ENDPOINT_NUMBER 10
uint8_t button = BOOT_PIN;

// Optional Time cluster variables
struct tm timeinfo;
struct tm *localTime;
int32_t timezone;

ZigbeeTempSensor zbTempSensor = ZigbeeTempSensor(TEMP_SENSOR_ENDPOINT_NUMBER);


/********************* Arduino functions **************************/
void setup() {
  Serial.begin(115200);

  // Init button switch
  pinMode(button, INPUT_PULLUP);

  // Optional: set Zigbee device name and model
  zbTempSensor.setManufacturerAndModel("Espressif", "ZigbeeTempSensor");

  // Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
  zbTempSensor.setMinMaxValue(10, 50);

  // Optional: Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
  zbTempSensor.setTolerance(1);

  // Optional: Time cluster configuration (default params, as this device will revieve time from coordinator)
  zbTempSensor.addTimeCluster();

  // Add endpoint to Zigbee Core
  Zigbee.addEndpoint(&zbTempSensor);

    float tsens_value = temperatureRead();
    Serial.printf("Updated temperature sensor value to %.2f°C\r\n", tsens_value);
    // Update temperature value in Temperature sensor EP
    zbTempSensor.setTemperature(tsens_value);

  Serial.println("Starting Zigbee...");
  // When all EPs are registered, start Zigbee in End Device mode
  if (!Zigbee.begin()) {
    Serial.println("Zigbee failed to start!");
    Serial.println("Rebooting...");
    ESP.restart();
  } else {
    Serial.println("Zigbee started successfully!");
  }
  Serial.println("Connecting to network");
  while (!Zigbee.connected()) {
    Serial.print(".");
    delay(100);
  }
  Serial.println("Connected");

  // Optional: If time cluster is added, time can be read from the coordinator
  timeinfo = zbTempSensor.getTime();
  timezone = zbTempSensor.getTimezone();

  Serial.println("UTC time:");
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");

  time_t local = mktime(&timeinfo) + timezone;
  localTime = localtime(&local);

  Serial.println("Local time with timezone:");
  Serial.println(localTime, "%A, %B %d %Y %H:%M:%S");

  // Set reporting interval for temperature measurement in seconds, must be called after Zigbee.begin()
  // min_interval and max_interval in seconds, delta (temp change in 0,1 °C)
  // if min = 1 and max = 0, reporting is sent only when temperature changes by delta
  // if min = 0 and max = 10, reporting is sent every 10 seconds or temperature changes by delta
  // if min = 0, max = 10 and delta = 0, reporting is sent every 10 seconds regardless of temperature change
  zbTempSensor.setReporting(1, 0, 1);
}

void loop() {
  // Checking button for factory reset
  if (digitalRead(button) == LOW) {  // Push button pressed
    // Key debounce handling
    delay(100);
    int startTime = millis();
    while (digitalRead(button) == LOW) {
      delay(50);
      if ((millis() - startTime) > 3000) {
        // If key pressed for more than 3secs, factory reset Zigbee and reboot
        Serial.println("Resetting Zigbee to factory and rebooting in 1s.");
        delay(1000);
        Zigbee.factoryReset();
      }
    }
    zbTempSensor.reportTemperature();
  }
  delay(100);
}

Debug Message

09:33:07.461 -> ESP-ROM:esp32h2-20221101
09:33:07.504 -> Build:Nov  1 2022
09:33:07.504 -> rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
09:33:07.504 -> Saved PC:0x400031b6
09:33:07.504 -> SPIWP:0xee
09:33:07.504 -> mode:DIO, clock div:1
09:33:07.504 -> load:0x408460e0,len:0x11fc
09:33:07.504 -> load:0x4083cad0,len:0xe00
09:33:07.504 -> load:0x4083efd0,len:0x2ea8
09:33:07.504 -> entry 0x4083cad0
09:33:07.969 -> Updated temperature sensor value to 19.00°C
09:33:07.969 -> �[0;31mE (475) ZB OSIF: Zigbee lock is not ready!�[0m
09:33:08.014 -> ZB_TRACE_LOG[0]: common/zb_debug.c:64    Assertion failed /builds/thread_zigbee/esp-zboss/components/zboss_stack/zboss/zcl/zcl_general_commands.c:608
09:33:08.014 -> Zigbee stack assertion failed zcl/zcl_general_commands.c:608
09:33:08.014 -> 
09:33:08.387 -> abort() was called at PC 0x4201eb0f on core 0
09:33:08.387 -> Core  0 register dump:
09:33:08.387 -> MEPC    : 0x4080163a  RA      : 0x40806066  SP      : 0x4081c230  GP      : 0x4080d354  
09:33:08.387 -> TP      : 0x4081c460  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
09:33:08.387 -> S0/FP   : 0x4081c25c  S1      : 0x4081c25c  A0      : 0x4081c268  A1      : 0x4081c24a  
09:33:08.387 -> A2      : 0x00000000  A3      : 0x4081c295  A4      : 0x00000001  A5      : 0x40814000  
09:33:08.387 -> A6      : 0x00000000  A7      : 0x76757473  S2      : 0x0000ffff  S3      : 0x00000402  
09:33:08.387 -> S4      : 0x00000001  S5      : 0x0000000a  S6      : 0x00000001  S7      : 0x4081c37e  
09:33:08.387 -> S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
09:33:08.387 -> T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
09:33:08.387 -> MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000002  MTVAL   : 0x00000000  
09:33:08.387 -> MHARTID : 0x00000000  
09:33:08.387 -> 
09:33:08.387 -> Stack memory:
09:33:08.387 -> 4081c230: 0x00000000 0x00000000 0x4081c248 0x4080ba1a 0x00000001 0x0000000a 0x00000030 0x4080e790
09:33:08.387 -> 4081c250: 0x4081c25c 0x4080e7ac 0x4081c248 0x31303234 0x66306265 0x00000000 0x726f6261 0x20292874
09:33:08.387 -> 4081c270: 0x20736177 0x6c6c6163 0x61206465 0x43502074 0x34783020 0x65313032 0x20663062 0x63206e6f
09:33:08.387 -> 4081c290: 0x2065726f 0x00000030 0x00000000 0xebd36353 0x0000002f 0x00000260 0x420c95fd 0x4201eb12
09:33:08.387 -> 4081c2b0: 0x00000260 0x0000000a 0x00000001 0x00000402 0x0000ffff 0x00000000 0x0000000a 0x420457b0
09:33:08.387 -> 4081c2d0: 0x00000402 0x00000000 0x0000ffff 0x42073d64 0x00000000 0x00000000 0x00000000 0x00000402
09:33:08.387 -> 4081c2f0: 0x420c8000 0x00000000 0x4080f000 0x420457cc 0x20646574 0x706d6574 0x74617265 0x4204255c
09:33:08.387 -> 4081c310: 0x0000000a 0x00000001 0x00000402 0x00000000 0x302e3931 0x43b0c230 0x40814000 0x00000000
09:33:08.387 -> 4081c330: 0x00000000 0x00000000 0x41980000 0x420e3000 0x4080f000 0x4080ea30 0x4080f000 0x420075ee
09:33:08.387 -> 4081c350: 0x4080f000 0x4080ea30 0x4080f000 0x42002a26 0x4080f000 0x4080ea9c 0x0000000c 0x4081c388
09:33:08.387 -> 4081c370: 0x4080f000 0x4080ea9c 0x4080ea30 0x076c017a 0x0000000a 0x00000032 0x41980000 0x420e3000
09:33:08.387 -> 4081c390: 0x4080f000 0x4080f000 0x4080f000 0x42000184 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c3b0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x4080cd98 0x00000001 0x4200593c
09:33:08.387 -> 4081c3d0: 0x4081c460 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c3f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c410: 0x00000000 0x00000000 0x00000000 0x420064a8 0x00000000 0x00000000 0x00000000 0x40806e8c
09:33:08.387 -> 4081c430: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c450: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xbaad5678
09:33:08.387 -> 4081c470: 0x00000168 0xabba1234 0x0000015c 0x4081c120 0x00000000 0x40811afc 0x40811afc 0x4081c47c
09:33:08.387 -> 4081c490: 0x40811af4 0x00000018 0x00000000 0x00000000 0x4081c47c 0x00000000 0x00000001 0x4081a46c
09:33:08.387 -> 4081c4b0: 0x706f6f6c 0x6b736154 0x00000000 0x00000000 0x4081c460 0x00000005 0x00000000 0x00000001
09:33:08.387 -> 4081c4d0: 0x00000000 0x00000000 0x00000000 0x0000027d 0x00000000 0x408147a4 0x4081480c 0x40814874
09:33:08.387 -> 4081c4f0: 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x4081d234 0x40011484 0x00000000
09:33:08.387 -> 4081c510: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c530: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c550: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c570: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c590: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c5b0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
09:33:08.387 -> 4081c5d0: 0x00000000 0x00000000 0xbaad5678 0x00000068 0xabba1234 0x0000005c 0x00000000 0x4081c5e8
09:33:08.387 -> 4081c5f0: 0x00000000 0x00000000 0x00000000 0x4081c600 0xffffffff 0x4081c600 0x4081c600 0x00000000
09:33:08.387 -> 4081c610: 0x4081c614 0xffffffff 0x4081c614 0x4081c614 0x00000001 0x00000001 0x00000000 0xf400ffff
09:33:08.387 -> 
09:33:08.387 -> 
09:33:08.387 -> 
09:33:08.387 -> ELF file SHA256: 005cb3076
09:33:08.387 -> 
09:33:08.513 -> Rebooting...
09:33:08.513 -> ESP-ROM:esp32h2-20221101
09:33:08.513 -> Build:Nov  1 2022
09:33:08.513 -> rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
09:33:08.513 -> Saved PC:0x400031b6
09:33:08.513 -> SPIWP:0xee
09:33:08.513 -> mode:DIO, clock div:1
09:33:08.513 -> load:0x408460e0,len:0x11fc
09:33:08.513 -> load:0x4083cad0,len:0xe00
09:33:08.513 -> load:0x4083efd0,len:0x2ea8
09:33:08.513 -> entry 0x4083cad0

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@vatsake vatsake added the Status: Awaiting triage Issue is waiting for triage label May 13, 2025
@SuGlider SuGlider added the Area: Zigbee Issues and Feature Request about Zigbee label May 13, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this May 14, 2025
@P-R-O-C-H-Y
Copy link
Member

@vatsake You cannot set the temp when the device is not connected. Please move:

float tsens_value = temperatureRead();
    Serial.printf("Updated temperature sensor value to %.2f°C\r\n", tsens_value);
    // Update temperature value in Temperature sensor EP
    zbTempSensor.setTemperature(tsens_value);

After Zigbee.begin() or better after Zigbee.connected().
You can take a look to the examples to see how to do that correct way.

@P-R-O-C-H-Y P-R-O-C-H-Y removed the Status: Awaiting triage Issue is waiting for triage label May 14, 2025
@vatsake
Copy link
Author

vatsake commented May 14, 2025

@P-R-O-C-H-Y Thanks for the reply, I moved them after zigbee is connected, but nothing changed.
Serial doesn't print "Connected" (which is after the while loop), so it crashes during connection.

@P-R-O-C-H-Y
Copy link
Member

Can you set:
Core Debug level -> Verbose
Zigbee mode -> Zigbee ED (end device) - Debug
and post a new log please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Zigbee Issues and Feature Request about Zigbee
Projects
None yet
Development

No branches or pull requests

3 participants