esp-zigbee-sdk: esp_zb_sleep_now() does not wake up from gpio (TZ-268)
Hello,
I’m trying to make my device sleep, and wake it up when a button is pressed. I am not sure what esp_zb_sleep_now() does. My signal handler looks like this:
case ESP_ZB_COMMON_SIGNAL_CAN_SLEEP:
ESP_ERROR_CHECK(
gpio_wakeup_enable(GPIO_INPUT_IO_TOGGLE_SWITCH, GPIO_INTR_LOW_LEVEL));
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());
esp_zb_sleep_now();
ESP_LOGI(TAG, "wake up cause %d", esp_sleep_get_wakeup_cause());
break;
But when I push my button, the controller will not wake up from sleep. And when it wakes up, the cause is always 4 (the timer).
Is this supposed to work, and my issue is somewhere else? What does the esp_zb_sleep_now() function do? Is there a way to just call esp_light_sleep_start() instead?
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 25 (9 by maintainers)
I have reported this as a proper issue in https://github.com/espressif/esp-zigbee-sdk/issues/148 to give it more visibility. It includes more detailed steps to reproduce the issue.
@blastrock
ESP_ZB_COMMON_SIGNAL_CAN_SLEEPis a signal in the Zigbee stack that notifies the user stack when it’s safe to put the device to sleep. When esp_zb_sleep_now is called, the stack provides the sleep duration, during which the device enters a low-power sleep mode, effectively shutting down RF and peripheral power.To enable wake-up from sleep using GPIO, you should call
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());before invoking esp_zb_init(). This setup should not be called repeatedly within this context.