Every Raspberry Pi with a 40-pin header, from the Pi 2 and Zero to the Pi 4, Pi 5 and Pi 500, uses the same layout. This page shows every pin, what it can do, and the rules that keep your Pi safe.
Physical pins and GPIO numbers
There are two ways to number the pins. Physical (or board) numbers count the header itself: pin 1 is the square pad nearest the corner of the board, odd numbers run along the inner row and even numbers along the outer edge. GPIO (or BCM) numbers are the chip's own names, and they are what almost all code uses. So "GPIO 17" is physical pin 11.
Power Ground GPIO / signal Control
| Also used for | Function | Pin | Pin | Function | Also used for |
|---|---|---|---|---|---|
| 3V3 | 1 | 2 | 5V | ||
| I²C1 SDA | GPIO 2 | 3 | 4 | 5V | |
| I²C1 SCL | GPIO 3 | 5 | 6 | GND | |
| GPCLK0 | GPIO 4 | 7 | 8 | GPIO 14 | UART TX |
| GND | 9 | 10 | GPIO 15 | UART RX | |
| GPIO 17 | 11 | 12 | GPIO 18 | PWM0, PCM CLK | |
| GPIO 27 | 13 | 14 | GND | ||
| GPIO 22 | 15 | 16 | GPIO 23 | ||
| 3V3 | 17 | 18 | GPIO 24 | ||
| SPI0 MOSI | GPIO 10 | 19 | 20 | GND | |
| SPI0 MISO | GPIO 9 | 21 | 22 | GPIO 25 | |
| SPI0 SCLK | GPIO 11 | 23 | 24 | GPIO 8 | SPI0 CE0 |
| GND | 25 | 26 | GPIO 7 | SPI0 CE1 | |
| ID_SD (HAT EEPROM) | GPIO 0 | 27 | 28 | GPIO 1 | ID_SC (HAT EEPROM) |
| GPIO 5 | 29 | 30 | GND | ||
| GPIO 6 | 31 | 32 | GPIO 12 | PWM0 | |
| PWM1 | GPIO 13 | 33 | 34 | GND | |
| PWM1, PCM FS | GPIO 19 | 35 | 36 | GPIO 16 | |
| GPIO 26 | 37 | 38 | GPIO 20 | PCM DIN | |
| GND | 39 | 40 | GPIO 21 | PCM DOUT |
On a Pi with gpiozero installed, which includes Raspberry Pi OS, run pinout in a terminal to print this map for the exact board in front of you.
Power pins
- 5V (pins 2 and 4) connect straight to the Pi's power input. What they can supply depends on your power supply, minus what the Pi itself is using. They're fine for a few sensors or a small fan. For motors, LED strips or servos, give those their own supply and share only ground.
- 3V3 (pins 1 and 17) come from the Pi's on-board regulator. Use them for 3.3 V sensors and modules, but keep the load modest. Anything hungry needs its own regulator.
- GND: there are eight ground pins. Any of them will do, and every external circuit you connect must share a ground with the Pi.
The special-purpose pins
- I²C (GPIO 2 and 3) already have 1.8 kΩ pull-up resistors to 3.3 V on the board. That's handy for I²C, but it means these two pins read high when nothing is connected.
- UART (GPIO 14 and 15) are the serial port. Connect TX to the other device's RX and RX to its TX. Turn the serial port on in
raspi-configunder Interface Options. - SPI0 (GPIO 7 to 11) handles fast devices such as displays and ADCs. CE0 and CE1 are two chip selects, so two SPI devices can share the bus.
- Hardware PWM (GPIO 12, 13, 18 and 19) gives steady PWM for servos and dimming. There are two PWM channels, so GPIO 12 and 18 share one, and 13 and 19 share the other.
- ID_SD and ID_SC (GPIO 0 and 1) are reserved for the identity EEPROM on HAT add-on boards. Leave them alone unless you are designing a HAT.
Any GPIO pin can also be a plain input or output. The extra functions only matter when you turn them on.
How much current can a GPIO pin give?
Very little. A GPIO pin is a signal, not a power source. It can light a small LED through a resistor (see the LED resistor calculator), but for anything more, such as a relay, motor, buzzer or bright LED, switch it with a transistor or MOSFET. Our guide to transistors as switches shows how.
Blink an LED on GPIO 17
Wire GPIO 17 (physical pin 11) to an LED's long leg through a 330 Ω resistor, and the LED's short leg to any GND pin. Then run:
from gpiozero import LED
from signal import pause
led = LED(17) # GPIO number, not physical pin number
led.blink() # on for 1 second, off for 1 second, forever
pause()
gpiozero works on every Pi model including the Pi 5. The older RPi.GPIO library does not work on the Pi 5, because the Pi 5's GPIO pins are driven by a different chip (RP1).
Common mistakes
- Mixing up physical and GPIO numbers. If nothing happens, check which numbering your code uses.
- Connecting 5 V signals. Arduino boards and many older modules output 5 V. Use a level shifter or a voltage divider on any signal going into the Pi.
- Powering motors from the header. The voltage dip can crash or reset the Pi. Use a separate supply.
- Wiring with the power on. A slipped jumper wire can short 5 V to 3V3. Shut down and unplug first.
Sources
The main references behind this guide. Numbers we worked out ourselves, such as the code outputs, come from running the code.