← Pinout library
Raspberry Pi GPIO pinout (40-pin header)
Every Raspberry Pi since the B+ has the same 40-pin header, so this map fits the Pi 5, Pi 4, Pi 3, Zero 2 W and Zero. Pin 1 is the square pad nearest the corner, marked 3V3. Code usually uses the GPIO (BCM) numbers, not the physical pin numbers.
- Power
- Ground
- GPIO
- Bus (I2C, SPI, UART)
- Special: read the note
40-pin header
13V3
25V
3GPIO 2I2C1 SDA
45V
5GPIO 3I2C1 SCL
6GND
7GPIO 4GPCLK0
8GPIO 14UART TXD
9GND
10GPIO 15UART RXD
11GPIO 17
12GPIO 18PWM0, PCM CLK
13GPIO 27
14GND
15GPIO 22
16GPIO 23
173V3
18GPIO 24
19GPIO 10SPI0 MOSI
20GND
21GPIO 9SPI0 MISO
22GPIO 25
23GPIO 11SPI0 SCLK
24GPIO 8SPI0 CE0
25GND
26GPIO 7SPI0 CE1
27GPIO 0ID_SD
28GPIO 1ID_SC
29GPIO 5
30GND
31GPIO 6
32GPIO 12PWM0
33GPIO 13PWM1
34GND
35GPIO 19PWM1, SPI1 MISO, PCM FS
36GPIO 16SPI1 CE2
37GPIO 26
38GPIO 20SPI1 MOSI, PCM DIN
39GND
40GPIO 21SPI1 SCLK, PCM DOUT
- Pin 27 (GPIO 0): HAT EEPROM, leave free
- Pin 28 (GPIO 1): HAT EEPROM, leave free
Good to know
- GPIO pins are 3.3 V only and are not 5 V tolerant: a 5 V signal can damage the Pi. Use a level shifter or a voltage divider.
- Keep the current from each GPIO pin to a few mA (an LED with a 330 Ω or larger resistor is fine). Drive motors, relays and LED strips through a transistor, MOSFET or driver.
- The 3V3 pins supply only a small current for sensors. The 5V pins connect straight to the power input, so a short there can reset or damage the Pi.
- I2C1 (GPIO 2 and 3) has 1.8 kΩ pull-up resistors to 3.3 V on the board. Enable I2C, SPI and the serial port in raspi-config first.
- On the Pi 5 the GPIO is driven by the RP1 chip: use libgpiod, gpiozero or lgpio, as the older RPi.GPIO library does not work.


