← index #16801Issue #16180
Related · high · value 3.000
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

lightsleep() not working properly Pi Pico WH v1.24.0

openby RYoder97opened 2024-11-07updated 2025-03-03
bugport-rp2

Port, board and/or hardware

Raspberry Pi Pico WH

MicroPython version

MicroPython v1.24.0 on 2024-10-25; Raspberry Pi Pico W with RP2040

Reproduction

Attempt following code, both with lightsleep() having no ms argument and one with:

import machine
from machine import Pin, deepsleep, lightsleep

def wake_up(pin):
    # Handle wake-up logic here
    led.toggle()
    print("Button pressed, waking up!")

# Configure buttons
button = Pin(11, Pin.IN, Pin.PULL_UP) # Example pin
led    = Pin(20, Pin.OUT)

led.on()

# Set up interrupt
button.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=wake_up)

# Go to sleep until a button is pressed
lightsleep()

Expected behaviour

Expect LED to react to button press when asleep and execute wake_up function. LED is on by default. LED should toggle/turn off when button is pressed down, both when machine is asleep and not asleep.

Observed behaviour

USB power tester indicates that the board sleeps only when NO MILLISECONDS ARGUMENT IS SPECIFIED.

When milliseconds ARE SPECIFIED, board does not appear to sleep as power consumption does not drop according to the USB tester. The board continues to work at full power, and the LED reacts to the button.

When NO MILLISECONDS ARE SPECIFIED, board appears to go to sleep (reducing power from >10ma to 0-1ma. But button does not do anything to LED.

Additional Information

I have tried adding the wake argument to button.irq, but Micropython says that extra keyword arguments are present.

I understand sleeping may have issues on the Pico W models. I have also tried turning off WiFi/setting the pin associated with Wifi to "low". That does not seem to have any impact whatsoever, since my code never explicitly turns Wifi on

https://forums.raspberrypi.com/viewtopic.php?p=2266590#p2266590

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