Skip to content

Pinout / Raspberry Pi

Raspberry Pi 5 Pinout

Every pin on the Raspberry Pi 5 40-pin GPIO header, with a labeled diagram, a full pin table, what changed from the Pi 4, and the limits to know before you wire.

Pinout DiagramGPIOBy VilrosRaspberry Pi

Published · Updated

Raspberry Pi 5 board with its 40 GPIO pins labeled by pin number, GPIO number and function

The Raspberry Pi 5 has a 40-pin GPIO header: two 5V pins (2 and 4), two 3.3V pins (1 and 17), eight ground pins and 28 GPIO pins. Two of those, GPIO0 and GPIO1, are reserved for HAT identification, which leaves 26 for your projects. All GPIO pins work at 3.3V, and the layout matches the Raspberry Pi 4.

Raspberry Pi 5 GPIO pinout diagram

Raspberry Pi 5 40-pin GPIO header pinout diagram
The header with pin 1 at the top left. Select the image for full size.

How to find pin 1

Hold the board with the USB ports at the bottom and the GPIO header on the right. Pin 1 is the top pin of the inner row. Odd numbers run down the inner row and even numbers run down the outer row, next to the board edge. Pin 40 is at the bottom of the outer row.

Raspberry Pi 5 board with its 40 GPIO pins labeled by pin number, GPIO number and function
Where the header sits on the Raspberry Pi 5. Select the image for full size.

Raspberry Pi 5 pin table

PinNameCommon useOther functions
13.3VPower
25VPower
3GPIO2I2C1 SDAUART1 CTS, SPI2 MOSI
45VPower
5GPIO3I2C1 SCLUART1 RTS, SPI2 SCLK
6GroundGround
7GPIO4General use, GPCLK0I2C2 SDA, UART2 TXD, SPI3 CE0
8GPIO14UART TXDUART0 TXD, I2C3 SDA, UART4 CTS, SPI5 MOSI
9GroundGround
10GPIO15UART RXDUART0 RXD, I2C3 SCL, UART4 RTS, SPI5 SCLK
11GPIO17General use, SPI1 CE1UART0 RTS
12GPIO18PWM, I2S clock, SPI1 CE0PWM channel 2
13GPIO27General useSPI1 CE1
14GroundGround
15GPIO22General useI2C3 SDA
16GPIO23General useI2C3 SCL
173.3VPower
18GPIO24General useSPI2 CE1
19GPIO10SPI0 MOSII2C1 SDA, UART3 CTS, SPI4 MISO
20GroundGround
21GPIO9SPI0 MISOI2C0 SCL, UART3 RXD, SPI4 MOSI
22GPIO25General useSPI3 CE1
23GPIO11SPI0 SCLKI2C1 SCL, UART3 RTS, SPI4 SCLK
24GPIO8SPI0 CE0I2C0 SDA, UART3 TXD, SPI4 CE0
25GroundGround
26GPIO7SPI0 CE1I2C3 SCL, UART2 RTS, SPI3 SCLK
27GPIO0ID_SD, reserved for HAT IDI2C0 SDA, UART1 TXD, SPI2 CE0
28GPIO1ID_SC, reserved for HAT IDI2C0 SCL, UART1 RXD, SPI2 MISO
29GPIO5General useI2C2 SCL, UART2 RXD, SPI3 MISO, GPCLK1
30GroundGround
31GPIO6General useI2C3 SDA, UART2 CTS, SPI3 MOSI, GPCLK2
32GPIO12PWMPWM channel 0, I2C2 SDA, UART4 TXD, SPI5 CE0
33GPIO13PWMPWM channel 1, I2C2 SCL, UART4 RXD, SPI5 MISO
34GroundGround
35GPIO19PWM, I2S frame sync, SPI1 MISOPWM channel 3
36GPIO16General use, SPI1 CE2UART0 CTS
37GPIO26General useSPI5 CE1
38GPIO20I2S data in, SPI1 MOSIGPCLK0
39GroundGround
40GPIO21I2S data out, SPI1 SCLKGPCLK1

"Common use" is what the pin is normally used for. "Other functions" can be selected in software.

Pins by function

You needPins
5VPins 2 and 4
3.3VPins 1 and 17
GroundPins 6, 9, 14, 20, 25, 30, 34 and 39
I2C (I2C1)Pin 3 (GPIO2, SDA) and pin 5 (GPIO3, SCL)
SPI (SPI0)Pin 19 (GPIO10, MOSI), pin 21 (GPIO9, MISO), pin 23 (GPIO11, SCLK), pin 24 (GPIO8, CE0), pin 26 (GPIO7, CE1)
UART serialPin 8 (GPIO14, TXD) and pin 10 (GPIO15, RXD)
Hardware PWMPin 12 (GPIO18), pin 32 (GPIO12), pin 33 (GPIO13), pin 35 (GPIO19)
I2S digital audioPin 12 (GPIO18, clock), pin 35 (GPIO19, frame sync), pin 38 (GPIO20, data in), pin 40 (GPIO21, data out)
Reserved for HAT identificationPin 27 (GPIO0) and pin 28 (GPIO1)

What changed from the Raspberry Pi 4

The header looks the same, but a new chip called RP1 now runs it. Simple wiring carries over. Some software and accessories do not.

Raspberry Pi 4Raspberry Pi 5
GPIO controllerBCM2711RP1
Pin positions and GPIO numbersStandard 40-pin layoutSame
RPi.GPIO Python libraryWorksDoes not work, use GPIO Zero or rpi-lgpio
Serial consoleGPIO14 and GPIO15Separate 3-pin UART connector
Hardware PWM2 channels4 channels
Fan connection5V and ground on the headerSeparate 4-pin fan connector
PoE HATPi 3B+ and Pi 4 modelsNeeds one made for the Pi 5, the PoE pins moved

Voltage and current limits

  • GPIO pins are 3.3V only. They are not 5V tolerant. Putting 5V on a GPIO pin can permanently damage the board. Use a level shifter for 5V sensors and 5V serial devices.
  • Keep all GPIO pins together under 50 mA. Raspberry Pi does not publish a per-pin maximum for the Pi 5, so stay well below that total.
  • Give every LED a resistor. A 330 ohm resistor on a red LED draws about 4 mA.
  • Never drive a motor or a bare relay coil from a GPIO pin. Use a motor driver or a relay board, powered from 5V.
  • Check pin 1 before you plug in. A board or cable shifted by one pin can put 5V where it does not belong.

A GPIO input reads low up to 0.8V and high from 2.0V.

Pin numbers and GPIO numbers

Each pin has two numbers. The pin number (1 to 40) is its place on the header. The GPIO number is the name your code uses. They do not match: GPIO17 is pin 11.

This Python program blinks an LED on GPIO17. Connect pin 11 to a 330 ohm resistor, the resistor to the long leg of the LED, and the short leg to ground on pin 9.

from gpiozero import LED
from signal import pause

led = LED(17)  # GPIO17, physical pin 11
led.blink()
pause()

GPIO Zero uses GPIO numbers. To use the physical position instead, write LED("BOARD11").

To see the pinout of your own board, open a terminal and type:

pinout

Fix RPi.GPIO on the Raspberry Pi 5

The RPi.GPIO library cannot control the RP1 chip. Many older tutorials use it, and they often stop with the error Cannot determine SOC peripheral base address. You have two choices:

  1. Use GPIO Zero, as in the example above.
  2. Keep your old code and install rpi-lgpio, which provides the same commands:
sudo apt remove python3-rpi.gpio
sudo apt install python3-rpi-lgpio

The two libraries cannot be installed together. A few RPi.GPIO features behave differently in rpi-lgpio, so test your project.

Turn on I2C or SPI

Run sudo raspi-config, open Interface Options, and turn on I2C or SPI. To check that an I2C sensor is detected, run i2cdetect -y 1 from the i2c-tools package.

