Mathieu GAILLARD

Using the serial port with the Raspberry Pi model B

To ease the development of my Rapsberry Pi OS, I need to be able to connect a serial cable to the Raspberry Pi UART for debugging. This article gathers the steps that are necessary to connect to the Raspberry Pi UART with a USB cable.

Prerequisite

You will need the following items:

  • Raspberry Pi 1 Model B
  • Adafruit USB to TTL Serial Cable

Install the driver for the cable on Windows

The USB cable is not supported by default on Windows, it requires a driver.

You can download the driver from the manufacturer’s website Silicon Labs: CP210x USB to UART Bridge VCP Drivers. Once on the webpage, click on the Downloads tab and select the option CP210x Universal Windows Driver. At the time of writing the most recent option is version 11.3.0. Download and unzip the folder CP210x_Universal_Windows_Driver.zip on your computer.

Open the Windows device manager and find the device with a name like: “Silicon Labs CP210x USB to UART Bridge”. Right click on it and select Update driver. Windows will offer you the option to browse your computer for drivers, click on it and select the folder you previously unzipped.

Once the driver is installed, the computer will restart.

Activate the serial communication in Raspbian

By default the Raspberry Pi will not communicate on the serial port, you need to activate it in Raspbian OS. Fortunately there is a configuration utility to activate serial communications.

$ sudo raspi-config
  1. In the menu, select “3 Interface Options”.
  2. In the menu, select “I6 Serial Port”.
  3. A screen will ask if you want a login shell accessible over serial, select Yes.
  4. Optionally a screen may ask you if you would like the serial port hardware to be enabled, select Yes.
  5. A confirmation screen will apper and tell you what was configured.
  6. Finally, Reboot the Raspberry Pi.

Connecting the serial cable

Connect the cable as shown on the image.

Raspberry Pi Model B with a USB to TTL Serial Cable

Note that if the Raspberry Pi is powered by the regular cable, DO NOT connect the red cable. However, if you want to power the Raspberry Pi with the serial cable, you could connect the red wire.

Opening a terminal on Windows with PuTTY

Now that the serial cable is connected to the Raspberry Pi, and it is powered, you can connect to the terminal on Windows using PuTTY.

To know which COM port the Raspberry Pi is connected to, open the Windows device manager, find the device with a name like: “Silicon Labs CP210x USB to UART Bridge”. At the end of the device’s name, the COM port will be shown. For example, Silicon Labs CP210x USB to UART Bridge (COM3).

On Windows, open PuTTY, and select a Serial connection type, on port COM3, with the speed 115200 bauds. Once the PuTTY window is open, press ENTER to start the communication.

References