Jetson Nano – UART

There is a UART on the J41 GPIO Header of the NVIDIA Jetson Nano Developer Kit. Useful when you need a little bit of extra serial connectivity action. Looky here:

Background

There are two UARTs on the Jetson Nano. We have an article about the Serial Debug Console which is on the J44 header. The Serial Debug Console is useful for many tasks, including helping with start-up issues.

The second UART, which we are writing about here, is on the J41 header. This is what you consider a general purpose UART, with no special assigned function. However, there is an assumption about its use which may confuse folks who aren’t in the know.

When the Jetson starts up it opens a Serial Console on the J41 UART as a service. You can observe the console by simply wiring the Nano to another computer, either through another UART or a TTL to USB cable. Then open up a serial communications program and power on the Jetson. You will see the familiar login prompt from the Jetson.

This may not be the behavior you desire. For example, if you are interfacing with a micro-controller such as an Arduino or another device, you may want to just pass data back and forth. The Serial Console is in the way, and can lead to some strange data. The answer is simple, you need to stop the Serial Console on the UART.

Installation

The J41 UART is a 3.3V TTL signal. An easy way to communicate with the UART from another computer is via a TTL to USB Serial Cable. In the video, we use an Adafruit USB to TTL Serial Cable – Debug / Console Cable [954] available from Amazon. Most computers have a USB port, just plug the cable into the USB port.

If you are using the UART as a Serial Console, you’re almost done. You just need to run a serial terminal program on the machine that you are connecting to the Jetson. In the video, we use PuTTY on a Windows 10 PC. We start PuTTY and select Serial with 115200 baud, 8 bits, no parity, 1 stop bit.

You can plug the UART into another TTL type of device by just wiring the two directly together, but note the 3.3V signal. Many serial devices, such as some Arduinos, use 5V. The Jetson Nano is not tolerant of 5V, and if you connect directly bad things can happen. If you are using a 5V device with the Jetson Nano, you will need to do some level shifting to get the levels to match.

Also, remember to “crossover” the connections. Transmit (TXD – Transmit Data) goes to Receive (RXD – Receive Data) from the Jetson to the other machine/device. Similarly, Receive (RXD) goes to Transmit (TXD).

Wiring

The wiring is straightforward. Make sure that the Nano is disconnected from any power source and wire:

Jetson Nano J41 Pin 8 (TXD) → Cable RXD (White Wire)
Jetson Nano J41 Pin 10 (RXD) → Cable TXD (Green Wire)
Jetson Nano J4 Pin 6 (GND) → Cable GND (Black Wire)

Note: The color of the wires on your cable may be different.

The pinout of the J41 Header is available on JetsonHacks. The Jetson Nano J41 pins are also silkscreened on the underside of the board. The UART is on /dev/ttyTHS1.  After wiring, it should looks something like this:

Jetson Nano UART on J41
Jetson Nano UART on J41

Software

On the JetsonHacksNano account on Github, there is a repository UARTDemo. From a Terminal, clone the repository:

$ git clone https://github.com/JetsonHacksNano/UARTDemo

$ cd UARTDemo

If you do not intend to use the Serial Console on the UART, you should disable the Serial Console:

$ systemctl stop nvgetty
$ systemctl disable nvgetty
$ udevadm trigger

# You may want to reboot instead

The Demo Script requires py-serial. To install py-serial:

$ sudo apt-get install python3-serial

Now you are ready to run the Demo Script. Make sure that you have a Serial Terminal running on the computer that you connect to the Jetson. Connection speed is 115200, with 8 bits, no parity, and 1 stop bit (115200 8N1). Then run the script on the Jetson:

$ sudo python3 uart_example.py

On the connected machine, you should see a short identification when you connect. When you type on the machine, you should see the characters echo back (as if you are typing the character directly). The machine sends a character to the Jetson, the script reads the character and sends it back (we call this an echo).

In the video, we read through the script to get a feel for how it operates.

Conclusion

This should be a start on how to use the UART. The applications that you write can be very simple, or complex depending on the capabilities of the device that you attach.

As a special note, there are no serial/cereal jokes in this article because we use the monthly allotment in the video.

Notes

Tested on:

Be the first to comment

Leave a Reply

Your email address will not be published.


*