DeepSleep on Nucleo-WB55
I'm currently trying to use micropython on a Nucleo-WB55.
ATM it works well for what I need (using BLE to advertize data) but I can't reach to use deepsleep.
I tried this
machine.deepsleep(5000)
But this is ignored, i.e. the LED is instantly tuned off with the code below
while True: led_bleue.off() time.sleep(2) led_bleue.on() machine.deepsleep(5000)
Any idea on what is wrong ?
RP2350 / Pico 2 machine.deepsleep results in crash
Port, board and/or hardware
Pico 2 / RP2350
MicroPython version
MicroPython v1.24.0-preview.201.g269a0e0e1 on 2024-08-09; Raspberry Pi Pico2 with RP2350
Reproduction
- Install latest Firmware from https://micropython.org/download/RPI_PICO2/
- Implement
machine.deepsleep(5000)in your code - Run code.
Expected behaviour
Expected Pico 2 to enter deepsleep mode for 5 seconds, then continue to next bit of code.
Observed behaviour
Upon reaching deepsleep, the LED on my Pico blinks when it reaches that part of the code, but Thonny's console outputs:
PROBLEM IN THONNY'S BACK-END: Exception while handling 'Run' (ConnectionError: read failed: [Errno 6] Device not configured).
See Thonny's backend.log for more info.
You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.
Process ended with exit code 1.
Unable to connect to /dev/cu.usbmodem83101: [Errno 2] could not open port /dev/cu.usbmodem83101: [Errno 2] No such file or directory: '/dev/cu.usbmodem83101'
Contents of backend.log after the Shell displays that error:
12:00:29.977 [MainThread] INFO thonny: Thonny version: 4.1.4
12:00:29.977 [MainThread] INFO thonny: cwd: /Users/jgeerling
12:00:29.977 [MainThread] INFO thonny: original argv: ['/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python', '-s', '-u', '-B', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/thonny/plugins/rp2040/rp2040_back.py', "{'clean': True, 'port': '/dev/cu.usbmodem83101', 'dtr': None, 'rts': None, 'submit_mode': 'raw_paste', 'interrupt_on_connect': True, 'write_block_size': 64, 'write_block_delay': None, 'proxy_class': 'RaspberryPiPicoBackendProxy', 'sync_time': True, 'validate_time': False, 'local_rtc': True}"]
12:00:29.977 [MainThread] INFO thonny: sys.executable: /Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/bin/python3.10
12:00:29.977 [MainThread] INFO thonny: sys.argv: ['/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/thonny/plugins/rp2040/rp2040_back.py', "{'clean': True, 'port': '/dev/cu.usbmodem83101', 'dtr': None, 'rts': None, 'submit_mode': 'raw_paste', 'interrupt_on_connect': True, 'write_block_size': 64, 'write_block_delay': None, 'proxy_class': 'RaspberryPiPicoBackendProxy', 'sync_time': True, 'validate_time': False, 'local_rtc': True}"]
12:00:29.977 [MainThread] INFO thonny: sys.path: ['/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/thonny/plugins/rp2040', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python310.zip', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages']
12:00:29.977 [MainThread] INFO thonny: sys.flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=1, no_user_site=1, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0, dev_mode=False, utf8_mode=0, warn_default_encoding=0, int_max_str_digits=-1)
12:00:29.978 [MainThread] INFO thonny.plugins.micropython.bare_metal_backend: Starting backend, args: {'clean': True, 'port': '/dev/cu.usbmodem83101', 'dtr': None, 'rts': None, 'submit_mode': 'raw_paste', 'interrupt_on_connect': True, 'write_block_size': 64, 'write_block_delay': None, 'proxy_class': 'RaspberryPiPicoBackendProxy', 'sync_time': True, 'validate_time': False, 'local_rtc': True}
Additional Information
Full code example:
# Lightsleep MicroPython example.
from machine import Pin
import time
led = Pin(25, Pin.OUT)
while True:
led.toggle()
time.sleep_ms(5000)
led.toggle()
machine.deepsleep(5000)
On the original Pico, deepsleep was, I believe, an alias to lightsleep. On Pico 2, it looks like there are deeper sleep states that may be implemented and an internal RTC that can be used to wake the chip... is it possible that either the deepsleep option could differ on the Pico 2, or should it just remain an alias to lightsleep?
Either way, the behavior here is different than lightsleep—which also breaks right now, see #15622.
Code of Conduct
Yes, I agree