Main code in deepsleep loop, unable to connect over serial #14292
Replies: 4 comments 4 replies
-
If you have a copy of your code, you could simply erase and reflash your board. If you don't you could copy the flash to a binary file on your pc, then try to recover the code from that. There are some tools for littlefs to do just that. OH, and look at using git to avoid this a next time |
Beta Was this translation helpful? Give feedback.
-
Thanks for your answers. I reflashed it. I didn't really lose anything, it was test code and I did save a copy. I can confirm the 'stop' message is being received by the code. main.py import time
##########################################################
# startup delay needed to connect serial before sleepcycle
start = time.ticks_ms()
while time.ticks_ms() - start < 5000: time.sleep_ms(100)
##########################################################
import test_deepsleep test_deepsleep.py import machine, network, espnow, json
from time import sleep_ms as sms
sta = network.WLAN(network.STA_IF)
sta.active(True) # Setting to active and disconnecting
sta.disconnect() # needed for yet unknown reason
espn = espnow.ESPNow()
espn.active(True)
def recv(e):
while True:
org, payl = espn.irecv(0) # Read message(s) waiting in the buffer (origin, payload)
if org is None: return # Exit on empty buffer
msg = json.loads(payl)
if 'stop' in msg:
???????????? # <<< What code could go here?
def init():
espn.irq(recv) # Interrupt on receive
main()
def main():
while True:
sms(110) # Normal sleep to wait for messages
machine.deepsleep(10000)
init() |
Beta Was this translation helpful? Give feedback.
-
I would try to solve it this way:
Maybe this will work. This will break the main() loop and go back to REPL. |
Beta Was this translation helpful? Give feedback.
-
Another tip for when you need to catch a short wakeup is to use a terminal application like tio You can hold down ctrl+c while waiting for the device to wakeup. It will spam the device and you will have more chance of catching it. From my experience I believe programs like thonny need to detect the board before allowing you to send input, by which time it is too late. |
Beta Was this translation helpful? Give feedback.
-
Ok...
So I got myself into a 'bricked not bricked' situation here.
I hope you can help me.
Sorry I cant show you the code since it's on the 'bricked' board.
I programmed a XIAO ESP32-S3 to be a ESPnow reciever.
If I monitor the power consumption, as shown below, this works.
But I can not connect to it over serial using thonny,
mpremote says:
But CTRL-C doesn't do anything.
I have a main.py file that imports the code, could i delete that main.py file with some mpremote command?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions