Skip to content
ArtMG edited this page Jul 6, 2021 · 9 revisions

This is the ultimate "headless" solution, and includes a way to remotely use your Pi via nothing but a couple of GPIO pins!

Requirements

Connect to a Raspberry Pi session without using any of the following

  • the built-in wired Ethernet connection
  • the built-in HDMI connector
  • a wireless network adapter

Solution overview

The three most commonly referenced solutions are:

  1. SSH over Serial Connection via USB-TTL cable
  2. USBnet connection via USB Host-to-Host cable or adapter
  3. SSH from Android via USB cabled tethering

footnotes:

  • this may not be an exhaustive list.
  • it is probably as simple to use the Serial SSH from 1 with the USB Host-to-Host from 2.
  • you could probably achieve the same effect by bending the requirements to allow using the built-in ethernet, if you had a cross-over network cable. However you would have the complication of IP addresses and subnets.

Serial SSH over USB-TTL

specialist cable, simple software

the cable

This requires a specialist, but simple cable called a USB to TTL adapter. A common example is the Adadfruit 954, now with its distinctive light blue plug moulding, containing the circuitry.

Many of the USB TTL adapters sold seem to be based on the FT232RL integrated circuit (IC), and you can get very cheap (£3 to £4) boards which break this IC out to a USB B connector, a series of pins (some expose ALL the IC's signals, and a handy voltage selector jumper. This is a great budget way to get all the TTL connectivity you need, whether its for your Pi or for hacking old wifi routers with open source software.

In case you care TTL stands for Transistor-Transistor Logic, which was the origin of us defining low voltage levels between 0-1v as OFF or FALSE, and higher levels from 2v to 5v as ON or TRUE - so now you know.

the software

Because you are connecting using the humble old Serial connection standard (RS232), the mainstay of computer communications from the 1970s to the 1990s, it means the software solution will be available on virtually any system.

connecting it up

First you must make sure that you connect only 3.3v signals to the GPIO signal pins - 5v is too much for the circuits on the Pi. If you have a FT232RL breakout, you will find a jumper that you can move between positions to change between 5v and 3.3v logic levels.

Some cables and boards have a 5v power wire that comes straight from the USB on your client computer. You can theoretically use this to power the Pi (see option below). You should probably still power the Pi via the normal 5v Micro USB socket, however, as:

  • the microUSB power socket has voltage regulation, to prevent flucuating levels in your power line from frying the Pi's circuitry. The GPIO power pin does NOT have that protection.
  • if you unplug the USB to reset the data signals into the Pi, you would also cut the power to the Pi - it might be easier to have data and power connected independently

My FT232RL board does not a 5v power line anyhow, so I have no choice :)

Precautions

5 volts and up to 2 amps is not going to give your fingers more than a little tingle if you touch something wrong. However if you slip as you are making connections with live circuits, you may accidentally connect (or 'short') components with more current than they can tolerate, so you could damage (or 'fry') the electronics on your Pi circuit board.

  • start with no power - do not connect either your Pi nor your USB-TTL board to the power adaptor not to a computer's USB (which will supply power) UNTIL you have finished connecting your data wiring leads, and have verified that the right pin on one side goes to the right pin on the other side, following the table below
  • you should always be cautious with the two 5V pins (pin 2 and pin 4, on the outer corner of the GPIO header) - most other pins can only tolerate up to 3.3v, so do not connect or short them to these two pins.

pin connection table

FTL PIN GPIO PIN Comment
RXD Pin 10 (GPIO15)
TXD Pin 8 (GPIO14)
GND Pin 6 (Ground) Recommended
5VCC Pin 2 (5V) Preferably NOT connected (see above)

If you want to look at a pretty picture, see https://pinout.xyz/pinout/uart

Software - setup

Host

If you are running Raspbian / Raspberry Pi OS on the Pi whose GPIO pins you have connected to, it is very straightforward to make it boot with a serial terminal (using getty?) that you can connect to.

The simplest way is to use sudo raspi-config for Interface Options and choose Serial to enable Shell messages on the serial connection. In previous years, especially with earlier models, this was enabled out of the box, but you can use this utility to check.

More recently, and with Pi models 3 and 4, this will add the following lines to /boot/config.txt

# allow serial console over GPIO pins
enable_uart=1

However the history of serial terminals (and other uses for the serial port(s)) is documented reasonably well at https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3-4/

Client

Where you plug in the USB, you have a couple more steps

# check the USB adapter can be seen
lsusb

# check which device it is on
# and which group may use it (e.g. tty or dialout)
ls -l /dev/ttyUSB*

# check you are a member of that group
groups

# if not add yourself (or 'dialout' alternatively)
sudo usermod -a -G tty $USER
# you may need to log off and on again to make this setting take effect
#########


# install the software
sudo apt-get install minicom

# configure the port
sudo minicom -s

# configure Serial Port Setup:
# 
# A - Serial device: /dev/ttyS0
# E - Bps/Par/Bits: 115200 8N1
# F - Hardware Flow Control : No
# A - Init string: <empty>

then Save as dfl (default) and exit

# run the terminal
minicom

advanced consoles

The minicom terminal has no kind of screen buffer to look back at previous output. The old screen program also has a built-in terminal, which gets around this issue. However, as screen is no longer maintained, you might find it better to run tmux, then run minicom inside it.

On the client:

sudo apt update && sudo apt install -y tmux
tmux new -s serial

minicom

Connecting from mac

Simply use the minicom program. If you prefer a GUI program you could use screen instead.

Here is an example of using screen on macos:

screen `ls /dev/cu.usbserial-*`  115200 –L   # cu. prefix for mac os

Remember it's Ctrl-A then Ctrl-K to kill the session

other research

See also:

USBnet host-to-host

specialist cable, plug and play

The host-to-host cables or adapters are the modern equivalent of the old "Laplink" cable, and they are sometimes sold as "PC Link cables" or "data transfer cables". Generally they are A-to-A cables, but not just cross-wired, they have USBnet circuitry inside, which is slightly more complex than the basic TTL level conversion above. Still, you can find them available from £6-£15, and older cables have a big bulge in the middle, whereas more modern ones simply have an elongated plug at one end.

Providing you have a linux distribution with the usbnet drivers built-in, this gives you a plug and play way to transfer as if the two devices were on the same network.

Android tethering

common cable, more software config

the cable

You probably connect your android device to a USB cable most days, so you're bound to have one of these lying around.

Configure Pi USB as network interface

Options include:

  • leave default IP or hardcode
  • hot swap option for late connection