Raspberry Pi Pinout – Interactive GPIO Board

Last updated: November 2026

Our interactive Raspberry Pi GPIO Pinout shows all 40 GPIO pins at a glance – click any pin for its BCM number, function, and code example. The layout is identical across Pi 3, Pi 4, Pi 5, Pi 400, and Zero 2 W. Official reference: raspberrypi.com/documentation/computers/raspberry-pi.html

👉 Click on a pin, USB port, or Ethernet port for details.

Numbering / Naming Schemas of GPIO Pins

GPIO numbering is inconsistent and can be confusing – even I have to check my own posts repeatedly to see which specification is meant. The simplest is the physical numbering, as it is the same across all Raspberry Pi models.

The Three Common Numbering Systems

  • Physical Numbering (Board) – Pin 1 is the pin with the square solder pad on the back of the Raspberry Pi. Counted from top left to bottom right.
  • BCM Numbering – Refers to the GPIO pins according to the Broadcom SoC pin assignment (e.g., GPIO2, GPIO3). Used by Python libraries like RPi.GPIO and gpiozero.
  • WiringPi Numbering – Custom schema of the WiringPi library, hardly relevant today.

Recommendation: Use BCM numbering – it is the standard in current tutorials and libraries.

Important: Raspberry Pi 5

On the Raspberry Pi 5, all GPIO pins are controlled via the new RP1 I/O coprocessor. The physical 40-pin layout is identical, but the original RPi.GPIO library doesn’t run on it. Old scripts with import RPi.GPIO usually keep working through rpi-lgpio, which Raspberry Pi OS has included since October 2024 (on older installs: sudo apt install python3-rpi-lgpio). For new projects, use gpiozero or lgpio. The Pi 5’s GPIO pins still use 3.3V logic and are not 5V tolerant either – use a level shifter for 5V signals.

USB Ports

The number and speed of the USB ports depend on the Raspberry Pi model:

ModelUSB Ports
Raspberry Pi 52× USB 3.0 (5 Gbps) + 2× USB 2.0
Raspberry Pi 4 Model B2× USB 3.0 (5 Gbps) + 2× USB 2.0
Raspberry Pi 4002× USB 3.0 + 1× USB 2.0
Raspberry Pi 3 Model B+4× USB 2.0
Raspberry Pi Zero 2 W1× Micro-USB OTG (USB 2.0)

On older models (Pi 1–3), the USB controller and Ethernet port share the same bus, which limits throughput. From Pi 4 onwards, USB 3.0 and Gigabit Ethernet are completely separate.

Per USB port, devices with up to 500 mA (USB 2.0) or 900 mA (USB 3.0) are intended. For hard drives without their own power supply, an active USB hub is recommended.

Ethernet Port

The Ethernet port is model dependent:

ModelEthernet
Raspberry Pi 5Gigabit Ethernet (true Gbit, PoE+ with HAT)
Raspberry Pi 4 Model BTrue Gigabit Ethernet
Raspberry Pi 3 Model B+Gigabit Ethernet over USB 2.0 (max. ~300 Mbps)
Raspberry Pi 3 Model B100 Mbps Fast Ethernet
Raspberry Pi Zero 2 WNo Ethernet (WLAN only)

From the Raspberry Pi 4 onwards, the Ethernet controller is connected directly to the PCIe bus – this achieves true Gigabit speeds. Network Boot (booting without an SD card via the network) is possible from Pi 3 and is activated by default on Pi 4/5.

WLAN Info

ModelWLANBluetooth
Raspberry Pi 5Dual-Band 802.11ac (2.4 + 5 GHz)Bluetooth 5.0 / BLE
Raspberry Pi 4 Model BDual-Band 802.11ac (2.4 + 5 GHz)Bluetooth 5.0 / BLE
Raspberry Pi 3 Model B+Dual-Band 802.11ac (2.4 + 5 GHz)Bluetooth 4.2 / BLE
Raspberry Pi 3 Model B2.4 GHz 802.11nBluetooth 4.1
Raspberry Pi Zero 2 W2.4 GHz 802.11 b/g/nBluetooth 4.2 / BLE
Raspberry Pi Zero W2.4 GHz 802.11 b/g/nBluetooth 4.1

Tip: When using WLAN on older models (Pi 3), deactivate Bluetooth, as both modules use the same chip and can influence each other. From Pi 4 onwards, this is no longer a problem.

Setting up WLAN on the Raspberry Pi is described in this article.

Power Button

The Raspberry Pi 5 is the first Raspberry Pi with a built-in power button. The small button sits on the edge of the board next to the USB-C port, so you no longer have to pull the plug.

How the Power Button Works on the Pi 5

  • Pi is off: a short press starts it.
  • Pi is running (desktop): one short press opens the shutdown menu, two short presses shut the system down cleanly right away.
  • No desktop (Lite/headless): one short press triggers a clean shutdown.
  • Press and hold: hard power-off. Use it only in an emergency, as you risk losing data.

After shutting down, the Pi 5 still draws a little over 1 watt. With POWER_OFF_ON_HALT=1 in the EEPROM configuration (sudo rpi-eeprom-config -e), standby power drops to almost zero, and the power button still wakes the Pi reliably.

External Button via the J2 Pads

Right next to the battery connector for the real-time clock, the Pi 5 has two small solder pads (J2). A button wired to them behaves exactly like the built-in power button, which is handy for cases where the onboard button is hard to reach.

Older Models: Add a Power Button via GPIO3

The Pi 4 and older models don’t have a power button, but you can add one with a push button between Pin 5 (GPIO3) and Pin 6 (Ground):

  • Wake up: while the Pi is halted, briefly connecting GPIO3 to ground starts it. No configuration needed.
  • Shut down: with dtoverlay=gpio-shutdown in config.txt, the same button triggers a clean shutdown while the Pi is running.

Note: GPIO3 is also the I2C clock line (SCL), so this trick won’t work if you run I2C devices on pins 3/5. On the Raspberry Pi 400 and Pi 500, the keyboard takes care of the power function.

Bluetooth

Every Raspberry Pi since the Pi 3 has Bluetooth built in, including Bluetooth Low Energy (BLE). WLAN and Bluetooth share a single radio chip and antenna.

ModelBluetooth
Raspberry Pi 5 / Pi 500Bluetooth 5.0 / BLE
Raspberry Pi 4 Model B / Pi 400Bluetooth 5.0 / BLE
Raspberry Pi 3 Model B+Bluetooth 4.2 / BLE
Raspberry Pi 3 Model BBluetooth 4.1
Raspberry Pi Zero 2 WBluetooth 4.2 / BLE
Raspberry Pi Zero WBluetooth 4.1

Bluetooth and the Serial Port

On the Pi 3 and Pi 4, Bluetooth uses the fast hardware UART (PL011) by default, so the serial port on pins 8/10 has to make do with the slower mini UART. If you need a reliable GPIO UART, for a GPS module for example, you can turn Bluetooth off with dtoverlay=disable-bt in config.txt. The Raspberry Pi 5 doesn’t have this problem, because the RP1 controller provides its own UARTs.

The easiest way to pair devices is the Bluetooth menu on the desktop, or bluetoothctl in the terminal.

Pin 1 – 3.3V Power Supply

Voltage: 3.3VType: SupplyMax. Current: 50mA total

Physical Pin 1 provides a constant voltage of 3.3V, fed from the internal voltage regulator of the Raspberry Pi. The maximum load per pin is 16 mA. If multiple 3.3V pins are used simultaneously, the total load across all 3.3V GPIOs must not exceed 50 mA. Twin pin with the same function: Pin 17. Pin 1 can always be recognized by the square solder pad on the back of the circuit board.

Typical Use

  • Powering 3.3V sensors (BME280, DHT22, OLED displays)
  • Reference voltage for level shifters (3.3V to 5V)
  • Powering microcontrollers (Arduino Pro Mini 3.3V)

Caution: Excessive current consumption can destabilize the 3.3V rail and cause the Pi to crash. No short-circuit protection available.

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 2 – 5V Power Supply

Voltage: 5VType: SupplyCurrent: PSU-dependent

Physical Pin 2 is directly connected to the 5V supply line of the Raspberry Pi. The voltage comes unfiltered from the power supply. Twin pin: Pin 4.

The available current depends on the power supply unit. An official Raspberry Pi 5 power supply (27W USB-C) delivers up to 5A. For connected consumers, a reserve of at least 500 mA should be planned for the Pi itself.

Typical Use

  • Powering 5V devices (fans, 5V relays, servo drivers)
  • Injecting an external 5V source (instead of USB power)
  • Powering level shifters (5V side)

Caution: GPIO pins are only designed for 3.3V. Never apply 5V directly to GPIO pins!

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 3 – BCM 2 (GPIO2) – I2C Bus 1 SDA (Data Line)

Phys. Pin: 3BCM: 2Type: I2C SDABus: 1

Physical Pin 3 (BCM GPIO2) is the data line (SDA) of I2C bus 1. I2C (Inter-Integrated Circuit) is a 2-wire serial bus where data is transmitted synchronously between a master (Raspberry Pi) and several slaves (sensors, displays). Both lines require pull-up resistors (typically 4.7 kOhm – many modules already have these integrated).

Activate I2C: sudo raspi-config → Interfacing Options → I2C → Enable, then restart.

Show connected devices:

i2cdetect -y 1

Python Code Example (smbus2)

import smbus2

bus = smbus2.SMBus(1)          # I2C bus 1
addr = 0x76                    # Example: BME280

# Read register
value = bus.read_byte_data(addr, 0xD0)
print(f"Chip ID: {value:#x}")
bus.close()

Typical Use

  • Temperature/Air pressure sensors (BME280, BMP180, BMP280)
  • OLED displays (SSD1306)
  • Real-time clock modules (DS3231)
  • A/D converters (ADS1115)
  • GPIO expanders (MCP23017)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSDA1SA3LCD_VSYNCAVEOUT_VSYNCAVEIN_VSYNC–
Pi 4, 400SDA1SA3LCD_VSYNCSPI3_MOSICTS2SDA3

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 2 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_CE3DPI_VSYNCCTS1SDA1IR_RX0SPI2_SIO0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 4 – 5V Power Supply

Voltage: 5VType: SupplyCurrent: PSU-dependent

Physical Pin 4 is directly connected to the 5V supply line of the Raspberry Pi. The voltage comes unfiltered from the power supply. Twin pin: Pin 2.

The available current depends on the power supply unit. An official Raspberry Pi 5 power supply (27W USB-C) delivers up to 5A. For connected consumers, a reserve of at least 500 mA should be planned for the Pi itself.

Typical Use

  • Powering 5V devices (fans, 5V relays, servo drivers)
  • Injecting an external 5V source (instead of USB power)
  • Powering level shifters (5V side)

Caution: GPIO pins are only designed for 3.3V. Never apply 5V directly to GPIO pins!

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 5 – BCM 3 (GPIO3) – I2C Bus 1 SCL (Clock Line)

Phys. Pin: 5BCM: 3Type: I2C SCLBus: 1

Physical Pin 5 (BCM GPIO3) is the clock line (SCL) of I2C bus 1. I2C (Inter-Integrated Circuit) is a 2-wire serial bus where data is transmitted synchronously between a master (Raspberry Pi) and several slaves (sensors, displays). Both lines require pull-up resistors (typically 4.7 kOhm – many modules already have these integrated).

Activate I2C: sudo raspi-config → Interfacing Options → I2C → Enable, then restart.

Show connected devices:

i2cdetect -y 1

Python Code Example (smbus2)

import smbus2

bus = smbus2.SMBus(1)          # I2C bus 1
addr = 0x76                    # Example: BME280

# Read register
value = bus.read_byte_data(addr, 0xD0)
print(f"Chip ID: {value:#x}")
bus.close()

Typical Use

  • Temperature/Air pressure sensors (BME280, BMP180, BMP280)
  • OLED displays (SSD1306)
  • Real-time clock modules (DS3231)
  • A/D converters (ADS1115)
  • GPIO expanders (MCP23017)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSCL1SA2LCD_HSYNCAVEOUT_HSYNCAVEIN_HSYNC–
Pi 4, 400SCL1SA2LCD_HSYNCSPI3_SCLKRTS2SCL3

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 3 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_CE2DPI_HSYNCRTS1SCL1IR_TX0SPI2_SCLK

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 6 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 6 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 7 – BCM 4 (GPIO4) – GPCLK0 (General Purpose Clock)

Phys. Pin: 7BCM: 4Type: GPIO / GPCLKFrequency (Pi 1–4): up to ~125MHz

Physical Pin 7 (BCM GPIO4) is a free GPIO in default mode. In ALT0 mode, it is available as General Purpose Clock 0 (GPCLK0) and generates a hardware clock signal without CPU load. On the Pi 1 to 3, you can set the frequency from about 4.7 kHz, and from about 13 kHz on the Pi 4. The datasheet gives roughly 125 MHz as the upper limit, less on heavily loaded pins. On the Pi 5, the RP1 chip generates the clock, and GPCLK0 is function a0 there.

A Note on pigpio

Older guides use pigpio to generate the clock signal. That doesn’t work on the Raspberry Pi 5, and current Raspberry Pi OS no longer offers the pigpio daemon as a package.

Typical Use

  • Clock signal for external ICs (Ethernet controllers, audio codecs)
  • Frequency generator / test signal
  • Synchronization of external circuits

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroGPCLK0SA1DPI_D0AVEOUT_VID0AVEIN_VID0ARM_TDI
Pi 4, 400GPCLK0SA1DPI_D0SPI4_CE0_NTXD3SDA3

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 4 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5GPCLK0DPI_D0TXD2SDA2RI0SPI3_CE0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 8 – BCM 14 (GPIO14) – UART TXD0 (Transmit Line)

Phys. Pin: 8BCM: 14Type: UART TXD0Level: 3.3V

Physical Pin 8 (BCM GPIO14) is the transmit line (TXD0) of the primary UART interface. UART (Universal Asynchronous Receiver Transmitter) transmits data serially without a separate clock signal. Typical baud rate: 115200 baud. The level is 3.3V – for connections with 5V systems (Arduino), a level shifter is necessary.

Activate UART: In /boot/firmware/config.txt (Pi 5) or /boot/config.txt (Pi 4), add at the end: enable_uart=1
In /boot/cmdline.txt, remove the entry console=serial0,115200 so that the Linux console does not block the port. Then restart.

Python Code Example (pyserial)

import serial

ser = serial.Serial("/dev/serial0", baudrate=115200, timeout=1)
ser.write(b"Hello from Raspberry Pi!n")
line = ser.readline()
print(line.decode("utf-8", errors="replace"))
ser.close()

Typical Use

  • Serial terminal / Debug console (USB-UART adapter)
  • Communication with Arduino, ESP32, GPS modules
  • Controlling Bluetooth modules (HC-05/06)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroTXD0SD6DPI_D10AVEOUT_VID10AVEIN_VID10TXD1
Pi 4, 400TXD0SD6DPI_D10SPI5_MOSICTS5TXD1

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 14 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5PWM0_CHAN2DPI_D10CTS4SDA3TXD0SPI5_SIO0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 9 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 9 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 10 – BCM 15 (GPIO15) – UART RXD0 (Receive Line)

Phys. Pin: 10BCM: 15Type: UART RXD0Level: 3.3V

Physical Pin 10 (BCM GPIO15) is the receive line (RXD0) of the primary UART interface. UART (Universal Asynchronous Receiver Transmitter) transmits data serially without a separate clock signal. Typical baud rate: 115200 baud. The level is 3.3V – for connections with 5V systems (Arduino), a level shifter is necessary.

Activate UART: In /boot/firmware/config.txt (Pi 5) or /boot/config.txt (Pi 4), add at the end: enable_uart=1
In /boot/cmdline.txt, remove the entry console=serial0,115200 so that the Linux console does not block the port. Then restart.

Python Code Example (pyserial)

import serial

ser = serial.Serial("/dev/serial0", baudrate=115200, timeout=1)
ser.write(b"Hello from Raspberry Pi!n")
line = ser.readline()
print(line.decode("utf-8", errors="replace"))
ser.close()

Typical Use

  • Serial terminal / Debug console (USB-UART adapter)
  • Communication with Arduino, ESP32, GPS modules
  • Controlling Bluetooth modules (HC-05/06)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroRXD0SD7DPI_D11AVEOUT_VID11AVEIN_VID11RXD1
Pi 4, 400RXD0SD7DPI_D11SPI5_SCLKRTS5RXD1

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 15 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5PWM0_CHAN3DPI_D11RTS4SCL3RXD0SPI5_SCLK

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 11 – BCM 17 (GPIO17)

Phys. Pin: 11BCM: 17Type: GPIOLevel: 3.3V

Physical Pin 11 corresponds to BCM GPIO17. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors. In ALT3 mode, it can be used as UART0 RTS0, and in ALT4 mode as SPI1 CE1.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 17)   # BCM 17 as output

lgpio.gpio_write(h, 17, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 17, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • Switching LED or relay
  • Reading a button
  • Sending a digital signal

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroFL1SD9DPI_D13RTS0SPI1_CE1_NRTS1
Pi 4, 400–SD9DPI_D13RTS0SPI1_CE1_NRTS1

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 17 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI1_CE1DPI_D13DSI1_TE_EXT–RTS0–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 12 – BCM 18 (GPIO18) – PWM0

Phys. Pin: 12BCM: 18Type: GPIO / PWMHW PWM: Channel 0 (Pi 5: 2)

Physical Pin 12 (BCM GPIO18) supports Hardware PWM (Channel 0, Channel 2 on the Pi 5) in addition to normal GPIO function. Pulse Width Modulation (PWM) generates a square wave signal with variable duty cycle. Hardware PWM is generated directly by the internal timer block and does not cause any CPU load.

Python Code Example (Software PWM via lgpio)

import lgpio, time

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 18)
# Software PWM: Frequency 50 Hz, Duty Cycle 50%
lgpio.tx_pwm(h, 18, 50, 50)
time.sleep(2)
lgpio.tx_pwm(h, 18, 50, 0)   # Stop
lgpio.gpiochip_close(h)

Typical Use

  • Controlling an RC servo (50 Hz, 1-2 ms pulse width)
  • Dimming LED brightness
  • Regulating fan speed
  • Audio output (low-budget DAC)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroPCM_CLKSD10DPI_D14I2CSL_SDA_MOSISPI1_CE0_NPWM0
Pi 4, 400PCM_CLKSD10DPI_D14SPI6_CE0_NSPI1_CE0_NPWM0_0

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 18 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI1_CE0DPI_D14I2S0_SCLKPWM0_CHAN2I2S1_SCLKGPCLK1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 13 – BCM 27 (GPIO27)

Phys. Pin: 13BCM: 27Type: GPIOLevel: 3.3V

Physical Pin 13 corresponds to BCM GPIO27. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 27)   # BCM 27 as output

lgpio.gpio_write(h, 27, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 27, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • Controlling LED / Buzzer
  • Reading button / sensor

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSD0_DAT3TE1DPI_D23SD1_DAT3ARM_TMS–
Pi 4, 400SD0_DAT3–DPI_D23SD1_DAT3ARM_TMSSPI6_CE1_N

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 27 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SD0_DAT3DPI_D23I2S0_SDO3MIC_DAT1I2S1_SDO3SPI1_CE1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 14 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 14 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 15 – BCM 22 (GPIO22)

Phys. Pin: 15BCM: 22Type: GPIOLevel: 3.3V

Physical Pin 15 corresponds to BCM GPIO22. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 22)   # BCM 22 as output

lgpio.gpio_write(h, 22, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 22, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • Switching output
  • Interrupt input

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSD0_CLKSD14DPI_D18SD1_CLKARM_TRST–
Pi 4, 400SD0_CLKSD14DPI_D18SD1_CLKARM_TRSTSDA6

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 22 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SD0_CLKDPI_D18I2S0_SDI1SDA3I2S1_SDI1–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 16 – BCM 23 (GPIO23)

Phys. Pin: 16BCM: 23Type: GPIOLevel: 3.3V

Physical Pin 16 corresponds to BCM GPIO23. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 23)   # BCM 23 as output

lgpio.gpio_write(h, 23, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 23, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • LED control
  • Reading button signal

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSD0_CMDSD15DPI_D19SD1_CMDARM_RTCK–
Pi 4, 400SD0_CMDSD15DPI_D19SD1_CMDARM_RTCKSCL6

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 23 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SD0_CMDDPI_D19I2S0_SDO1SCL3I2S1_SDO1–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 17 – 3.3V Power Supply

Voltage: 3.3VType: SupplyMax. Current: 50mA total

Physical Pin 17 provides a constant voltage of 3.3V, fed from the internal voltage regulator of the Raspberry Pi. The maximum load per pin is 16 mA. If multiple 3.3V pins are used simultaneously, the total load across all 3.3V GPIOs must not exceed 50 mA. Twin pin with the same function: Pin 1.

Typical Use

  • Powering 3.3V sensors (BME280, DHT22, OLED displays)
  • Reference voltage for level shifters (3.3V to 5V)
  • Powering microcontrollers (Arduino Pro Mini 3.3V)

Caution: Excessive current consumption can destabilize the 3.3V rail and cause the Pi to crash. No short-circuit protection available.

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 18 – BCM 24 (GPIO24)

Phys. Pin: 18BCM: 24Type: GPIOLevel: 3.3V

Physical Pin 18 corresponds to BCM GPIO24. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 24)   # BCM 24 as output

lgpio.gpio_write(h, 24, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 24, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • HC-SR04 Echo pin
  • Reading button signal

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSD0_DAT0SD16DPI_D20SD1_DAT0ARM_TDO–
Pi 4, 400SD0_DAT0SD16DPI_D20SD1_DAT0ARM_TDOSPI3_CE1_N

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 24 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SD0_DAT0DPI_D20I2S0_SDI2–I2S1_SDI2SPI2_CE1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 19 – BCM 10 (GPIO10) – SPI0 MOSI (Master-Out Slave-In)

Phys. Pin: 19BCM: 10Type: SPI0 MOSIBus: 0

Physical Pin 19 (BCM GPIO10) is the Master-Out Slave-In (MOSI) of SPI bus 0. SPI (Serial Peripheral Interface) is a synchronous 4-wire serial protocol based on the master-slave principle with high data transfer rates (up to several MHz). Unlike I2C, each SPI device requires its own Chip Enable (CE) line.

Activate SPI: sudo raspi-config → Interfacing Options → SPI → Enable, then restart.

SPI Lines at a Glance

  • MOSI (Pin 19 / 38) – Master sends, Slave receives
  • MISO (Pin 21 / 35) – Slave sends, Master receives
  • SCLK (Pin 23 / 40) – Clock signal from the Master
  • CE0/CE1/CE2 (Pin 24 / 26 / 36) – Chip Enable (Slave selection)

Python Code Example (spidev)

import spidev

spi = spidev.SpiDev()
spi.open(0, 0)           # Bus 0, CE0
spi.max_speed_hz = 1000000

# Send byte and receive simultaneously
response = spi.xfer2([0x01, 0x80, 0x00])
print(f"Response: {response}")
spi.close()

Typical Use

  • SPI displays (ILI9341, ST7789)
  • A/D converters (MCP3008)
  • RFID modules (RC522)
  • Accelerometers (MPU6000)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSPI0_MOSISD2DPI_D6AVEOUT_VID6AVEIN_VID6–
Pi 4, 400SPI0_MOSISD2DPI_D6I2CSL_SDA_MOSICTS4SDA5

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 10 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_MOSIDPI_D6CTS3SDA1–SPI4_SIO1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 20 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 20 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 21 – BCM 9 (GPIO9) – SPI0 MISO (Master-In Slave-Out)

Phys. Pin: 21BCM: 9Type: SPI0 MISOBus: 0

Physical Pin 21 (BCM GPIO9) is the Master-In Slave-Out (MISO) of SPI bus 0. SPI (Serial Peripheral Interface) is a synchronous 4-wire serial protocol based on the master-slave principle with high data transfer rates (up to several MHz). Unlike I2C, each SPI device requires its own Chip Enable (CE) line.

Activate SPI: sudo raspi-config → Interfacing Options → SPI → Enable, then restart.

SPI Lines at a Glance

  • MOSI (Pin 19 / 38) – Master sends, Slave receives
  • MISO (Pin 21 / 35) – Slave sends, Master receives
  • SCLK (Pin 23 / 40) – Clock signal from the Master
  • CE0/CE1/CE2 (Pin 24 / 26 / 36) – Chip Enable (Slave selection)

Python Code Example (spidev)

import spidev

spi = spidev.SpiDev()
spi.open(0, 0)           # Bus 0, CE0
spi.max_speed_hz = 1000000

# Send byte and receive simultaneously
response = spi.xfer2([0x01, 0x80, 0x00])
print(f"Response: {response}")
spi.close()

Typical Use

  • SPI displays (ILI9341, ST7789)
  • A/D converters (MCP3008)
  • RFID modules (RC522)
  • Accelerometers (MPU6000)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSPI0_MISOSD1DPI_D5AVEOUT_VID5AVEIN_VID5–
Pi 4, 400SPI0_MISOSD1DPI_D5I2CSL_SDI_MISORXD4SCL4

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 9 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_MISODPI_D5RXD3SCL0–SPI4_SIO0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 22 – BCM 25 (GPIO25)

Phys. Pin: 22BCM: 25Type: GPIOLevel: 3.3V

Physical Pin 22 corresponds to BCM GPIO25. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 25)   # BCM 25 as output

lgpio.gpio_write(h, 25, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 25, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • Reset signal for external chips
  • LED indicator

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSD0_DAT1SD17DPI_D21SD1_DAT1ARM_TCK–
Pi 4, 400SD0_DAT1SD17DPI_D21SD1_DAT1ARM_TCKSPI4_CE1_N

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 25 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SD0_DAT1DPI_D21I2S0_SDO2MIC_CLKI2S1_SDO2SPI3_CE1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 23 – BCM 11 (GPIO11) – SPI0 SCLK (Clock Signal)

Phys. Pin: 23BCM: 11Type: SPI0 SCLKBus: 0

Physical Pin 23 (BCM GPIO11) is the clock signal (SCLK) of SPI bus 0. SPI (Serial Peripheral Interface) is a synchronous 4-wire serial protocol based on the master-slave principle with high data transfer rates (up to several MHz). Unlike I2C, each SPI device requires its own Chip Enable (CE) line.

Activate SPI: sudo raspi-config → Interfacing Options → SPI → Enable, then restart.

SPI Lines at a Glance

  • MOSI (Pin 19 / 38) – Master sends, Slave receives
  • MISO (Pin 21 / 35) – Slave sends, Master receives
  • SCLK (Pin 23 / 40) – Clock signal from the Master
  • CE0/CE1/CE2 (Pin 24 / 26 / 36) – Chip Enable (Slave selection)

Python Code Example (spidev)

import spidev

spi = spidev.SpiDev()
spi.open(0, 0)           # Bus 0, CE0
spi.max_speed_hz = 1000000

# Send byte and receive simultaneously
response = spi.xfer2([0x01, 0x80, 0x00])
print(f"Response: {response}")
spi.close()

Typical Use

  • SPI displays (ILI9341, ST7789)
  • A/D converters (MCP3008)
  • RFID modules (RC522)
  • Accelerometers (MPU6000)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSPI0_SCLKSD3DPI_D7AVEOUT_VID7AVEIN_VID7–
Pi 4, 400SPI0_SCLKSD3DPI_D7I2CSL_SCL_SCLKRTS4SCL5

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 11 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_SCLKDPI_D7RTS3SCL1–SPI4_SCLK

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 24 – BCM 8 (GPIO8) – SPI0 CE0 (Chip Enable 0)

Phys. Pin: 24BCM: 8Type: SPI0 CE0Bus: 0

Physical Pin 24 (BCM GPIO8) is the Chip Enable 0 (CE0, also Chip Select) of SPI bus 0. With the CE signal, the master selects the desired slave chip by pulling the line LOW. Another SPI device can be operated on the same bus via CE1.

Further SPI lines: MOSI (Pin 19/38), MISO (Pin 21/35), SCLK (Pin 23/40), CE0 (Pin 24), CE1 (Pin 26), CE2 (Pin 36).

Typical Use

  • Operating a second SPI device alongside CE0 (e.g., two RFID modules)
  • Display on CE0, memory IC on CE1

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSPI0_CE0_NSD0DPI_D4AVEOUT_VID4AVEIN_VID4–
Pi 4, 400SPI0_CE0_NSD0DPI_D4I2CSL_CE_NTXD4SDA4

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 8 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_CE0DPI_D4TXD3SDA0–SPI4_CE0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 25 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 25 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 26 – BCM 7 (GPIO7) – SPI0 CE1 (Chip Enable 1)

Phys. Pin: 26BCM: 7Type: SPI0 CE1Bus: 0

Physical Pin 26 (BCM GPIO7) is the Chip Enable 1 (CE1, also Chip Select) of SPI bus 0. With the CE signal, the master selects the desired slave chip by pulling the line LOW. Another SPI device can be operated on the same bus via CE1.

Further SPI lines: MOSI (Pin 19/38), MISO (Pin 21/35), SCLK (Pin 23/40), CE0 (Pin 24), CE1 (Pin 26), CE2 (Pin 36).

Typical Use

  • Operating a second SPI device alongside CE0 (e.g., two RFID modules)
  • Display on CE0, memory IC on CE1

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSPI0_CE1_NSWE_N_SRW_NDPI_D3AVEOUT_VID3AVEIN_VID3–
Pi 4, 400SPI0_CE1_NSWE_N_SRW_NDPI_D3SPI4_SCLKRTS3SCL4

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 7 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_CE1DPI_D3RTS2SCL3DSR0SPI3_SCLK

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 27 – BCM 0 (GPIO0) – I2C ID EEPROM SDA (Data Line)

Phys. Pin: 27BCM: 0Type: I2C EEPROM SDA

Physical Pin 27 (BCM GPIO0) belongs to the special I2C bus 0, which is reserved exclusively for the automatic recognition of HAT (Hardware Attached on Top) expansion boards. At startup, the Raspberry Pi reads an EEPROM on the HAT via this bus and configures itself automatically.

Important: This bus is not suitable for custom sensors – it is controlled by the GPU firmware. For your own I2C devices, use I2C bus 1 (Pin 3 + Pin 5) instead.

Typical Use

  • HAT EEPROM detection (automatic, no user code necessary)
  • In exceptional cases: Bus 0 can be released in config.txt: dtparam=i2c0=on

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSDA0SA5PCLKAVEOUT_VCLKAVEIN_VCLK–
Pi 4, 400SDA0SA5PCLKSPI3_CE0_NTXD2SDA6

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 0 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_SIO3DPI_PCLKTXD1SDA0–SPI2_CE0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 28 – BCM 1 (GPIO1) – I2C ID EEPROM SCL (Clock Line)

Phys. Pin: 28BCM: 1Type: I2C EEPROM SCL

Physical Pin 28 (BCM GPIO1) belongs to the special I2C bus 0, which is reserved exclusively for the automatic recognition of HAT (Hardware Attached on Top) expansion boards. At startup, the Raspberry Pi reads an EEPROM on the HAT via this bus and configures itself automatically.

Important: This bus is not suitable for custom sensors – it is controlled by the GPU firmware. For your own I2C devices, use I2C bus 1 (Pin 3 + Pin 5) instead.

Typical Use

  • HAT EEPROM detection (automatic, no user code necessary)
  • In exceptional cases: Bus 0 can be released in config.txt: dtparam=i2c0=on

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSCL0SA4DEAVEOUT_DSYNCAVEIN_DSYNC–
Pi 4, 400SCL0SA4DESPI3_MISORXD2SCL6

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 1 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI0_SIO2DPI_DERXD1SCL0–SPI2_SIO1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 29 – BCM 5 (GPIO5)

Phys. Pin: 29BCM: 5Type: GPIOLevel: 3.3V

Physical Pin 29 corresponds to BCM GPIO5. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors. In ALT0 mode, it can be used as GPCLK1.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 5)   # BCM 5 as output

lgpio.gpio_write(h, 5, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 5, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • GPCLK1 in ALT0 mode
  • Sending a digital signal

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroGPCLK1SA0DPI_D1AVEOUT_VID1AVEIN_VID1ARM_TDO
Pi 4, 400GPCLK1SA0DPI_D1SPI4_MISORXD3SCL3

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 5 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5GPCLK1DPI_D1RXD2SCL2DTR0SPI3_SIO1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 30 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 30 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 31 – BCM 6 (GPIO6)

Phys. Pin: 31BCM: 6Type: GPIOLevel: 3.3V

Physical Pin 31 corresponds to BCM GPIO6. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors. In ALT0 mode, it can be used as GPCLK2.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 6)   # BCM 6 as output

lgpio.gpio_write(h, 6, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 6, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • GPCLK2 in ALT0 mode

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroGPCLK2SOE_N_SEDPI_D2AVEOUT_VID2AVEIN_VID2ARM_RTCK
Pi 4, 400GPCLK2SOE_N_SEDPI_D2SPI4_MOSICTS3SDA4

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 6 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5GPCLK2DPI_D2CTS2SDA3DCD0SPI3_SIO0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 32 – BCM 12 (GPIO12) – PWM0

Phys. Pin: 32BCM: 12Type: GPIO / PWMHW PWM: Channel 0

Physical Pin 32 (BCM GPIO12) supports Hardware PWM (Channel 0) in addition to normal GPIO function. Pulse Width Modulation (PWM) generates a square wave signal with variable duty cycle. Hardware PWM is generated directly by the internal timer block and does not cause any CPU load.

Python Code Example (Software PWM via lgpio)

import lgpio, time

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 12)
# Software PWM: Frequency 50 Hz, Duty Cycle 50%
lgpio.tx_pwm(h, 12, 50, 50)
time.sleep(2)
lgpio.tx_pwm(h, 12, 50, 0)   # Stop
lgpio.gpiochip_close(h)

Typical Use

  • Controlling an RC servo (50 Hz, 1-2 ms pulse width)
  • Dimming LED brightness
  • Regulating fan speed
  • Audio output (low-budget DAC)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroPWM0SD4DPI_D8AVEOUT_VID8AVEIN_VID8ARM_TMS
Pi 4, 400PWM0_0SD4DPI_D8SPI5_CE0_NTXD5SDA5

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 12 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5PWM0_CHAN0DPI_D8TXD4SDA2AAUD_LEFTSPI5_CE0

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 33 – BCM 13 (GPIO13) – PWM1

Phys. Pin: 33BCM: 13Type: GPIO / PWMHW PWM: Channel 1

Physical Pin 33 (BCM GPIO13) supports Hardware PWM (Channel 1) in addition to normal GPIO function. Pulse Width Modulation (PWM) generates a square wave signal with variable duty cycle. Hardware PWM is generated directly by the internal timer block and does not cause any CPU load.

Python Code Example (Software PWM via lgpio)

import lgpio, time

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 13)
# Software PWM: Frequency 50 Hz, Duty Cycle 50%
lgpio.tx_pwm(h, 13, 50, 50)
time.sleep(2)
lgpio.tx_pwm(h, 13, 50, 0)   # Stop
lgpio.gpiochip_close(h)

Typical Use

  • Controlling an RC servo (50 Hz, 1-2 ms pulse width)
  • Dimming LED brightness
  • Regulating fan speed
  • Audio output (low-budget DAC)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroPWM1SD5DPI_D9AVEOUT_VID9AVEIN_VID9ARM_TCK
Pi 4, 400PWM0_1SD5DPI_D9SPI5_MISORXD5SCL5

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 13 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5PWM0_CHAN1DPI_D9RXD4SCL2AAUD_RIGHTSPI5_SIO1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 34 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 34 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 35 – BCM 19 (GPIO19) – SPI1 MISO (Master-In Slave-Out)

Phys. Pin: 35BCM: 19Type: SPI1 MISOBus: 1

Physical Pin 35 (BCM GPIO19) is the Master-In Slave-Out (MISO) of SPI bus 1. SPI (Serial Peripheral Interface) is a synchronous 4-wire serial protocol based on the master-slave principle with high data transfer rates (up to several MHz). Unlike I2C, each SPI device requires its own Chip Enable (CE) line.

Activate SPI: sudo raspi-config → Interfacing Options → SPI → Enable, then restart.

SPI Lines at a Glance

  • MOSI (Pin 19 / 38) – Master sends, Slave receives
  • MISO (Pin 21 / 35) – Slave sends, Master receives
  • SCLK (Pin 23 / 40) – Clock signal from the Master
  • CE0/CE1/CE2 (Pin 24 / 26 / 36) – Chip Enable (Slave selection)

Python Code Example (spidev)

import spidev

spi = spidev.SpiDev()
spi.open(1, 0)           # Bus 1, CE0
spi.max_speed_hz = 1000000

# Send byte and receive simultaneously
response = spi.xfer2([0x01, 0x80, 0x00])
print(f"Response: {response}")
spi.close()

Typical Use

  • SPI displays (ILI9341, ST7789)
  • A/D converters (MCP3008)
  • RFID modules (RC522)
  • Accelerometers (MPU6000)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroPCM_FSSD11DPI_D15I2CSL_SCL_SCLKSPI1_MISOPWM1
Pi 4, 400PCM_FSSD11DPI_D15SPI6_MISOSPI1_MISOPWM0_1

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 19 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI1_MISODPI_D15I2S0_WSPWM0_CHAN3I2S1_WS–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 36 – BCM 16 (GPIO16) – SPI1 CE2 (Chip Enable 2)

Phys. Pin: 36BCM: 16Type: SPI1 CE2Bus: 1

Physical Pin 36 (BCM GPIO16) is the Chip Enable 2 (CE2, also Chip Select) of SPI bus 1. With the CE signal, the master selects the desired slave chip by pulling the line LOW. Another SPI device can be operated on the same bus via CE2.

Further SPI lines: MOSI (Pin 19/38), MISO (Pin 21/35), SCLK (Pin 23/40), CE0 (Pin 24), CE1 (Pin 26), CE2 (Pin 36).

Typical Use

  • Operating a second SPI device alongside CE0 (e.g., two RFID modules)
  • Display on CE0, memory IC on CE1

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroFL0SD8DPI_D12CTS0SPI1_CE2_NCTS1
Pi 4, 400–SD8DPI_D12CTS0SPI1_CE2_NCTS1

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 16 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI1_CE2DPI_D12DSI0_TE_EXT–CTS0–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 37 – BCM 26 (GPIO26)

Phys. Pin: 37BCM: 26Type: GPIOLevel: 3.3V

Physical Pin 37 corresponds to BCM GPIO26. It is a freely configurable General Purpose I/O pin and can be operated by software as an Input or Output. The logic level is 3.3V (HIGH) or 0V (LOW). The pin supports internal configurable pull-up and pull-down resistors.

Raspberry Pi 5: On the Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run on it. Old code with import RPi.GPIO usually works through rpi-lgpio, included in Raspberry Pi OS since October 2024 (otherwise sudo apt install python3-rpi-lgpio). For new code, use gpiozero or lgpio.

Python Code Example

import lgpio  # all models, including the Pi 5
# or: import RPi.GPIO as GPIO  # via rpi-lgpio on the Pi 5

h = lgpio.gpiochip_open(0)
lgpio.gpio_claim_output(h, 26)   # BCM 26 as output

lgpio.gpio_write(h, 26, 1)  # HIGH (3.3V)
lgpio.gpio_write(h, 26, 0)  # LOW (0V)

lgpio.gpiochip_close(h)

Typical Use

  • General Purpose GPIO
  • Switching output
  • Sensor input

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroSD0_DAT2TE0DPI_D22SD1_DAT2ARM_TDI–
Pi 4, 400SD0_DAT2–DPI_D22SD1_DAT2ARM_TDISPI5_CE1_N

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 26 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SD0_DAT2DPI_D22I2S0_SDI3MIC_DAT0I2S1_SDI3SPI5_CE1

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 38 – BCM 20 (GPIO20) – SPI1 MOSI (Master-Out Slave-In)

Phys. Pin: 38BCM: 20Type: SPI1 MOSIBus: 1

Physical Pin 38 (BCM GPIO20) is the Master-Out Slave-In (MOSI) of SPI bus 1. SPI (Serial Peripheral Interface) is a synchronous 4-wire serial protocol based on the master-slave principle with high data transfer rates (up to several MHz). Unlike I2C, each SPI device requires its own Chip Enable (CE) line.

Activate SPI: sudo raspi-config → Interfacing Options → SPI → Enable, then restart.

SPI Lines at a Glance

  • MOSI (Pin 19 / 38) – Master sends, Slave receives
  • MISO (Pin 21 / 35) – Slave sends, Master receives
  • SCLK (Pin 23 / 40) – Clock signal from the Master
  • CE0/CE1/CE2 (Pin 24 / 26 / 36) – Chip Enable (Slave selection)

Python Code Example (spidev)

import spidev

spi = spidev.SpiDev()
spi.open(1, 0)           # Bus 1, CE0
spi.max_speed_hz = 1000000

# Send byte and receive simultaneously
response = spi.xfer2([0x01, 0x80, 0x00])
print(f"Response: {response}")
spi.close()

Typical Use

  • SPI displays (ILI9341, ST7789)
  • A/D converters (MCP3008)
  • RFID modules (RC522)
  • Accelerometers (MPU6000)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroPCM_DINSD12DPI_D16I2CSL_MISOSPI1_MOSIGPCLK0
Pi 4, 400PCM_DINSD12DPI_D16SPI6_MOSISPI1_MOSIGPCLK0

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 20 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI1_MOSIDPI_D16I2S0_SDI0GPCLK0I2S1_SDI0–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 39 – Ground (GND)

Voltage: 0V / GNDType: Ground

Physical Pin 39 is a ground pin (Ground, GND). It forms the common reference potential for all circuits on the Raspberry Pi. The 40-pin header has a total of 8 ground pins (Pins 6, 9, 14, 20, 25, 30, 34, 39).

Tips

  • For multiple sensors, use a separate GND pin for each (avoids voltage drops)
  • Place the GND pin and signal pin as close together as possible (short lines = less interference)
  • For motor drivers, provide a separate GND for the load side

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Pin 40 – BCM 21 (GPIO21) – SPI1 SCLK (Clock Signal)

Phys. Pin: 40BCM: 21Type: SPI1 SCLKBus: 1

Physical Pin 40 (BCM GPIO21) is the clock signal (SCLK) of SPI bus 1. SPI (Serial Peripheral Interface) is a synchronous 4-wire serial protocol based on the master-slave principle with high data transfer rates (up to several MHz). Unlike I2C, each SPI device requires its own Chip Enable (CE) line.

Activate SPI: sudo raspi-config → Interfacing Options → SPI → Enable, then restart.

SPI Lines at a Glance

  • MOSI (Pin 19 / 38) – Master sends, Slave receives
  • MISO (Pin 21 / 35) – Slave sends, Master receives
  • SCLK (Pin 23 / 40) – Clock signal from the Master
  • CE0/CE1/CE2 (Pin 24 / 26 / 36) – Chip Enable (Slave selection)

Python Code Example (spidev)

import spidev

spi = spidev.SpiDev()
spi.open(1, 0)           # Bus 1, CE0
spi.max_speed_hz = 1000000

# Send byte and receive simultaneously
response = spi.xfer2([0x01, 0x80, 0x00])
print(f"Response: {response}")
spi.close()

Typical Use

  • SPI displays (ILI9341, ST7789)
  • A/D converters (MCP3008)
  • RFID modules (RC522)
  • Accelerometers (MPU6000)

Alternative Functions

ModelALT0ALT1ALT2ALT3ALT4ALT5
Pi 1–3, ZeroPCM_DOUTSD13DPI_D17I2CSL_CE_NSPI1_SCLKGPCLK1
Pi 4, 400PCM_DOUTSD13DPI_D17SPI6_SCLKSPI1_SCLKGPCLK1

Raspberry Pi 5: The RP1 chip numbers its functions a0 to a8, which you set with pinctrl set 21 a3, for example. a5 is the plain GPIO, and every pin has a6 and a7 (PROC_RIO, PIO).

Modela0a1a2a3a4a8
Pi 5SPI1_SCLKDPI_D17I2S0_SDO0GPCLK1I2S1_SDO0–

Available on the following boards

ModelAvailable
Raspberry Pi 5✓ J8 Header (40-Pin)
Raspberry Pi 4 Model B / 400✓ J8 Header (40-Pin)
Raspberry Pi 3 Model B / B+✓ J8 Header (40-Pin)
Raspberry Pi 2 Model B✓ J8 Header (40-Pin)
Raspberry Pi Zero 2 W / Zero W✓ J8 Header (40-Pin)
Raspberry Pi 1 Models A+ and B+✓ J8 Header (40-Pin)
Raspberry Pi 1 Model A and B✓ P1 Header (26-Pin)

Raspberry Pi 5 Pinout in Detail

Our interactive Raspberry Pi 5 Pinout tool shows you all 40 GPIO pins of the new flagship (and its predecessors) at a glance. Click on a pin to get details about its function, BCM number, and alternative functions.

The 40-pin GPIO layout is identical on all current models – Raspberry Pi 3, Pi 4, Pi 5, Pi 400, and Pi Zero 2 W use the same physical pinout. The Raspberry Pi Pico microcontroller has its own layout, covered in our Pico pinout. On the Raspberry Pi 5, the RP1 chip takes over GPIO control. The original RPi.GPIO doesn’t run there, but old scripts usually keep working through rpi-lgpio, which Raspberry Pi OS has included since October 2024. To see which pins a HAT uses and whether two HATs clash, try our HAT check.

 

Detailed information on how old scripts or programs with GPIO references can continue to be used on the Raspberry Pi 5 can be found here.

Most Important GPIO Pins at a Glance

PhysicalBCM No.Function
Pin 3GPIO 2 (SDA)I²C Data
Pin 5GPIO 3 (SCL)I²C Clock
Pin 8GPIO 14 (TXD)UART Transmit
Pin 10GPIO 15 (RXD)UART Receive
Pin 19GPIO 10 (MOSI)SPI Data Out
Pin 21GPIO 9 (MISO)SPI Data In
Pin 23GPIO 11 (SCLK)SPI Clock
Pin 13.3VPower supply
Pin 25VPower supply
Pin 6GNDGround
Common Mistakes with GPIO Access
  • Raspberry Pi 5: The original RPi.GPIO doesn’t run. Don’t install it with apt either, because that replaces rpi-lgpio. If an older install doesn’t have rpi-lgpio yet, add it with sudo apt install python3-rpi-lgpio. For new code, use gpiozero or lgpio.
  • 3.3V logic: GPIO pins output max. 3.3V – never connect 5V components directly (use a voltage divider).
  • Current limit: Max. 16 mA per pin, 50 mA total – always use a series resistor for LEDs.
  • Pins 2/3 have pull-ups: GPIO 2 and GPIO 3 have fixed internal pull-up resistors (1.8 kΩ) – no external pull-up needed for I²C.

About the Author

This page is maintained by the raspberry.tips team. We have been working hands-on with the Raspberry Pi since 2013 – from early GPIO experiments to current Pi 5 projects. All pin data is based on practical experience and the official Raspberry Pi Foundation datasheets.

Download the pinout as a graphic and use it freely

You may use this pinout graphic free of charge, modified or unmodified, including commercially: in class, in blog posts, in documentation or on the wall of your makerspace. It is licensed under CC BY 4.0. The only condition is attribution with a link to this page.

Raspberry Pi GPIO pinout: 40-pin header with GPIO numbers, I2C, SPI, UART, PWM, power and ground
The GPIO pinout as a graphic, free to use under CC BY 4.0.

You can copy this credit line as it is:

Graphic: <a href="https://raspberry.tips/en/raspberry-pi-gpio-pinout">Raspberry Pi GPIO pinout by raspberry.tips</a>, licensed under <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>

For printed material without links, “Graphic: raspberry.tips, CC BY 4.0” is enough.

How many GPIO pins does the Raspberry Pi have?

All Raspberry Pi models (Pi 3, Pi 4, Pi 5, and Zero 2 W) have a 40-pin header. 26 of those pins are usable as GPIO, plus two 5V and two 3.3V power pins and 8 ground pins.

What is the difference between BCM and BOARD numbering?

BCM (Broadcom) uses the SoC’s internal chip numbers, e.g. GPIO 17. BOARD uses the physical pin position on the header, e.g. pin 11. The interactive pinout shows BCM numbers.

Can the Raspberry Pi’s GPIO pins tolerate 5V?

No. All GPIO pins use 3.3V logic and are not 5V-tolerant. To connect 5V devices you must use a level shifter, otherwise you risk permanently damaging your Pi.

Which GPIO pins support hardware PWM?

On the Raspberry Pi 4 and Pi 5, GPIO 12, 13, 18, and 19 support hardware PWM. On the Pi 4, GPIO 12 and 18 share a PWM channel, as do GPIO 13 and 19. The Pi 5 has a separate channel for each of the four pins. Software PWM works on all GPIO pins but is less precise.

Is the Raspberry Pi 5 pinout identical to the Pi 4?

Yes, the 40-pin header of the Raspberry Pi 5 is pin-compatible with the Pi 4. The BCM numbers and functions (I2C, SPI, UART, PWM) are identical. However, the Pi 5 uses the new RP1 I/O controller, which may require adjustments with some low-level libraries.

Links marked with * are affiliate links, which makes them advertising. If you buy through one, I earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases. Learn more