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
- In the menu, select “3 Interface Options”.
- In the menu, select “I6 Serial Port”.
- A screen will ask if you want a login shell accessible over serial, select Yes.
- Optionally a screen may ask you if you would like the serial port hardware to be enabled, select Yes.
- A confirmation screen will apper and tell you what was configured.
- Finally, Reboot the Raspberry Pi.
Connecting the serial cable
Connect the cable as shown on the image.
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.
Appendix: Connecting to the serial port with Windows 98
For a more vintage experience, I also tried to connect the Raspberry Pi to a Windows 98 laptop via the serial port (with a DB9 connector). I ordered an RS232 to TTL Converter Module from Amazon. It can convert the RS232 from the laptop’s serial port to a TTL serial communication that the Raspberry Pi understands.
With this adapter, all four cables (GND, TXD, RXD, VCC) need to be connected respectively to the same pins on the Raspberry Pi. Not connecting the VCC cable will result in defective communication, so do not forget to connect it.
Once all cables are connected, open PuTTY and start a connection to the COM1 port with 115200 bauds. Then, press Enter to start communications.
Start the Raspberry Pi by plugging its power cable. Hopefully you should see logs from Linux booting.