The Raspberry Pi 5's 40-pin header looks exactly like every Pi since the Pi 2: same pins, same BCM numbers, same HAT footprint. What changed is underneath. GPIO is now driven by RP1, a Raspberry Pi-designed I/O chip connected to the main processor over PCIe, and that's why some old GPIO code stops working on a Pi 5 even though the wiring is identical.
Quick answer: the pinout is unchanged: GPIO 2/3 I2C, GPIO 7–11 SPI0, GPIO 14/15 UART, hardware PWM on GPIO 12, 13, 18, 19, all 3.3 V logic. Use gpiozero or lgpio in Python. RPi.GPIO and pigpio don't work on a Pi 5; for old RPi.GPIO scripts, install the rpi-lgpio drop-in. Power it from a 5 V / 5 A USB-C supply.
Below: the full pin table, what RP1 changes for your code, the library situation, UART and PWM details that differ from the Pi 4, the new connectors, power limits and fixes for the common migration errors.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
40 of 40 pins match
Hover or tap any pin on the board
ODD header · pin 7
GPIO4
Safe to use
General-purpose clock output GPCLK0.
Nothing else on the board depends on this pin. A good first choice for sensors, LEDs and buttons.
Can be used as
- Clock out
Signals on this pad
- GPIO4
- GPCLK0
Raspberry Pi 5 GPIO Pinout Table
Pin 1 is the square pad, at the end of the header nearest the board's corner mounting hole. Odd pins run along the inside row, even pins along the board edge.
| Function | BCM | Pin | Pin | BCM | Function |
|---|---|---|---|---|---|
| 3.3 V | — | 1 | 2 | — | 5 V |
| I2C1 SDA | 2 | 3 | 4 | — | 5 V |
| I2C1 SCL | 3 | 5 | 6 | — | GND |
| GPCLK0 | 4 | 7 | 8 | 14 | UART TX |
| GND | — | 9 | 10 | 15 | UART RX |
| GPIO | 17 | 11 | 12 | 18 | PWM / PCM CLK |
| GPIO | 27 | 13 | 14 | — | GND |
| GPIO | 22 | 15 | 16 | 23 | GPIO |
| 3.3 V | — | 17 | 18 | 24 | GPIO |
| SPI0 MOSI | 10 | 19 | 20 | — | GND |
| SPI0 MISO | 9 | 21 | 22 | 25 | GPIO |
| SPI0 SCLK | 11 | 23 | 24 | 8 | SPI0 CE0 |
| GND | — | 25 | 26 | 7 | SPI0 CE1 |
| HAT ID EEPROM SDA | 0 | 27 | 28 | 1 | HAT ID EEPROM SCL |
| GPIO | 5 | 29 | 30 | — | GND |
| GPIO | 6 | 31 | 32 | 12 | PWM |
| PWM | 13 | 33 | 34 | — | GND |
| PWM / PCM FS | 19 | 35 | 36 | 16 | GPIO |
| GPIO | 26 | 37 | 38 | 20 | PCM DIN |
| GND | — | 39 | 40 | 21 | PCM DOUT |
That's 26 general-purpose GPIOs (BCM 2–27). BCM 0 and 1 are reserved for the HAT identification EEPROM; leave them alone unless you know you need them.
Everything is 3.3 V. No pin is 5 V tolerant. A 5 V sensor output, an HC-SR04 echo pin or a 5 V Arduino TX line needs a divider or level shifter before it reaches the header.
BCM vs physical numbering. Python libraries use BCM numbers: LED(17) means GPIO17, which is physical pin 11. Mixing the two up is still the most common wiring mistake on every Pi.
from gpiozero import LED
from time import sleep
led = LED(17) # BCM 17 = physical pin 11
while True:
led.toggle()
sleep(0.5)What RP1 Changes
On a Pi 4 and earlier, GPIO registers sat inside the Broadcom processor, and libraries such as RPi.GPIO and pigpio poked them directly through /dev/mem. On a Pi 5 those registers are inside RP1, at different addresses and with a different design. RP1 also handles USB, Gigabit Ethernet, and the camera and display connectors.
So anything that uses the Linux GPIO character-device interface (/dev/gpiochip*) works, and anything that accessed the old Broadcom registers directly doesn't. That's the whole compatibility story.
About gpiochip4: at launch, RP1's GPIO appeared as gpiochip4, and many tutorials hard-code that number. Since the Raspberry Pi OS kernel update in 2024 (6.6.y), it's gpiochip0 again, so old code that opens chip 4 now fails. Check your own board with gpiodetect and look for the line labelled pinctrl-rp1.
GPIO Library Compatibility on the Pi 5
| Library | Works on Pi 5? | Use it for |
|---|---|---|
gpiozero | Yes | The default. LEDs, buttons, sensors, motors; preinstalled on Raspberry Pi OS |
lgpio | Yes | Low-level control, and the backend gpiozero uses on a Pi 5 |
rpi-lgpio | Yes | Drop-in replacement that runs old RPi.GPIO code unchanged |
libgpiod / gpiod | Yes | C and Python bindings for the kernel GPIO interface |
RPi.GPIO | No | Fails with RuntimeError: Cannot determine SOC peripheral base address |
pigpio | No | Its daemon relies on the old Broadcom hardware |
Fixing an old RPi.GPIO project usually takes one command. rpi-lgpio provides the same import RPi.GPIO as GPIO API on top of lgpio:
sudo apt remove python3-rpi.gpio
sudo apt install python3-rpi-lgpioInside a virtual environment, use pip uninstall RPi.GPIO and pip install rpi-lgpio instead. Most scripts then run unchanged; edge-detection callbacks and software PWM behave slightly differently, so test those parts.
Using lgpio directly, open chip 0 on a current OS:
import lgpio
h = lgpio.gpiochip_open(0) # RP1 is gpiochip0 on kernels since 2024
lgpio.gpio_claim_output(h, 17)
lgpio.gpio_write(h, 17, 1)
lgpio.gpiochip_close(h)From the shell, the pinctrl tool that ships with Raspberry Pi OS reads and sets pins without any Python. It's the quickest way to check wiring:
pinctrl get 17 # show GPIO17's mode and level
pinctrl set 17 op dh # make it an output, drive high
pinctrl set 17 dl # drive lowI2C, SPI, UART and PWM
Enable the buses in sudo raspi-config → Interface Options, or add lines to /boot/firmware/config.txt (note the new path; it was /boot/config.txt before Bookworm).
I2C is on GPIO 2 (SDA) and 3 (SCL), with 1.8 kΩ pull-ups already on the board. After enabling it, i2cdetect -y 1 lists connected devices.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
SPI0 is on GPIO 10 (MOSI), 9 (MISO), 11 (SCLK), 8 (CE0) and 7 (CE1). Devices appear as /dev/spidev0.0 and /dev/spidev0.1.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
UART is the one that catches Pi 4 users out. On a Pi 5 the Linux console goes to the new 3-pin debug UART connector between the HDMI ports (/dev/ttyAMA10), not to GPIO 14/15. After enabling the serial port in raspi-config, GPIO 14/15 is /dev/ttyAMA0. RP1 has more UARTs that can be routed to other header pins with overlays such as dtoverlay=uart2-pi5.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
Hardware PWM is available on GPIO 12, 13, 18 and 19. Enable two channels with dtoverlay=pwm-2chan (GPIO 18 and 19 by default). gpiozero's PWMLED uses software PWM on any pin, which is fine for LEDs but too jittery for servos.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
Power: The 5 A Supply and the 5 V Pins
The Pi 5 is designed for the official 27 W (5.1 V, 5 A) USB-C supply. A good 5 V / 3 A supply still boots it, but the firmware then limits the total current to the USB ports to 600 mA, instead of 1.6 A, and shows a warning. A USB SSD or several peripherals can then disconnect or misbehave, which looks like a software fault.
On the header:
- 5 V pins (2, 4) connect to the supply input. They can power small 5 V loads. You can also power the Pi through them from a regulated 5 V supply, but it then can't negotiate 5 A and limits USB current unless you add
usb_max_current_enable=1to config.txt. Get the polarity right: that path has no reverse protection. - 3.3 V pins (1, 17) come from the Pi's regulator. Keep the total load to a few sensors and modules, not motors, LED strips or a power-hungry display.
- GPIO pins are for signals. Drive LEDs through a resistor (330 Ω is typical) and switch relays, motors and buzzers through a transistor or driver board.
Boots, but SSDs may disconnect
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
What's Actually on the Board
The BCM2712 is the main processor, but it doesn't drive the header itself: RP1, Raspberry Pi's own I/O controller, does. Along the edges are the 40-pin header (pin 1 at the end away from the USB ports), the fan connector, two USB stacks and Ethernet on the right, USB-C power and two HDMI outputs along the bottom, the power button, and the PCIe connector on the left side.
New Connectors on the Pi 5
None of these change the 40-pin header, but they're worth knowing before you plan a build:
| Connector | What it's for |
|---|---|
| PCIe 2.0 x1 FFC | NVMe SSDs and AI accelerators through an M.2 HAT |
| Two 4-lane MIPI connectors | Two cameras, two DSI displays, or one of each (smaller 22-pin connectors; Pi 4 camera cables need an adapter cable) |
| 3-pin debug UART | Serial console without using GPIO 14/15 |
| 4-pin fan header | The official Active Cooler, with PWM speed control |
| RTC battery connector | Keeps the built-in real-time clock running when unplugged |
| Power button | On the board edge; press to start, and to shut down cleanly |
HAT Compatibility
Physically and electrically, almost every HAT fits and works. Where a HAT fails on a Pi 5, it's nearly always its software: a driver or Python library built on RPi.GPIO, pigpio or direct register access. Check for an updated driver or a Pi 5 note from the maker first, and try rpi-lgpio for Python-based HATs. Tall HATs also need a stacking header to clear the Active Cooler.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
Raspberry Pi 5 vs Pi 4 for GPIO Projects
| Raspberry Pi 4 | Raspberry Pi 5 | |
|---|---|---|
| Processor | BCM2711, 4 × Cortex-A72, 1.8 GHz | BCM2712, 4 × Cortex-A76, 2.4 GHz |
| GPIO controller | Inside the BCM2711 | RP1 over PCIe |
| 40-pin header layout | Same | Same |
| RPi.GPIO / pigpio | Work | Don't work |
| Console UART | GPIO 14/15 | Separate debug connector |
| Recommended supply | 5 V / 3 A | 5 V / 5 A |
| PCIe / NVMe | No | Yes |
| Real-time clock, power button | No | Yes |
Troubleshooting Old Projects on a Pi 5
| Error or symptom | Cause | Fix |
|---|---|---|
RuntimeError: Cannot determine SOC peripheral base address | RPi.GPIO | Install python3-rpi-lgpio or port to gpiozero |
Can't connect to pigpio | pigpio doesn't support RP1 | Use gpiozero or lgpio |
lgpio.error: 'can not open gpiochip' | Code opens chip 4 on a newer kernel | Open chip 0; check with gpiodetect |
| No data on GPIO 14/15 serial | Serial port not enabled, or using /dev/ttyAMA10 | Enable it in raspi-config and use /dev/ttyAMA0 |
| I2C device not found | I2C disabled, or wiring | Enable I2C, run i2cdetect -y 1, check SDA/SCL aren't swapped |
Edits to /boot/config.txt do nothing | Wrong file on Bookworm | Edit /boot/firmware/config.txt |
| USB drive disconnects, power warning | Supply under 5 A | Use the 27 W supply or a powered USB hub |
| GPIO pin reads wrong after wiring a 5 V module | Overvoltage on a 3.3 V pin | Add a level shifter; test the pin with pinctrl get |
Work through those in order and almost every "it worked on my Pi 4" problem is solved before you touch the wiring.
Pin Planning Tips
- Keep I2C on GPIO 2/3 and put several sensors on it; it saves pins and the pull-ups are already there.
- Reserve GPIO 18 and 19 if you might need hardware PWM for servos or a fan.
- Use GPIO 5, 6, 16, 17, 22–27 for buttons, LEDs and relays; they have no bus duties.
- Give buttons an internal pull-up (gpiozero's
Buttondoes this by default) and wire them to GND.
Highlighted on the SolderHub Simulator Raspberry Pi 5. Explore every pin on the Raspberry Pi 5 board page.
When a Pi 5 Is the Right Board
Choose a Pi 5 for camera and vision projects, local AI with an accelerator HAT, home servers such as Mosquitto and Node-RED, and anything that benefits from NVMe instead of a microSD card.
Choose something smaller for a simple always-on sensor or relay controller. A Raspberry Pi Zero uses the same header at a fraction of the power, and a microcontroller such as an ESP32 or a Pico 2 W gives precise timing that Linux can't, at well under a watt.
Plan your header wiring first. The SolderHub Simulator has the same Raspberry Pi 5 you see in these figures, so you can check which pins your sensors and modules need before you wire the real board.
FAQ
Is the Raspberry Pi 5 pinout the same as the Pi 4? Yes. Same 40 pins, same BCM numbers, same bus pins. Only the chip driving them changed.
Does RPi.GPIO work on the Raspberry Pi 5? No. Install rpi-lgpio, which runs RPi.GPIO code on the Pi 5, or switch to gpiozero.
Is it gpiochip0 or gpiochip4? On an up-to-date Raspberry Pi OS it's gpiochip0. Early Pi 5 kernels used gpiochip4. Run gpiodetect to be sure.
Which pins have hardware PWM? GPIO 12, 13, 18 and 19.
Are the GPIO pins 5 V tolerant? No. Every GPIO pin is 3.3 V only.
Can I use a 3 A power supply? It boots, but USB current is limited to 600 mA. Use 5 A for SSDs and power-hungry peripherals.
Do Pi 4 HATs work on the Pi 5? Almost all of them, electrically. Check that the HAT's software doesn't depend on RPi.GPIO or pigpio.
Related guides: Raspberry Pi GPIO pinout reference (all 40-pin models, boot pull states, libraries) · Install Mosquitto on the Pi 5 · Install Node-RED on the Pi 5 · Raspberry Pi Zero pinout



