Contact Us
Blog / Raspberry Pi GPIO Pinout: The Complete Guide (Pi 5, Pi 4 & Pico)

Raspberry Pi GPIO Pinout: The Complete Guide (Pi 5, Pi 4 & Pico)

Posted: July, 2026 Last Updated: July, 2026 Writer: Lolly Zheng Share: NEXTPCB Official youtube NEXTPCB Official Facefook NEXTPCB Official Twitter NEXTPCB Official Instagram NEXTPCB Official Linkedin NEXTPCB Official Tiktok NEXTPCB Official Bksy

If you just need the short answer: the Raspberry Pi 5, Pi 4, and every 40-pin Pi before them share the exact same physical GPIO layout and pin functions. What changed with the Pi 5 isn't the pinout — it's the chip behind it. A new I/O coprocessor called RP1 now handles all GPIO traffic instead of the main processor, and that has real consequences for your code even though your wiring stays the same.

The Raspberry Pi Pico is a different story entirely — it's a microcontroller board, not a computer, and its pin layout, naming, and voltage rules follow their own logic.

This guide covers what's common across all of them, what's genuinely different, and links to full pin-by-pin references for each board. If you're not yet sure which model you're working with, our overview of Raspberry Pi models, features, and uses is a good starting point.

Voltage Warning: Read This First

Every GPIO pin on every Raspberry Pi board — Pi 4, Pi 5, and Pico alike — runs at 3.3V logic and is not 5V tolerant. This hasn't changed with the Pi 5, despite what you might read elsewhere. Feeding a 5V signal directly into a GPIO pin can permanently damage the board.

If you're connecting a 5V sensor, an Arduino, or any 5V logic device, you need a level shifter between it and the Pi. This is the single most common way people damage a Raspberry Pi, and it's worth checking twice before you wire anything up.

The Standard 40-Pin Layout (Pi 4 and Pi 5)

Both the Pi 4 and Pi 5 use the same 40-pin header (2 rows of 20 pins), the same BCM (Broadcom) GPIO numbering, and the same pin assignments. Of the 40 physical pins, 28 carry BCM GPIO signals — but GPIO0 and GPIO1 are reserved for HAT identification and aren't meant for general use, which leaves 26 GPIO pins for your own projects.

Pin type Physical pin numbers Notes
3.3V power 1, 17 Two dedicated 3.3V supply pins
5V power 2, 4 Two dedicated 5V supply pins — for powering external devices, not for feeding into GPIO pins
Ground (GND) 6, 9, 14, 20, 25, 30, 34, 39 Eight ground pins spread across the header
Reserved (HAT EEPROM) 27, 28 GPIO0 (ID_SD) and GPIO1 (ID_SC) — used for HAT identification, avoid for general I/O
I2C 3, 5 GPIO2 (SDA), GPIO3 (SCL)
SPI 19, 21, 23, 24, 26 GPIO10 (MOSI), GPIO9 (MISO), GPIO11 (SCLK), GPIO8 (CE0), GPIO7 (CE1)
UART 8, 10 GPIO14 (TXD), GPIO15 (RXD) — note that on Pi 3B+ and later, the primary hardware UART is used by Bluetooth by default, so this is typically the software-based mini UART
Hardware PWM 12, 33, 35, 32 GPIO18, GPIO13, GPIO19, GPIO12
Complete 40-pin GPIO header diagram for Raspberry Pi 4 and Pi 5, showing all pin numbers, functions, and color-coded categories: power, ground, I2C, SPI, UART, PWM, and reserved pins. 1 3.3V power 2 5V power 3 GPIO2 (SDA, I2C) 4 5V power 5 GPIO3 (SCL, I2C) 6 Ground 7 GPIO4 8 GPIO14 (TXD, UART) 9 Ground 10 GPIO15 (RXD, UART) 11 GPIO17 12 GPIO18 (PWM) 13 GPIO27 14 Ground 15 GPIO22 16 GPIO23 17 3.3V power 18 GPIO24 19 GPIO10 (MOSI, SPI) 20 Ground 21 GPIO9 (MISO, SPI) 22 GPIO25 23 GPIO11 (SCLK, SPI) 24 GPIO8 (CE0, SPI) 25 Ground 26 GPIO7 (CE1, SPI) 27 GPIO0 (ID_SD, reserved) 28 GPIO1 (ID_SC, reserved) 29 GPIO5 30 Ground 31 GPIO6 32 GPIO12 (PWM) 33 GPIO13 (PWM) 34 Ground 35 GPIO19 (PWM) 36 GPIO16 37 GPIO26 38 GPIO20 39 Ground 40 GPIO21 Power Ground I2C SPI UART PWM Reserved GPIO Left row (pins 1–39, odd) Right row (pins 2–40, even)
Complete 40-pin GPIO header layout for Raspberry Pi 4 and Pi 5. Pin numbers match physical header position; functions shown are BCM defaults.

Three Ways to Number the Same Pins

One common source of confusion: the same physical pin can be referred to by three different numbering schemes depending on which library or diagram you're reading. If you're new to the Pi, it's worth knowing all three exist before you start cross-referencing tutorials — and worth reading through our guide to getting started with Raspberry Pi first if you're setting one up for the first time.

Scheme What it refers to Example Used by
Physical (BOARD) The pin's literal position on the header, counted 1–40 Physical pin 12 Datasheets, wiring diagrams, most tutorials
BCM (Broadcom) The GPIO number as known to the underlying Broadcom SoC GPIO18 (same physical pin as above) RPi.GPIO, gpiozero, most Python code
WiringPi A legacy hardware-independent numbering scheme from the WiringPi library WiringPi pin 1 (same physical pin as above) Older C-based projects, some legacy scripts

In practice, almost all current Python code uses BCM numbering, so that's the scheme worth memorizing if you're starting fresh. Physical numbering is what you'll count off the board itself when you're wiring something by hand.

Power Pin Current Limits

The 5V and 3.3V pins can power small modules directly, but each rail has a practical ceiling — exceeding it can brown out the Pi or damage the power circuitry.

Rail Typical current limit Practical notes
5V (pins 2, 4) Up to roughly 2.5A, shared with the rest of the board Depends on your power supply's total capacity — a 3A USB-C supply is standard for the Pi 4 and Pi 5
3.3V (pins 1, 17) Roughly 800mA This rail is derived on-board and has a much lower ceiling than 5V — don't power motors or high-draw modules from it

If you're designing a custom board or HAT that draws significant current — for example, one that uses the PWM pins to drive a fan or heating element, as covered in our guide to PWM-based thermal management PCBs for Raspberry Pi — it's worth budgeting your power draw against these limits early rather than discovering a brownout after the board is built.

Pi 5 vs. Pi 4 vs. Pico: What's Actually Different

Feature Raspberry Pi 4 Raspberry Pi 5 Raspberry Pi Pico
Physical header 40-pin, 2×20 40-pin, 2×20 (identical layout) 40-pin, 20 per side (different numbering scheme)
Usable GPIO pins 26 26 (same as Pi 4) 26 (GP0–GP22, GP26–GP28)
GPIO controller Broadcom BCM2711 SoC, direct control RP1 I/O coprocessor, talks to BCM2712 SoC via PCIe RP2040 microcontroller, direct control
HAT / accessory compatibility Standard Physically and functionally pin-compatible with Pi 4 HATs Not HAT-compatible; uses its own smaller add-on ecosystem
Software library RPi.GPIO, gpiozero RPi.GPIO is not compatible — use gpiozero or lgpio instead MicroPython or C/C++ SDK, not RPi.GPIO
Logic voltage 3.3V, not 5V tolerant 3.3V, not 5V tolerant 3.3V, not 5V tolerant
Ground pins 8 8 8

The takeaway: if you're moving a project between a Pi 4 and a Pi 5, your wiring and pin numbers carry over directly. What might break is code that talks to the GPIO hardware at a low level — that's covered in the next section.

What the RP1 Chip Changes on the Pi 5

On every Raspberry Pi before the Pi 5, the GPIO pins were wired directly into the main processor. The Pi 5 changes that: GPIO handling has been moved to a dedicated I/O coprocessor called RP1, which communicates with the Pi 5's BCM2712 main processor over a high-speed PCIe link. Physically, nothing changes — the 40-pin header, the BCM numbering, and the pin functions (I2C, SPI, UART, PWM) are all identical to the Pi 4.

Where this matters is software:

  • RPi.GPIO is not compatible with the Pi 5. If your existing scripts import RPi.GPIO, they won't work as-is. Switch to gpiozero (which now supports the Pi 5 automatically) or lgpio for lower-level control.
  • The Linux gpiochip device path changes. Older Pi models expose GPIO through /dev/gpiochip0. On the Pi 5, GPIO is accessed through a different gpiochip number tied to the RP1. If you have code or tools that hardcode gpiochip0, they'll need updating.

None of this affects your wiring — a sensor or HAT that worked on a Pi 4 will physically fit and electrically function the same way on a Pi 5. It's specifically low-level GPIO libraries and scripts that need a second look.

Why the Pico's Pinout Doesn't Match the Others

The Raspberry Pi Pico is built around the RP2040 microcontroller, not the same Broadcom SoC family used in the full Raspberry Pi computers — so its pinout follows completely different conventions:

  • Different pin naming. Pico pins are labeled GP0 through GP28 (skipping a few reserved numbers), not by physical pin position like the Pi 4/5's BCM scheme.
  • Four GPIOs aren't exposed on the header at all. GP23, GP24, GP25, and GP29 are used internally — for onboard power management, USB voltage sensing, the built-in LED, and system voltage monitoring — and can't be wired to externally.
  • Different power pin names. Instead of the Pi 4/5's 5V and 3.3V pins, the Pico has 3V3(OUT), VSYS, and VBUS — each with a distinct role in how the board is powered.
  • Built-in analog input. The Pico has 4 ADC channels (3 usable GPIO pins plus an internal temperature sensor) — something the full-size Pi models don't expose directly on their GPIO header at all.

For the complete Pico pin map, including which GPIOs double as I2C, SPI, UART, and PWM, see our Raspberry Pi Pico Pinout Guide. If you're still deciding whether the Pico is the right board for your project in the first place, our Raspberry Pi Pico vs. Arduino comparison breaks down the hardware and ecosystem differences in more depth.

FAQ

Is the Raspberry Pi 5 pinout the same as the Pi 4?

Yes, physically and functionally. The 40-pin header layout, BCM GPIO numbering, and pin functions (I2C, SPI, UART, PWM) are identical between the Pi 4 and Pi 5. The difference is under the hood: the Pi 5 uses a new RP1 chip to manage GPIO instead of the main processor handling it directly, which mainly affects which software libraries you use.

Can I use 5V devices with the Raspberry Pi GPIO pins?

Not directly. All Raspberry Pi GPIO pins, including on the Pi 5, run at 3.3V logic and are not 5V tolerant. Connecting a 5V signal directly to a GPIO pin can permanently damage the board. Use a level shifter for any 5V sensors or devices.

Why doesn't my old RPi.GPIO code work on a Raspberry Pi 5?

The Pi 5 moved GPIO control to a new RP1 I/O coprocessor, and the RPi.GPIO library was never updated to support it. Switch to gpiozero or lgpio, both of which support the Pi 5's GPIO architecture.

How many GPIO pins does a Raspberry Pi actually have?

On the Pi 4 and Pi 5, the 40-pin header exposes 28 BCM GPIO signals, but 2 of those (GPIO0 and GPIO1) are reserved for HAT identification, leaving 26 pins for general use. The Raspberry Pi Pico also exposes 26 usable GPIO pins, though under a completely different numbering scheme.

Designing a custom HAT or breakout board around your Raspberry Pi's GPIO header? 

Author Name

About the Author

Lolly Zheng- Sales Account Manager at NextPCB.com

Four years of proven sales experience across electronic components and PCBA industries, with strong expertise in key account acquisition, customer relationship management, and contract negotiations. Focused on driving revenue growth through strategic client development and solution-based selling. Experienced in expanding high-value accounts, securing long-term partnerships, and consistently exceeding sales targets in competitive markets.