Skip to content

wifi.sta.disconnect() does not sleep the modem #1480

@joysfera

Description

@joysfera

Expected behavior

when wifi is disconnected it would be logical if the wifi modem went to sleep. Especially when the sleeptype is set to MODEM_SLEEP.

Actual behavior

After disconnecting the power load increases up to 70 mA - that indicates the wifi modem is fully powered.

Test code

Provide a minimal and isolated test which will reproduce the problem.

wifi.setmode(wifi.STATION)
wifi.sleeptype(wifi.MODEM_SLEEP)
wifi.config(...,...)
wifi.connect()
-- here the ESP needs about 15 mA
wifi.sta.disconnect()
-- now the ESP requires more than 70 mA

NodeMCU version

custom build by frightanic.com
branch: dev
commit: 3328c66

Hardware

plain ESP8266 version 07

Still trying to figure out how to program a battery powered ESP device. It would be logical to connect to an AP only when needed, fetch fresh data, then disconnect immediately and run in low power. However, currently disconnecting from an AP actually increases battery load. Hopefully can be fixed similarly to the recent setmode(wifi.NULLMODE) fix.

That's actually the only way now to save power - i.e. change the mode from STATION to NULLMODE after disconnecting and then change the mode back before reconnecting. I'd think it shouldn't be necessary if the MODEM_SLEEP worked in all cases hence I'm submitting this issue. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions