Connecting to your Raspberry Pi Console via the Serial Cable

Sarala Saraswati
7 min readOct 20, 2019

--

Although it’s easier to attach a spare monitor, HDMI cable, and USB keyboard to your Pi it’s definitely nerdier (and therefore cooler!) to attach color-coded wires carefully to contact pins and connect via a remote console session over a serial cable. (Seriously, ask anyone!)

To take the nerdy high-road, however, you’ll need an Adafruit USB-TO-TTL Serial Cable.

And before we begin it’s critical to note:

WARNING: You must not attach both the Raspberry Pi’s USB power adapter and the red lead (wire) on the USB-TO-TTL cable or you will fry your Pi!

With reminders and warnings out of the way, let’s begin!

1.0 Enabling the Serial Console UART

Recent versions of the Raspbian operating system disable access via the serial console cable by default so, unfortunately, you’ll need to connect a monitor and USB keyboard to your Pi to enable the serial console UART which is a little bit of a bummer. Just in case you’re wondering, UART stands for Universal Asynchronous Receiver/Transmitter.

Thankfully, this is easily accomplished by firing up the nano text editor on your Pi with super-user privileges via sudo and making a small change to the /boot/config.txt file.

To get started, log-in to your Pi using the default username pi and password raspberry. Then issue the following command:

sudo nano /boot/config.txt

This will launch the nano text editor with sufficient privileges to modify the file. Then use the arrow keys to navigate to the end of the file and add the following line:

enable_uart=1

And that’s it! The next time you reboot your Raspberry Pi you’ll be ready to move on to the task of actually attaching that funky USB serial cable.

1.1 Attaching the USB serial cable

First, it’s easier to show you how to attach the serial cable to the Raspberry Pi than it is to explain how to do it. In fact, you might be able to work out the process just by carefully examining the following image and duplicating the results with your own cable and Raspberry Pi.

How to connect the serial. Colors from left to right are green, white, black, and red.

We won’t delve too deeply into what’s going on here but a brief overview will help demystify things a bit. First, notice there are four wires. These are also referred to as leads. Their function is described below:

  • The red lead provides 5V of power at 500mA from the USB port to the Pi
  • The green lead transmits (TX) data from the USB port to the Pi
  • The white lead receives (RX) data into the USB port from the Pi
  • The black lead provides electrical ground to the system

WARNING: Again, make sure you attach the red lead to the correct pin as transmitting power into the wrong pin could also fry your Pi!

I won’t go into detail describing all 40 pins on the Raspberry Pi but the image below should at least help you figure out which pin is which for future reference. In this image, the orientation of the GPIO diagram (i.e., the General Purpose Input/Output diagram) on the right matches the orientation of the Raspberry Pi board on the left.

Raspberry Pi and GPIO pin diagram with matching orientation

Based on this diagram and the previous image of the leads correctly attached to the Raspberry Pi we can express how to wire up the board in more formal terms:

red   lead        5V                     Pin  2 
black lead GND Pin 6
white lead TXD0 / GPIO 14 Pin 8
green lead RXD0 / GPIO 15 Pin 10

Armed with the above you should be able to wire up your Raspberry Pi. Before you plug it in to your computer’s USB port though we need to insure you have the correct driver installed.

1.2 (MacOS only) Install the USB serial cable driver

If you’re running Linux you can skip ahead to section 2.2. If you’re running Mac OS X you’ll need to install a driver so you can communicate using the serial cable.

First, download the driver from Prolific’s web-site. Prolific manufactures the PL2303 chip that powers the USB-TO-TTL serial cable.

PL2303 MacOS Driver Download

You’ll need to choose the version of the driver corresponding to whatever version of MacOS you are using. If you are unsure which version of OS X you’re using just navigate to the Apple menu and select “About This Mac”

Since I’m using macOS Catalina (Version 10.15) I’ll download version 1.6.2 of the driver using the curl command from the terminal. Be aware that the version you need to download may be different. You can copy and paste the correct URL matching the download for your system into the following command by right-clicking on the download link and selecting "Copy Link" (Safari), "Copy Link Location" (Firefox), or "Copy Link Address" (Chrome) depending on your browser.

