Posted on

Raspberry Pi GPIO Pins Explained: 40-Pin Header, Power, Ground and Interfaces

Raspberry Pi 40-pin GPIO header diagram showing physical pin numbers, BCM GPIO names, power and ground

Raspberry Pi GPIO pins let a Python program read switches and sensors or control LEDs, relays and other hardware. The 40-pin header also exposes power, ground and dedicated interfaces such as I²C, SPI and UART. This guide explains how to read the header safely and choose a pin for a project.

For the complete interactive diagram, keep the Raspberry Pi GPIO Pinout reference open while you wire. Pinout.xyz distinguishes the physical position on the header from the BCM GPIO number used by many Python libraries.

The three kinds of pins

Every header position belongs to one of three practical groups:

  • GPIO: General-purpose input/output pins that software can configure as digital inputs or outputs. The BCM number is the GPIO identifier, such as GPIO17.
  • Power: 3.3V and 5V pins provide a supply rail. They are not ordinary GPIO outputs and must not be driven by software.
  • Ground: Ground pins complete the circuit. Connect the device ground to a Pi ground pin before testing signals.

BCM numbers versus physical pin numbers

A physical pin number describes a position on the header: physical pin 11 is the eleventh header position. A BCM number describes the SoC signal assigned to that position: physical pin 11 carries GPIO17. These names are not interchangeable. A wiring diagram may say “pin 11” while Python code expects GPIO17 or 17.

Orient the Pi with the HDMI connectors on the left and the GPIO header on the right. In that view, physical pin 1 is at the top; the square pad on the underside identifies pin 1 on an unmounted board. Always compare the board orientation with the interactive pinout before inserting a jumper wire.

Raspberry Pi 40-pin GPIO header diagram showing physical pin numbers, BCM GPIO names, power and ground
Raspberry Pi 40-pin header overview. Open the interactive Pinout.xyz reference for the complete, board-orientation-aware diagram.

A practical 40-pin reference

Physical pinBCM / functionTypical use
13.3V power3.3V supply rail
25V power5V supply rail
3GPIO2 / I²C SDAI²C data
5GPIO3 / I²C SCLI²C clock
6GroundCircuit return
7GPIO4Digital input/output
8GPIO14 / UART TXSerial transmit
10GPIO15 / UART RXSerial receive
11GPIO17General-purpose input/output
12GPIO18 / PCM CLKDigital I/O or audio clock
13GPIO27General-purpose input/output
15GPIO22General-purpose input/output
16GPIO23General-purpose input/output
18GPIO24General-purpose input/output
19GPIO10 / SPI MOSISPI controller output
21GPIO9 / SPI MISOSPI controller input
23GPIO11 / SPI SCLKSPI clock
24GPIO8 / SPI CE0SPI chip select
26GPIO7 / SPI CE1Second SPI chip select
29GPIO5General-purpose input/output
31GPIO6General-purpose input/output
32GPIO12 / PWM0Hardware PWM option
33GPIO13 / PWM1Hardware PWM option
35GPIO19 / PCM FSDigital I/O or audio frame sync
36GPIO16General-purpose input/output
37GPIO26General-purpose input/output
38GPIO20 / PCM DINDigital I/O or audio input
40GPIO21 / PCM DOUTDigital I/O or audio output

This is a working-project reference, not a replacement for the board-specific documentation. Physical pins 27 and 28 carry the ID EEPROM signals (GPIO0 and GPIO1), and the remaining header positions are power or ground. Check the complete diagram before using a less common alternate function.

Common GPIO interfaces

InterfaceCommon pinsWhat it is for
I²CGPIO2 (SDA), GPIO3 (SCL)Multiple addressed sensors and display modules on two signal wires.
SPIGPIO10, GPIO9, GPIO11 plus GPIO8 or GPIO7Fast peripherals such as ADCs, displays and storage devices.
UARTGPIO14 (TX), GPIO15 (RX)Serial consoles and GPS or other serial modules.
PWMGPIO12, GPIO13 and other software-controlled pinsBrightness, motor or servo control when the hardware and library support it.
1-WireConfigured GPIO pinDevices such as DS18B20 temperature probes on a shared data line.

A safe first GPIO test

Use an LED with a suitable resistor, or an LED module designed for 3.3V logic. This example uses BCM GPIO17, which is physical pin 11:

from gpiozero import LED
from time import sleep

led = LED(17)  # BCM GPIO17 = physical pin 11

try:
    while True:
        led.toggle()
        sleep(1)
except KeyboardInterrupt:
    led.off()Code language: Python (python)
  • Never connect 5V to a GPIO signal pin. Raspberry Pi GPIO uses 3.3V logic.
  • Use a resistor to limit LED current, and use a level shifter or voltage divider when a peripheral outputs more than 3.3V.
  • Turn the Pi off while changing wiring, and verify the pin number convention in both the guide and the code.
  • Do not draw more current than the board, power supply or peripheral is designed to provide.

GPIO troubleshooting checklist

  • Confirm whether the diagram uses physical, BCM or WiringPi numbering.
  • Check that the circuit has a shared ground with the Pi.
  • Check the pin is not already claimed by I²C, SPI, UART, a HAT or a background service.
  • Check the input pull-up or pull-down setting and whether the switch is active-low.
  • Return to the interactive Pinout.xyz diagram for alternate functions and the exact header orientation.

Source and next step

Pin names, physical positions, alternate interfaces and orientation in this guide are based on Pinout.xyz’s Raspberry Pi GPIO Pinout reference. Use it as the canonical visual check before wiring a project. Next, try the Raspberry Pi weather dashboard project and map its sensor wires to the GPIO numbers in the code.