Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tve
Copy link
Contributor

@tve tve commented Dec 29, 2019

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
Copy link
Contributor Author

tve commented Dec 29, 2019

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
Copy link
Contributor Author

tve commented Dec 29, 2019

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
Copy link
Contributor Author

tve commented Mar 1, 2020

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

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
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

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
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.

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.

None yet

5 participants