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

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 pin table
| Pin | Name | Common use | Other functions |
|---|---|---|---|
| 1 | 3.3V | Power | |
| 2 | 5V | Power | |
| 3 | GPIO2 | I2C1 SDA | I2C3 SDA, UART2 CTS, SPI3 MOSI |
| 4 | 5V | Power | |
| 5 | GPIO3 | I2C1 SCL | I2C3 SCL, UART2 RTS, SPI3 SCLK |
| 6 | Ground | Ground | |
| 7 | GPIO4 | General use, GPCLK0 | I2C3 SDA, UART3 TXD, SPI4 CE0 |
| 8 | GPIO14 | UART TXD | UART0 TXD, UART1 TXD, UART5 CTS, SPI5 MOSI |
| 9 | Ground | Ground | |
| 10 | GPIO15 | UART RXD | UART0 RXD, UART1 RXD, UART5 RTS, SPI5 SCLK |
| 11 | GPIO17 | General use, SPI1 CE1 | UART0 RTS |
| 12 | GPIO18 | PWM, I2S clock, SPI1 CE0 | PWM channel 0, SPI6 CE0 |
| 13 | GPIO27 | General use | SPI6 CE1 |
| 14 | Ground | Ground | |
| 15 | GPIO22 | General use | I2C6 SDA |
| 16 | GPIO23 | General use | I2C6 SCL |
| 17 | 3.3V | Power | |
| 18 | GPIO24 | General use | SPI3 CE1 |
| 19 | GPIO10 | SPI0 MOSI | I2C5 SDA, UART4 CTS |
| 20 | Ground | Ground | |
| 21 | GPIO9 | SPI0 MISO | I2C4 SCL, UART4 RXD |
| 22 | GPIO25 | General use | SPI4 CE1 |
| 23 | GPIO11 | SPI0 SCLK | I2C5 SCL, UART4 RTS |
| 24 | GPIO8 | SPI0 CE0 | I2C4 SDA, UART4 TXD |
| 25 | Ground | Ground | |
| 26 | GPIO7 | SPI0 CE1 | I2C4 SCL, UART3 RTS, SPI4 SCLK |
| 27 | GPIO0 | ID_SD, reserved for HAT ID | I2C0 SDA, I2C6 SDA, UART2 TXD, SPI3 CE0 |
| 28 | GPIO1 | ID_SC, reserved for HAT ID | I2C0 SCL, I2C6 SCL, UART2 RXD, SPI3 MISO |
| 29 | GPIO5 | General use | I2C3 SCL, UART3 RXD, SPI4 MISO, GPCLK1 |
| 30 | Ground | Ground | |
| 31 | GPIO6 | General use | I2C4 SDA, UART3 CTS, SPI4 MOSI, GPCLK2 |
| 32 | GPIO12 | PWM | PWM channel 0, I2C5 SDA, UART5 TXD, SPI5 CE0 |
| 33 | GPIO13 | PWM | PWM channel 1, I2C5 SCL, UART5 RXD, SPI5 MISO |
| 34 | Ground | Ground | |
| 35 | GPIO19 | PWM, I2S frame sync, SPI1 MISO | PWM channel 1, SPI6 MISO |
| 36 | GPIO16 | General use, SPI1 CE2 | UART0 CTS |
| 37 | GPIO26 | General use | SPI5 CE1 |
| 38 | GPIO20 | I2S data in, SPI1 MOSI | SPI6 MOSI, GPCLK0 |
| 39 | Ground | Ground | |
| 40 | GPIO21 | I2S data out, SPI1 SCLK | SPI6 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) |
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:
pinoutTurn 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.
| Port | Pins | Line to add |
|---|---|---|
| UART2 | GPIO0 (TXD), GPIO1 (RXD) | dtoverlay=uart2 |
| UART3 | GPIO4 (TXD), GPIO5 (RXD) | dtoverlay=uart3 |
| UART4 | GPIO8 (TXD), GPIO9 (RXD) | dtoverlay=uart4 |
| UART5 | GPIO12 (TXD), GPIO13 (RXD) | dtoverlay=uart5 |
| I2C3 | GPIO4 (SDA), GPIO5 (SCL) | dtoverlay=i2c3 |
| I2C4 | GPIO8 (SDA), GPIO9 (SCL) | dtoverlay=i2c4 |
| I2C5 | GPIO12 (SDA), GPIO13 (SCL) | dtoverlay=i2c5 |
| I2C6 | GPIO22 (SDA), GPIO23 (SCL) | dtoverlay=i2c6 |
| SPI1 | GPIO19 (MISO), GPIO20 (MOSI), GPIO21 (SCLK), GPIO18 (CE0) | dtoverlay=spi1-1cs |
| SPI5 | GPIO13 (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
- Raspberry Pi 4 Model B
- 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
- Raspberry Pi 4 Model B datasheet
- BCM2711 ARM Peripherals
- Raspberry Pi device tree overlays
Checked against these sources in December 2026.