-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Zigbee: problem with battery powered devices after power off/on #10612
Comments
Hi @michapr, Thanks for the report. I will take a look and try to reproduce. |
Today have seen that my "solution" is not working stable - after some time reporting stop with error: log looks like:
And - in the morning the device after power on (with changed code) was still rebooting again for some time - then was starting reporting. Thanks for checking! |
I was able to reproduce it with C6, however with ESP32-H2 there is no issue. Will continue in the investigation. btw. the message |
As the example with/without selecting power source works on H2, I assume there must be some error in the esp-zigbee-sdk for C6. It may take more time to fix. I will keep this issue updated when I get any news. |
Have changed the lines in lib files - but no changes in original Temperature sample code (after power off / on - no reporting more)
|
I assume you removed the device from your system and do a factory reset. |
I removed, erased flash while programming, restarted Zigbee2MQTT (in database it is deleted, nothing more in memory) - so it should be new device... |
Time to time that happens to me also, but lets say 1 out of 10 times. |
Can you try to flash other ESP32C6/H2 with Thermostat example and try to connect to that one? To check if its related to the Zigbee2MQTT? |
I have installed the Zigbee2MQTT add-on in my HomeAssistant. |
Yes,... I have tried several times, the device is not reporting values more after power off/on... I do not have a second ESP32C6 in this time, wanted to test at first how Zigbee is working with ESP32 ;) As far as I understood the thermostat sample is not an end device, but is waiting for any other temperature sensor device right? In my Zigbee2MQTT installation are 14 other devices connected, sensors, plugs and thermostats (valves) - they do not have such problems, so I hope, that Z2M installation is not the problem. As I wrote, the color_dimmable_light is working fine, even after power off/on. Any other idea? |
Does the board reboots after the stack fails to initialize? That's the behavior I added to reset the board after I am really not sure what is happening on your side, this is not happening to me. I will try to investigate more but its hard when I am not able to replicate it. |
IF you can try to sniff the packets going between the coordinator and the ESP that can help. |
No, board does not reboot in my case (with temperature sketch). It only does not report more values - looks like does not join again. What I just have tried - I added again a dely between some lines:
Now it "can happen" that device is reporting value after power off/on. If not reporting - I do not see any packets in Z2M debug log from the device. |
looks like with this settings (delay) device is reporting after power off/on every time:
Not sure at what place it is right/needed - maybe you have an idea ;) |
Can you just add a bigger delay after the |
this did not help at all - up to 5000ms (removed other delays) Maybe that reporting starts before the stack was initialized? |
ok,.... have two different debug logs - one for working, second for not working device. Difference is after the "After Setup End" section - maybe you know why there can be different result?? NOT WORKING:
WORKING:
|
Hi @michapr, yeah there is nothing more to see then the failure of the Zigbee stack: I am sometimes getting this error too, so that's why I added a reboot if this initialization fails. I will try to discuss it with a colleague working the Zigbee stack. |
This example works. Attached the log from z2m:
|
On the Arduino IDE after starting the board there were some (6) errors with ESp_FAIL but it sends data to Z2M. At the moment no more errors. Even when i move away from the dongle.
|
now sometimes:
|
@P-R-O-C-H-Y I was testing the new Seeed Studio C6 module and found something interesting. The Zigbee_Temperature_Sensor example script seems to work fine, and if I power off the module it can reconnect with no issues. The sleepy temp sensor example still doesn't work though. I'm not sure what the two scripts are doing differently, but maybe that can help your investigation. |
@Nawor3565 - have you modified something in library? Like And, have you tried multiple off/on - also with longer off time? Never any reboot at first? And - can you try to run it multiple hours? Will it stop to report in your setup after longer time? |
@Nawor3565 Thank you for the test. Can you post a log from the Sleepy temp sensor example? Also use the Zigbee mode: End Device - Debug to have all the logs available :) |
@michapr I just tried using a fresh download of the RC-3.1.X branch with no changes to the library files. Haven't done any long term testing yet but will do that today. @P-R-O-C-H-Y Here's the log. I also put the slightly modified Temperature Sensor example script below, I copy/pasted some stuff to enable deep sleep. It probably isn't the "right" way to add deep sleep support, but it appears to be working with my setup for now. The first few reconnects were unsuccessful, but then it started working reliably as far as I can tell:
Modified script:
|
@michapr @Nawor3565 @ggtimtom To describe what's happening.
![]()
![]() In screenshot 2 you can see, that on the 1st rejoin request there was no response form HA, at that time you get in the ESP log the:
I have discussed that with the colleague working on esp-zigbee-sdk, and they will add a feature to auto-restart this rejoin request if there is no reply. Now we are solving the issue with the last commits, as we start the commissioning again. As I said, I was able to reproduce this behavior with the SonOff End device, and they do the same, if there is no reply in certain time, they send the Rejoin Request again. I hope @Nawor3565 issue was solved by the new ESP32C6 devkit. I always use the Official Espressifs Devkits, so I can recommend them to you. But sure, you may need a smaller/specific ones for your projects. I will try the Sleepy Temp Sensor example again, if I will be able to reproduce any issue. |
@P-R-O-C-H-Y Yes, looks like the rejoin problem was reproduced, nice.... This we have seen in logs, that multiple tried were needed. About the "long term" usage and the error that device is stopping send values - maybe open a new issue (maybe not related to the restart issue) |
@P-R-O-C-H-Y I just found something interesting. I was copying parts of my original script into a modified Zigbee_Temperature_Sensor example, because that example seemed to be reconnecting fine, and it suddenly started failing to reconnect when I added the code for the battery level reporting. When I removed those lines, it started reconnecting again. So, I went back to my original modified Zigbee_Temp_Hum_Sensor_Sleepy script, and commented out just these lines (although the original example was missing the second two lines, so the battery percent was sent once and never updated):
After removing those lines so that there was nothing left to do with the battery level reporting, my original script seems to work fine, which I hadn't been able to get working on either ESP32 board or with any of the changes to the Zigbee config. Maybe you can test this out on your end and see if you can reproduce? You might need to add |
@michapr I will keep those issues written to be investigated and about the |
@Nawor3565 I will try it and see if I am able to reproduce. Thanks for the feedback. |
@michapr @Nawor3565 |
im not shure what i have to do to get this updates. Do i have the wrong setup in the arduino IDE when i use https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json in the Boards Manager? |
@ggtimtom, the Fix will be included in next release. If you want to be able to use the latest changes without a release, you will need to use the Manual Install option, instead of using the Board Manager in the IDE. If you decide to, you need to be using the |
@P-R-O-C-H-Y H2 after reboot:
|
@michapr Does this happened only once or you can reproduce it? I have never saw this error. |
Yes, could reproduce sometimes. Will make next tests with latest PR, my latest sketch with changed lib was working stable. |
Sleeping sample is working now fine, power on/off is working too. I have added to the sleeping sketch a missing definition: Additional have added
For Zigbee2MQTT the time is not enough for configure the sensor - so it will never report the values. Additional: the live time is now much shorter, about 2,5 seconds only ;) THANKS! |
Have tested with H2 and C6 - sleeping device is working stable now for me. A good idea maybe to add a delay after reporting before sleep, so that device have a chance to finish reporting.
|
BOOT_PIN is declared in arduino-esp32/cores/esp32/esp32-hal.h Line 64 in a1f58ad
|
I am happy that it's now working also for you. I will add the delay after sending the last report. That sounds reasonable :) |
Strange,... I have got an error for H2 :) So I can close this issue? |
Idk its there:
But this was added recently. Maybe you did not have that synced yet? Anyway yes we can close this issue and maybe also the other one. If it's all fine now. |
Board
ESP32C6
Device Description
DevKit
Hardware Configuration
No external connections, only modul.
Version
latest development Release Candidate (RC-X)
IDE Name
Arduino IDE
Operating System
Windows 11
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
921600
Description
Using Zigbee2MQTT battery powered device will be recognized and values will be reported as expected.
After power on/off device (remove power) the device will not more join and send values to the network and reboots regularly.
Have seen that this is happen only for battery powered devices.
If adding some delay after
Zigbee.addEndpoint(&zbTempSensor);
and afterZigbee.begin();
device will not reboot, but will also not join again / report values (some other debug messages).Sketch
Debug Message
Other Steps to Reproduce
Removing from
esp_zb_task(void *pvParameters)
in ZigbeeCore.cpp the workaround device will join and report values after power off/on (without described delay device will reboot before stable work 2-3 times...) :I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: