Raspberry Pi — GPIO Pinout Quick Reference
raspberry pigpiopinoutreferencehardware1c3d
Markdown
Raspberry Pi — GPIO Pinout Quick Reference
All Raspberry Pi models with the 40-pin header (Pi 2, 3, 4, 5, Zero, Zero 2W) share the same GPIO pinout.
40-Pin Header Layout
Pins are numbered 1–40 left-to-right, top-to-bottom when the Pi is oriented with the USB ports facing down and the GPIO header at the top-right.
| Physical | BCM | Function | Physical | BCM | Function |
|---|---|---|---|---|---|
| 1 | — | 3.3V | 2 | — | 5V |
| 3 | 2 | I2C SDA1 | 4 | — | 5V |
| 5 | 3 | I2C SCL1 | 6 | — | GND |
| 7 | 4 | GPIO4 | 8 | 14 | UART TX |
| 9 | — | GND | 10 | 15 | UART RX |
| 11 | 17 | GPIO17 | 12 | 18 | GPIO18 (PWM0) |
| 13 | 27 | GPIO27 | 14 | — | GND |
| 15 | 22 | GPIO22 | 16 | 23 | GPIO23 |
| 17 | — | 3.3V | 18 | 24 | GPIO24 |
| 19 | 10 | SPI MOSI | 20 | — | GND |
| 21 | 9 | SPI MISO | 22 | 25 | GPIO25 |
| 23 | 11 | SPI CLK | 24 | 8 | SPI CE0 |
| 25 | — | GND | 26 | 7 | SPI CE1 |
| 27 | 0 | ID SDA | 28 | 1 | ID SCL |
| 29 | 5 | GPIO5 | 30 | — | GND |
| 31 | 6 | GPIO6 | 32 | 12 | GPIO12 (PWM0) |
| 33 | 13 | GPIO13 (PWM1) | 34 | — | GND |
| 35 | 19 | SPI1 MISO | 36 | 16 | GPIO16 |
| 37 | 26 | GPIO26 | 38 | 20 | SPI1 MOSI |
| 39 | — | GND | 40 | 21 | SPI1 CLK |
Key Interfaces
| Interface | Pins (BCM) | Notes |
|---|---|---|
| I2C (primary) | SDA=2, SCL=3 | 3.3V, 400kHz fast mode |
| SPI (primary) | MOSI=10, MISO=9, CLK=11, CE0=8, CE1=7 | |
| UART | TX=14, RX=15 | Disabled by default on Pi 3+ (used by Bluetooth) |
| PWM | GPIO12, GPIO13, GPIO18, GPIO19 | Hardware PWM |
| 3.3V power | Pins 1, 17 | Max 50mA total |
| 5V power | Pins 2, 4 | Direct from power supply — use carefully |
| GND | Pins 6, 9, 14, 20, 25, 30, 34, 39 |
Electrical Limits
- All GPIO are 3.3V logic — never apply 5V to GPIO inputs
- Max current per pin: 16mA (8mA recommended)
- Max total GPIO current: 50mA
- Use level shifters for 5V devices
- Use transistors/MOSFETs for anything drawing more than 16mA
Quick Reference Commands
# Visual pinout diagram in terminal
pinout
# Read all GPIO states
raspi-gpio get
# Set GPIO 17 as output, drive high
raspi-gpio set 17 op dh
# Set GPIO 4 as input with pull-up
raspi-gpio set 4 ip pu
Links
- pinout.xyz — interactive pinout diagram
- gpiozero docs — best Python GPIO library
- BCM2837 datasheet