Hi,
I flashed microPython on a generic ESP32 module (ESP2-WROOM-32D) that I've been using without any problems when coded with Arduino IDE. I tried to test with a very simple code the deepsleep function. This is the code I got from an example on the web at this link https://microcontrollerslab.com/micropy ... p-sources/
import machine
from machine import Pin
from time import sleep
led = Pin (2, Pin.OUT) #GPIO14 as output for LED
led.value(1) #LED is ON
sleep(1) #delay of 1 second
led.value(0) #LED is OFF
sleep(1) #delay of 1 second
# add a 10 second delay before ESP32 goes into deep sleep mode.
# it is just see the message on serial console
sleep(10) #delay of 10 seconds
print('Setting to Deep Sleep Mode')
machine.deepsleep(10000) #10000ms sleep time
However, I get a strange behaviour: the code is executed just ONCE, then when the deepsleep time has elapsed, the board seems to wake up, I get the following message on the shell (I'm using Thonny) and nothing else happens.
Since I am an old(74) newbie I would be very grateful if you could help me to solve this puzzle. Thanks for your help.
This is the message on the shell
>>> %Run -c $EDITOR_CONTENT
MPY: soft reboot
Setting to Deep Sleep Mode
ets Jul 29 2019 12:21:46
rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4728
load:0x40078000,len:14888
load:0x40080400,len:3368
entry 0x400805cc
Waking up from deep sleep
MicroPython v1.22.2 on 2024-02-22; Generic ESP32 module with ESP32
Type "help()" for more information.
>>>
ESP32 not working after deepsleep
Re: ESP32 not working after deepsleep
Experiment with different durations for deep sleep to see if the behavior changes.
-
- Posts: 1
- Joined: Tue Nov 02, 2021 10:18 pm
Re: ESP32 not working after deepsleep
I believe the code executed only once because you may have not saved your code with the name main.py. The article you mentioned seems not to ask for this. If you save the code with that name you will see that it will be repeated over and over after waking up from deepsleep.
Who is online
Users browsing this forum: MicroController and 116 guests