![]() We can find the source of reset by using machine.reset_cause() function. We will then import the pin and the sleep class from their respective modules. Therefore, we will import the esp32, machine, and time module. epsleep() #module goes in deep sleepĪs always, the first step is to import the different modules which we would be using. Print('I am in active Mode for 10 seconds') Push_button = Pin(14, mode = Pin.IN) #setting push_button as wake up sourceĮsp32.wake_on_ext0(pin = push_button, level = esp32.WAKEUP_ANY_HIGH) #initializing wake up If machine.reset_cause() = machine.DEEPSLEEP_RESET: # check if the device woke from a deep sleep MicroPython Script import machine #importing modules After that upload the file to the ES32 board and click on the reset/enable button: DemonstrationĬreate a new file in uP圜raft or Thonny IDE and give it a main.py name. Note: If you call deepsleep() without argument inside your code, it will put the ESP32 into deep sleep indefinitely. After the 10 seconds are over, the ESP board would wake up and restart. We will be setting it to sleep for 10000ms which is 10 seconds. The final step is initiating the deepsleep() function from the machine module. Hence, we will also print “Setting to Deep Sleep Mode” on the screen to specify that we will be entering the deep sleep mode shortly. To upload newer pieces of program code, the board has to be awake. This delay will help in establishing a serial communication when the ESP board is awake (before putting it in deep sleep). We will be incorporating a delay of 10 seconds ( sleep(10)) after the Led has gone from the ON to OFF transition once.
0 Comments
Leave a Reply. |