Pinout reference · Beginner · 3 min read
Raspberry Pi GPIO Pinout

40-Pin Header Reference
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
All Raspberry Pi models since 2014 share the same 40-pin header: 26 GPIO pins at 3.3 V logic, two 5 V pins, two 3.3 V pins and eight grounds. Code uses BCM numbers (GPIO 17), not physical pin numbers (pin 11). I2C is on GPIO 2 and 3, SPI on GPIO 7 to 11, UART on GPIO 14 and 15, and hardware PWM on GPIO 12, 13, 18 and 19.
Key specs at a glance
- Header
- 2 x 20 pins, 2.54 mm pitch
- Logic level
- 3.3 V, not 5 V tolerant
- Per-pin current
- About 16 mA max; 50 mA total across all GPIO
- Power pins
- 5 V on pins 2 and 4; 3.3 V on pins 1 and 17
- I2C
- GPIO 2 (SDA), GPIO 3 (SCL), with 1.8 kΩ pull-ups on board
- SPI0
- GPIO 10 (MOSI), 9 (MISO), 11 (SCLK), 8 (CE0), 7 (CE1)
- UART
- GPIO 14 (TXD), GPIO 15 (RXD)
- Hardware PWM
- GPIO 12, 13, 18, 19
BCM vs physical (board) numbering
Physical numbering counts the header pins 1 to 40: pin 1 is the 3.3 V pin nearest the SD card, odd numbers on the inside row, even numbers on the outside. BCM numbering uses the chip's GPIO number and is what gpiozero and most libraries expect. "GPIO 17" is physical pin 11. Pinout diagrams and the pinout command on the Pi show both.
Full 40-pin pinout
| Pin | Function | Pin | Function |
|---|---|---|---|
| 1 | 3.3 V | 2 | 5 V |
| 3 | GPIO 2 (SDA1) | 4 | 5 V |
| 5 | GPIO 3 (SCL1) | 6 | GND |
| 7 | GPIO 4 (GPCLK0, 1-Wire) | 8 | GPIO 14 (TXD) |
| 9 | GND | 10 | GPIO 15 (RXD) |
| 11 | GPIO 17 | 12 | GPIO 18 (PWM0, PCM_CLK) |
| 13 | GPIO 27 | 14 | GND |
| 15 | GPIO 22 | 16 | GPIO 23 |
| 17 | 3.3 V | 18 | GPIO 24 |
| 19 | GPIO 10 (MOSI) | 20 | GND |
| 21 | GPIO 9 (MISO) | 22 | GPIO 25 |
| 23 | GPIO 11 (SCLK) | 24 | GPIO 8 (CE0) |
| 25 | GND | 26 | GPIO 7 (CE1) |
| 27 | ID_SD (EEPROM, reserved) | 28 | ID_SC (EEPROM, reserved) |
| 29 | GPIO 5 | 30 | GND |
| 31 | GPIO 6 | 32 | GPIO 12 (PWM0) |
| 33 | GPIO 13 (PWM1) | 34 | GND |
| 35 | GPIO 19 (PWM1, PCM_FS) | 36 | GPIO 16 |
| 37 | GPIO 26 | 38 | GPIO 20 (PCM_DIN) |
| 39 | GND | 40 | GPIO 21 (PCM_DOUT) |
- 1
- Function:
- 3.3 V
- Pin:
- 2
- Function:
- 5 V
- 3
- Function:
- GPIO 2 (SDA1)
- Pin:
- 4
- Function:
- 5 V
- 5
- Function:
- GPIO 3 (SCL1)
- Pin:
- 6
- Function:
- GND
- 7
- Function:
- GPIO 4 (GPCLK0, 1-Wire)
- Pin:
- 8
- Function:
- GPIO 14 (TXD)
- 9
- Function:
- GND
- Pin:
- 10
- Function:
- GPIO 15 (RXD)
- 11
- Function:
- GPIO 17
- Pin:
- 12
- Function:
- GPIO 18 (PWM0, PCM_CLK)
- 13
- Function:
- GPIO 27
- Pin:
- 14
- Function:
- GND
- 15
- Function:
- GPIO 22
- Pin:
- 16
- Function:
- GPIO 23
- 17
- Function:
- 3.3 V
- Pin:
- 18
- Function:
- GPIO 24
- 19
- Function:
- GPIO 10 (MOSI)
- Pin:
- 20
- Function:
- GND
- 21
- Function:
- GPIO 9 (MISO)
- Pin:
- 22
- Function:
- GPIO 25
- 23
- Function:
- GPIO 11 (SCLK)
- Pin:
- 24
- Function:
- GPIO 8 (CE0)
- 25
- Function:
- GND
- Pin:
- 26
- Function:
- GPIO 7 (CE1)
- 27
- Function:
- ID_SD (EEPROM, reserved)
- Pin:
- 28
- Function:
- ID_SC (EEPROM, reserved)
- 29
- Function:
- GPIO 5
- Pin:
- 30
- Function:
- GND
- 31
- Function:
- GPIO 6
- Pin:
- 32
- Function:
- GPIO 12 (PWM0)
- 33
- Function:
- GPIO 13 (PWM1)
- Pin:
- 34
- Function:
- GND
- 35
- Function:
- GPIO 19 (PWM1, PCM_FS)
- Pin:
- 36
- Function:
- GPIO 16
- 37
- Function:
- GPIO 26
- Pin:
- 38
- Function:
- GPIO 20 (PCM_DIN)
- 39
- Function:
- GND
- Pin:
- 40
- Function:
- GPIO 21 (PCM_DOUT)
Power and current limits
GPIO pins source about 16 mA each, with roughly 50 mA available across the whole header, so a GPIO can light an LED through a 330 Ω to 1 kΩ resistor but nothing bigger. The 5 V pins connect straight to the Pi's input supply and can power a few hundred milliamps of accessories if your PSU has headroom. The 3.3 V rail is good for about 500 mA on the Pi 4 and 5. Motors, relays and LED strips go through a transistor, MOSFET or relay module with their own supply.
Enabling I2C, SPI, UART and 1-Wire
Run sudo raspi-config > Interface Options to enable I2C and SPI, and the serial port (disable the login shell over serial if you want to use the UART for a device). 1-Wire for DS18B20 sensors is enabled by adding dtoverlay=w1-gpio to /boot/firmware/config.txt, using GPIO 4 by default. Check for I2C devices with i2cdetect -y 1.
Reading a button and lighting an LED
from gpiozero import LED, Button
from signal import pause
led = LED(17) # physical pin 11, through a 330 ohm resistor
button = Button(2) # physical pin 3, uses the internal pull-up
button.when_pressed = led.on
button.when_released = led.off
pause()Pi 5 differences
On the Raspberry Pi 5 the header is driven by the RP1 I/O chip. The pins and numbers are unchanged, but libraries that poke the old registers directly (RPi.GPIO, pigpio, WiringPi) stop working. Use gpiozero (with the lgpio backend), the gpiod tools, or libraries updated for the Pi 5.
Try it: LED resistor calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Mixing BCM and physical numbers, so the wrong pin toggles.
- Connecting 5 V sensor outputs to GPIO pins.
- Drawing more than a few milliamps from a pin.
- Using pins 27 and 28 (ID EEPROM), which are reserved for HATs.
- Shorting 5 V to 3.3 V or GPIO while probing a live header.
Frequently asked questions
Which Raspberry Pi pins are 5 V?
Physical pins 2 and 4 supply 5 V. Pins 1 and 17 supply 3.3 V. All GPIO pins are 3.3 V logic.
How much current can a Raspberry Pi GPIO pin supply?
About 16 mA per pin and around 50 mA in total across all GPIO. Use a transistor or driver for anything more.
Is the Raspberry Pi 5 pinout the same as the Pi 4?
Yes. Every 40-pin Raspberry Pi shares the same header layout and GPIO numbers. Only the software library support changed on the Pi 5.
Which pins are I2C on the Raspberry Pi?
GPIO 2 (SDA) on physical pin 3 and GPIO 3 (SCL) on physical pin 5, with onboard 1.8 kΩ pull-ups to 3.3 V.
Does the Raspberry Pi have analog pins?
No. Use an external ADC such as the MCP3008 (SPI) or ADS1115 (I2C) to read analog sensors.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 9 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- Raspberry Pi hardware documentation: GPIO and the 40-pin header (Raspberry Pi Ltd)
- BCM2711 and RP1 peripheral documentation (Raspberry Pi Ltd)
- gpiozero documentation
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.


