The 40-pin header is what turns the Raspberry Pi into more than a mini computer: with it you can read sensors, light LEDs or talk to displays. This guide explains what each pin does, how they are numbered and which electrical limits you must not exceed.
In short
- GPIOs work at 3.3 V and are not 5 V tolerant: putting 5 V on a pin can permanently damage the chip.
- Each pin supplies at most about 16 mA, and Raspberry Pi states about 50 mA total for all GPIOs at once.
- There are two numberings: physical (1 to 40, by position) and BCM/GPIO (what software uses). Do not mix them.
Data from the official Raspberry Pi documentation. The header is the same on the Pi 5, Pi 4, Pi 3 and Zero 2 W.
What is on the 40 pins
Not all pins are GPIOs. The header mixes several types:
| Type | How many | Purpose |
|---|---|---|
| 5 V power | 2 (pins 2 and 4) | Direct output from the power supply, no regulator |
| 3.3 V power | 2 (pins 1 and 17) | Output of the board’s regulator |
| Ground (GND) | 8 | Common reference for all circuits |
| GPIO | 26 (GPIO 2 to GPIO 27) | Configurable digital inputs and outputs |
| ID EEPROM | 2 (pins 27 and 28, GPIO 0 and 1) | Reserved for HATs to identify themselves |
How to find your way on the board
- Pin 1 is the one with the square pad on the board, in the corner nearest the microSD slot.
- Odd pins (1, 3, 5…) form the inner row; even ones (2, 4, 6…) the edge row.
- In a Raspberry Pi OS terminal you can see the ASCII map with:
pinout
Physical versus BCM numbering
This is the number one beginner mistake. The same pin has two names:
- Physical (BOARD): its position on the header, 1 to 40.
- BCM (or GPIO): the signal number on the chip. It is what almost all current libraries use.

| Physical pin | BCM name | Alternate function |
|---|---|---|
| 3 | GPIO 2 | I2C SDA |
| 5 | GPIO 3 | I2C SCL |
| 7 | GPIO 4 | GPCLK0 |
| 8 | GPIO 14 | UART TX |
| 10 | GPIO 15 | UART RX |
| 11 | GPIO 17 | General purpose |
| 12 | GPIO 18 | PWM / PCM CLK |
| 19 | GPIO 10 | SPI MOSI |
| 21 | GPIO 9 | SPI MISO |
| 23 | GPIO 11 | SPI SCLK |
| 24 | GPIO 8 | SPI CE0 |
| 26 | GPIO 7 | SPI CE1 |
| 32 | GPIO 12 | PWM0 |
| 33 | GPIO 13 | PWM1 |
Example: if a tutorial says “connect the LED to GPIO 17”, it goes to physical pin 11, not pin 17 (which is a 3.3 V output).
With the gpiozero library included in Raspberry Pi OS, numbers are always BCM:
from gpiozero import LED
from time import sleep
led = LED(17) # GPIO 17 = physical pin 11
while True:
led.toggle()
sleep(0.5)
Electrical limits: 3.3 V and few milliamps
Voltage: 3.3 V, never 5 V
GPIOs use 3.3 V logic. A “1” is 3.3 V and a “0” is 0 V. The official documentation is clear: they are not 5 V tolerant, and applying 5 V to a GPIO can permanently damage the SoC.
This matters when you connect modules designed for Arduino (which usually runs at 5 V):
- A 5 V powered sensor that sends data to the Pi needs a voltage divider or a logic level shifter.
- If the Pi only sends to a 5 V module, it usually works, because 3.3 V is normally read as “1”. Check its datasheet.
Current: very little

| Limit | Official value |
|---|---|
| Maximum current per pin | 16 mA |
| Total for all GPIOs at once | 50 mA |
| Default output drive strength | 8 mA |
With these figures a GPIO can light one LED with its resistor (about 5–10 mA), but not a motor, a bare relay, a large buzzer or an LED strip.
For larger loads use a transistor, a MOSFET or a relay module with its own power, and let the GPIO only control the signal.
The 5 V and 3.3 V pins
- The 5 V pins come straight from the power supply. What they can provide depends on the supply and what USB devices draw.
- The 3.3 V pin comes from the board’s regulator and is for small sensors, not for motors or large displays.
Special pins: I2C, SPI, UART and PWM
Many GPIOs have alternate functions enabled from sudo raspi-config → Interface Options.
I2C (pins 3 and 5)
Two-wire bus for sensors, OLED displays, clocks… Several devices share the same two wires, each with its own address. Pins 3 and 5 have fixed 1.8 kΩ pull-ups to 3.3 V, so you do not need to add any.
sudo apt install i2c-tools
i2cdetect -y 1
SPI (pins 19, 21, 23, 24 and 26)
Faster than I2C, used for TFT displays, card readers or analog-to-digital converters. Each device needs its own chip select line (CE0, CE1).
UART (pins 8 and 10)
Serial port: the Pi’s TX goes to the other device’s RX and vice versa, with grounds joined. Useful for GPS modules or a console without network.
PWM (GPIO 12, 13, 18 and 19)
A signal switching on and off very fast to dim an LED or control a servo. There are two hardware PWM channels, available on those pins.
To understand when to use each bus, see I2C, SPI and UART: differences.
How not to fry your Raspberry Pi
- Always wire with the Pi powered off. A wire touching the 5 V pin to a GPIO while connecting is the classic cause of failure.
- Never connect 5 V or 3.3 V straight to GND: it is a short circuit.
- Always use a resistor with LEDs. Use the LED resistor calculator.
- Configure as input the pins that receive signals. Two outputs facing each other (one high, one low) fight.
- Join the grounds of the Pi and any external circuit.
- Use pull-up or pull-down resistors on buttons so the input is not “floating”.
Common problems
| Symptom | Likely cause |
|---|---|
| The LED does not light | Physical and BCM confused, or LED reversed |
| The button gives random readings | Input without pull-up/pull-down |
i2cdetect shows nothing | I2C not enabled or SDA/SCL swapped |
| The Pi reboots when you connect something | Too much load on 5 V or short circuit |
| A pin stopped responding | It got 5 V or too much current |
Frequently asked questions
Can I power the Raspberry Pi through the 5 V pins?
You can, but you bypass the USB-C input protections. Only with a stable, well-sized supply.
Is the pinout the same on the Pi 5?
Yes, the 40-pin layout is the same. The chip that controls them (RP1) changed, not the position.



