Skip to content

ESP32: support dynamic freq scaling and wifi power save - #5473

Closed
tve wants to merge 2 commits into
micropython:masterfrom
tve:esp32-low-power
Closed

tve wants to merge 2 commits into
micropython:masterfrom
tve:esp32-low-power

Conversation

@tve

@tve tve commented Dec 29, 2019 •

Copy link
Copy Markdown
Contributor

This PR allows the power consumption of the esp32 to be tweaked. It enables:

  • using dynamic frequency scaling allowing FreeRTOS to reduce the clock frequency when the processor is idle
  • using listen interval on the WiFi STA interface to reduce the amount of time the radio is powered on
  • using listen interval to keep the radio on permanently to reduce network latency

The punchline is that one can halve the power consumption for more battery life or double it for lower network latency.

These features are documented, see the PR files. I have not been able to preview the docs, however, so I assume there are issues. I need to figure out how to do that...

One caveat I'm just realizing is that I haven't tested with ESP-IDF v3....

@tve

tve commented Dec 29, 2019 •

Copy link
Copy Markdown
Contributor Author

AN issue I just discovered: the following loop in uselect busy-waits: https://github.com/micropython/micropython/blob/master/extmod/moduselect.c#L250-L257. I'll throw a ulTaskNotifyTake(pdFALSE, 1); in there to see what happens...

Edit: also https://github.com/micropython/micropython/blob/master/extmod/moduselect.c#L176

@tve

tve commented Dec 29, 2019

Copy link
Copy Markdown
Contributor Author

Well, this last commit fixed asyncio. But now I better profess that I have no friggin' clue about what I'm doing, LOL :-)

@tve
tve force-pushed the esp32-low-power branch 2 times, most recently from 32cc9e0 to de52c2e Compare March 1, 2020 06:44
@tve

tve commented Mar 1, 2020

Copy link
Copy Markdown
Contributor Author

rebased on master and squashed commits

tve added 2 commits April 16, 2020 17:48
ports/esp32: fix some peripheral clocks for low-power op
@moefear85

Copy link
Copy Markdown

I'd like to mention, that as per the esp-idf documentation, it is possible to keep some peripherals, including UART, functioning properly during auto-lightsleep (specifically frequency scaling), by using "REF_TICK" as a tick source. That would make this feature far more usable and desirable.

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Oct 28, 2021
Allow any character except / in port or board name
@dpgeorge

Copy link
Copy Markdown
Member

I think the WLAN.connect.(..., listen_interval) addition is great, definitely useful and even necessary for some applications.

The dynamic frequency scaling is also good but I think it's not yet clear how to make it work properly. And the changes here (like changing the UART clock source) seem like they could have unintended affects on existing behaviour. Also newer version of the IDF (since v4.1) have changed how this is configured.

So I suggest to split out the addition of listen_interval and merge just that feature.

@EternityForest

Copy link
Copy Markdown

What if auto lightsleep was something you manually enabled and disabled? Lots of applications don't need to do anything besides listen for commands, most of the time, you could just manually come out of that state when needed.

@projectgus

Copy link
Copy Markdown
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

@dpgeorge

Copy link
Copy Markdown
Member

Closing due to inactivity. Also this probably won't work with IDF 5.x.

(Still, it would be great to have the listen_interval feature per #5473 (comment), if someone wants to implement just that bit, feel free to open another PR.)

@dpgeorge dpgeorge closed this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants