Esp8266 doesn't execute code after woke up from deep sleep
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
ESP32 module wake on touch, wake on ext1
Hi there,
I'm running MicroPython v1.9.4-409-g434975def and have successfully used a Pin irq to wake from deep sleep and can confirm the wake reason:
import machine
from machine import Pin, TouchPad, deepsleep
import time
wake = Pin(14, mode = Pin.IN, pull = Pin.PULL_DOWN)
wake.irq(trigger=Pin.WAKE_HIGH, wake = machine.DEEPSLEEP)
time.sleep(5)
deepsleep(5*1000)
after bringing Pin 14 line up to 3V3
Reset cause: DEEPSLEEP_RESET
Wake reason: PIN_WAKE/EXT0_WAKE
Now I'm trying to do the same but with a TouchPad input:
from machine import Pin, TouchPad, deepsleep
import time
import esp32
wake = Pin(14, mode = Pin.IN)
touch = TouchPad(wake)
touch.config(500)
esp32.wake_on_touch(True)
time.sleep(5)
deepsleep(5*1000)
(after 5 seconds and touching/untouching wire to Pin 14)
Reset cause: DEEPSLEEP_RESET
Wake reason: TIMER_WAKE
The range of my touch.read() values are around 700 when untouched, and down to around 100 when touched. I've tried adjusting the touch.config to various settings but I cannot get my ESP32 to wake from touch.. only from timer in this mode.
Lastly,
I've tried using wake_on_ext1
import machine
from machine import Pin, TouchPad
import time
import esp32
wake = Pin(14, mode = Pin.IN, pull = Pin.PULL_DOWN)
esp32.wake_on_ext1(pins = [wake], level = Pin.WAKE_HIGH)
time.sleep(5)
deepsleep(5*1000)
But this resets immediately regardless of whether I bring Pin 14 high or not (not in touch mode, mind you).
Reset cause: DEEPSLEEP_RESET
Wake reason: EXT1_WAKE
I've browsed through the esp32 module code, but I'm not sure if any of the wake modes work?
Any ideas?