GPIO2 and GPIO3 have fixed 1.8 kilohm pull-up resistors to 3.3V. That is right for I2C, but makes them a poor choice for other uses.

Extra I2C, SPI and UART ports on the Pi 5

Add the overlay line to /boot/firmware/config.txt and restart. A pin can only do one job at a time. These port numbers differ from the Pi 4.

PortPinsLine to add
UART0GPIO14 (TXD), GPIO15 (RXD)dtoverlay=uart0-pi5
UART1GPIO0 (TXD), GPIO1 (RXD)dtoverlay=uart1-pi5
UART2GPIO4 (TXD), GPIO5 (RXD)dtoverlay=uart2-pi5
UART3GPIO8 (TXD), GPIO9 (RXD)dtoverlay=uart3-pi5
UART4GPIO12 (TXD), GPIO13 (RXD)dtoverlay=uart4-pi5
I2C2GPIO4 (SDA), GPIO5 (SCL)dtoverlay=i2c2-pi5
I2C3GPIO6 (SDA), GPIO7 (SCL)dtoverlay=i2c3-pi5
SPI1GPIO19 (MISO), GPIO20 (MOSI), GPIO21 (SCLK), GPIO18 (CE0)dtoverlay=spi1-1cs
SPI3GPIO5 (MISO), GPIO6 (MOSI), GPIO7 (SCLK), GPIO4 (CE0)dtoverlay=spi3-1cs-pi5
SPI5GPIO13 (MISO), GPIO14 (MOSI), GPIO15 (SCLK), GPIO12 (CE0)dtoverlay=spi5-1cs-pi5

Only GPIO2 and GPIO3 have built-in I2C pull-up resistors. The other I2C pairs need your own, typically 4.7 kilohm to 3.3V.

UART on the Raspberry Pi 5

On the Pi 5, the main serial console is on the small 3-pin connector labeled UART, not on GPIO14 and GPIO15. To move the console back to the header, add enable_uart=1 to /boot/firmware/config.txt and restart with nothing plugged into the 3-pin connector.

Fan connector and other Pi 5 connectors

The Pi 5 has a 4-pin fan connector (JST-SH, 1 mm pitch) between the GPIO header and the USB 2.0 ports:

Fan pinFunctionWire color on the official fan
15VRed
2PWM speed controlBlue
3GroundBlack
4TachometerYellow

The board also has a 3-pin UART connector, a 2-pin connector for a clock (RTC) battery, a PCIe connector, and a 4-pin PoE header between the Ethernet jack and the camera and display connectors. Bridging the two J2 pads with a momentary push button gives you an external power button.

Frequently asked questions

How many GPIO pins does the Raspberry Pi 5 have?

The 40-pin header carries 28 GPIO pins, GPIO0 to GPIO27. GPIO0 and GPIO1 are reserved for HAT identification, so 26 are free to use.

Is the Raspberry Pi 5 pinout the same as the Raspberry Pi 4?

Yes for the 40 pins: same positions and same GPIO numbers. The extra I2C, SPI and UART ports are numbered differently, and software that relies on RPi.GPIO needs a change. See the Raspberry Pi 4 pinout.

Are Raspberry Pi 5 GPIO pins 5V tolerant?

No. They accept up to 3.3V. Only pins 2 and 4 are 5V pins.

Will my Raspberry Pi 4 HAT work on the Raspberry Pi 5?

Most HATs should, but check that the software supports the Pi 5. PoE HATs made for the Pi 4 or Pi 3B+ will not work because the PoE pins moved.

Can I power the Raspberry Pi 5 through the GPIO header?

Yes. Pins 2 and 4 accept 5V power input. Use a regulated 5V supply that can deliver enough current and double-check polarity. The board cannot negotiate a 5A supply through these pins, so it may limit power to the USB ports. The USB-C port is the safer choice for most people.

Which pins do I use for a fan on the Raspberry Pi 5?

Use the 4-pin fan connector rather than the GPIO header. The board then controls the fan speed by temperature.

What you need to start wiring

Sources

Checked against these sources in December 2026.

Download

Printable guide