August 28, 2013 · console gpio hacks linux productivity raspberrypi raspbian shell tricks ttl ubuntu

Setting up Raspberry Pi to display on PC (serial connection)

After three hours of cursing, I've finally managed to connect to my RPi via serial port. The problem was a confusing description on my TTL adapter I've bought on eBay. It is a USB To RS232 TTL PL2303HX Converter Module that was cheap, compared to similar items sold on eBay or via Adafruit, and I'm not willing to give ca. £8 for a cable. Yet, I've seen for myself, sometimes it's better to pay a bit more to get a good quality product.

RPi console connection

I don't know whose fault was it to wrongly describe pins, whether the error occurred on the board production line or the soldering machine had a bad day, the converter made my blood boil and I was just about to give up and throw it out, when I've decided to test one more configuration and"¦ it worked! instead of having the pin connections described as they should be they were mismatched so GND is described as TXD, TXD as RXD, and RXD as GDN. Bravo! But now it's working, and I'm enjoying my cable Pi connection without any unnecessary data flow through my WiFi adapter.

Why a console connection?

The great advantage of connecting to RPi via a console cable is that you do not need keyboard, mouse or display attached to the Pi to log into it. You also don't need ssh configured and if you're using only WiFi dongle with your Pi, it eliminates any unnecessary data flow (and additional heat) through the WiFi adapter. To go even further, it can even supply the power for your Pi, so there is no need for additional power adaptors. The Raspberry Pi uses its built-in serial port to allow devices to connect to its console and issue commands just as if you were logged in.

How to connect?

In order to connect to your RPi via the serial port, you need the serial port console lead. The easiest way is to connect via RPi's GPIO pins and your PC's USB. I've bought this one. To establish a connection with your Pi, you must first install additional software on the PC you want to connect to your RPi from. I'll write about Linux and Windows configuration, ommitting Mac OSes, as I don't use them at all. I've Raspbian 7 on my RPi, so the tutorial will cover only the distribution.

Connecting the lead

In most cases, your console cable would have 4 female connections that can be plugged directly onto the GPIO header of the Raspberry Pi: PWR (for powering the Pi, either 3.3V or 5V logic), GND (ground or 0V logic), TXD (a 'transmit' signal) and RXD (a 'receive' signal). The important thing here is to only power your Raspberry from one power source, the USB power adaptor or the console lead **BUT NOT BOTH!!! **

For my purposes, I'm using external power source, not the console. To get you working, attach the leads as shown below:

GPIO connection

GPIO connection 2

The colours may vary, you may have red lead for PWR, black for GND, white for TXD and green for RXD. Check the diagram below if you are not sure about the connections.

gpio-srm

Once you connected the GPIO's, you can connect the console adapter to your PC's USB port.

Linux software installation

Linux Kernels 2.4.31 and above already have the PL2303 USB driver for the Console Lead built-in, so you should not need to install that. The only thing you should take care about is the software. I'm using minicom, a brilliant tool, but there is also an "easier" one - screen.

Some distributions such as Ubuntu 12.04 do not include the screen/minicom command.

You can install screen by typing the following command (under Debian based systems) in your terminal:

sudo apt-get install screen

or if you'd prefer minicom:

sudo apt-get install minicom

Linux connection to RPi

Plug the adapter into your USB port. First, we need to check the adapter's address in the system. Type in your terminal:

dmesg | grep usb

You'll get a list of recent calls within your system on the USB ports. You should get something like this:

[ 8869.420080] usb 3-2: new full-speed USB device number 4 using ohci_hcd
[ 8869.587067] usb 3-2: New USB device found, idVendor=067b, idProduct=2303
[ 8869.587080] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 8869.587087] usb 3-2: Product: USB-Serial Controller
[ 8869.587093] usb 3-2: Manufacturer: Prolific Technology Inc.
[ 8869.611286] usb 3-2: pl2303 converter now attached to <strong>ttyUSB0</strong>

We are looking for the adapter's address, in my case it's ttyUSB0. We'll be using it any time we want to access our RPi via the console.

To connect using screen, type in your terminal:

sudo screen /dev/ttyUSB0 115200

and press ENTER key. You will be asked for root password (from the machine you are connecting from!), and you should see a blank screen or a login prompt. In case of a blank screen, try pressing ENTER. If nothing happens, check your pin connection on the adapter as well as on your RPi.

Type your RPi user login, the same one you use to log in, and your password. If you've never logged into your Pi before, the default Raspbian username is "pi" and password: "raspberry", and you're in! to exit the console, press [Ctrl] + A and then K.

For connecting via minicom, type in your terminal:

minicom -D /dev/ttyUSB0 -b 115200 -o

RPi access via minicom on Ubuntu 12.04 LTS

To exit minicom press [Ctrl] + A and then X.

Windows software installation

If you are using Windows, get putty first. It will allow you to explore your Pi from your desktop. You'd also need drivers for the console adapter. you can get them here: PL2303 Drivers: https://www.prolific.com.tw/US/ShowProduct.aspx?p_id=225&pcid=41. This will save a zip file called

PL2303_Prolific_DriverInstaller_v1_7_0.zip.

Unzip this onto your desktop or a temp folder, plug your USB console adapter and within the folder run the installer called

PL2303_Prolific_DriverInstaller_v1.7.0.exe.

Once the driver is installed you can prepare putty connection.

Windows PuTTy connection

before you start Putty, you need to know which com port is being used for the cable. You can find this by looking in the Ports section of the Windows Device Manager. The Device Manager is accessible from the Control Panel under System. In my case it is COM7 that is in use.

Now start Putty and you will see a connection window.

PuTTy window

Select a connection type of "Serial" from the radio buttons, then set the speed to 115200 and the serial line to COM7. Finally click 'Open' to connect. Remember to press ENTER to start communications.

Thats it! You are connected and can use the command line to navigate around your Pi.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket

Contact