Once you’ve sorted out the correct download URL for your system you’ll type the following command into the terminal on your Mac:

curl "http://www.prolific.com.tw/UserFiles/files/PL2303_Mac%20OSX%20Drv_V1_6_2_20190723(2).rar" -o "pl2303.zip"

Once the download is complete you’ll extract the contents of the file using the unrar utility. Unfortunately, you probably don’t have this already installed as it doesn’t ship with MacOS by default. To install it we’ll first need to install the homebrew package manager. So before completing the next step visit https://brew.sh/ and follow the instructions there to install homebrew. Thankfully, installing homebrew only requires running one command in the terminal so I’ll expect you back right away. :)

OK, now that you’re back with homebrew installed you should be able to execute the following two commands:

brew install unrar
unrar x pl2303.zip

You’ll want to use the ls command to verify the name of the installer. Chances are good it will begin with "PL2302" and end with the extension ".pkg" On my system the extracted file is named the following:

"PL2303_Mac OSX Drv_V1.6.2_20190723.pkg"

To kick off the driver installation from the MacOS terminal we execute the following command:

sudo open "PL2303_Mac OSX Drv_V1.6.2_20190723.pkg"

At this point a new window will pop-up guiding you through the installation process. After following all the prompts you’ll need to reboot your computer. Before rebooting be sure to bookmark this guide in your browser so you can pick up where you left off!

Once you’re back skip ahead to section 2.3.

1.3 (Linux only) Install the screen utility

The Linux kernel includes the PL2303 USB-TO-TTL driver by default so you’re good to go there.

However, since Raspbian doesn’t include the screen utility by default we’ll run the following command to install it:

sudo apt-get install screen

And that’s it! You’re ready to boot your Raspberry Pi sans mouse, monitor, and even networking!

1.4 Connect using the Serial Cable

Before we plug the USB cable attached to your Raspberry Pi into your Linux or Mac computer make sure a terminal is running and make sure the Raspberry Pi is off and no power supply is connected to it.

This is IMPORTANT: Your computer’s USB port provides the power necessary to power the Pi. Attaching any other power source will IRREVOCABLY DESTROY YOUR RASPBERRY PI.

With appropriate warnings heeded, plug the USB cable into your computer and get ready to watch the magic happen! If the LED on the Pi lights up you’re in business! To establish a console session connected to the Pi issue the following command depending on whether you’re running MacOS or Linux.

MacOS users should run:

sudo screen /dev/cu.usbserial 115200

Linux users should run:

sudo screen /dev/ttyUSB0 115200

If nothing seems to happen and the screen is blank the boot process may have already completed. Just hit enter and you should see something similar to the following on your screen, prompting you to log in to your AMAZING new Raspbian Pi system!

Raspbian GNU/Linux 10 raspberrypi ttyS0raspberrypi login:

Here’s a bit of trivia: The value 115200 at the end of the command is the "baud rate" you're connecting at. If you're as old as I am you'll remember the days of dial-up modems that connected to other systems over phone lines using acoustic couplers at 300 baud or less! That's 300 bits (not even bytes!) per second.Things have really changed over the last few decades!

Congratulations! You can now log into your Raspberry Pi and experience all of the power of a quad-core Unix system without needing to attach a monitor, keyboard, or even a network connection. Your nerd score is now at least +1! :)

To safely shutdown your pi before disconnecting the power and other leads just issue the following command:

WARNING: Make sure you execute this command only while connected to the console session on your raspberry pi! Executing this command accidentally from your MacOS terminal shell will shut down your Mac or Linux PC instead!

sudo shutdown -h now

To exit the screen session you used to connect to the Raspberry Pi over the USB-TO-TTL cable just type ctrl+a followed by k and the y.

--

--

Sarala Saraswati

Sarala Saraswati is the pen name of a writer, technologist, and avid student of esoteric hermeneutics living in Reykjavik, Iceland.