Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

Raspberry Pi GPIO Pinout Explained: The Complete Reference Guide

Every engineer who works with Raspberry Pi eventually faces the same challenge: staring at that 40-pin header wondering which pins do what. After spending years designing embedded systems and prototyping countless Pi-based projects, I’ve learned that understanding the raspberry pi pinout isn’t just about memorizing numbers. It’s about knowing how to leverage each pin’s capabilities without frying your board.

This guide breaks down every aspect of the GPIO pins on modern Raspberry Pi models. Whether you’re connecting your first LED or designing a complex sensor array, this reference will become your go-to resource for working with raspberry pi pins.

What Are GPIO Pins on a Raspberry Pi?

GPIO stands for General Purpose Input/Output. These pins form the physical interface between your Raspberry Pi and the outside world. Unlike dedicated pins on microcontrollers, GPIO pins can be configured through software as either inputs or outputs, giving you flexibility in how you interact with external hardware.

The 40-pin header found on Raspberry Pi models from the B+ onwards provides 26 configurable GPIO pins, power outputs, ground connections, and specialized communication interfaces. This standardized layout means HATs (Hardware Attached on Top) and breakout boards designed for one Pi model typically work across the entire modern lineup.

What makes the raspberry pi pinout particularly powerful is the alternate functions many pins support. Beyond simple digital I/O, specific pins handle I2C, SPI, UART serial communication, PWM signal generation, and even audio output. Understanding these capabilities unlocks the Pi’s full potential for hardware projects.

Complete Raspberry Pi GPIO Pinout Diagram Reference

The 40-pin header layout has remained consistent across Raspberry Pi B+, 2, 3, 4, 5, and Zero models. Pin 1 sits in the top-left corner when you orient the board with the GPIO header on the right and HDMI ports on the left. Pin 1 is identifiable by its square solder pad on the underside of the PCB.

Full 40-Pin Header Pinout Table

Physical PinGPIO (BCM)FunctionPhysical PinGPIO (BCM)Function
13.3V Power25V Power
3GPIO 2I2C1 SDA45V Power
5GPIO 3I2C1 SCL6Ground
7GPIO 4GPCLK0 / 1-Wire8GPIO 14UART TX
9Ground10GPIO 15UART RX
11GPIO 17General I/O12GPIO 18PCM CLK / PWM0
13GPIO 27General I/O14Ground
15GPIO 22General I/O16GPIO 23General I/O
173.3V Power18GPIO 24General I/O
19GPIO 10SPI0 MOSI20Ground
21GPIO 9SPI0 MISO22GPIO 25General I/O
23GPIO 11SPI0 SCLK24GPIO 8SPI0 CE0
25Ground26GPIO 7SPI0 CE1
27GPIO 0ID EEPROM SDA28GPIO 1ID EEPROM SCL
29GPIO 5General I/O30Ground
31GPIO 6General I/O32GPIO 12PWM0
33GPIO 13PWM134Ground
35GPIO 19PCM FS / PWM136GPIO 16General I/O
37GPIO 26General I/O38GPIO 20PCM DIN
39Ground40GPIO 21PCM DOUT

This table shows the physical pin numbers alongside their BCM (Broadcom) GPIO numbers and primary functions. Keep this reference handy when wiring your projects.

Understanding GPIO Pin Numbering Systems

One of the most confusing aspects of the raspberry pi pinout for newcomers is the dual numbering system. Two completely different schemes exist for referencing the same physical pins, and mixing them up causes endless debugging headaches.

BCM (Broadcom) Numbering

BCM numbering refers to the GPIO channel numbers assigned by the Broadcom SoC (System on Chip). When you see “GPIO 17” in documentation or code, that’s BCM numbering. This scheme is what most Python libraries like gpiozero and RPi.GPIO expect when you select BCM mode.

The BCM numbers appear somewhat random when looking at the physical header because they reflect the chip’s internal architecture rather than any logical pin arrangement. For example, physical pin 11 corresponds to GPIO 17, while physical pin 12 maps to GPIO 18.

Physical (Board) Numbering

Physical numbering counts pins sequentially based on their position on the header. Pin 1 sits top-left, pin 2 is top-right, and they continue alternating down to pin 40. This system is intuitive when physically wiring components but requires looking up the BCM equivalent for programming.

Which Numbering System Should You Use?

For most projects, BCM numbering is the standard. Modern libraries default to it, and documentation typically references GPIO by BCM number. However, when working from a physical pinout diagram or following older tutorials, you might encounter board numbering.

In Python using the gpiozero library:

from gpiozero import LED

led = LED(17)  # Uses BCM numbering – GPIO 17 (physical pin 11)

The key is consistency. Pick one system and stick with it throughout your project. Mixing systems within the same codebase leads to confusion and potential hardware damage.

Power Pins on the Raspberry Pi Header

Not all raspberry pi pins handle data. Several provide power for external circuits, and misusing them can destroy your Pi or connected components.

3.3V Power Pins

