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

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 pin table
| Pin | Name | Common use | Other functions |
|---|---|---|---|
| 1 | 3.3V | Power | |
| 2 | 5V | Power | |
| 3 | GPIO2 | I2C1 SDA | UART1 CTS, SPI2 MOSI |
| 4 | 5V | Power | |
| 5 | GPIO3 | I2C1 SCL | UART1 RTS, SPI2 SCLK |
| 6 | Ground | Ground | |
| 7 | GPIO4 | General use, GPCLK0 | I2C2 SDA, UART2 TXD, SPI3 CE0 |
| 8 | GPIO14 | UART TXD | UART0 TXD, I2C3 SDA, UART4 CTS, SPI5 MOSI |
| 9 | Ground | Ground | |
| 10 | GPIO15 | UART RXD | UART0 RXD, I2C3 SCL, UART4 RTS, SPI5 SCLK |
| 11 | GPIO17 | General use, SPI1 CE1 | UART0 RTS |
| 12 | GPIO18 | PWM, I2S clock, SPI1 CE0 | PWM channel 2 |
| 13 | GPIO27 | General use | SPI1 CE1 |
| 14 | Ground | Ground | |
| 15 | GPIO22 | General use | I2C3 SDA |
| 16 | GPIO23 | General use | I2C3 SCL |
| 17 | 3.3V | Power | |
| 18 | GPIO24 | General use | SPI2 CE1 |
| 19 | GPIO10 | SPI0 MOSI | I2C1 SDA, UART3 CTS, SPI4 MISO |
| 20 | Ground | Ground | |
| 21 | GPIO9 | SPI0 MISO | I2C0 SCL, UART3 RXD, SPI4 MOSI |
| 22 | GPIO25 | General use | SPI3 CE1 |
| 23 | GPIO11 | SPI0 SCLK | I2C1 SCL, UART3 RTS, SPI4 SCLK |
| 24 | GPIO8 | SPI0 CE0 | I2C0 SDA, UART3 TXD, SPI4 CE0 |
| 25 | Ground | Ground | |
| 26 | GPIO7 | SPI0 CE1 | I2C3 SCL, UART2 RTS, SPI3 SCLK |
| 27 | GPIO0 | ID_SD, reserved for HAT ID | I2C0 SDA, UART1 TXD, SPI2 CE0 |
| 28 | GPIO1 | ID_SC, reserved for HAT ID | I2C0 SCL, UART1 RXD, SPI2 MISO |
| 29 | GPIO5 | General use | I2C2 SCL, UART2 RXD, SPI3 MISO, GPCLK1 |
| 30 | Ground | Ground | |
| 31 | GPIO6 | General use | I2C3 SDA, UART2 CTS, SPI3 MOSI, GPCLK2 |
| 32 | GPIO12 | PWM | PWM channel 0, I2C2 SDA, UART4 TXD, SPI5 CE0 |
| 33 | GPIO13 | PWM | PWM channel 1, I2C2 SCL, UART4 RXD, SPI5 MISO |
| 34 | Ground | Ground | |
| 35 | GPIO19 | PWM, I2S frame sync, SPI1 MISO | PWM channel 3 |
| 36 | GPIO16 | General use, SPI1 CE2 | UART0 CTS |
| 37 | GPIO26 | General use | SPI5 CE1 |
| 38 | GPIO20 | I2S data in, SPI1 MOSI | GPCLK0 |
| 39 | Ground | Ground | |
| 40 | GPIO21 | I2S data out, SPI1 SCLK | GPCLK1 |
"Common use" is what the pin is normally used for. "Other functions" can be selected in software.
Pins by function
| You need | Pins |
|---|---|
| 5V | Pins 2 and 4 |
| 3.3V | Pins 1 and 17 |
| Ground | Pins 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 serial | Pin 8 (GPIO14, TXD) and pin 10 (GPIO15, RXD) |
| Hardware PWM | Pin 12 (GPIO18), pin 32 (GPIO12), pin 33 (GPIO13), pin 35 (GPIO19) |
| I2S digital audio | Pin 12 (GPIO18, clock), pin 35 (GPIO19, frame sync), pin 38 (GPIO20, data in), pin 40 (GPIO21, data out) |
| Reserved for HAT identification | Pin 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 4 | Raspberry Pi 5 | |
|---|---|---|
| GPIO controller | BCM2711 | RP1 |
| Pin positions and GPIO numbers | Standard 40-pin layout | Same |
| RPi.GPIO Python library | Works | Does not work, use GPIO Zero or rpi-lgpio |
| Serial console | GPIO14 and GPIO15 | Separate 3-pin UART connector |
| Hardware PWM | 2 channels | 4 channels |
| Fan connection | 5V and ground on the header | Separate 4-pin fan connector |
| PoE HAT | Pi 3B+ and Pi 4 models | Needs 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:
pinoutFix 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:
- Use GPIO Zero, as in the example above.
- Keep your old code and install rpi-lgpio, which provides the same commands:
sudo apt remove python3-rpi.gpio
sudo apt install python3-rpi-lgpioThe 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.
| Port | Pins | Line to add |
|---|---|---|
| UART0 | GPIO14 (TXD), GPIO15 (RXD) | dtoverlay=uart0-pi5 |
| UART1 | GPIO0 (TXD), GPIO1 (RXD) | dtoverlay=uart1-pi5 |
| UART2 | GPIO4 (TXD), GPIO5 (RXD) | dtoverlay=uart2-pi5 |
| UART3 | GPIO8 (TXD), GPIO9 (RXD) | dtoverlay=uart3-pi5 |
| UART4 | GPIO12 (TXD), GPIO13 (RXD) | dtoverlay=uart4-pi5 |
| I2C2 | GPIO4 (SDA), GPIO5 (SCL) | dtoverlay=i2c2-pi5 |
| I2C3 | GPIO6 (SDA), GPIO7 (SCL) | dtoverlay=i2c3-pi5 |
| SPI1 | GPIO19 (MISO), GPIO20 (MOSI), GPIO21 (SCLK), GPIO18 (CE0) | dtoverlay=spi1-1cs |
| SPI3 | GPIO5 (MISO), GPIO6 (MOSI), GPIO7 (SCLK), GPIO4 (CE0) | dtoverlay=spi3-1cs-pi5 |
| SPI5 | GPIO13 (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 pin | Function | Wire color on the official fan |
|---|---|---|
| 1 | 5V | Red |
| 2 | PWM speed control | Blue |
| 3 | Ground | Black |
| 4 | Tachometer | Yellow |
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
- Raspberry Pi 5
- Male to female jumper wires, to go from the header to a breadboard
- 400 hole breadboard
- 240 piece jumper wire set
Sources
- Raspberry Pi documentation: 40-pin GPIO header and Pi 5 connectors
- RP1 Peripherals datasheet
- Raspberry Pi documentation: UART configuration
- Raspberry Pi device tree overlays
- rpi-lgpio installation
Checked against these sources in December 2026.