The Pragmatic Addict

Use all 5 Serial Ports on a Raspberry Pi 4b

Background

A while ago I wrote an article on how to turn your Raspberry Pi into a serial console server. As we all know by default a Pi has a serial console port - er a TTL port controlled a UART (Universal Asynchronous Receiver-Transmitter). In order to connect it to a standard serial port you need a nullmodem and a serial-ttl converter.

I started poking around in /boot/overlays/README to see how else that same port could be used (maybe as a client?) but found more UARTs?!? It turns out that the Pi 4b in fact has a total of 5 TTL ports (1 console, plus extra)!

TTL Pinouts

PortTX GPIOTX PINRX GPIORX PINDevice
uart01481510/dev/ttyAMA0
uart11481510/dev/ttyAMA1
uart2027128/dev/ttyAMA2
uart347529/dev/ttyAMA3
uart4824921/dev/ttyAMA4
uart512321333/dev/ttyAMA5

But wait there are 6 ports, plus uart1 and uart0 both use the same pins. You can remap uart1 to GPIO 32/33 or GPIO 40/41 but that’s only used with the computing modules. So uart1 is basically non-functional.

Enable UARTS

To enable uarts use the following entries in /boot/firmware/config.txt to enable individual uarts. dtoverlay=uart2 dtoverlay=uart3 dtoverlay=uart4 dtoverlay=uart5

Connect to another Pi’s serial console

I’m actually using this in production. The idea is that I want Raspi A to act as a terminal client and Raspi B to be the console I’m connecting to:

Raspi A (Client)Raspi B (Console)
27 PIN TXD10 PIN RXD
28 PIN RXD8 PIN TXD
6 PIN GND6 PIN GND

Now lets break this down:

Does it work?

You’ll need a utility like screen:

apt-get install screen

Execute this from Raspi A

screen /dev/ttyAMA2 115200

You should see the console login screen from Raspi B!


Created: 2025-02-07 Modified: 2025-02-07