Page 1 of 1

[SOLVED] Issues connecting to WLAN after deep sleep

Posted: Sun Apr 07, 2019 8:06 am
by jonaslorander
Hi,

I'm having an issue with connecting to my WLAN after a deep sleep.
I'm using MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266

Since the credentials are stored in flash, all I have to do to reconnect to the last AP should be

Code: Select all

import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
But this only works if it is a hard reset or machine.reset(), not if the ESP is waken up from machine.deepsleep() using RTC IRQ or even esp.deepsleep(time). If I do this however, it will connect to my WLAN again, even after a deep sleep.

Code: Select all

import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("myssid", "mypassword")
I'm I missing something from the documentation regarding deep sleep and WLAN capabilities? Or is the documentation missing something regarding this? I don't want to be using wlan.connect(..., ...) on every reset as (in my understanding) it will break the flash.

Any suggestions? Thanks in advance!

Regards,
Jonas

Re: Issues connecting to WLAN after deep sleep

Posted: Wed Apr 10, 2019 6:50 pm
by jonaslorander
I have made some more tests with different values for the second parameter of esp.deepsleep(). I've tested 0 (default) and 1 (make RF calibration on wake). But there is no difference.

Havn't anybody experienced this issue? And is it a problem with using wlan.connect(), will it wear out the flash?

Re: Issues connecting to WLAN after deep sleep

Posted: Wed Apr 17, 2019 6:50 pm
by jonaslorander
So I just solved this.
Turns out that if you deactivate the WLAN ( wlan.active(False) ) it is not possible, at least for me, to reconnect to a network after a deep sleep. When I commented out the deactivate, that I had just before entering deep sleep it all works.