QUERY · ISSUE
Esp8266 doesn't execute code after woke up from deep sleep
port-esp8266proposed-close
I have a problem with waking ESP8266 from deep sleep. Here is my code that i run:
import network
import machine
import time
from machine import RTC
import ntptime
from wdt import WDT
def deep_sleep(msecs):
#configure RTC.ALARM0 to be able to wake the device
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.)
# set RTC.ALARM0 to fire after Xmilliseconds, waking the device
rtc.alarm(rtc.ALARM0, msecs)
#put the device to sleep
machine.deepsleep()
wdt=WDT()
led = machine.Pin(2, machine.Pin.OUT)
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if.scan() # Scan for available access points
sta_if.connect("TS-C99W", "VyHPS8ZJ") # Connect to an AP
sta_if.isconnected()
print(sta_if.isconnected())
rtc = RTC()
while True:
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print('woke from a deep sleep')
else:
print('power on or hard reset')
for i in range(10):
led.off()
time.sleep(1)
led.on()
time.sleep(1)
print(sta_if.isconnected())
ntptime.settime() # set the rtc datetime from the remote server
print(rtc.datetime()) # get the date and time in UTC
time.sleep(0.25)
deep_sleep(20000)
wdt.feed()
The output that I am getting is this:

The board that I am using is this:

I am not sure why is this happening? What am I doing wrong?
Please help me to solve this issue.
Thanks
CANDIDATE · ISSUE
NodeMCU v1.0 stuck at deep sleep rtc wakeup
Following the docs i tried the deep sleep example
import machine
# configure RTC.ALARM0 to be able to wake the device
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
# check if the device woke from a deep sleep
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print('woke from a deep sleep')
# set RTC.ALARM0 to fire after 10 seconds (waking the device)
rtc.alarm(rtc.ALARM0, 10000)
# put the device to sleep
machine.deepsleep()
but when it wakes up it gets stuck in booting and doesn't let me erase the flash memmory or anything cause everytime i reset the device it keeps "waking up" from deep sleep and it enters to it once again.
I have tried the esptool.py to erase memory but it doesn't find the device with the usbserial converter nor usb.