Raspberry Pi Pinout

The Raspberry Pi's 40-pin GPIO header follows a fixed, well-documented layout, and knowing which physical pin maps to which power rail or GPIO/BCM number is essential before wiring anything to it.

The 40-Pin Header

Every current full-size Raspberry Pi board, along with the Zero line, shares the same 40-pin header layout, arranged as two rows of 20 pins. Pin 1 is the corner closest to the SD card slot, usually marked with a square solder pad or a small "1" printed on the board itself; odd-numbered pins run down one row and even-numbered pins down the other. Because the layout is standardized across models, a HAT (Hardware Attached on Top) or breakout board designed for one modern Pi will physically line up on any other.

Physical PinFunction
13.3V power
25V power
3GPIO2 (I2C1 SDA)
45V power
5GPIO3 (I2C1 SCL)
6Ground
7GPIO4
8GPIO14 (UART TXD)
9Ground
10GPIO15 (UART RXD)
11GPIO17
12GPIO18 (PWM)
13GPIO27
14Ground
15GPIO22
16GPIO23
173.3V power
18GPIO24
19GPIO10 (SPI0 MOSI)
20Ground
21GPIO9 (SPI0 MISO)
22GPIO25
23GPIO11 (SPI0 SCLK)
24GPIO8 (SPI0 CE0)
25Ground
26GPIO7 (SPI0 CE1)
27ID_SD (reserved, HAT EEPROM)
28ID_SC (reserved, HAT EEPROM)
29GPIO5
30Ground
31GPIO6
32GPIO12 (PWM)
33GPIO13 (PWM)
34Ground
35GPIO19 (PWM)
36GPIO16
37GPIO26
38GPIO20
39Ground
40GPIO21

Power Pins

The header carries two kinds of power rail. Pins 2 and 4 supply 5V taken almost directly from whatever power source feeds the board, so they carry more current but bypass onboard regulation, meaning they're better suited to powering small add-on boards than sensitive sensors. Pins 1 and 17 supply 3.3V through the board's onboard regulator, which has a limited total current budget shared across everything connected to it, so it suits low-power sensors and logic rather than motors or bright LED strips.

Ground Pins

Eight pins on the header (6, 9, 14, 20, 25, 30, 34, and 39) are all ground, and electrically they're all the same net, so it doesn't matter which one you use. A complete circuit always needs a ground connection back to the Pi in addition to whichever signal or power pin you're using, so pick whichever ground pin is physically convenient for your wiring.

Special-Function Pins

  • I2C (physical pins 3 and 5, GPIO2/GPIO3): a two-wire bus for sensors and small displays that support addressing multiple devices on the same two lines
  • SPI (physical pins 19, 21, 23, 24, and 26): a faster bus typically used for displays, SD card readers, and analog-to-digital converters
  • UART (physical pins 8 and 10, GPIO14/GPIO15): a simple serial link, often used for a debug console or communicating with serial hardware like GPS modules
  • PWM-capable pins (including GPIO12, GPIO13, GPIO18, and GPIO19): useful for dimming LEDs or controlling servo motors
Note: Pins 27 and 28 (ID_SD and ID_SC) are reserved for HAT identification, letting an add-on board's EEPROM tell the Pi what it is and how to configure itself automatically. Avoid using these two pins for general-purpose wiring.

Printing Your Board's Pinout

# gpiozero ships with Raspberry Pi OS by default
pinout
# Prints an ASCII diagram of your specific board's header,
# with physical pin numbers and BCM/GPIO numbers shown side by side
Note: Never assume a physical pin number equals its BCM/GPIO number; they only coincidentally match for a couple of pins. For example, physical pin 7 is GPIO4, and physical pin 11 is GPIO17. Always check a pinout reference, or run the pinout command, before wiring or writing code against a pin number.