# Complete project details at https://RandomNerdTutorials.com/micropython-programming-with-esp32-and-esp8266/ import machine from machine import Pin from time import sleep led = Pin(2, Pin.OUT) def deep_sleep(msecs): # configure RTC.ALARM0 to be able to wake the device rtc = machine.RTC() rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP) # set RTC.ALARM0 to fire after X milliseconds (waking the device) rtc.alarm(rtc.ALARM0, msecs) # put the device to sleep machine.deepsleep() #blink LED led.value(1) sleep(1) led.value(0) sleep(1) # wait 5 seconds so that you can catch the ESP awake to establish a serial communication later # you should remove this sleep line in your final script sleep(5) print('Im awake, but Im going to sleep') #sleep for 10 seconds (10000 milliseconds) deep_sleep(10000)