1

noob in arduino here.

I'm trying to connect via BLE after the ESP32 wakeups from light sleep. I have tried many different things, but none of them work. Everything works fine before the device sleeps the first time. Could you guys please give some ideas of what is wrong? the official docs are terrible.


 btStop();
 delay(1000);
 esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
 Serial.println("Going to light sleep now");
 esp_light_sleep_start();
 btStart();
asked Apr 1, 2023 at 21:27

1 Answer 1

0

I finally found the answer, you just need to advertise again the service after it sleeps. First you need to define this:

#if CONFIG_PM_ENABLE
// Configure dynamic frequency scaling:
// maximum and minimum frequencies are set in sdkconfig,
// automatic light sleep is enabled if tickless idle support is enabled.
// esp_pm_config_esp32c3_t pm_config = { // old version
esp_pm_config_t pm_config = {
 .max_freq_mhz = 160, // e.g. 80, 160,
 .min_freq_mhz = 80, // 40
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
 .light_sleep_enable = true
#endif
 };
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
#endif // CONFIG_PM_ENABLE

Then in your loop you could do something like:

esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println("Going to light sleep now");
esp_light_sleep_start();
Serial.println("depois do sleep start");
BLEDevice::startAdvertising();
answered Apr 5, 2023 at 14:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.