Page 1 of 1

ESP32 - configuring wifi power save mode from micropython

Posted: Sun Feb 20, 2022 2:39 pm
by pingu077
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...

Re: ESP32 - configuring wifi power save mode from micropython

Posted: Sun Feb 20, 2022 10:29 pm
by karfas
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

Re: ESP32 - configuring wifi power save mode from micropython

Posted: Mon Feb 21, 2022 12:54 pm
by pingu077
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 ?

Re: ESP32 - configuring wifi power save mode from micropython

Posted: Sun Jun 12, 2022 3:00 pm
by ThomasF
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

Re: ESP32 - configuring wifi power save mode from micropython

Posted: Fri Aug 26, 2022 5:50 am
by Jibun no kage
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.

Re: ESP32 - configuring wifi power save mode from micropython

Posted: Fri Aug 26, 2022 6:30 am
by davef
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

Re: ESP32 - configuring wifi power save mode from micropython

Posted: Sun Sep 04, 2022 11:30 pm
by glenn20
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.