← index #8160Issue #4225
Off-topic · high · value 0.568
QUERY · ISSUE

uart.any freezing when second data has sended

openby ertugrulcakiciopened 2022-01-11updated 2026-03-16
port-rp2needs-info

main.py in rasberry pi pico

from machine import UART
from time import sleep


uart = UART(0,9600)

def read():
    global uart
    data = uart.read()

while True:
    if uart.any():
        read()
        sleep(0.3)

When i open the serial port with the same settings as rasberry pi pico's serial port, its works nicely. But then, I open Arduino Uno editor then serial port screen, I'm able to send the first data but when I send the second data, it's just freezing forever.
I tried with different rasberry pi pico but the result is the same.

CANDIDATE · ISSUE

esp8266 uart.read() problem

closedby cemoxopened 2018-10-08updated 2019-10-26

Hi, I am trying to read from uart(0) on nodemcu lolin board. In the below code, I configured uart(1) for sending data and uart(0) for receiving. Both uarts are initiated successfully at 115200 baud.

I checked uart1 tx pin (i.e. d4-gpio2 on the board) to a serial module, checked it with cutecom, it works ok. It sends the text at intervals as intended. I ran the code directly from memory (i.e. main.py) and powered the board externally, no usb connected to board. Could not read from the uart0 rx d0 pin (gpio3). uart0.read(32) returns None, always.

`import time
import uselect
from machine import UART

uart0 = UART(0)
uart1 = UART(1)
print(uart0)
print(uart1)

print("starting")
uart1.write("send me something")
uart0.write("waiting for data")

while (True):
# if (uart0.any() > 3):
uart1.write("test data")
time.sleep(0.5)
# print("reading")
a = uart0.read(32)
print(a)
if a is not None:
print(a)
uart0.write('received data')
`

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