In this guide, you’ll find the Raspberry Pi 5 pinout diagram (the full 40-pin GPIO header), the Raspberry Pi 5 datasheet and schematic details, and every pin group explained with its default pins, the Linux overlays that enable it, and the gotchas that are new on the Pi 5. Without further ado, let’s get right into it!
The Raspberry Pi 5 is a single-board Linux computer built around the Broadcom BCM2712 (4x Cortex-A76 at 2.4GHz) with 1GB to 16GB of LPDDR4X RAM. The big change for hardware projects is that its 28 header GPIOs no longer come from the main SoC: they belong to RP1, Raspberry Pi’s own I/O chip. The header layout is the same as on older Pis, but the libraries, the GPIO numbers and a few defaults are not.
Raspberry Pi 5 Pinout Diagram
Here is a detailed Raspberry Pi 5 GPIO Pinout Diagram with colored labels and legends to help you easily identify the functionalities that each pin can perform. Each pin of the 40-pin header shows its physical pin number, the BCM GPIO number, the Linux sysfs number, the WiringPi number, and every function you can enable in Raspberry Pi OS.
Read it from the grey strip in the middle: odd pins (1, 3, 5…) are the left column, which is the inner row on the board, and even pins (2, 4, 6…) are the right column, the row along the board edge. Pin 1 is at the top, at the end of the header next to the PCIe connector. The small square next to a GPIO means it’s 3.3v only, the PWM icon marks the hardware PWM pins, and the numbered badges point to the notes at the bottom of the diagram.
Buy a Raspberry Pi 5: If you don’t have one yet, you can get the official board from Amazon or AliExpress. The 4GB version is plenty for GPIO and sensor projects; pick 8GB or 16GB for a desktop, containers or local machine-learning work.
Download Raspberry Pi 5 Pinout Diagrams (Full Resolution)
The Raspberry Pi 5 40-pin header pinout diagram in full resolution (5120 px), in one ZIP file.
Raspberry Pi 5 Datasheet
Raspberry Pi doesn’t publish one big “datasheet” for the Raspberry Pi 5. The board’s official data is split between the product brief and the RP1 Peripherals datasheet (the I/O chip behind the 40-pin header). Here are the official documents you’ll need:
| Document | ID | Revision / Date | What You’ll Use It For | Link |
|---|---|---|---|---|
| Raspberry Pi 5 Product Brief | RP-008348-DS | Published Nov 2026 | Specs, RAM options, power input (5v / 5A USB-C PD), operating temperature, production lifetime | |
| RP1 Peripherals | RP-008370-DS | Release 1 (Nov 2023) | The GPIO function-select table (Table 4) and the UART, SPI, I2C, I2S, PWM and GPCLK blocks behind the header | |
| Raspberry Pi 5 Mechanical Drawing | RP-008347-DS | Release 1 | Board outline, mounting holes and connector positions for cases and HATs | |
| Compute Module 5 Datasheet | RP-008180-DS | Latest release | The GPIO alternate-function table the Raspberry Pi docs point to for the BCM2712 + RP1 platform | |
| GPIO Usage on Raspberry Pi Devices | RP-006553-WP | White paper | Which GPIO libraries work on the Pi 5, the gpiochip reorder, and the gpioset behaviour | |
| Device Tree Overlays README | – | firmware repo (live) | Every dtparam/dtoverlay option and its pins (uart0-pi5…uart4-pi5, i2c0-pi5…i2c3-pi5, spi overlays, pwm, pwm-pio) | GitHub |
Which document do I need? The product brief for the board specs, the official 40-pin header docs for the electrical limits, the overlays README to enable a bus on specific pins, and the RP1 Peripherals PDF only if you need the register-level detail. The board’s product page links the latest versions.
Raspberry Pi 5 Schematic
Raspberry Pi has not published a schematic for the Raspberry Pi 5. The reduced schematics on the official site stop at the Raspberry Pi 4, and the files you’ll find on Scribd, EasyEDA or Pinterest under “Raspberry Pi 5 schematic” aren’t official. What Raspberry Pi does publish is enough to wire the board safely:
- The device tree (bcm2712-rpi-5-b.dts) shows how everything on the board is wired logically: the 40-pin header GPIOs are RP1 GPIO0–27 (bank 0), and the RP1 hangs off the BCM2712 on a PCIe link.
- LEDs: the red PWR LED is on RP1 GPIO44 and the green ACT LED on a BCM2712 always-on GPIO, both active low. Neither is on a header pin.
- Power button: the button is on BCM2712 GPIO20 with a pull-up (active low), as a KEY_POWER input. The J2 pads are wired in parallel with it, for your own button.
- Fan (J17): driven by RP1 PWM1 channel 3, with its tachometer read back by the PWM block, and speed steps set by the thermal trip points in the device tree.
- Debug UART (J16): the BCM2712’s own UART10 ( /dev/ttyAMA10), which is the boot console. That’s why the header UART isn’t the console on a Pi 5.
- The mechanical drawing (RP-008347-DS) gives the board outline, the 4x M2.5 mounting holes and the connector positions.
What isn’t published: the series resistors or ESD protection (if any) between RP1 and the header, and the power-path parts. So treat every GPIO as a bare 3.3v pin and protect it yourself.
Raspberry Pi 5 Specs
Here are the Raspberry Pi 5 specifications, with the board-level details that matter when you wire it:

Get a Raspberry Pi 5: the official board is the one I recommend. Grab it from Amazon or AliExpress.
| Feature | Raspberry Pi 5 |
|---|---|
| SoC | Broadcom BCM2712, 4x Cortex-A76 (Arm v8.2) 64-bit @ 2.4GHz, 512KB L2 per core, 2MB shared L3, VideoCore VII GPU @ 800MHz |
| I/O controller | RP1 (Raspberry Pi silicon), on PCIe from the SoC: drives the 40-pin GPIOs, USB, Ethernet and MIPI |
| RAM | 1GB, 2GB, 4GB, 8GB or 16GB LPDDR4X-4267 |
| Storage | microSD card slot with SDR104 high-speed mode; NVMe through the PCIe connector and an M.2 HAT |
| Wireless | Dual-band 802.11ac Wi-Fi, Bluetooth 5.0 / BLE |
| Ethernet | Gigabit Ethernet, PoE+ with the separate PoE+ HAT |
| USB | 2x USB 3.0 (5Gbps each, at the same time) + 2x USB 2.0; 1.6A total with a 5A supply, 600mA otherwise |
| Video / camera | 2x micro-HDMI (4Kp60 with HDR), 2x 4-lane MIPI camera/display transceivers |
| PCIe | PCIe 2.0 x1 on an FPC connector (needs an M.2 HAT or adapter) |
| GPIO header | 40-pin, 28 RP1 GPIOs (GPIO0–27), 3.3v logic, not 5v tolerant |
| Power input | 5v / 5A USB-C with Power Delivery (27W official supply); or 5v through the header from a HAT |
| On-board extras | Power button, real-time clock with a battery connector (J5), 4-pin fan connector (J17), 3-pin debug UART (J16) |
| Operating temperature | 0°C to 70°C |
| Size | 85 x 56mm, 4x M2.5 mounting holes |
| Production lifetime | Until at least January 2036 |
Raspberry Pi 5 Specifications Summary
- The Raspberry Pi 5 has 28 GPIOs on its 40-pin header (GPIO0–27, all on the RP1 chip); 26 are free for your circuits because GPIO0/1 (pins 27/28) are reserved for the HAT ID EEPROM.
- All GPIOs are 3.3v only and not 5v tolerant: never apply 5v to a GPIO pin.
- RP1 GPIO outputs have a selectable drive strength (2mA, 4mA, 8mA or 12mA settings; a typical 15.8mA source current at the 8mA setting), so keep each load to a few mA and buffer anything bigger.
- Power pins: 5v on pins 2 and 4, 3.3v on pins 1 and 17, and 8 GND pins (6, 9, 14, 20, 25, 30, 34, 39).
- There are no analog inputs: neither the BCM2712 nor the RP1 has an ADC on the header, so analog sensors need an external ADC.
- UART: 5 on the header (UART0–UART4). UART0 is on pins 8 (TX) and 10 (RX) as /dev/ttyAMA0, but serial0 is the separate 3-pin debug UART.
- I2C: the main bus is I2C1 on pins 3 (SDA) and 5 (SCL) (/dev/i2c-1), plus I2C0, I2C2 and I2C3 through the -pi5 overlays.
- SPI: SPI0 on pins 19, 21, 23, 24 and 26, plus SPI1, SPI2, SPI3 and SPI5 through overlays.
- PWM: 4 hardware channels (RP1 PWM0) on 6 pins: GPIO12, GPIO13, and the shared pairs GPIO14/GPIO18 and GPIO15/GPIO19.
- Power: 5v / 5A USB-C PD; with a 3A supply the USB ports are limited to 600mA.
- Linux GPIO numbers: libgpiod, gpiozero and pinctrl use the BCM number on gpiochip0; the deprecated sysfs uses 571 + BCM (GPIO17 = 588) on kernel 6.6+.
- GPIO libraries: only the original RPi.GPIO and pigpio lack Pi 5 support. Raspberry Pi OS provides RPi.GPIO through rpi-lgpio; for new code use gpiozero, lgpio or libgpiod.
Raspberry Pi 5 RP1 Peripherals vs the 40-Pin Header
| Peripheral | On the Header | Enabled With | Notes |
|---|---|---|---|
| GPIO | 28 (GPIO0–27) | Always available | RP1 bank 0; GPIO28+ stay on the board (Ethernet PHY, LEDs, fan, camera) |
| UART | 5: UART0–UART4 | dtparam=uart0=on, dtoverlay=uart1-pi5 … uart4-pi5 | All PL011, no mini UART; the console is UART10 on J16 |
| I2C | 4: I2C0 (HAT ID), I2C1, I2C2, I2C3 | dtparam=i2c_arm=on, dtoverlay=i2c0-pi5 … i2c3-pi5 | I2C1 has the 1.8kΩ pull-ups |
| SPI | 5 usable: SPI0, SPI1, SPI2, SPI3, SPI5 | dtparam=spi=on, dtoverlay=spi1-1cs, spi2-1cs-pi5, spi3-1cs-pi5, spi5-1cs | RP1 SPI4 is slave-only, so it’s left out |
| PWM | 4 channels on 6 pins | dtoverlay=pwm / pwm-2chan, or pwm-pio on any GPIO | CH2 and CH3 each come out on two pins |
| PCM / I2S | 1 (pins 12, 35, 38, 40) | dtparam=i2s=on or a DAC overlay | Shares GPIO18/19 with PWM CH2/CH3 |
| GPCLK | 3 (GPCLK0–2) | Device tree / registers | Not supported through WiringPi on the Pi 5 |
| PIO | Any of GPIO0–27 | pwm-pio overlay, piolib | The RP2040-style PIO block, new on the Pi 5 |
| ADC / DAC | None | – | Use an external ADC or DAC |
| CAN | None | – | Use an SPI CAN controller (MCP2515 overlay) |
Raspberry Pi 5 Quick Pin Selection Guide
| Use Case | Recommended Pins | Why |
|---|---|---|
| Serial console | The 3-pin J16 debug connector | It’s serial0 (/dev/ttyAMA10) on the Pi 5 |
| UART to a device | Pin 8 (GPIO14, TX), pin 10 (GPIO15, RX) | UART0, /dev/ttyAMA0 with dtparam=uart0=on |
| A second UART | Pins 7/29 (UART2) or pins 24/21 (UART3) | Leaves the HAT ID pins and I2C1 alone |
| I2C sensors and displays | Pin 3 (GPIO2, SDA), pin 5 (GPIO3, SCL) | I2C1 (/dev/i2c-1), pull-ups already fitted |
| A second I2C bus | Pins 15/16 (I2C3, pins_22_23) or pins 7/29 (I2C2) | Free pins with no other default job |
| SPI devices | Pins 19, 21, 23 + CE0 pin 24 / CE1 pin 26 | SPI0 (/dev/spidev0.0 and 0.1) |
| Hardware PWM | Pin 32 (GPIO12, CH0) and pin 33 (GPIO13, CH1) | Their own channels, and GPIO18/19 stay free for I2S |
| I2S audio DAC | Pins 12, 35, 38, 40 | The only PCM pins on the header |
| LEDs, buttons, relays | GPIO17, 27, 22, 23, 24, 25, 26, 16 (pins 11, 13, 15, 16, 18, 22, 37, 36) | No default bus on them |
| Analog input | None on the board | Add an I2C or SPI ADC |
Raspberry Pi 5 Pins to Use With Caution
| Pin | Reason | What to Do |
|---|---|---|
| Pins 27, 28 (GPIO0/1, ID_SD/ID_SC) | The HAT ID EEPROM bus (I2C0) | Leave them unconnected unless you fit a HAT EEPROM |
| Pins 3, 5 (GPIO2/3) | Fixed 1.8kΩ pull-ups to 3.3v on the board | Don’t use them as inputs that need a pull-down |
| Pins 8, 12 (GPIO14/18) | The same PWM channel (CH2) | Use hardware PWM on only one of them |
| Pins 10, 35 (GPIO15/19) | The same PWM channel (CH3) | Use hardware PWM on only one of them |
| Pin 12 (GPIO18) | PWM CH2, the I2S clock, and the pin many fan and LED HATs use | Use only one of these on it |
| Pins 2, 4 (5v) | Wired to the board’s 5v rail; a supply here skips the USB-C input protection | Never connect a second supply while USB-C is plugged in |
| Pins 1, 17 (3V3) | No published current budget for the Pi 5 | Power big loads from their own regulator |
Raspberry Pi 5 Pins Functions
Only 28 of the 40 pins of the Raspberry Pi 5 header are GPIO pins; the rest are power and ground. The 40 pins are divided into the following groups based on the hardware functionality they’re used for.
- Power Pins (2x 5v, 2x 3.3v, 8x GND)
- 28x GPIO Pins (with 4 numbering systems)
- Analog Input Pins (none: no ADC)
- 5x UART
- 4x I2C Buses
- 5x SPI Buses
- 4x PWM Channels (6 pins)
- PCM / I2S Audio Pins
- 3x GPCLK Clock Outputs
- HAT ID EEPROM Pins
Besides the header, the Raspberry Pi 5 has its own connectors for the debug UART, the fan, the RTC battery and an external power button; they’re covered in the On-Board Connectors section. We’ll discuss each pin group in the following sections one by one in more detail.
Raspberry Pi 5 Power Pins
The Raspberry Pi 5 header has two 5v pins (2 and 4), two 3.3v pins (1 and 17) and eight GND pins (6, 9, 14, 20, 25, 30, 34 and 39). They’re highlighted in red and black in the pinout diagram.

| Pin | Name | Function | Notes |
|---|---|---|---|
| 1, 17 | 3V3 | 3.3v output | From the board’s 3.3v rail; no official current figure for the Pi 5 |
| 2, 4 | 5V | 5v output or input | The board’s 5v rail: an output for modules, or an input from a HAT |
| 6, 9, 14, 20, 25, 30, 34, 39 | GND | Ground | Common ground for everything you connect |
Power supply: the Raspberry Pi 5 wants a 5v / 5A USB-C supply with Power Delivery, like the official 27W one. It still runs from a 5v / 3A supply, but then it limits the four USB ports to 600mA in total instead of 1.6A, and warns you at boot. Below 4.63v (±5%) the board flags an under-voltage, and vcgencmd get_throttled reports it. The details are in the official power supply docs.
5V pins: Raspberry Pi’s docs say these pins provide 5v to peripherals or accept 5v input, which is how the PoE+ HAT and UPS HATs power the board. Power fed here doesn’t go through the USB-C negotiation, so the Pi can’t know the supply is good for 5A and keeps the USB limit at 600mA. HAT makers tell you to add usb_max_current_enable=1 to config.txt (and PSU_MAX_CURRENT=5000 in the bootloader EEPROM) when the HAT can really supply 5A (see Waveshare’s PoE HAT notes and Raspberry Pi’s USB Power Delivery white paper).
|
1 2 3 4 5 |
# /boot/firmware/config.txt (only if the supply on the 5v pins can deliver 5A) usb_max_current_enable=1 # check what the board negotiated vcgencmd get_config usb_max_current_enable |
3V3 pins: a 3.3v output for sensors and modules. Raspberry Pi doesn’t publish a current budget for the Pi 5’s 3.3v pins, so keep the load to sensors and logic chips, and give motors, LED strips and other heavy loads their own supply.
Note: Never connect a supply to the 5v pins while the USB-C cable is plugged in. Power fed into the header bypasses the input protection of the USB-C side, and two supplies on one rail fight each other. Use one or the other, and if you power the Pi 5 from the header, use a regulated 5v supply rated for the current you need.
Never forget to connect the ground of every circuit to the Pi’s GND (common ground). External sensors and modules need the same ground line as the Raspberry Pi to communicate with it properly.
Raspberry Pi 5 GPIO Pins
The Raspberry Pi 5 has 28 GPIO pins (GPIO0 to GPIO27) on its 40-pin header, and every one of them is a 3.3v pin that is not 5v tolerant. On the Pi 5, all 28 belong to the RP1 I/O chip (bank 0), not the BCM2712, which is why old code that wrote the Broadcom GPIO registers directly doesn’t run on it.

| Parameter | Raspberry Pi 5 GPIO |
|---|---|
| Logic level | 3.3v (high when connected to 3.3v, low at 0v) |
| 5v tolerant | No, on every pin |
| Drive strength | Selectable 2mA / 4mA / 8mA / 12mA settings (typical source current 6.3mA / 9.5mA / 15.8mA / 19mA, RP1 Peripherals) |
| Internal pulls | Pull-up or pull-down on every GPIO, set in software |
| Fixed pull-ups | GPIO2 and GPIO3 (pins 3 and 5): 1.8kΩ to 3.3v on the board |
| Interrupts | Any GPIO can trigger on rising, falling or both edges (libgpiod events, gpiozero callbacks) |
Drive strength isn’t a current limit: it’s the current at which the pin still meets its output voltage levels. Older Raspberry Pi pages quote “16mA per pin, 50mA total”, but that’s the Broadcom-era figure, so don’t plan a Pi 5 design around it. Keep loads to a few mA: an LED with a 330Ω resistor (about 4mA) is fine; anything that needs more, like a relay coil, a motor or a buzzer, needs a transistor or a driver board.
Raspberry Pi 5 GPIO Numbering: Physical vs BCM vs WiringPi vs Linux
Every GPIO on the Raspberry Pi 5 has four different numbers, and mixing them up is the most common beginner mistake. Take physical pin 11 as an example:
| Numbering | Pin 11 Is | Used By |
|---|---|---|
| Physical (BOARD) | 11 | Counting pins on the header (1–40) |
| BCM | GPIO17 | gpiozero, libgpiod, lgpio, pinctrl, the overlays README, and most tutorials |
| Linux sysfs (kernel 6.6+) | 588 (571 + 17) | /sys/class/gpio (deprecated) |
| WiringPi (wPi) | 0 | The WiringPi library and gpio readall |
Use the BCM number unless a tool asks for something else; on the Pi 5 it’s simply the RP1 line number. It works the same way as the GP numbers in our Raspberry Pi Pico & Pico W Pinout Guide: write the BCM number in code, and use the physical number only when you wire. The sysfs number is where the Pi 5 bites: the RP1 GPIO chip registers at base 571 on kernel 6.6+, so echo 17 > /sys/class/gpio/export fails with “Invalid argument” (users report it in processing4 #807). That base isn’t guaranteed, and Raspberry Pi says sysfs is due to be removed, so move to libgpiod, gpiozero or pinctrl instead.
|
1 2 3 4 |
pinctrl get 17 # show GPIO17's function, level and pull pinctrl set 17 op dh # make GPIO17 an output and drive it high gpioinfo gpiochip0 # list the 54 RP1 lines (pinctrl-rp1) pinout # print a header map in the terminal (gpiozero) |
Raspberry Pi 5 GPIO Libraries: Which Ones Work
Only the original RPi.GPIO and pigpio lack Raspberry Pi 5 support. Both write the Broadcom GPIO registers directly, and on the Pi 5 the header pins live in RP1 instead, so the original RPi.GPIO fails with “Cannot determine SOC peripheral base address” (one of the most reported Pi 5 problems, for example on the Home Assistant forum). Current Raspberry Pi OS installs rpi-lgpio under the RPi.GPIO name, so import RPi.GPIO works out of the box; I tested it on a Pi 5 and every feature passed. For new code, use gpiozero, lgpio or libgpiod, as Raspberry Pi’s white paper GPIO Usage on Raspberry Pi Devices recommends:
| Library | Language | Works on the Pi 5? | Notes |
|---|---|---|---|
| gpiozero | Python | Yes | Installed with Raspberry Pi OS; uses lgpio underneath |
| libgpiod (gpiod) | C/C++, Python, CLI | Yes | The standard Linux GPIO interface; gpioset, gpioget, gpiomon |
| lgpio | C, Python | Yes | Uses /dev/gpiochip; also the backend of gpiozero and rpi-lgpio |
| WiringPi | C | Yes | Updated for the Pi 5 and maintained (GitHub), but no GPCLK support |
| pinctrl | CLI | Yes | Raspberry Pi’s own tool to read and set pins |
| RPi.GPIO (rpi-lgpio) | Python | Yes | What Raspberry Pi OS installs as RPi.GPIO: the same API on top of lgpio |
| RPi.GPIO (original) | Python | No | Direct register access; not supported on the Pi 5 |
| pigpio | C, Python | No | DMA and register access; not supported on the Pi 5 |
gpiochip0 or gpiochip4? The first Pi 5 kernels put the header GPIOs on gpiochip4. In 2024, Raspberry Pi reordered them to gpiochip0 like the older models (raspberrypi/linux PR #6144), and Raspberry Pi OS adds a gpiochip4 symlink so old code keeps working. Many guides still say gpiochip4. The safe way is to open the chip by its label, pinctrl-rp1, or use gpiozero, which picks it for you.
Raspberry Pi 5 GPIO Code Example (C/C++ and Python)
Here’s one real job in both languages: a push button on GPIO17 (pin 11) toggles an LED on GPIO27 (pin 13). Wire the button between pin 11 and GND (pin 9); the code turns on the internal pull-up. Wire the LED’s anode to pin 13 through a 330Ω resistor and its cathode to GND (pin 14). The C version uses the libgpiod v2 API ( sudo apt install libgpiod-dev on Raspberry Pi OS Trixie; Bookworm ships the older v1.6 API), and the Python version uses gpiozero, which comes with Raspberry Pi OS.
C/C++ (libgpiod v2)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
// Button on GPIO17 (pin 11) toggles an LED on GPIO27 (pin 13) // libgpiod v2. Build: gcc button_led.c -o button_led -lgpiod #include <gpiod.h> #include <stdio.h> int main(void) { unsigned int btn = 17, led = 27; /* BCM numbers */ struct gpiod_chip *chip = gpiod_chip_open("/dev/gpiochip0"); if (!chip) { perror("gpiochip0"); return 1; } struct gpiod_line_settings *in = gpiod_line_settings_new(); gpiod_line_settings_set_direction(in, GPIOD_LINE_DIRECTION_INPUT); gpiod_line_settings_set_bias(in, GPIOD_LINE_BIAS_PULL_UP); gpiod_line_settings_set_edge_detection(in, GPIOD_LINE_EDGE_FALLING); gpiod_line_settings_set_debounce_period_us(in, 10000); struct gpiod_line_settings *out = gpiod_line_settings_new(); gpiod_line_settings_set_direction(out, GPIOD_LINE_DIRECTION_OUTPUT); struct gpiod_line_config *cfg = gpiod_line_config_new(); gpiod_line_config_add_line_settings(cfg, &btn, 1, in); gpiod_line_config_add_line_settings(cfg, &led, 1, out); struct gpiod_line_request *req = gpiod_chip_request_lines(chip, NULL, cfg); struct gpiod_edge_event_buffer *ev = gpiod_edge_event_buffer_new(1); int on = 0; for (;;) { /* Ctrl+C to quit */ gpiod_line_request_read_edge_events(req, ev, 1); /* blocks */ on = !on; gpiod_line_request_set_value(req, led, on ? GPIOD_LINE_VALUE_ACTIVE : GPIOD_LINE_VALUE_INACTIVE); printf("LED %s\n", on ? "on" : "off"); } } |
Python (gpiozero)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# Button on GPIO17 (pin 11) toggles an LED on GPIO27 (pin 13) # gpiozero (installed with Raspberry Pi OS). Run: python3 button_led.py from gpiozero import Button, LED from signal import pause button = Button(17, bounce_time=0.01) # internal pull-up, BCM number led = LED(27) def toggle(): led.toggle() print("LED", "on" if led.is_lit else "off") button.when_pressed = toggle pause() # Ctrl+C to quit |
One Pi-specific detail: Raspberry Pi’s kernel keeps a GPIO at the value gpioset left it after the command exits (upstream Linux returns it to an input). Add dtparam=strict_gpiod to config.txt if you want the upstream behaviour.
Note: The Raspberry Pi 5’s GPIOs are not 5v tolerant. Raspberry Pi’s documentation warns that 5v on a GPIO can permanently damage the board. To connect 5v logic (an Arduino’s TX pin, a 5v sensor output), use a level shifter or a resistor divider.
Raspberry Pi 5 Analog Input Pins (ADC)
The Raspberry Pi 5 has no analog input pins: there’s no ADC on the 40-pin header, so every header pin is digital only. To read a potentiometer, a light sensor or any analog voltage, add an external ADC, such as an ADS1115 (16-bit, I2C) or an MCP3008 (10-bit, SPI), or hand the analog side to a microcontroller like the Raspberry Pi Pico. Power the ADC from 3.3v so its digital lines stay Pi-safe.
Raspberry Pi 5 UART Pins
The Raspberry Pi 5 has 5 UARTs on its header (UART0 to UART4, all full PL011 UARTs). UART0 is on pin 8 (GPIO14, TX) and pin 10 (GPIO15, RX) as /dev/ttyAMA0. Unlike older Pis, the Raspberry Pi 5’s serial0 console is not on these pins: it’s the separate 3-pin debug UART (J16).
Raspberry Pi 5 Default UART Pins: GPIO14 (UART0 TX, pin 8) and GPIO15 (UART0 RX, pin 10).

| UART | TX | RX | CTS | RTS | config.txt | Linux Device |
|---|---|---|---|---|---|---|
| UART0 | Pin 8 (GPIO14) | Pin 10 (GPIO15) | Pin 36 (GPIO16) | Pin 11 (GPIO17) | dtparam=uart0=on | /dev/ttyAMA0 |
| UART1 | Pin 27 (GPIO0) | Pin 28 (GPIO1) | Pin 3 (GPIO2) | Pin 5 (GPIO3) | dtoverlay=uart1-pi5 | /dev/ttyAMA1 |
| UART2 | Pin 7 (GPIO4) | Pin 29 (GPIO5) | Pin 31 (GPIO6) | Pin 26 (GPIO7) | dtoverlay=uart2-pi5 | /dev/ttyAMA2 |
| UART3 | Pin 24 (GPIO8) | Pin 21 (GPIO9) | Pin 19 (GPIO10) | Pin 23 (GPIO11) | dtoverlay=uart3-pi5 | /dev/ttyAMA3 |
| UART4 | Pin 32 (GPIO12) | Pin 33 (GPIO13) | Pin 8 (GPIO14) | Pin 10 (GPIO15) | dtoverlay=uart4-pi5 | /dev/ttyAMA4 |
| UART10 (debug) | J16 | J16 | – | – | Always on (boot console) | /dev/ttyAMA10 = serial0 |
This is the biggest serial gotcha on the Raspberry Pi 5: /dev/serial0 points at /dev/ttyAMA10 (the J16 debug connector), so any tool or tutorial that opens serial0 talks to the 3-pin connector, not pins 8/10 (users hit it in OctoPrint, Home Assistant and the docs issue tracker). Open /dev/ttyAMA0 directly for the header UART, or add dtparam=uart0_console to move the console to pins 8/10. An older dtoverlay=uart2 line still works: the firmware swaps in the -pi5 version for you. The details are in the official UART configuration docs.
|
1 2 3 4 |
# /boot/firmware/config.txt dtparam=uart0=on # UART0 on pins 8/10 -> /dev/ttyAMA0 dtoverlay=uart2-pi5 # UART2: TX pin 7, RX pin 29 -> /dev/ttyAMA2 #dtparam=uart0_console # move the Linux console to pins 8/10 |
Note: UART1 uses pins 27/28, the HAT ID EEPROM pins, and its flow-control pins are the I2C1 pins, so prefer UART2, UART3 or UART4. And remember that the UART pins are 3.3v: a 5v USB-serial adapter or an Arduino’s 5v TX needs a level shifter. Cross the lines (Pi TX to the device’s RX, Pi RX to its TX) and connect GND.
There are so many modules that we can interface with the Raspberry Pi 5 using the UART, which include: GPS receivers, RS-485 transceivers (Modbus), LoRa and cellular modems, fingerprint sensors, microcontroller boards, and much more.
Raspberry Pi 5 I2C Pins
The Raspberry Pi 5 has 4 I2C buses on its header. The main one is I2C1 on pin 3 (GPIO2, SDA) and pin 5 (GPIO3, SCL), which appears as /dev/i2c-1 once you turn it on with dtparam=i2c_arm=on (or in raspi-config).
Raspberry Pi 5 Default I2C1 Pins: GPIO2 (SDA, pin 3) and GPIO3 (SCL, pin 5).

| I2C Bus | SDA | SCL | Other Pin Options | config.txt |
|---|---|---|---|---|
| I2C1 (main) | Pin 3 (GPIO2) | Pin 5 (GPIO3) | pins_10_11 (pins 19/23) | dtparam=i2c_arm=on |
| I2C2 | Pin 7 (GPIO4) | Pin 29 (GPIO5) | pins_12_13 (pins 32/33) | dtoverlay=i2c2-pi5 |
| I2C3 | Pin 31 (GPIO6) | Pin 26 (GPIO7) | pins_14_15 (pins 8/10), pins_22_23 (pins 15/16) | dtoverlay=i2c3-pi5 |
| I2C0 (HAT ID) | Pin 27 (GPIO0) | Pin 28 (GPIO1) | pins_8_9 (pins 24/21) | Reserved for the HAT EEPROM |
GPIO2 and GPIO3 have 1.8kΩ pull-up resistors to 3.3v on the board, so I2C1 works without external pull-ups. The other buses don’t have them: add 2.2kΩ–4.7kΩ pull-ups to 3.3v, or use modules that already carry them. Add ,baudrate=400000 to an overlay line for fast mode, and scan a bus with i2cdetect -y 1 (change the number for the other buses).
|
1 2 3 |
# /boot/firmware/config.txt dtparam=i2c_arm=on # I2C1 on pins 3/5 -> /dev/i2c-1 dtoverlay=i2c3-pi5,pins_22_23 # I2C3 on pins 15/16 -> /dev/i2c-3 |
Note: Many I2C modules sold for Arduino pull SDA and SCL up to 5v. The Pi uses 3.3v signalling, so power such a module from 3.3v if it supports it, remove its 5v pull-ups, or put a bidirectional I2C level shifter between them.
There are so many modules and sensors that we can interface with the Raspberry Pi 5 using the I2C bus, which include: OLED displays (SSD1306), temperature and humidity sensors (BME280, SHT31), IMUs (MPU6050), ADCs (ADS1115) for analog inputs, GPIO expanders (MCP23017), PWM drivers (PCA9685), and much more.
Raspberry Pi 5 SPI Pins
The Raspberry Pi 5 has 5 usable SPI buses on its header. The main one is SPI0 on pins 19 (MOSI), 21 (MISO) and 23 (SCLK), with two chip selects on pin 24 (CE0) and pin 26 (CE1). Turn it on with dtparam=spi=on and it appears as /dev/spidev0.0 and /dev/spidev0.1.
Raspberry Pi 5 Default SPI0 Pins: GPIO10 (MOSI, pin 19), GPIO9 (MISO, pin 21), GPIO11 (SCLK, pin 23), GPIO8 (CE0, pin 24) and GPIO7 (CE1, pin 26).

| SPI Bus | MOSI | MISO | SCLK | CE0 | CE1 | config.txt |
|---|---|---|---|---|---|---|
| SPI0 | Pin 19 (GPIO10) | Pin 21 (GPIO9) | Pin 23 (GPIO11) | Pin 24 (GPIO8) | Pin 26 (GPIO7) | dtparam=spi=on |
| SPI1 | Pin 38 (GPIO20) | Pin 35 (GPIO19) | Pin 40 (GPIO21) | Pin 12 (GPIO18) | Pin 11 (GPIO17) | dtoverlay=spi1-1cs / 2cs / 3cs (CE2 = pin 36) |
| SPI2 | Pin 3 (GPIO2) | Pin 28 (GPIO1) | Pin 5 (GPIO3) | Pin 27 (GPIO0) | Pin 18 (GPIO24) | dtoverlay=spi2-1cs-pi5 / 2cs-pi5 |
| SPI3 | Pin 31 (GPIO6) | Pin 29 (GPIO5) | Pin 26 (GPIO7) | Pin 7 (GPIO4) | Pin 22 (GPIO25) | dtoverlay=spi3-1cs-pi5 / 2cs-pi5 |
| SPI5 | Pin 8 (GPIO14) | Pin 33 (GPIO13) | Pin 10 (GPIO15) | Pin 32 (GPIO12) | Pin 37 (GPIO26) | dtoverlay=spi5-1cs / 2cs |
SPI1 uses the I2S pins, SPI2 sits on the I2C1 and HAT ID pins, and SPI5 on the UART0 pins, so SPI3 is usually the easiest second bus. RP1 also has an SPI4, but it’s slave-only, so it isn’t listed here. The chip-select pin of each overlay can be moved to another GPIO with its cs0_pin parameter.
There are so many modules that we can interface with the Raspberry Pi 5 using the SPI bus, which include: TFT and e-paper displays, MCP3008 ADCs, MCP2515 CAN controllers, LoRa radios (SX127x), RFID readers (RC522), W5500 Ethernet modules, and much more.
Raspberry Pi 5 PWM Pins
The Raspberry Pi 5 has 4 hardware PWM channels (RP1 PWM0, channels 0–3) on 6 header pins: CH0 on pin 32 (GPIO12), CH1 on pin 33 (GPIO13), CH2 on pin 8 (GPIO14) or pin 12 (GPIO18), and CH3 on pin 10 (GPIO15) or pin 35 (GPIO19). The two pins of CH2 carry the same signal, and so do the two pins of CH3.

| Channel | Header Pin(s) | Example config.txt Line |
|---|---|---|
| PWM0 CH0 | Pin 32 (GPIO12) | dtoverlay=pwm,pin=12,func=4 |
| PWM0 CH1 | Pin 33 (GPIO13) | dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4 |
| PWM0 CH2 | Pin 8 (GPIO14) or pin 12 (GPIO18) | dtoverlay=pwm (default: GPIO18) |
| PWM0 CH3 | Pin 10 (GPIO15) or pin 35 (GPIO19) | dtoverlay=pwm-2chan (default: GPIO18 + GPIO19) |
This is where Pi 4 guides go wrong on a Pi 5. They check for the pwm_bcm2835 driver and for pwmchip0/pwm0, but on the Raspberry Pi 5 GPIO18 is channel 2 of the RP1 PWM, and users report it shows up as pwm2 under a different pwmchip number (rpi_hardware_pwm #10, rppal #141). Check the pin with pinctrl get 18 (it should say PWM0_CHAN2) and find the chip with ls /sys/class/pwm instead of hard-coding it.
Need PWM on another pin? The Pi 5 has a new option: dtoverlay=pwm-pio,gpio=<n> makes PIO-driven hardware PWM on any of GPIO0–27 (up to 4 of them). Plain software PWM from gpiozero also works on any pin; it’s fine for dimming an LED but jitters too much for servos.
Note: GPIO18 and GPIO19 are also the I2S bit clock and frame sync, and many fan and LED HATs use GPIO18. With an I2S DAC, put your PWM on pins 32/33 (GPIO12/13), which have channels of their own.
There are so many things that we can control with the Raspberry Pi 5 PWM pins, which include: LED dimming, DC motor speed (through a driver), servo motors, fan speed, buzzers and tone generation, and much more.
Raspberry Pi 5 PCM / I2S Pins
The Raspberry Pi 5 has one PCM/I2S digital audio interface on the header: pin 12 (GPIO18, PCM_CLK), pin 35 (GPIO19, PCM_FS), pin 38 (GPIO20, PCM_DIN) and pin 40 (GPIO21, PCM_DOUT). It’s what audio DAC HATs, I2S amplifiers and I2S microphones use.

| Signal | Pin | GPIO | I2S Name |
|---|---|---|---|
| PCM_CLK | 12 | GPIO18 | BCLK (bit clock) |
| PCM_FS | 35 | GPIO19 | LRCLK / WS (word select) |
| PCM_DIN | 38 | GPIO20 | Data in (microphone, ADC) |
| PCM_DOUT | 40 | GPIO21 | Data out (DAC, amplifier) |
Enable it with dtparam=i2s=on, or better, with the overlay for your DAC (for example dtoverlay=hifiberry-dac), which also loads the right sound driver. The Pi 5 has no 3.5mm audio jack, so an I2S DAC (or HDMI audio) is how you get sound out of it.
Raspberry Pi 5 GPCLK Pins
The Raspberry Pi 5 has 3 general-purpose clock outputs on the header: GPCLK0 on pin 7 (GPIO4) or pin 38 (GPIO20), GPCLK1 on pin 29 (GPIO5) or pin 40 (GPIO21), and GPCLK2 on pin 31 (GPIO6). They output a clock divided down from one of RP1’s internal sources, which is handy as a reference clock for an audio codec, a camera sensor or another chip.
| Clock | Pin | Alternative Pin |
|---|---|---|
| GPCLK0 | Pin 7 (GPIO4) | Pin 38 (GPIO20) |
| GPCLK1 | Pin 29 (GPIO5) | Pin 40 (GPIO21) |
| GPCLK2 | Pin 31 (GPIO6) | – |
A device tree overlay for the chip that needs the clock sets them up. Note that WiringPi doesn’t support GPCLK on the Pi 5 (Raspberry Pi’s GPIO white paper says so).
Raspberry Pi 5 HAT ID EEPROM Pins
Pins 27 (ID_SD, GPIO0) and 28 (ID_SC, GPIO1) of the Raspberry Pi 5 are reserved for the HAT ID EEPROM. At boot, the firmware looks for an I2C EEPROM on these pins (I2C0) to identify an attached HAT and set it up automatically.
| Pin | Name | GPIO | Function |
|---|---|---|---|
| 27 | ID_SD | GPIO0 | I2C0 SDA to the HAT EEPROM |
| 28 | ID_SC | GPIO1 | I2C0 SCL to the HAT EEPROM |
Leave these pins unconnected unless you’re fitting a HAT EEPROM. They can technically carry UART1 or SPI2, but put those on other pins. If you design your own HAT, follow the official HAT+ specification for the EEPROM.
Raspberry Pi 5 On-Board Connectors & Features
Besides the 40-pin header, the Raspberry Pi 5 adds a few small connectors that older Pis didn’t have. None of them is on a header pin, but you’ll meet all of them when you build a project.
| Connector / Feature | Where | What It Does |
|---|---|---|
| Debug UART (J16) | 3-pin JST-SH labelled UART, between the micro-HDMI ports | The BCM2712 UART10, /dev/ttyAMA10 = serial0, the boot console at 115200 8N1. Plug in a 3.3v JST-SH serial cable such as the Raspberry Pi Debug Probe. |
| Fan (J17) | 4-pin JST-SH labelled FAN, next to the USB 2.0 ports | 5v fan with PWM speed control (RP1 PWM1 CH3) and a tachometer; the firmware runs it from the CPU temperature (fan_temp0… dtparams). |
| RTC battery (J5) | 2-pin JST-SH labelled BAT, next to the USB-C input | Keeps the real-time clock running when the board is unplugged. Use a rechargeable lithium-manganese cell (like the official one), not a Li-ion or a primary cell. |
| Power button | On the short edge, below the PCIe connector | Short press: clean shutdown (on the desktop it shows a menu; press twice to shut down). Press again to start a halted board. Hold to force power-off. |
| Power button pads (J2) | Two pads between the RTC battery connector and the board edge | Wire a normally open push button across them for your own case button; it does the same as the on-board button. |
| PCIe connector | FPC on the short edge, next to header pin 1 | PCIe 2.0 x1 for an M.2 HAT (NVMe SSD, accelerators). Enable with dtparam=pciex1. |
| PWR LED (red) | Next to the USB-C input | Driven by RP1 GPIO44 (Linux LED “PWR”); active low; you can control it from Linux like any LED. |
| ACT LED (green) | Next to the PWR LED (labelled STAT) | Flashes on microSD activity (trigger mmc0); long/short flash patterns at boot are error codes. |
RTC battery charging is off by default. The RTC has a 3mA constant-current, constant-voltage charger: enable it with dtparam=rtc_bbat_vchg=3000000 in config.txt, but only for a rechargeable cell. The official RTC docs and power button docs have the details.
|
1 2 3 4 5 6 |
# /boot/firmware/config.txt dtparam=rtc_bbat_vchg=3000000 # charge a rechargeable RTC cell at 3.0v dtparam=pciex1 # enable the external PCIe connector # read the debug UART from another Linux machine screen /dev/ttyACM0 115200 |
Getting Started With Raspberry Pi 5 GPIO
Getting the Raspberry Pi 5’s pins working takes three steps: install the OS, enable the interfaces you need, and pick a GPIO library that supports the Pi 5.
- Install Raspberry Pi OS (Bookworm or newer, the first release with Pi 5 support) on a microSD card with Raspberry Pi Imager. The config file for overlays is /boot/firmware/config.txt.
- Enable the interfaces: run sudo raspi-config → Interface Options to turn on I2C, SPI and the serial port, or add the dtparam/ dtoverlay lines from the sections above to config.txt, then reboot.
- Pick a library: gpiozero for Python, libgpiod for C/C++ (and its Python bindings), and the pinctrl command to check or set a pin from the terminal. Old RPi.GPIO scripts run as they are on Raspberry Pi OS, which provides RPi.GPIO through rpi-lgpio.
| Interface | config.txt Line | Linux Device / Tool |
|---|---|---|
| GPIO | – (always on) | /dev/gpiochip0 (libgpiod, gpiozero, pinctrl) |
| UART0 on pins 8/10 | dtparam=uart0=on | /dev/ttyAMA0 |
| UART1–4 | dtoverlay=uart1-pi5 … uart4-pi5 | /dev/ttyAMA1–4 |
| Debug UART (J16) | – (always on) | /dev/ttyAMA10 = /dev/serial0 |
| I2C1 | dtparam=i2c_arm=on | /dev/i2c-1 (i2cdetect -y 1) |
| I2C0, I2C2, I2C3 | dtoverlay=i2c0-pi5, i2c2-pi5, i2c3-pi5 | /dev/i2c-0, /dev/i2c-2, /dev/i2c-3 |
| SPI0 | dtparam=spi=on | /dev/spidev0.0, /dev/spidev0.1 |
| SPI1, 2, 3, 5 | dtoverlay=spi1-1cs, spi2-1cs-pi5, spi3-1cs-pi5, spi5-1cs | /dev/spidevN.0 |
| PWM | dtoverlay=pwm-2chan (or pwm-pio) | /sys/class/pwm/pwmchipN (check with ls) |
| 1-Wire | dtoverlay=w1-gpio | /sys/bus/w1/devices/ |
| I2S | dtparam=i2s=on or a DAC overlay | ALSA sound card (aplay -l) |
Raspberry Pi 5 Common Problems & Fixes
Why does RPi.GPIO say “Cannot determine SOC peripheral base address”? That’s the original RPi.GPIO, which writes the Broadcom GPIO registers directly, while the Raspberry Pi 5’s header GPIOs are on RP1. If you see it on Raspberry Pi OS, check whether a pip or virtual-environment install pulled in the original package instead of the rpi-lgpio version the OS provides as RPi.GPIO ( pip show RPi.GPIO), or move to gpiozero, lgpio or libgpiod. Older HAT libraries that bundle the original RPi.GPIO fail the same way until they’re updated.
Why do I get “Invalid argument” when I export GPIO17 through sysfs? On kernel 6.6+, the Raspberry Pi 5’s sysfs numbers start at 571, so GPIO17 is 588. Check the real numbers in /sys/kernel/debug/gpio, but better, move to libgpiod, gpiozero or pinctrl, which all use the BCM number.
My code opens gpiochip4 and it fails (or works on one Pi and not another). The header GPIOs moved from gpiochip4 to gpiochip0 in 2024. Raspberry Pi OS keeps a gpiochip4 symlink, but other distributions may not. Open the chip by its label, pinctrl-rp1, or use gpiozero.
Why doesn’t serial work on pins 8/10? /dev/serial0 is the J16 debug UART on the Pi 5. Turn on UART0 with dtparam=uart0=on and open /dev/ttyAMA0, or move the console with dtparam=uart0_console. Also check the wiring is crossed and the adapter is 3.3v.
Why can’t I find hardware PWM on GPIO18? Pi 4 instructions look for pwmchip0/pwm0. On the Pi 5, GPIO18 is RP1 PWM0 channel 2, under whichever pwmchip number the kernel gives it. Load the overlay, run pinctrl get 18, then ls /sys/class/pwm and export channel 2.
My HAT powers the Pi through the 5v pins and USB devices disconnect. Why? Without USB-C Power Delivery, the Pi 5 limits the USB ports to 600mA. If the HAT can supply 5A, add usb_max_current_enable=1 to config.txt.
A pin stays high after my gpioset script exits. Is that a bug? No, Raspberry Pi’s kernel keeps the last value on purpose. Add dtparam=strict_gpiod to config.txt if you want released lines to go back to inputs.
Raspberry Pi 5 vs Raspberry Pi 4 and 3B
All three boards share the same 40-pin header layout, so most HATs and wiring carry over. What changes is what’s behind the pins: the Raspberry Pi 5 moved the GPIOs to its own RP1 chip, which brings more PWM channels and a new set of overlays, but also breaks the old register-level libraries.
| Feature | Raspberry Pi 5 | Raspberry Pi 4 Model B | Raspberry Pi 3 Model B |
|---|---|---|---|
| SoC / CPU | BCM2712, 4x Cortex-A76 @ 2.4GHz | BCM2711, 4x Cortex-A72 @ 1.8GHz | BCM2837, 4x Cortex-A53 @ 1.2GHz |
| RAM | 1GB–16GB LPDDR4X | 1GB–8GB LPDDR4 | 1GB LPDDR2 |
| GPIO controller | RP1 I/O chip | SoC | SoC |
| UART / I2C / SPI on the header | 5 / 4 / 5 | 6 / 6 / 6 | 2 / 2 / 2 |
| Hardware PWM channels | 4 (6 pins) | 2 (4 pins) | 2 (4 pins) |
| Linux sysfs GPIO base (kernel 6.6+) | 571 | 512 | 512 |
| RPi.GPIO | Yes, through rpi-lgpio (the original: no) | Yes | Yes |
| pigpio | No | Yes | Yes |
| serial0 | Debug UART (J16) | Pins 8/10 | Pins 8/10 |
| USB | 2x USB 3.0 + 2x USB 2.0 | 2x USB 3.0 + 2x USB 2.0 | 4x USB 2.0 |
| Extras | Power button, RTC, fan header, PCIe | PoE header | – |
| Power input | 5v / 5A USB-C (Power Delivery) | 5v / 3A USB-C | 5v / 2.5A micro-USB |
Pick the Raspberry Pi 5 for speed, PCIe storage and the extra PWM channels, as long as your libraries support it (gpiozero and libgpiod do). Pick the Raspberry Pi 4 when you depend on pigpio or a HAT whose software hasn’t caught up, or when the 5A supply is a problem. The 3B only makes sense for light jobs and existing projects.
Raspberry Pi 5 Pin Details
Here is every pin of the Raspberry Pi 5 40-pin header in physical order, with all four numbers, the functions you can enable in Raspberry Pi OS, and every RP1 alternate function (RP1 Peripherals Table 4; a5–a7 are RIO and PIO on every pin). Pin 1 is the square pad at the end next to the PCIe connector; odd pins are on the inner row and even pins on the board edge.
Click to expand the full pin table (40 pins)
| Pin | Name | BCM | Linux # | wPi | Main Functions (Pi OS) | All RP1 Alternate Functions | Description |
|---|---|---|---|---|---|---|---|
| 1 | 3V3 | – | – | – | 3.3v power | – | 3.3v output from the board’s own 3.3v rail; feed sensors and modules from it, never a supply into it. |
| 2 | 5V | – | – | – | 5v power | – | The board’s 5v rail: a 5v output for modules, or a 5v input from a HAT or regulated supply. |
| 3 | GPIO2 | 2 | 573 | 8 | I2C1 SDA, SPI2 MOSI, UART1 CTS | a0: SPI0_CSn3, a1: DPI_VSYNC, a2: UART1_CTS, a3: I2C1_SDA, a4: UART0_IR_RX, a8: SPI2_SIO0 | The main I2C data line (/dev/i2c-1), with a fixed 1.8kΩ pull-up to 3.3v on the board. |
| 4 | 5V | – | – | – | 5v power | – | Second 5v pin, the same rail as pin 2. |
| 5 | GPIO3 | 3 | 574 | 9 | I2C1 SCL, SPI2 SCLK, UART1 RTS | a0: SPI0_CSn2, a1: DPI_HSYNC, a2: UART1_RTS, a3: I2C1_SCL, a4: UART0_IR_TX, a8: SPI2_SCLK | The main I2C clock line, with a fixed 1.8kΩ pull-up to 3.3v on the board. |
| 6 | GND | – | – | – | Ground | – | Ground. |
| 7 | GPIO4 | 4 | 575 | 7 | GPCLK0, UART2 TX, I2C2 SDA, SPI3 CE0 | a0: GPCLK0, a1: DPI_D0, a2: UART2_TX, a3: I2C2_SDA, a4: UART0_RI, a8: SPI3_CSn0 | General-purpose pin; GPCLK0 clock output and the default pwm-pio and 1-Wire pin. |
| 8 | GPIO14 | 14 | 585 | 15 | UART0 TX, PWM0 CH2, UART4 CTS, SPI5 MOSI, I2C3 SDA | a0: PWM0_2, a1: DPI_D10, a2: UART4_CTS, a3: I2C3_SDA, a4: UART0_TX, a8: SPI5_SIO0 | UART0 transmit (/dev/ttyAMA0); not serial0 on the Pi 5, which is the debug UART. |
| 9 | GND | – | – | – | Ground | – | Ground. |
| 10 | GPIO15 | 15 | 586 | 16 | UART0 RX, PWM0 CH3, UART4 RTS, SPI5 SCLK, I2C3 SCL | a0: PWM0_3, a1: DPI_D11, a2: UART4_RTS, a3: I2C3_SCL, a4: UART0_RX, a8: SPI5_SCLK | UART0 receive, paired with pin 8; 3.3v levels only. |
| 11 | GPIO17 | 17 | 588 | 0 | UART0 RTS, SPI1 CE1 | a0: SPI1_CSn1, a1: DPI_D13, a2: DSI1_TE, a4: UART0_RTS | Free general-purpose pin; also UART0 RTS and SPI1 chip select 1. |
| 12 | GPIO18 | 18 | 589 | 1 | PWM0 CH2, PCM CLK, SPI1 CE0 | a0: SPI1_CSn0, a1: DPI_D14, a2: I2S0_SCLK, a3: PWM0_2, a4: I2S1_SCLK, a8: GPCLK1 | Hardware PWM channel 2 (shared with pin 8) and the I2S bit clock. |
| 13 | GPIO27 | 27 | 598 | 2 | GPIO only | a0: SDIO0_DAT3, a1: DPI_D23, a2: I2S0_SDO3, a3: AUDIO_IN_DAT1, a4: I2S1_SDO3, a8: SPI1_CSn1 | Free general-purpose pin with no default bus. |
| 14 | GND | – | – | – | Ground | – | Ground. |
| 15 | GPIO22 | 22 | 593 | 3 | I2C3 SDA | a0: SDIO0_CLK, a1: DPI_D18, a2: I2S0_SDI1, a3: I2C3_SDA, a4: I2S1_SDI1 | Free general-purpose pin; optional I2C3 data pin (pins_22_23). |
| 16 | GPIO23 | 23 | 594 | 4 | I2C3 SCL | a0: SDIO0_CMD, a1: DPI_D19, a2: I2S0_SDO1, a3: I2C3_SCL, a4: I2S1_SDO1 | Free general-purpose pin; optional I2C3 clock pin. |
| 17 | 3V3 | – | – | – | 3.3v power | – | Second 3.3v output, the same rail as pin 1. |
| 18 | GPIO24 | 24 | 595 | 5 | SPI2 CE1 | a0: SDIO0_DAT0, a1: DPI_D20, a2: I2S0_SDI2, a4: I2S1_SDI2, a8: SPI2_CSn1 | Free general-purpose pin; SPI2 chip select 1. |
| 19 | GPIO10 | 10 | 581 | 12 | SPI0 MOSI, UART3 CTS, I2C1 SDA | a0: SPI0_SIO0, a1: DPI_D6, a2: UART3_CTS, a3: I2C1_SDA, a8: SPI4_SIO1 | SPI0 data out (MOSI) when dtparam=spi=on. |
| 20 | GND | – | – | – | Ground | – | Ground. |
| 21 | GPIO9 | 9 | 580 | 13 | SPI0 MISO, UART3 RX, I2C0 SCL | a0: SPI0_SIO1, a1: DPI_D5, a2: UART3_RX, a3: I2C0_SCL, a8: SPI4_SIO0 | SPI0 data in (MISO). |
| 22 | GPIO25 | 25 | 596 | 6 | SPI3 CE1 | a0: SDIO0_DAT1, a1: DPI_D21, a2: I2S0_SDO2, a3: AUDIO_IN_CLK, a4: I2S1_SDO2, a8: SPI3_CSn1 | Free general-purpose pin; SPI3 chip select 1. |
| 23 | GPIO11 | 11 | 582 | 14 | SPI0 SCLK, UART3 RTS, I2C1 SCL | a0: SPI0_SCLK, a1: DPI_D7, a2: UART3_RTS, a3: I2C1_SCL, a8: SPI4_SCLK | SPI0 clock. |
| 24 | GPIO8 | 8 | 579 | 10 | SPI0 CE0, UART3 TX, I2C0 SDA | a0: SPI0_CSn0, a1: DPI_D4, a2: UART3_TX, a3: I2C0_SDA, a8: SPI4_CSn0 | SPI0 chip select 0 (/dev/spidev0.0). |
| 25 | GND | – | – | – | Ground | – | Ground. |
| 26 | GPIO7 | 7 | 578 | 11 | SPI0 CE1, SPI3 SCLK, UART2 RTS, I2C3 SCL | a0: SPI0_CSn1, a1: DPI_D3, a2: UART2_RTS, a3: I2C3_SCL, a4: UART0_DSR, a8: SPI3_SCLK | SPI0 chip select 1 (/dev/spidev0.1). |
| 27 | ID_SD (GPIO0) | 0 | 571 | 30 | HAT ID EEPROM SDA (I2C0), UART1 TX, SPI2 CE0 | a0: SPI0_SIO3, a1: DPI_PCLK, a2: UART1_TX, a3: I2C0_SDA, a8: SPI2_CSn0 | Reserved for the HAT ID EEPROM; leave it unconnected unless it’s a HAT EEPROM. |
| 28 | ID_SC (GPIO1) | 1 | 572 | 31 | HAT ID EEPROM SCL (I2C0), UART1 RX, SPI2 MISO | a0: SPI0_SIO2, a1: DPI_DE, a2: UART1_RX, a3: I2C0_SCL, a8: SPI2_SIO1 | Reserved for the HAT ID EEPROM clock, like pin 27. |
| 29 | GPIO5 | 5 | 576 | 21 | GPCLK1, UART2 RX, I2C2 SCL, SPI3 MISO | a0: GPCLK1, a1: DPI_D1, a2: UART2_RX, a3: I2C2_SCL, a4: UART0_DTR, a8: SPI3_SIO1 | General-purpose pin; GPCLK1 clock output. |
| 30 | GND | – | – | – | Ground | – | Ground. |
| 31 | GPIO6 | 6 | 577 | 22 | GPCLK2, UART2 CTS, I2C3 SDA, SPI3 MOSI | a0: GPCLK2, a1: DPI_D2, a2: UART2_CTS, a3: I2C3_SDA, a4: UART0_DCD, a8: SPI3_SIO0 | General-purpose pin; GPCLK2 clock output. |
| 32 | GPIO12 | 12 | 583 | 26 | PWM0 CH0, UART4 TX, I2C2 SDA, SPI5 CE0 | a0: PWM0_0, a1: DPI_D8, a2: UART4_TX, a3: I2C2_SDA, a4: AUDIO_OUT_L, a8: SPI5_CSn0 | Hardware PWM channel 0, the only header pin on that channel. |
| 33 | GPIO13 | 13 | 584 | 23 | PWM0 CH1, UART4 RX, I2C2 SCL, SPI5 MISO | a0: PWM0_1, a1: DPI_D9, a2: UART4_RX, a3: I2C2_SCL, a4: AUDIO_OUT_R, a8: SPI5_SIO1 | Hardware PWM channel 1, the only header pin on that channel. |
| 34 | GND | – | – | – | Ground | – | Ground. |
| 35 | GPIO19 | 19 | 590 | 24 | PWM0 CH3, PCM FS, SPI1 MISO | a0: SPI1_SIO1, a1: DPI_D15, a2: I2S0_WS, a3: PWM0_3, a4: I2S1_WS | Hardware PWM channel 3 (shared with pin 10) and the I2S frame sync. |
| 36 | GPIO16 | 16 | 587 | 27 | UART0 CTS, SPI1 CE2 | a0: SPI1_CSn2, a1: DPI_D12, a2: DSI0_TE, a4: UART0_CTS | Free general-purpose pin; UART0 CTS and SPI1 chip select 2. |
| 37 | GPIO26 | 26 | 597 | 25 | SPI5 CE1 | a0: SDIO0_DAT2, a1: DPI_D22, a2: I2S0_SDI3, a3: AUDIO_IN_DAT0, a4: I2S1_SDI3, a8: SPI5_CSn1 | Free general-purpose pin; SPI5 chip select 1. |
| 38 | GPIO20 | 20 | 591 | 28 | PCM DIN, SPI1 MOSI, GPCLK0 | a0: SPI1_SIO0, a1: DPI_D16, a2: I2S0_SDI0, a3: GPCLK0, a4: I2S1_SDI0 | I2S data in. |
| 39 | GND | – | – | – | Ground | – | Ground. |
| 40 | GPIO21 | 21 | 592 | 29 | PCM DOUT, SPI1 SCLK, GPCLK1 | a0: SPI1_SCLK, a1: DPI_D17, a2: I2S0_SDO0, a3: GPCLK1, a4: I2S1_SDO0 | I2S data out. |
Wrap Up
To conclude this guide article, the Raspberry Pi 5 is a very solid single-board computer for hardware projects: 28 GPIOs, five UARTs, four I2C buses, five SPI buses, and four hardware PWM channels on one header, with a fast Linux system behind them. Just remember what’s new: the pins belong to RP1, so pigpio and the original RPi.GPIO are out (Raspberry Pi OS ships rpi-lgpio as RPi.GPIO); serial0 is the debug connector, not pins 8/10; the sysfs numbers start at 571; and every pin is still 3.3v only.
I hope you’ve found this guide helpful for you to decide which pins to use for your project. For more boards, check out the Pinouts, Datasheets & Schematic Diagrams Library.