Page 1 of 1

stopping wifi before going into deep sleep?

Posted: Fri Jun 16, 2023 9:56 pm
by RobLatour
if my esp32 is connected to wifi before going into deep sleep, is there any advantage to issuing the commands:

esp_wifi_stop();
esp_wifi_deinit();

before

going into deep sleep?

I'm thinking perhaps that may tell the AP that the wifi will no longer be required and save resources there, until the esp wakes up and reconnects - however I'm not sure if the deep sleep stops the wifi and does the deinit anyway?

Re: stopping wifi before going into deep sleep?

Posted: Tue Jun 20, 2023 5:38 am
by boarchuz
Yes, you should at least esp_wifi_stop. If your IDF version is fairly recent then it will automatically esp_wifi_stop before deep sleep anyway (see esp_register_shutdown_handler).
I would also recommend waiting a moment for the subsequent WIFI_EVENT_[STA/AP]_STOP event to ensure it has actually stopped before sleeping. In the past, I've seen an additional few hundred uA in deep sleep if this isn't given enough time.