[SOLVED] Issues connecting to WLAN after deep sleep

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
jonaslorander
Posts: 11
Joined: Tue Nov 08, 2016 12:33 pm

[SOLVED] Issues connecting to WLAN after deep sleep

Post by jonaslorander » Sun Apr 07, 2019 8:06 am

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
Last edited by jonaslorander on Wed Apr 17, 2019 6:51 pm, edited 1 time in total.

jonaslorander
Posts: 11
Joined: Tue Nov 08, 2016 12:33 pm

Re: Issues connecting to WLAN after deep sleep

Post by jonaslorander » Wed Apr 10, 2019 6:50 pm

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?

jonaslorander
Posts: 11
Joined: Tue Nov 08, 2016 12:33 pm

Re: Issues connecting to WLAN after deep sleep

Post by jonaslorander » Wed Apr 17, 2019 6:50 pm

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.

Post Reply