← index #16801Issue #16713
Related · medium · value 2.373
QUERY · ISSUE

Raspberry Pi Pico - No UART after lightsleep when not connected to USB

openby juehvopened 2025-02-24updated 2025-03-03
bugport-rp2

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

CANDIDATE · ISSUE

Serial com and external power supply

openby eleroyopened 2025-02-06updated 2025-02-23
bug

Port, board and/or hardware

rp2, raspberry pico

MicroPython version

MicroPython v1.24.1 on 2024-11-29; Raspberry Pi Pico with RP2040

Reproduction

  1. Start a code with serial printing such as:
import time

while True:
    print(time.time())
    time.sleep(0.1)    
  1. Connect external power supply (+5V or 3V3)
  2. Disconnect usb
  3. Wait ~4 s
  4. Reconnect usb

Expected behaviour

When you reconnect USB, the board should be normally detected as CDC Serial device and printing.

Observed behaviour

When you reconnect USB the board is not detected anymore and it seems the program has been interrupted.

Additional Information

I suspect something like a buffer overflow on the serial output hardware is happening.

If the usb is reconnected quickly (in 1 second or so), the board is well detected.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied