Raspberry Pi Pico - No UART after lightsleep when not connected to USB
Port, board and/or hardware
Raspberry Pi Pico (1)
MicroPython version
MicroPython v1.24.1 on 2024-11-29; Raspberry Pi Pico with RP2040
Reproduction
Run this code in main.py
from machine import UART, Pin, lightsleep
from utime import sleep_ms
UART_BAUD_RATE=9600
UART_BITS=8
UART_PARITY=None
UART_STOP=1
UART_INSTANCE=0
TX_PIN = 16
RX_PIN=17
uart = UART(UART_INSTANCE, baudrate=UART_BAUD_RATE, tx=Pin(TX_PIN), rx=Pin(RX_PIN), bits=UART_BITS, parity=UART_PARITY, stop=UART_STOP)
sleep_ms(5000) # give windows a chance to identify device before everything is messed up
while True:
print ("run loop")
uart.write("second uart")
uart.flush()
lightsleep(1000)
sleep_ms(10) # wait for everything to wake up
Expected behaviour
Expected to putout this on second uart0 (not USB Uart, but second UART device). This is also the case when constantly connected to PC (Windows 10 in my case, but doesn't matter).
second uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uart
Observed behaviour
This is observed when connected to a power bank via USB instead of PC (same behaviour with other powering methods)
second uartsgV▒sc▒▒sc▒▒sg▒▒sg▒▒wg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒wg▒▒sg▒▒wg▒▒sc▒▒
Additional Information
No, I've provided everything above.
PS: My personal theory is that uart is not put to sleep when connected to PC and therefore works fine, but is put to slepp when no PC connection is present and does not wake properly ...
Code of Conduct
Yes, I agree
RP2350 / Pico 2 machine.lightsleep not working correctly
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.lightsleep(5000)in your code - Run code.
Expected behaviour
Expected Pico 2 to enter lightsleep mode for 5 seconds, then continue to next bit of code.
Observed behaviour
lightsleep is maybe entered for a cycle or so, but code carries on and never stops executing for any time value I enter for lightsleep.
Additional Information
Complete 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.lightsleep(5000)
Code of Conduct
Yes, I agree