Physical pins 1 and 17 supply regulated 3.3V power. This voltage matches the GPIO logic level, making these pins ideal for powering low-current sensors and small ICs. The combined current draw from both 3.3V pins should stay under 50mA for safety.

5V Power Pins

Physical pins 2 and 4 provide 5V directly from the Pi’s power input. These pins bypass the onboard voltage regulator, so they deliver whatever your power supply provides (typically 5V within tolerance). Use these for powering components that require 5V, but remember that the GPIO logic remains 3.3V.

Critical Warning: Never connect 5V directly to any GPIO pin. The Broadcom SoC operates at 3.3V logic levels. Applying 5V to a GPIO input will permanently damage your Raspberry Pi. If you’re interfacing with 5V devices, use a level shifter or voltage divider.

Ground Pins

Eight ground pins are distributed throughout the header at physical positions 6, 9, 14, 20, 25, 30, 34, and 39. Always connect external circuits to these ground pins to establish a common reference. Failing to share ground between circuits causes erratic behavior, incorrect readings, and potential damage.

Power Pin Summary Table

Pin TypePhysical PinsVoltageNotes
3.3V Power1, 173.3V regulatedMax ~50mA combined
5V Power2, 45V from supplyDirectly from USB power
Ground6, 9, 14, 20, 25, 30, 34, 390VEssential for all circuits

Communication Protocol Pins Explained

Beyond simple digital I/O, the raspberry pi pinout includes dedicated pins for standard communication protocols. These interfaces dramatically expand what you can connect to your Pi.

I2C (Inter-Integrated Circuit) Pins

I2C provides a two-wire interface for connecting multiple peripherals to the same bus. Sensors, displays, ADCs, and numerous other devices support I2C communication.

Pin FunctionPhysical PinGPIO (BCM)
SDA (Data)3GPIO 2
SCL (Clock)5GPIO 3

The Raspberry Pi includes fixed 1.8kΩ pull-up resistors on these pins, so external pull-ups are typically unnecessary. Each I2C device has a unique address (between 0x03 and 0x77), allowing up to 112 devices on a single bus theoretically.

To enable I2C on Raspberry Pi OS:

sudo raspi-config

# Navigate to: Interface Options > I2C > Enable

Detect connected I2C devices with:

sudo i2cdetect -y 1

Note: Pins 27 and 28 (GPIO 0 and GPIO 1) are reserved for HAT EEPROM identification. Don’t use these for general I2C communication unless you understand the implications.

SPI (Serial Peripheral Interface) Pins

SPI offers faster data transfer than I2C and works well for displays, SD cards, and high-speed sensors. The Raspberry Pi supports two SPI buses with multiple chip select lines.

Pin FunctionPhysical PinGPIO (BCM)
MOSI (Master Out)19GPIO 10
MISO (Master In)21GPIO 9
SCLK (Clock)23GPIO 11
CE0 (Chip Enable 0)24GPIO 8
CE1 (Chip Enable 1)26GPIO 7

SPI runs significantly faster than I2C, with the Pi supporting clock speeds up to 125MHz theoretically (though practical speeds depend on the peripheral). The tradeoff is that each SPI device requires its own chip enable line, limiting simultaneous connections.

Enable SPI through raspi-config under Interface Options, similar to I2C.

UART (Serial Communication) Pins

UART provides simple serial communication, commonly used for debugging, GPS modules, and communication between microcontrollers.

Pin FunctionPhysical PinGPIO (BCM)
TX (Transmit)8GPIO 14
RX (Receive)10GPIO 15

By default, Raspberry Pi OS uses these pins for the serial console. To use UART for other purposes, disable the console in raspi-config under Interface Options > Serial Port.

When connecting UART devices, remember to cross TX and RX lines. Your Pi’s TX connects to the peripheral’s RX, and vice versa. Also, ensure both devices share a common ground.

Communication Protocol Comparison

ProtocolSpeedWiresDevicesBest For
I2CUp to 400kHz (standard)2Multiple (127 max)Sensors, small displays
SPIUp to 125MHz4+Limited by CE pinsDisplays, SD cards, fast sensors
UARTUp to 115200 baud typical2Point-to-pointDebug, GPS, microcontroller comm

PWM (Pulse Width Modulation) Pins

PWM signals control LED brightness, servo motor positions, and motor speeds. The Raspberry Pi provides both hardware and software PWM options.

Hardware PWM Pins

True hardware PWM runs independently of CPU load and provides stable, precise signals. Four GPIO pins support hardware PWM:

Physical PinGPIO (BCM)PWM Channel
12GPIO 18PWM0
32GPIO 12PWM0
33GPIO 13PWM1
35GPIO 19PWM1

Note that GPIO 12 and 18 share PWM channel 0, while GPIO 13 and 19 share channel 1. You can only generate two independent hardware PWM signals simultaneously.

Software PWM

Any GPIO pin can produce software-generated PWM, but these signals depend on CPU timing and may jitter under load. For LED dimming or non-critical applications, software PWM works fine. For servo control or precision applications, hardware PWM is essential.

Essential Safety Precautions for GPIO Usage

