Skip to content

Pinout / Raspberry Pi

Raspberry Pi 4 Pinout

Every pin on the Raspberry Pi 4 Model B 40-pin GPIO header, with a labeled diagram, a full pin table and the voltage limits to know before you wire.

Pinout DiagramGPIOBy VilrosRaspberry Pi

Published · Updated

Raspberry Pi 4 Model B board with its 40 GPIO pins labeled by pin number, GPIO number and function

The Raspberry Pi 4 Model B 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.

Raspberry Pi 4 GPIO pinout diagram

Raspberry Pi 4 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 4 Model B board with its 40 GPIO pins labeled by pin number, GPIO number and function
Where the header sits on the Raspberry Pi 4 Model B. Select the image for full size.

Raspberry Pi 4 pin table

PinNameCommon useOther functions
13.3VPower
25VPower
3GPIO2I2C1 SDAI2C3 SDA, UART2 CTS, SPI3 MOSI
45VPower
5GPIO3I2C1 SCLI2C3 SCL, UART2 RTS, SPI3 SCLK
6GroundGround
7GPIO4General use, GPCLK0I2C3 SDA, UART3 TXD, SPI4 CE0
8GPIO14UART TXDUART0 TXD, UART1 TXD, UART5 CTS, SPI5 MOSI
9GroundGround
10GPIO15UART RXDUART0 RXD, UART1 RXD, UART5 RTS, SPI5 SCLK
11GPIO17General use, SPI1 CE1UART0 RTS
12GPIO18PWM, I2S clock, SPI1 CE0PWM channel 0, SPI6 CE0
13GPIO27General useSPI6 CE1
14GroundGround
15GPIO22General useI2C6 SDA
16GPIO23General useI2C6 SCL
173.3VPower
18GPIO24General useSPI3 CE1
19GPIO10SPI0 MOSII2C5 SDA, UART4 CTS
20GroundGround
21GPIO9SPI0 MISOI2C4 SCL, UART4 RXD
22GPIO25General useSPI4 CE1
23GPIO11SPI0 SCLKI2C5 SCL, UART4 RTS
24GPIO8SPI0 CE0I2C4 SDA, UART4 TXD
25GroundGround
26GPIO7SPI0 CE1I2C4 SCL, UART3 RTS, SPI4 SCLK
27GPIO0ID_SD, reserved for HAT IDI2C0 SDA, I2C6 SDA, UART2 TXD, SPI3 CE0
28GPIO1ID_SC, reserved for HAT IDI2C0 SCL, I2C6 SCL, UART2 RXD, SPI3 MISO
29GPIO5General useI2C3 SCL, UART3 RXD, SPI4 MISO, GPCLK1
30GroundGround
31GPIO6General useI2C4 SDA, UART3 CTS, SPI4 MOSI, GPCLK2
32GPIO12PWMPWM channel 0, I2C5 SDA, UART5 TXD, SPI5 CE0
33GPIO13PWMPWM channel 1, I2C5 SCL, UART5 RXD, SPI5 MISO
34GroundGround
35GPIO19PWM, I2S frame sync, SPI1 MISOPWM channel 1, SPI6 MISO
36GPIO16General use, SPI1 CE2UART0 CTS
37GPIO26General useSPI5 CE1
38GPIO20I2S data in, SPI1 MOSISPI6 MOSI, GPCLK0
39GroundGround
40GPIO21I2S data out, SPI1 SCLKSPI6 SCLK, GPCLK1

"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)

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 4, 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

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 4

The Pi 4 has more serial ports than earlier boards. Add the overlay line to /boot/firmware/config.txt and restart. A pin can only do one job at a time.

PortPinsLine to add
UART2GPIO0 (TXD), GPIO1 (RXD)dtoverlay=uart2
UART3GPIO4 (TXD), GPIO5 (RXD)dtoverlay=uart3
UART4GPIO8 (TXD), GPIO9 (RXD)dtoverlay=uart4
UART5GPIO12 (TXD), GPIO13 (RXD)dtoverlay=uart5
I2C3GPIO4 (SDA), GPIO5 (SCL)dtoverlay=i2c3
I2C4GPIO8 (SDA), GPIO9 (SCL)dtoverlay=i2c4
I2C5GPIO12 (SDA), GPIO13 (SCL)dtoverlay=i2c5
I2C6GPIO22 (SDA), GPIO23 (SCL)dtoverlay=i2c6
SPI1GPIO19 (MISO), GPIO20 (MOSI), GPIO21 (SCLK), GPIO18 (CE0)dtoverlay=spi1-1cs
SPI5GPIO13 (MISO), GPIO14 (MOSI), GPIO15 (SCLK), GPIO12 (CE0)dtoverlay=spi5-1cs

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 and Bluetooth

On the Pi 4, the full UART (UART0) is connected to Bluetooth by default, and GPIO14 and GPIO15 use the simpler mini UART. If you need the full UART on those pins and can live without Bluetooth, add dtoverlay=disable-bt to /boot/firmware/config.txt and restart.

Frequently asked questions

How many GPIO pins does the Raspberry Pi 4 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 4 pinout the same as the Pi 3 and Pi 5?

The 40 pins are in the same places with the same GPIO numbers on the Pi 3, Pi 4 and Pi 5. The extra I2C, SPI and UART ports are numbered differently on each. See the Raspberry Pi 5 pinout and the Raspberry Pi 3 pinout.

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

For a simple two-wire 5V fan, connect the red wire to 5V (pin 4) and the black wire to ground (pin 6). Fans with a third, control wire follow their own instructions. See how to install a cooling fan.

Are Raspberry Pi 4 GPIO pins 5V tolerant?

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

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

Yes. Pins 2 and 4 accept 5V power input, which is how some HATs power the board. Use a regulated 5V supply and double-check polarity. The USB-C port is the safer choice for most people.

Which GPIO pins are high when the Pi 4 starts?

GPIO0 to GPIO8 are pulled high by default and GPIO9 to GPIO27 are pulled low. Choose GPIO9 or above for a relay that must stay off during startup if it switches on with a high signal.

What you need to start wiring

Sources

Checked against these sources in December 2026.

Download

Printable guide