I have been through countless uart posts, but can not seem to get uart to work for me. I have a Jetson Orin Nano, R36 distribution. From what I can take from the posts and the J4 mapping Making sure you're not a bot! the port seems to be /dev/ttyTHS1. However, when I try to use pySerial I continue to get
could not open port /dev/ttyTHS1: [Errno 13] Permission denied: ‘/dev/ttyTHS1’
Can anyone give me some direction on how to resolve this?
You need to add your username to the dialout group. This are the permissions:
crw–w---- 1 root tty 239, 0 Oct 1 13:33 /dev/ttyTCU0 crw-rw---- 1 root dialout 240, 1 Jun 4 07:17 /dev/ttyTHS1 crw-rw---- 1 root dialout 240, 2 Jun 4 07:17 /dev/ttyTHS2
and if you’re not part of dialout you get:
Error opening serial port: [Errno 13] could not open port /dev/ttyTHS1: [Errno 13] Permission denied: ‘/dev/ttyTHS1’
Run: sudo usermod -aG dialout $USER then logout and login again.
Run id and check what groups you’re part of. It works after you join dialout:
Serial port /dev/ttyTHS1 opened successfully. Sent: Hello from Jetson Orin Nano! Serial port closed.
Script used for testing:
mport serial
import time
SERIAL_PORT= ‘/dev/ttyTHS1’ # Jetson Orin Nano
BAUD_RATE = 115200
try:
ser = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=1)
print(f"Serial port {SERIAL_PORT} opened successfully.")
# Send data
message = "Hello from Jetson Orin Nano!\n"
ser.write(message.encode())
print(f"Sent: {message.strip()}")
# Read data
time.sleep(0.1) # Give time for the device to respond
while ser.in_waiting > 0:
received_data = ser.readline().decode().strip()
print(f"Received: {received_data}")
except serial.SerialException as e:
print(f"Error opening serial port: {e}")
finally:
if ‘ser’ in locals() and ser.is_open:
ser.close()
print(“Serial port closed.”)