Replies: 13 comments 18 replies
-
I'm not sure why your device is failing to wake from deepsleep, but I have a few comments that might help:
I would try:
And finally, it is easier to help if you format code in your messages following the guidelines at: https://github.com/orgs/micropython/discussions/9111. You can edit your message to fix the formatting. |
Beta Was this translation helpful? Give feedback.
-
Hi, it's the one depicted in this link: https://randomnerdtutorials.com/esp32-built-in-oled-ssd1306/ However, I flashed Micropython also on a generic ESP32 (that I'm using without any problem with deepsleep and timer wake-up when coded with Arduino IDE) and even this one shows the same behaviour. The code runs once rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) I know that I'm a newbie but this behaviour is absolutely awkward and I was not able to find any explanation. Waiting for your help. Thanks |
Beta Was this translation helpful? Give feedback.
-
Hi,
thanks for the prompt answer. I'm using Thonny and when I run a code without deep sleep it works. I've also tried to rename this code main.py but it just runs once, then prints the message, then nothing else
… Il 08/03/2024 22:32 CET Dave Festing ***@***.***> ha scritto:
It is a ESP32_WROOM variant. On my ESP32-WROOM-32 putting your script into main.py gives:
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
Setting to Deep Sleep Mode
ets Jun 8 2016 00:22:57
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
Setting to Deep Sleep Mode
ets Jun 8 2016 00:22:57
Getting this:
Type "help()" for more information.
at the end suggests that "main" ran with no output.
How are you loading Micropython onto the device?
—
Reply to this email directly, view it on GitHub #14044 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BIYK2ETBA36KTLV4UWRGDYXIU7PAVCNFSM6AAAAABEI72GIOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DOMRVGAYDK.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi, I tried to use esptool.py but I always get a SyntaxError and the source of the error should be esp32 ( since it's underlimed) However on the external envelop of my chip there is ESP32-WROOM- 32D. Could this help to identify the issue ? Thanks.
… Il 08/03/2024 23:15 CET Dave Festing ***@***.***> ha scritto:
Unfortunately I don't use Thonny. I use esptool for loading firmware and rshell to communicate with the board. mpremote is the official command line tool.
I will suggest installing esptool and run this command:
esptool.py --chip esp32 chip_id (shows the chip reversion)
or hope someone who is familiar with Thonny appears on the scene.
—
Reply to this email directly, view it on GitHub #14044 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BIYK56V4Z56CKVKVNOT33YXIZ73AVCNFSM6AAAAABEI72GIOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DOMRVGMYDE.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi, Answering your questions: |
Beta Was this translation helpful? Give feedback.
-
One more observation. I tried to modify the code adding a print statement and a second led that is supposed to blink if the code is executed after waking up and after on serial monitor appears the message "Waking up from deep sleep" and this happens but again just once.è That is, the first led blinks, then the board enters the deepsleep, then it seems to wake up since it prints the message "Waking up from deep sleep" and the second led blinks but after that nothing else happens.
|
Beta Was this translation helpful? Give feedback.
-
Hi,
good evening ( here in Turin, Italy, it's 9.10 pm )
Yes I flashed micropython also on a generic ESP32 that I've used several times with no problems for datalogging and deep sleep.
I got, as I told you, the same result that I had with trhe Wemos Lolin 32 with integrated OELD that was the first board on which I tried micropython.
However, I found an interesting phenomenon: if, instead of using deep sleep I use machine.lightsleep, the board wakes up and runs the code without any problem.
So I am forced to think that the problem is in the deepsleep function when applied to ESP32. And this fact sounds very strange for me because I found examples on the web where deep sleep is implemented into an ESP32 without problems.
One final word: I really appreciate your patience and your help: as an old(74) newbie I must confess that I've found the forums not so kind with old men( especially when they are newbies) so that I got the wrong idea that Arduino and Python forums were No Country for Old Men, as the movie says...
… Il 09/03/2024 20:42 CET Dave Festing ***@***.***> ha scritto:
Good morning, The image I saw for your board was quite different. This one is the same as the boards I use. First time that I have seen this image and I notice all the comments about GPIO state on every pin.
Have you got a ESP32 - DevKitC without a display on that you could run tests on?
—
Reply to this email directly, view it on GitHub #14044 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BIYKZYFKF366RXJSB35T3YXNQ3XAVCNFSM6AAAAABEI72GIOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DOMZRGU2DG.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi,
now I understand why you are so patient...
However, yes you are correct : with a generic ESP32 ( with esp32-WROOM-32D chip) I got the same problem that I had with the Wemos Lolin 32 with integrated OLED.
However, the code runs without problem if I use lightsleep anot deepsleep ( obviously it works if I use just sleep).
… Il 09/03/2024 21:26 CET Dave Festing ***@***.***> ha scritto:
Just to clarify, as I am 5 years older than you, the last script you posted fails when you run it on a generic ESP32 WITHOUT an attached display. Correct?
—
Reply to this email directly, view it on GitHub #14044 (reply in thread), or unsubscribe https://github.com/notifications/unsubscribe-auth/A5BIYK5CZSBGWX53QRER7G3YXNV73AVCNFSM6AAAAABEI72GIOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DOMZRG42TG.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your efforts. Also my board as a 10 uF between EN pin and GND just to avoid pressing BOOT button to upload codes : no other things attached except a LED with a 220 ohm resistor I've changed the ledpin according to your suggestion and this is the modified code
|
Beta Was this translation helpful? Give feedback.
-
No,
I've just said "have a nice day" because from your previous post I thought that you were engaged in other activities. Still only one loop.
Now I'm going to sleep (hopefully better than esp32) and tomorrow I'll try again with your suggestion to change the capacitor ( I have to find one)
--
Inviato da Libero Mail
|
Beta Was this translation helpful? Give feedback.
-
This is the logical structure of your code: if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print("Waking up from deep sleep")
else:
...
print("Setting to Deep Sleep Mode")
machine.deepsleep(10000) # 10000ms sleep time which means it will go into deepsleep once. After this deepsleep it will This is probably not what you want. You want to go into deep sleep every time your code runs. Try restructuring your code: ...
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print("Waking up from deep sleep")
# do some work here
print('do some work')
# go to deepsleep
print('Countdown to new deepsleep unless ctrl-c')
print('You have 10 seconds before deep sleep')
c=10
while c>=0:
try:
print(f'{c}..', end='')
sleep(1)
c-=1
except:
print(f'\nabort countdown at {c}')
print('Back to REPL - this code run from main.py')
break
else:
print('\ngoing to deepsleep now!!')
mc.deepsleep(1000)
print('You will never see this line printed out') This code runs from main.py, the countdown makes it possible to break out of main.py into the REPL. This is important if you want to edit or delete main.py. |
Beta Was this translation helpful? Give feedback.
-
Hi, at the end I succeded in obtaining what I need: the ESP32 wakes up, runs the code and goes to deepsleep, then wakes up, runs again the code and so on. I've tried with an ESP32 without integrated OLED but I connected a 1306SSD OLED through i2c and it works. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for your suggestion. Indeed now I renamed the code main.py. As a newbie I started with Thonny since I come from Arduino IDE. I'll try to use what you're suggesting . Have a nice day
--
Inviato da Libero Mail
|
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to use an ESP32 with integrated OLED SSD1306 as a datalogger collecting data from BME280 and time from RTCDS3231 (since I'm planning to use it where wifi is often not working) and saving them on a SD card. I've realized on other ESP32s with m NO integrated OLED display the same project taht worked fine. Since this peculiar board when coded with Arduino IDE didn't work I flashed micropython and used this code that works but the board doesn't wake up just sending when it is supposed to awake the following message
ets Jul 29 2019 12:21:46
rst:0x5 (DEEPSLEEP_RESET),boot:0x17 (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:14876
ho 0 tail 12 room 4
load:0x40080400,len:3368
entry 0x400805cc
MicroPython v1.21.0 on 2023-10-05; Generic ESP32 module with ESP32
Type "help()" for more information.
Here is the code where for debugging purposes I chose a very short deepsleep (30 seconds)
'''
`from machine import deepsleep
from machine import Pin, SoftI2C
from ds3231_port import DS3231
import utime
import sys
import uos
import BME280
import ssd1306
from time import sleep
import machine, os, sdcard
Assign chip select (CS) pin (and start it high)
cs = machine.Pin(15, machine.Pin.OUT)
Intialize SPI peripheral (start with 1 MHz)
spi = machine.SPI(1,
baudrate=1000000,
polarity=0,
phase=0,
bits=8,
firstbit=machine.SPI.MSB,
sck=machine.Pin(25),
mosi=machine.Pin(14),
miso=machine.Pin(13))
Initialize SD card
sd = sdcard.SDCard(spi, cs)
os.mount(sd, '/sd')
i2c = SoftI2C(scl=Pin(4), sda=Pin(5))
rtc = DS3231(i2c)
ds3231 = DS3231(i2c)
ds3231.get_time()
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
while True:
oled.fill(0)
bme = BME280.BME280(i2c=i2c)
temperature = str(bme.temperature)
humidity = str(bme.humidity)
print('Temperature is ', temperature)
print('Humidity is ', humidity)
print('{:02d}:{:02d}:{:02d} '.format(utime.localtime()[3], utime.localtime()[4], utime.localtime()[5]), end='')
print('{:02d}:{:02d}:{:04d} '.format(utime.localtime()[2], utime.localtime()[1], utime.localtime()[0]), end='')
oled.text("Temp. "+temperature, 0, 0)
oled.text("Hum, "+humidity, 0, 15)
oled.show()
sleep(5)
oled.fill(0)
file = open('/sd/test.txt', 'a')
file.write(str(bme.temperature) + '; ' + str(bme.humidity) + '; '+ str(utime.localtime()[3:6]) + '; \n')
file.close()
oled.text('Awake', 0, 0)
oled.text('but sleeping', 0, 10)
oled.text('in 5 seconds', 0, 20)
oled.text('for 30 seconds', 0, 30)
oled.text(str(utime.localtime()[3:6]),0,45)
oled.show()
sleep(5)
oled.fill(0)
oled.poweroff()
deepsleep(30000)
'''
Thanks for your precious help: I'm an old(74 y) newbie and this maybe is a silly question.
Beta Was this translation helpful? Give feedback.
All reactions