To use the serial port on a Raspberry Pi Zero, Zero W, or Zero 2 W, free it from the Linux serial console. Run sudo raspi-config, open Interface Options, select Serial Port, answer No to the login shell question and Yes to the serial port hardware question, then reboot. The port appears at /dev/serial0.
The Raspberry Pi Zero family packs a full Linux computer into a board small enough to embed almost anywhere, which makes it a favorite for compact robots and connected devices. Its GPIO serial port is the simplest way to attach external hardware such as motor controllers, GPS receivers, and microcontrollers. Out of the box, however, Raspberry Pi OS attaches a Linux login console to the port, and on the wireless models the best hardware UART belongs to the Bluetooth radio.
This application note covers the original Raspberry Pi Zero, the Zero W, and the Zero 2 W running current Raspberry Pi OS, the operating system installed by Raspberry Pi Imager. Once the port is freed it can drive any 3.3V serial device, including RoboClaw motor controllers in packet serial or standard serial mode.
What You Need
- 1× Raspberry Pi Zero, Zero W, or Zero 2 W
- 1× USB power supply for the Raspberry Pi
- 1× MicroSD card with current Raspberry Pi OS installed
- 1× Monitor and keyboard with mini HDMI and USB OTG adapters, or an SSH connection to the Pi
Which UART Does Each Zero Model Use?
The answer depends on the model. The original Raspberry Pi Zero has no wireless hardware, so its full-featured PL011 UART connects directly to the GPIO header. The Zero W and Zero 2 W assign the PL011 to the Bluetooth radio instead, leaving the mini UART on the GPIO pins, disabled by default. On every model, Raspberry Pi OS attaches a login console to whichever UART sits on GPIO 14 and 15.
| Model | UART on GPIO 14 and 15 | Linux device |
|---|---|---|
| Raspberry Pi Zero | PL011 (UART0) | /dev/ttyAMA0 |
| Raspberry Pi Zero W | Mini UART (UART1) | /dev/ttyS0 |
| Raspberry Pi Zero 2 W | Mini UART (UART1) | /dev/ttyS0 |
None of this changes the procedure. Raspberry Pi OS creates /dev/serial0, an alias that always points at the GPIO UART, and the configuration steps below are identical on all three models. On the wireless models, enabling the UART also locks the core clock so the mini UART’s baud rate stays stable; Raspberry Pi OS handles this automatically, and the mini UART is reliable at typical serial baud rates such as 38400 and 115200.
How Do You Enable the Serial Port with raspi-config?
The raspi-config tool makes all of the required changes in one place. This is the recommended method on current Raspberry Pi OS and works on both the desktop and Lite versions of the operating system.
- Open a terminal window on the Pi’s desktop, or connect to the Pi over SSH.
- Start the configuration tool:
sudo raspi-config - Select Interface Options.
- Select Serial Port.
- When asked if you would like a login shell to be accessible over serial, select No. This removes the Linux console from the port.
- When asked if you would like the serial port hardware to be enabled, select Yes.
- Select Finish, then reboot the Pi so the changes take effect:
sudo reboot
How Do You Configure the Serial Port Manually?
The same configuration can be made by editing two files, which is especially useful for the Zero family because these boards so often run headless. Both files live on the SD card’s boot partition, so they can be edited from another computer before the Pi ever boots. On current Raspberry Pi OS the files are found under /boot/firmware/; on Raspberry Pi OS Bullseye and earlier they were located at /boot/config.txt and /boot/cmdline.txt.
- Open the boot configuration file:
sudo nano /boot/firmware/config.txt - Scroll to the bottom of the file and add the following line, then press Ctrl+X, Y, and Enter to save. On the original Zero the UART is already enabled by default, and the line is harmless there:
enable_uart=1 - Open the kernel command line file:
sudo nano /boot/firmware/cmdline.txt - Delete the following portion of the single line in the file, leaving the rest of the line intact, then save:
console=serial0,115200 - Reboot the Raspberry Pi.
Everything in cmdline.txt must remain on a single line. If the console entry is not present, there is nothing to remove; raspi-config may have already made the change. The official Raspberry Pi UART configuration documentation covers additional options such as device tree overlays.
How Do You Verify the Serial Port Is Working?
After the reboot the UART is available on GPIO 14 (transmit, physical pin 8) and GPIO 15 (receive, physical pin 10). Confirm the port with:
ls -l /dev/serial0
The alias points at /dev/ttyAMA0 on the original Zero and at /dev/ttyS0 on the Zero W and Zero 2 W. Use /dev/serial0 as the port name in Python or other code and the same code runs unchanged on all three models.
The Raspberry Pi’s GPIO pins, including the serial port pins, are 3.3V only. Devices with 3.3V logic connect directly; RoboClaw motor controllers, for example, output 3.3V logic and tolerate up to 5V on their inputs, so no level shifter is needed. Never connect 5V logic or an RS-232 port directly to the Pi’s GPIO pins; doing so will damage the Pi.
Next Steps
If you are using the serial port to drive a motor controller, the wiring and Python examples in Packet Serial with the Raspberry Pi 3 and Standard Serial with the Raspberry Pi 3 apply to the Zero family as well: the GPIO serial pins are the same, and code that opens /dev/serial0 runs unchanged. If you are configuring a full-size board instead, see Configuring the Raspberry Pi 3 Serial Port.



