8000 Add wifi.radio.listen_interval to ESP32-family chips. by EternityForest · Pull Request #9476 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Add wifi.radio.listen_interval to ESP32-family chips. #9476

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 &ldquo 8000 ;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

Merged
merged 6 commits into from
Aug 6, 2024

Conversation

EternityForest
Copy link
@EternityForest EternityForest commented Jul 31, 2024

This is not heavily tested, and is posted for review and discussion as part of work on #9463.

It allows you to set the listen interval of the WiFi hardware to reduce power consumption.

When listen interval is 1, WIFI_PS_MIN_MODEM is used, when it is more than 1, WIFI_PS_MAX_MODEM is used.

The listen interval is set in units of whatever the AP's beacon interval is, most likely 100ms.

Without it, and running at 80MHz, power consumption hovers around 110mA with 140mA spikes. When set to 1, power is ~60mA with much less frequent spikes.

Setting it to more than 1 makes no difference that I can see on the power meter, it seems to be a sub-milliamp difference, so I almost wonder if it might be better to just cap it at 1, and use higher values only if there's more advanced features like target wake time available on your chip.

wifi.radio.listen_interval = 0

@anecdata
Copy link
Member
anecdata commented Jul 31, 2024

The main risk of WIFI_PS_MAX_MODEM (which doesn't sound severe for most use cases) seems to be that "broadcast data may be lost". This is mentioned in the linked issue.

@EternityForest
Copy link
Author

Yeah, I'm not sure if it also affects multicast, but broadcast isn't super commonly used so it might be fine.

The advantage of capping at 1 is that it could then be completely safe to use higher values on all boards, and there could just be one parameter for DTIM beacon sleep and target wake time.

But I'm not actually sure higher DTIM values are actually doing anything, ping times and power look the same as when set to 1.

Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition! Please add it to all wifi ports even if it raises an exception from the port code.

It also looks like you have a code formatter that disagrees with ours. I think setting up pre-commit will format it back for you.

@EternityForest
Copy link
Author
EternityForest commented Jul 31, 2024 via email

@EternityForest
Copy link
Author

I think I've partially figured out the issue! It was running the normal system uncrustify instead of the micropython-uncrustify version.

Not sure what to do about the error string translation stuff for the notimplemented error, looks like there's an existing string "can't set attribute" that would fit?

Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revisions. I think some of my old comments haven't been addressed either.

Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@tannewt tannewt changed the title DRAFT: Add wifi.radio.listen_interval to ESP32-family chips. Add wifi.radio.listen_interval to ESP32-family chips. Aug 6, 2024
@tannewt tannewt merged commit 736ba1e into adafruit:main Aug 6, 2024
212 of 214 checks passed
@dhalbert dhalbert mentioned this pull request Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0