JetsonHacks

Developing on NVIDIA® Jetson™ for AI on the Edge

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:

Facebook
Twitter
LinkedIn
Reddit
Email
Print

21 Responses

  1. I got an error when i want to stop the serial console. “Failed to stop nvgetty.service: Unit nvgetty.service not loaded”. How can i fix it

  2. When I am communicating with arduino uno using USART the data sent from arduino is perfect but the data sent from jetson nano is not at all perfect and it is sending random values to arduino. I have used level shifter for 3.3V level and also the code is verified through other sources. please help me with this issue.

    1. It is difficult to comment on this issue without more information. Did you turn off the nvgetty service? What version of L4T are you using? I don’t know what ‘random values’ mean.

      1. Yes I have turned off nvgetty service, actually randmom values means junk values the value which I am sending is not reflecting on arduino. whait i will send the screenshots. thank you for your reply.

        1. One other thing to check is the voltage levels. Many Arduinos have 5V signals, the Jetson generates 3.3V signals. You need to do some sort of level shifting if there is a difference.

          1. Yes, I have used a level shifter as well but still, the result is the same. I am unable to find out the issue for 3 days I am on it. Thank you for your reply

    2. Try to use lower baud rate, 9600 or less. I’m having the same issue and only lowering the baud rate improved the transmission, maybe if you use a voltage divider could improve more the transfer.

  3. Great content! Is there a way to use UART1 (on j40) for other serial comms? So I am looking to stop the serial console and use the UART to communicate with say an Arduino? Just to be clear – not UART 2 (on j41), – UART1.

  4. Since there is not a Jetson NX version of this article and code yet, if you want to use it on the Jetson NX, the only think you need to change is in the python file downloaded through the git repo, you need to use /dev/ttyTHS0

  5. I used ttl to usb to recive the nano
    ( serial_port.write(chr(0x5A).encode(‘utf-8’)) )
    message in the computer. But i receive ‘c2 A5’. How can i tackle this.

  6. Are you able to comment on how to disable to stop the default serial console on the J41 UART? (“The answer is simple, you need to stop the Serial Console on the UART.”)

  7. I have tried using UART with bluetooth module, I am able to send data from a mobile app and receive data in the Jetson console, but in whichever format I send data, be it text, hex or ascii, I am always receiving the same output which is(b’\x00′). How can I receive data in the exact format that I am sending? Be it alphabetical or numerical.

    Thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *

Disclaimer

Some links here are affiliate links. If you purchase through these links I will receive a small commission at no additional cost to you. As an Amazon Associate, I earn from qualifying purchases.

Books, Ideas & Other Curiosities