stopping wifi before going into deep sleep?

RobLatour
Posts: 12
Joined: Mon Dec 30, 2019 4:23 am

stopping wifi before going into deep sleep?

Postby RobLatour » Fri Jun 16, 2023 9:56 pm

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?

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: stopping wifi before going into deep sleep?

Postby boarchuz » Tue Jun 20, 2023 5:38 am

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.

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 133 guests