How to connect Raspberry Pi UART to a computer

By | June 8, 2015

The raspberry pi has a UART interface, with which it can send debug information to a serial console. As a basic step of Embedded Linux Development, let’s see the procedure to connect the Raspberry Pi UART to a computer.

Significance of UART in embedded Linux development

Linux porting is a difficult task. We can’t simply boot a Linux board by building u-boot, kernel, and root file system images. This type of approach never works. It will end up with several issues like kernel panics, device driver issues, device tree issues, bootloader issues, etc…

So to debug entire system, we need an interface that can send debug information from Linux hardware (raspberry pi) to a computer. There are three possible ways

  1. Network
  2. Video
  3. UART

Network and Video interfaces are not so popular in terms of system debugging. They need special hardware and initializations. Much custom Linux hardware doesn’t come with and video and network interface. In fact, network and video interface are not available during first a bootloader stage.

But UART is considered to be a basic peripheral for all SOCs. UART does not require any special hardware. Transmitter (Tx) and receiver (Rx) lines are enough to debug entire system.

Raspberry PI UART pins

***** Download Raspberry Pi B+ schematics here *****

For any board, first of all you need to find the ‘tx’ and ‘rx’ lines of the UART. For this, you need board schematics. Download raspberry pi schematics from the above link.

For raspberry, UART ‘tx’ and ‘rx’ pins are available on GPIO header (J8 connector). Refer  “GPIO EXPANSION“ section in the schematics.

Raspberry_pi_GPIO_Header

On GPIO header, pin-8 and pin-10 are UART ‘tx’ and ‘rx’ pins.

    • PIN8 – TXD
    • PIN10 – RXD

Raspberry Pi board ‘tx’, ‘rx’ pin identification has shown below. You can use PIN6 as common ground between raspberry Pi and a computer.

Raspberry pi UART connections

RPi UART to a computer

Two ways you can connect the UART to a computer

  1. Via a USB to UART converter
  2. Via a standard RS232 port

USB to serial converter

You can connect Raspberry pi to a computer using a USB to UART converter. In fact, it is the easiest way and also less risk involved.

Note that, the TTL logic levels of Broadcom SOC are Logic0-0v and Logic1-3.3v. So, before purchasing a USB to UART converter, make sure that it supports UART with 3.3v TTL logic levels.

Required hardware:

  • USB to UART with 3v3 TTL logic levels
  • Three female-to-female cables

If you have a USB to UART converter with 3v3 TTL logic levels, then connections are as simple as shown below.

Raspberry pi UART connections

TXD and RXD pins of the USB to UART converter and Raspberry Pi should connect as shown below.

Raspberry pi UART connections block diagram

Warning: If you have a USB to UART converter with 5V TTL logic levels, then don’t dare to connect to raspberry Pi. It defiantly damages your pi’s UART controller. In such cases, better buy a Logic Level Converter that converts 3.3V to 5V, vice versa.

Via standard RS232 port

Raspberry pi can connect to an RS232 port using MAX3232. You already know about MAX 232, it is a level converter that converts UART TTL-5V logic levels to RS232 logic levels.  Similarly MAX3232 converts UART TTL 3v3 logic levels to RS232 levels.

raspberry pi to rs232 port

You can purchase max3232 PCB online. You can also design your own MAX3232 board using below links.

Download Max3232 datasheet here

In datasheet, refer 10.2 section for circuit diagram. as per data sheet, For 3.3v Vcc, use 100nF (0.1 uF) capacitors.

You can also refer this link for max3232 circuit 

Warning:Try at your own risk Winking smile

Thanks

2 thoughts on “How to connect Raspberry Pi UART to a computer

  1. Félix Hauri

    Sometime pin 8 and 10, and elswhere pin 8 and 9…

    > On GPIO header, pin-8 and pin-10 are UART ‘tx’ and ‘rx’ pins.
    >
    > PIN8 – TXD
    > PIN9 – RXD
    >
    >Raspberry Pi board ‘tx’, ‘rx’ pin identification has shown below. You can use PIN6 as common ground between raspberry Pi and a computer.

    Sometime MAX3232 and elswhere MAX2323…

    Care!

    Reply

Leave a Reply

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