Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3755

Troubleshooting • Huge Latency When Receiving Data Through UART

$
0
0
Hi,

I'm trying to receive data from a LiDAR sensor using a UART on my Raspberry Pi 4. Since I'm already using UART 1 for other purposes, I've enabled UART 2 by adding

Code:

dtoverlay=uart2
to my /boot/config.txt. I'm using PySerial to open and read data from the serial port.
Here is how I'm connecting to the port:

Code:

    ser = serial.Serial(port='/dev/ttyAMA2',                    baudrate=230400,                    timeout=5.0,                    bytesize=8,                    parity='N',                    stopbits=1)
When I continuously print the output of the LiDAR sensor to the console, there is about 5-10 seconds of delay until the proper value is displayed. If I instead use a USB-to-serial converter and connect to /dev/ttyUSB0, there is no delay and everything works fine. For this reason, I feel like the Raspberry Pi is somehow introducing latency. I've tried switching to UART 3, instead of UART 2, but the same latency appears.
I don't know much about serial communication, so I would appreciate any insight into why there is such a big delay when using the Raspberry Pi UARTs.

Thanks!

Felix

Statistics: Posted by felixxperron — Fri Mar 15, 2024 8:45 pm



Viewing all articles
Browse latest Browse all 3755

Trending Articles