Working with raspberry pi pins requires careful attention to electrical specifications. I’ve seen plenty of dead Pis on lab benches, and most failures trace back to simple mistakes.

Voltage Limits

All GPIO pins operate at 3.3V logic levels. Input voltages above 3.3V damage the SoC permanently. When interfacing with 5V systems like Arduino Uno, use bidirectional level shifters or resistive voltage dividers.

Current Limits

Each GPIO pin can source or sink approximately 16mA safely. The total current across all GPIO pins should not exceed 50mA. For driving LEDs, always use appropriate current-limiting resistors (220Ω to 1kΩ typically).

ESD (Electrostatic Discharge) Protection

The BCM SoC has minimal ESD protection. Work on an anti-static mat and ground yourself before handling the Pi. In production designs, consider adding external ESD protection diodes on GPIO lines.

Hot Swapping Warning

Never connect or disconnect components while the Pi is powered. Hot-swapping causes voltage spikes that can damage both the Pi and your peripherals. Power down completely before making any wiring changes.

Useful Resources for Raspberry Pi GPIO Development

ResourceURLDescription
Pinout.xyzpinout.xyzInteractive pinout reference
Raspberry Pi Documentationraspberrypi.com/documentationOfficial hardware docs
gpiozero Documentationgpiozero.readthedocs.ioPython GPIO library
SparkFun Pi Tutorialslearn.sparkfun.comHardware tutorials
Pi My Life Up GPIO Guidepimylifeup.com/raspberry-pi-gpioBeginner tutorials
BCM2835 Datasheetraspberrypi.com/documentationSoC technical reference
Random Nerd Tutorialsrandomnerdtutorials.comProject guides

Getting Started with GPIO Programming

For those ready to start using GPIO pins, here’s a minimal Python example using the gpiozero library:

from gpiozero import LED, Button

from time import sleep

# LED on GPIO 17 (physical pin 11)

led = LED(17)

# Button on GPIO 27 (physical pin 13)

button = Button(27)

# Turn LED on when button pressed

button.when_pressed = led.on

button.when_released = led.off

# Keep program running

while True:

    sleep(1)

This example demonstrates both input (button) and output (LED) operations using BCM numbering. The gpiozero library handles pin configuration automatically, making it ideal for beginners.

Frequently Asked Questions About Raspberry Pi GPIO

What is the difference between BCM and BOARD pin numbering?

BCM numbering uses the Broadcom SoC’s internal GPIO channel numbers (like GPIO 17), while BOARD numbering counts physical pin positions on the header (1-40). Most modern Python libraries default to BCM. When programming, you specify which system you’re using at the start of your code. Physical pin 11 equals GPIO 17 in BCM terms.

Can I use 5V sensors with Raspberry Pi GPIO pins?

Not directly. All raspberry pi pins operate at 3.3V logic levels. Connecting 5V signals to GPIO inputs permanently damages the Broadcom SoC. Use a bidirectional logic level converter (like the TXB0108) or a resistive voltage divider to safely interface 5V devices with your Pi’s GPIO.

How many GPIO pins are available for general use?

The 40-pin header contains 26 GPIO pins technically, but practical availability depends on your needs. Subtracting I2C, SPI, and UART pins if you’re using those protocols leaves approximately 17-21 pins for general digital I/O. Pins 27 and 28 are reserved for HAT identification and shouldn’t be used for typical projects.

What is the maximum current I can draw from a GPIO pin?

Individual GPIO pins can safely source or sink up to 16mA. The combined current across all GPIO pins should stay below 50mA. For higher current loads, use transistors, MOSFETs, or driver ICs to switch the current rather than drawing it directly from GPIO. The 3.3V power pins can supply approximately 50mA total as well.

Do I need pull-up or pull-down resistors for GPIO inputs?

The Raspberry Pi includes internal pull-up and pull-down resistors that can be enabled through software. For most applications with switches and buttons, these internal resistors work fine. The I2C pins (GPIO 2 and 3) have fixed external 1.8kΩ pull-ups that cannot be disabled. For noise-sensitive applications or long wire runs, external resistors may provide better reliability.

Conclusion: Mastering the Raspberry Pi Pinout

The raspberry pi pinout represents the gateway between software and physical hardware. Understanding which pins handle power, communication protocols, and general I/O transforms a simple computer into a powerful embedded development platform.

Remember the critical points: always respect the 3.3V logic level limit, use appropriate current-limiting resistors, and never hot-swap connections. The 40-pin header design has remained consistent across modern Pi models specifically to ensure compatibility, so learning this layout once serves you for years of projects.

Start with simple LED circuits to build confidence with the GPIO pins, then progress to I2C sensors and SPI displays as your understanding grows. The Raspberry Pi’s GPIO interface balances accessibility for beginners with enough capability for sophisticated embedded systems work.

Keep this reference guide bookmarked. When you’re elbow-deep in wires at 2 AM trying to remember which pin is SPI MOSI, having a reliable raspberry pi pins reference makes all the difference between finishing your project and troubleshooting until sunrise.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.