ESP32 - configuring wifi power save mode from micropython

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
pingu077
Posts: 2
Joined: Sun Feb 20, 2022 2:11 pm

ESP32 - configuring wifi power save mode from micropython

Post by pingu077 » Sun Feb 20, 2022 2:39 pm

Hi,
I would like to configure my ESP32 board to disable WiFi power save mode from MicroPython.
How can this be done ?

From Espressif docs at
https://docs.espressif.com/projects/esp ... _wifi.html
it can be done with: esp_wifi_set_ps(WIFI_PS_NONE) , as by default ESP32 wifi is configured with WIFI_PS_MIN_MODEM
What is the equivalent in MicroPython ?

Note that the only other place where I have seen this mentionned is here, dating back to 2019...
viewtopic.php?f=2&t=7317&p=41719&hilit= ... _ps#p41719

Looking forward to any comment or advice...

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: ESP32 - configuring wifi power save mode from micropython

Post by karfas » Sun Feb 20, 2022 10:29 pm

There are already two different pull requests regarding WIFI Power save:

https://github.com/micropython/micropython/pull/6774 (mine)
https://github.com/micropython/micropython/pull/5473

I have no idea when someone will decide to merge one of them.

Regards,
Thomas
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

pingu077
Posts: 2
Joined: Sun Feb 20, 2022 2:11 pm

Re: ESP32 - configuring wifi power save mode from micropython

Post by pingu077 » Mon Feb 21, 2022 12:54 pm

Thanks for pointing out these 2 pull requests.
I checked both of them, and I think I prefer your approach (6774), although if none of them is gets merged, it won't help much...

I'm trying to use the ESP32 in a home automation system where the board must send and respond to MQTT messages with fairly low latency (< 300 ms). With the ESP32 default WIFI_PS_MIN_MODEM, latency when receiving MQTT messages can be anywhere between 400 and 3000 ms due the Wifi modem going into power save mode quickly after sending packets... Just not acceptable for my application, considering that the board is not operating from battery.

I think I will try to create a small mpy file with the one function esp_wifi_set_ps() exposed. It might be easier than recompiling the entire micropython image. What do you think ?

ThomasF
Posts: 1
Joined: Sun Jun 12, 2022 2:58 pm

Re: ESP32 - configuring wifi power save mode from micropython

Post by ThomasF » Sun Jun 12, 2022 3:00 pm

Did you have any luck with creating a MPY file or did you find another way to configure power save for the ESP32 wifi ?
Thomas

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: ESP32 - configuring wifi power save mode from micropython

Post by Jibun no kage » Fri Aug 26, 2022 5:50 am

Any work on this issue? I am seeing some real performance differences between ESP32 and ESP8266 when responding to MQTT communication. The ESP8266 is snappy, the ESP32 takes 1 to 5 seconds to receive and respond to MQTT traffic initially, speeds up, then slows again. The same happened PicoW, but there is a documented method in the Pico SDK, on how to disable the WiFI sleep feature. Appears need the same on ESP32.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP32 - configuring wifi power save mode from micropython

Post by davef » Fri Aug 26, 2022 6:30 am

I use power_save for a ESPNow Gateway using an image found at https://github.com/glenn20/micropython-espnow-images. Only for the ESP32.

Docs:
https://micropython-glenn20.readthedocs ... spnow.html

User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

Re: ESP32 - configuring wifi power save mode from micropython

Post by glenn20 » Sun Sep 04, 2022 11:30 pm

karfas wrote:
Sun Feb 20, 2022 10:29 pm
There are already two different pull requests regarding WIFI Power save:

https://github.com/micropython/micropython/pull/6774 (mine)
https://github.com/micropython/micropython/pull/5473
And a third at https://github.com/micropython/micropython/pull/8993 ;). (I missed the earlier PRs before I posted mine).

This latter PR has been split off from the ESPNow PR (#6515) and is the basis of the support in the images referred to by davef. I'm also unsure when any of these PRs will be merged, but a few other additions to the WLAN.config() method of the esp32 have been recently merged into master.

Post Reply