You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: Using the latest files from #10636, as recommended in #10612. Selected Zigbee mode is Zigbee ED (end device) - debug.
When initially connecting the device to Home Assistant, it works fine and the connection is stable (tested by commenting out the line that puts the ESP into deep sleep). However, upon power being removed and restored or the device waking from deep sleep, it will no longer connect. To get it to connect again, I have to re-flash the board with flash clearing enabled as Zigbee.factoryReset() doesnt seem to actually clear the stored network information. I also have to remove the device from HA and set it up as if it was a new device.
It seems to be related to the message ZBOSS: nwk/nwk_join.c:629 Rejoin failure: no dev with xpanid bf:de:b3:e8:e6:a6:c9:f9 or can't choose best parent. I checked, and that is definitely still the expended ID of the Zigbee network.
Sketch
#include<SHTSensor.h>
#include<arduino-sht.h>
#include<Wire.h>// 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 and humidity sensor Sleepy device. * * The example demonstrates how to use Zigbee library to create an end device temperature and humidity sensor. * The sensor is a Zigbee end device, which is reporting data to the Zigbee network. * * 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/)*/// Initialize SHT40 sensor instance
SHTSensor sht(SHTSensor::SHT4X);
#ifndef ZIGBEE_MODE_ED
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif
#include"Zigbee.h"
#defineBUTTON_PIN9//Boot button for C6/H2
#defineSDA_PIN10
#defineSCL_PIN11
#defineADC_PIN_3_3_VOLT1
#defineADC_TO_PERCENT(mv_reading) (mv_reading/3300.0)*100.0// 100% is 3.3V or 3,300mV
#defineTEMP_SENSOR_ENDPOINT_NUMBER10
#defineuS_TO_S_FACTOR1000000ULL/* Conversion factor for micro seconds to seconds */
#defineTIME_TO_SLEEP55/* Sleep for 55s will + 5s delay for establishing connection => data reported every 1 minute */
ZigbeeTempSensor zbTempSensor = ZigbeeTempSensor(TEMP_SENSOR_ENDPOINT_NUMBER);
/************************ Temp sensor *****************************/voidmeausureAndSleep() {
// Read capacitor voltageint capacitorPercent = ADC_TO_PERCENT(analogReadMilliVolts(ADC_PIN_3_3_VOLT));
zbTempSensor.setBatteryPercentage(capacitorPercent);
zbTempSensor.reportBatteryPercentage();
// Update temp and humidity readings
sht.readSample();
// Measure temperature sensor valuefloat temperature = sht.getTemperature();
/// Measure humidity sensor valuefloat humidity = sht.getHumidity();
// Update temperature and humidity values in Temperature sensor EP
zbTempSensor.setTemperature(temperature);
zbTempSensor.setHumidity(humidity);
// Report temperature and humidity values
zbTempSensor.reportTemperature();
zbTempSensor.reportHumidity();
delay(500);
Serial.printf("Reported temperature: %.2f°C, Humidity: %.2f%%, Bat Percent: %i\n", temperature, humidity, capacitorPercent);
// Put device to deep sleep
Serial.println("Going to sleep now");
esp_deep_sleep_start();
}
/********************* Arduino functions **************************/voidsetup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}
// Init "Wire" library (I2C)
Wire.begin(SDA_PIN, SCL_PIN);
// Init sht
sht.init();
// Init button switchpinMode(BUTTON_PIN, INPUT_PULLUP);
// Factory reset if BOOT is held during start-upif (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed// Key debounce handlingdelay(100);
while (digitalRead(BUTTON_PIN) == LOW) {
delay(50);
Serial.println("Resetting Zigbee to factory and rebooting in 1s.");
delay(1000);
Zigbee.factoryReset();
}
}
// Configure the wake up source and set to wake up every 5 secondsesp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
// Optional: set Zigbee device name and model
zbTempSensor.setManufacturerAndModel("Test", "LowCostEnviromentalSensor");
// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
zbTempSensor.setMinMaxValue(0, 100);
// Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
zbTempSensor.setTolerance(0.5);
// Set power source to battery and set battery percentage to measured value// The value can be also updated by calling zbTempSensor.setBatteryPercentage(percentage) anytime
zbTempSensor.setPowerSource(ZB_POWER_SOURCE_BATTERY, analogReadMilliVolts(ADC_PIN_3_3_VOLT));
// Add humidity cluster to the temperature sensor device with min, max and tolerance values
zbTempSensor.addHumiditySensor(0, 100, 1);
// Add endpoint to Zigbee Core
Zigbee.addEndpoint(&zbTempSensor);
// Create a custom Zigbee configuration for End Device with keep alive 10s to avoid interference with reporting dataesp_zb_cfg_t zigbeeConfig = ZIGBEE_DEFAULT_ED_CONFIG();
zigbeeConfig.nwk_cfg.zed_cfg.keep_alive = 10000;
// When all EPs are registered, start Zigbee in End Device modeif (!Zigbee.begin(&zigbeeConfig, false)){
Serial.println("Zigbee failed to start!");
Serial.println("Rebooting...");
ESP.restart();
}
Serial.println("Connecting to network");
while (!Zigbee.connected()) {
Serial.print(".");
delay(100);
}
Serial.println();
Serial.println("Sucessfully connected to Zigbee network");
// Delay 5s (may be adjusted) to allow establishing proper connection with coordinator, needed for sleepy devicesdelay(5000);
}
voidloop() {
// Checking button for factory resetif (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed// Key debounce handlingdelay(100);
int startTime = millis();
while (digitalRead(BUTTON_PIN) == 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();
}
}
}
// Call the function to measure temperature and put the device to sleepmeausureAndSleep();
}
Debug Message
ESP-ROM:esp32h2-20221101
Build:Nov 1 2022
rst:0xc (SW_CPU),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x400031b6
SPIWP:0xee
mode:DIO, clock div:1
load:0x408460e0,len:0x112c
load:0x4083cad0,len:0xe18
load:0x4083efd0,len:0x2d04
entry 0x4083cad0
[ 1][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42009e96
[ 13][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42009e5a
[ 24][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42009e1e
[ 35][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42009de2
[ 47][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42009e96
[ 58][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x42009e5a
[ 70][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x42009e1e
[ 81][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x42009de2
[ 92][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type USB_DM (38) successfully set to 0x42004058
[ 104][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type USB_DP (39) successfully set to 0x42004058
[ 115][V][ZigbeeEP.cpp:18] ZigbeeEP(): Endpoint: 10
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x20 attr_value 0x4084ef0f
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 1
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x30 attr_value 0x4084ef0e
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 1
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x21 attr_value 0x4084ef0e
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x29 attr_value 0x4084ef0e
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x29 attr_value 0x4084ef0c
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x29 attr_value 0x4084ef0a
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
[ 206][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 23 successfully set to type UART_RX (2) with bus 0x4080f914
[ 219][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 24 successfully set to type UART_TX (3) with bus 0x4080f914
[ 229][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 26 successfully set to type USB_DM (38) with bus 0x408119fc
[ 240][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 27 successfully set to type USB_DP (39) with bus 0x408119fc
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
Model : ESP32-H2
Package : 0
Revision : 0.01
Cores : 1
CPU Frequency : 96 MHz
XTAL Frequency : 32 MHz
Features Bitfield : 0x00000050
Embedded Flash : No
Embedded PSRAM : No
2.4GHz WiFi : No
Classic BT : No
BT Low Energy : Yes
IEEE 802.15.4 : Yes
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
Total Size : 233200 B ( 227.7 KB)
Free Bytes : 198952 B ( 194.3 KB)
Allocated Bytes : 29064 B ( 28.4 KB)
Minimum Free Bytes: 198952 B ( 194.3 KB)
Largest Free Block: 188404 B ( 184.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
Chip Size : 4194304 B (4 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 64 MHz
Bus Mode : QIO
------------------------------------------
Partitions Info:
------------------------------------------
nvs : addr: 0x00009000, size: 20.0 KB, type: DATA, subtype: NVS
otadata : addr: 0x0000E000, size: 8.0 KB, type: DATA, subtype: OTA
app0 : addr: 0x00010000, size: 1280.0 KB, type: APP, subtype: OTA_0
app1 : addr: 0x00150000, size: 1280.0 KB, type: APP, subtype: OTA_1
spiffs : addr: 0x00290000, size: 1388.0 KB, type: DATA, subtype: SPIFFS
zb_storage : addr: 0x003EB000, size: 16.0 KB, type: DATA, subtype: FAT
zb_fct : addr: 0x003EF000, size: 4.0 KB, type: DATA, subtype: FAT
coredump : addr: 0x003F0000, size: 64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
Compile Date/Time : Nov 23 2024 12:32:27
Compile Host OS : windows
ESP-IDF Version : v5.3.1-638-ga0f798cfc4-dirty
Arduino Version : 3.1.0
------------------------------------------
Board Info:
------------------------------------------
Arduino Board : ESP32H2_DEV
Arduino Variant : esp32h2
Arduino FQBN : esp32:esp32:esp32h2:UploadSpeed=921600,CDCOnBoot=cdc,FlashFreq=64,FlashMode=qio,FlashSize=4M,PartitionScheme=zigbee,DebugLevel=verbose,EraseFlash=all,JTAGAdapter=default,ZigbeeMode=ed_debug
============ Before Setup End ============
[ 377][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 26 already has type USB_DM (38) with bus 0x408119fc
[ 378][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 27 already has type USB_DP (39) with bus 0x408119fc
[ 379][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type I2C_MASTER_SDA (30) successfully set to 0x42007054
[ 380][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type I2C_MASTER_SCL (31) successfully set to 0x42007054
[ 381][I][esp32-hal-i2c.c:125] i2cInit(): Initializing I2C Master: sda=10 scl=11 freq=100000
[ 383][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 10 successfully set to type I2C_MASTER_SDA (30) with bus 0x1
[ 384][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 11 successfully set to type I2C_MASTER_SCL (31) with bus 0x1
[ 396][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x42005676
[ 398][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 9 successfully set to type GPIO (1) with bus 0xa
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x42 attr_value 0x4081a0f4
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 11
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x42 attr_value 0x4081a110
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 26
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x29 attr_value 0x4081e81c
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x29 attr_value 0x4081e81e
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x21 attr_value 0x4081e81e
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
[ 407][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ADC_ONESHOT (7) successfully set to 0x420052cc
[ 408][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 1 successfully set to type ADC_ONESHOT (7) with bus 0x2
[ 409][D][esp32-hal-adc.c:305] __analogReadMilliVolts(): Creating cali handle for ADC_0
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x30 attr_value 0x4081e81c
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 1
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x20 attr_value 0x4081e81b
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 1
Battery percent:
100.58
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x21 attr_value 0x4081e80e
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x21 attr_value 0x4081e808
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x21 attr_value 0x4081e80a
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
ZBOSS: zcl/zcl_common.c:215 >> zb_zcl_get_attribute_size: attr_type 0x21 attr_value 0x4081e80c
ZBOSS: zcl/zcl_common.c:348 << zb_zcl_get_attribute_size: result 2
[ 420][D][ZigbeeCore.cpp:82] addEndpoint(): Endpoint: 10, Device ID: 0x0302
[ 421][D][ZigbeeCore.cpp:119] zigbeeInit(): Initialize Zigbee stack
ZBOSS: common/zb_init_default.c:181 ED build
ZBOSS: common/zb_init_default.c:187 sizes: g_zb 7576 sched 224 bpool 16 nwk 912 aps 3040 addr 284 zdo 840
ZBOSS: common/zb_init_default.c:196 sec 2
ZBOSS: common/zb_init_default.c:198 zcl 768
ZBOSS: common/zb_init_default.c:201 zll 960
ZBOSS: common/zb_init_default.c:207 nvram 140
ZBOSS: common/zb_init_default.c:210 buttons 200
ZBOSS: common/zb_init_default.c:212 err_ind 4
ZBOSS: common/zb_init_default.c:218 scheduler q size 80
ZBOSS: common/zb_init_default.c:221 g_mac 816 g_imac 28
ZBOSS: common/zb_init_default.c:225 Configurable mem build, use ZBOSS lib defaults = 0
ZBOSS: common/zb_init_default.c:231 ZB_IOBUF_POOL_SIZE 80 ZB_NWK_IN_Q_SIZE 40 ZB_MAC_PENDING_QUEUE_SIZE 20 ZB_APS_DST_BINDING_TABLE_SIZE 16 ZB_APS_BIND_TRANS_TABLE_SIZE 20 ZB_N_APS_RETRANS_ENTRIES 27
ZBOSS: common/zb_init_default.c:261 ZB_N_APS_KEY_PAIR_ARR_MAX_SIZE 8 ZB_IEEE_ADDR_TABLE_SIZE 64 ZB_NEIGHBOR_TABLE_SIZE 64 ZB_NWK_ROUTING_TABLE_SIZE 0 ZB_APS_DUPS_TABLE_SIZE 32
[ 446][D][ZigbeeCore.cpp:126] zigbeeInit(): Register all Zigbee EPs in list
ZBOSS: zdo/af_descriptor.c:357 ep_count 1
[ 449][I][ZigbeeCore.cpp:134] zigbeeInit(): List of registered Zigbee EPs:
[ 450][I][ZigbeeCore.cpp:136] zigbeeInit(): Device type: Temperature Sensor, Endpoint: 10, Device ID: 0x0302
ZBOSS: common/zb_nvram.c:3190 ds_ver == 2
ZBOSS: zdo/zdo_app_prod_conf.c:144 no production config block found
ZBOSS: zdo/zdo_app_prod_conf.c:781 no valid production configuration found, signaling to application
[ 476][V][ZigbeeCore.cpp:322] esp_zb_app_signal_handler(): ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL
[ 477][I][ZigbeeCore.cpp:207] esp_zb_app_signal_handler(): Zigbee stack initialized
ZBOSS: commissioning/bdb/zdo_commissioning_bdb.c:349 dev type 2, joined 1, ext_pan_id 1, authenticated 1, tclk_valid 1
ZBOSS: mac/mac.c:1039 Oops - error beacon payload is too small buf_sz 15 - drop it
ZBOSS: mac/mac.c:1039 Oops - error beacon payload is too small buf_sz 13 - drop it
ZBOSS: nwk/nwk_join.c:629 Rejoin failure: no dev with xpanid bf:de:b3:e8:e6:a6:c9:f9 or can't choose best parent
ZBOSS: commissioning/bdb/zdo_commissioning_bdb.c:549 COMMISSIONING_STOP: app signal 6 comm status 3
[ 7827][E][ZigbeeCore.cpp:239] esp_zb_app_signal_handler(): Failed to initialize Zigbee stack (status: ESP_FAIL)
Zigbee failed to start!
Rebooting...
Other Steps to Reproduce
Zigbee coordinator is the ZHA integration in Home Assistant using the Nabu Casa SkyConnect v1.0 dongle.
I have checked existing issues, online documentation and the Troubleshooting Guide
I confirm I have checked existing issues, online documentation and Troubleshooting guide.
The text was updated successfully, but these errors were encountered:
Board
ESP32-H2
Device Description
"SuperMini" dev board
Hardware Configuration
GPIO 10 & 11 are connected to I2C, GPIO 0 is ADC
Version
latest master (checkout manually)
IDE Name
Arduino IDE
Operating System
Windows 10
Flash frequency
64MHz
PSRAM enabled
no
Upload speed
921600
Description
NOTE: Using the latest files from #10636, as recommended in #10612. Selected Zigbee mode is
Zigbee ED (end device) - debug
.When initially connecting the device to Home Assistant, it works fine and the connection is stable (tested by commenting out the line that puts the ESP into deep sleep). However, upon power being removed and restored or the device waking from deep sleep, it will no longer connect. To get it to connect again, I have to re-flash the board with flash clearing enabled as Zigbee.factoryReset() doesnt seem to actually clear the stored network information. I also have to remove the device from HA and set it up as if it was a new device.
It seems to be related to the message
ZBOSS: nwk/nwk_join.c:629 Rejoin failure: no dev with xpanid bf:de:b3:e8:e6:a6:c9:f9 or can't choose best parent
. I checked, and that is definitely still the expended ID of the Zigbee network.Sketch
Debug Message
Other Steps to Reproduce
Zigbee coordinator is the ZHA integration in Home Assistant using the Nabu Casa SkyConnect v1.0 dongle.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: