I am trying to get my Jetson Orin Nano with Dev Kit to talk to my Raspberry Pi 5 via pinout UART.
The connections:
GND-> GND
Jetson TX (pin 8) → Raspberry Pi RX (pin 10)
Jetson RX (pin 10)- > Raspberry Pi TX (pin 8)
My Raspberry Pi works with sending messages. Here is my Pi code:
import serial
import time
serial_port = ‘/dev/serial0’ # Use ‘/dev/serial0’ for Raspberry Pi’s UART
baud_rate = 115200
ser = serial.Serial(serial_port, baud_rate)
try:
while True:
message = “Hello from Raspberry Pi!”
ser.write(message.encode(‘utf-8’)) # Send the message
print(f"Sent: {message}")
time.sleep(2)
except KeyboardInterrupt:
print(“Exiting…”)
finally:
ser.close()
My Jetson Orin Nano code:
import serial
serial_port = ‘/dev/ttyTHS1’
baud_rate = 115200
ser = serial.Serial(serial_port, baud_rate)
try:
while True:
# Read data from the serial port
if ser.in_waiting > 0:
incoming_message = ser.readline().decode(‘utf-8’).strip()
print(f"Received: {incoming_message}")
except KeyboardInterrupt:
print(“Exiting…”)
finally:
ser.close()
The reason I use ‘/dev/ttyTHS1’ as my serial port is because JetsonHacks used it in his tutorial (https://jetsonhacks.com/2019/10/10/jetson-nano-uart/) however I don’t think its working because if I run the Jetson Nano python code with that port, it always says "serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyTHS1: [Errno 2] No such file or directory: ‘/dev/ttyTHS1’
Any advice on how to get the right port and make the 2 boards able to send messages back and forth? I appreciate any help.
I will add that the specific ttyTHS# or ttyS# changes depending on which type of Jetson. This also might change depending on whether this is a developer’s kit versus if it uses a third party carrier board. More specifically, you’ve posted this in the Nano forum, but that article is from the Orin Nano. This is the progression of Nanos:
Original “Nano” (which is a form factor for a TX1).
TX2.
Xavier.
Orin.
The latter “Orin” is far different than a regular (old) Nano. Are you really using an older Nano, or is it a newer Orin Nano?
For JP5.1.4(R35.6.0), you can refer to Jetson/L4T/peripheral/ - eLinux.org for the UART mapping.
Please use /dev/ttyTHS0 in your case with using PIN8 and PIN10 of 40-pins header.
Ok I changed the serial port to /dev/ttyTHS0, but to no avail
jetson1@jetson4:~/Documents$ python3 receive.py
Serial port closed.
Traceback (most recent call last):
File “/home/jetson1/.local/lib/python3.10/site-packages/serial/serialposix.py”, line 322, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/ttyTHS0’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/home/jetson1/Documents/receive.py”, line 9, in
ser = serial.Serial(serial_port, baud_rate)
File “/home/jetson1/.local/lib/python3.10/site-packages/serial/serialutil.py”, line 244, in init
self.open()
File “/home/jetson1/.local/lib/python3.10/site-packages/serial/serialposix.py”, line 325, in open
raise SerialException(msg.errno, “could not open port {}: {}”.format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyTHS0: [Errno 2] No such file or directory: ‘/dev/ttyTHS0’ jetson1@jetson4:~/Documents$ ls /dev/ttyTHS*
/dev/ttyTHS1 /dev/ttyTHS2 jetson1@jetson4:~/Documents$ ls /dev/ttyS*
/dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3
jetson1@jetson4:~/Documents$
Here is my Jetson code to receive from Raspberry Pi again, all the setup is the same as in photo
import serial
serial_port = ‘/dev/ttyTHS0’
baud_rate = 115200
try:
ser = serial.Serial(serial_port, baud_rate)
print(f"Listening on {serial_port} at {baud_rate} baud…“)
while True:
if ser.in_waiting > 0:
incoming_message = ser.readline().decode(‘utf-8’).strip()
print(f"Received: {incoming_message}”)
except KeyboardInterrupt:
print(“Exiting…”)
finally:
if ‘ser’ in locals() and ser.is_open:
ser.close()
print(“Serial port closed.”)
Do you mean /dev/ttyTHS0 can not be found on your devkit?
How could it show in dmesg but not exist in sysfs?
Please share your full dmesg and device tree again for further check.
You can run the following command to get the device tree configuration from your board.