Cannot set STA config after wakeup

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 1
Joined: Mon Sep 02, 2019 9:20 pm

Cannot set STA config after wakeup

Post by digitalchemy » Mon Sep 02, 2019 9:48 pm

Hello, I ran into issue trying to reconnect to wifi with my ESP8266 after waking up from deep sleep.
My code looks like this:

import network
import urequests
import machine

rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

wifi = network.WLAN(network.STA_IF)

while not wifi.isconnected():
wifi.connect("<my SSID>", "<my password>")

# do some requests an display the responses on display


rtc.alarm(rtc.ALARM0, 600000)

When the code statrts executing after boot everything works fine. But when the board wakes up from the sleep it raises:
OSError: Cannot set STA config
and it insists the error happens on the line where wifi.connect() is called.
Also, I noticed that the AP interface automaticaly activates after the wakeup, although I never called for it in my code (in this project).
My uPython version is v1.11-8-g48dcbbe60.
What am I doing wrong?
Does the ESP8266 somehow remeber the wireless configuration from previous project and load it up after wakeup by timer?

Post Reply