Raspberry Pi GPIO (General-Purpose Input/Output) pins are the 26 programmable digital signal paths on the 40-pin header that allow the board's software to read binary sensor states or drive external hardware high (3.3V) and low (0V). By toggling these pins, you change a physical circuit from an open to a closed state, letting a Python script turn on a relay, read a PIR motion sensor, or bit-bang a custom protocol. Beginners frequently confuse the programmable RPi GPIO pins with the dedicated 5V and 3.3V power rails, or fatally assume they are 5V-tolerant like an Arduino Uno; they are strictly 3.3V, and feeding 5V into them will instantly destroy the BCM2711 (Pi 4) or BCM2712 (Pi 5) SoC.

The Anatomy of the 40-Pin Header

While the header is colloquially called the "40-pin GPIO header," not all pins are programmable I/O. The physical layout has remained backward-compatible since the Raspberry Pi 1 Model B+, meaning a physical wiring harness designed for a Pi 3 will physically mate with a Pi 5. However, the underlying silicon and software ecosystems have shifted. On modern Raspberry Pi OS (Bookworm and later), direct memory access via the legacy RPi.GPIO library is deprecated; you must use gpiozero or the lgpio C-library to interact with the pins securely.

Here is how the 40 pins are actually distributed on the board:

Pin Category Count Function & Notes
Standard GPIO 26 Programmable 3.3V digital I/O. Can be configured with internal pull-ups/downs.
Power (5V) 2 Directly tied to the USB-C power input. Use for high-current external loads.
Power (3.3V) 2 Output from the onboard voltage regulator. Max draw is typically ~50mA.
Ground (GND) 8 Common ground reference. Always share this ground with external power supplies.
Dedicated I2C 2 GPIO 2 (SDA) and GPIO 3 (SCL). Include onboard 1.8kΩ pull-up resistors to 3.3V.
EEPROM / HAT ID 2 GPIO 0 and GPIO 1. Reserved for HAT identification; do not use for general I/O.

Source: The definitive pin mappings and alternate functions are best visualized using the interactive Raspberry Pi Pinout tool, which accounts for board-specific revisions.

Electrical Limits and a Worked Numeric Example

The most common way makers brick a Raspberry Pi is by ignoring the absolute maximum ratings of the GPIO bank. The Broadcom SoC is designed for logic signaling, not power delivery.

Critical Limit: The absolute maximum current draw is 16mA per individual GPIO pin, and the total combined current across all GPIO pins must not exceed 50mA. If you need to drive a motor, a high-power LED strip, or a mechanical relay, you must use a transistor (like a 2N2222 or IRLZ44N MOSFET) or an optocoupler to switch a separate power supply.

Worked Numeric Example: Sizing a Resistor for a GPIO-Driven LED

Let’s say you want to wire a standard 5mm red indicator LED directly to GPIO 17 (Physical Pin 11) to signal when a Python script finishes a task.

  • GPIO High Voltage ($V_{cc}$): 3.3V
  • LED Forward Voltage ($V_f$): 2.0V (typical for red)
  • Target Current ($I$): 10mA (0.01A) — chosen to stay safely under the 16mA per-pin limit.

Using Ohm’s Law ($R = V / I$), we first find the voltage drop the resistor must handle:
$V_{drop} = V_{cc} - V_f = 3.3V - 2.0V = 1.3V$

Now, calculate the resistance:
$R = 1.3V / 0.01A = 130\Omega$

Since 130Ω is not a standard E12 resistor value, we round up to the next standard value to ensure we don't exceed our current target: 150Ω.
Finally, check the power dissipation to ensure the resistor won't overheat:
$P = I^2 \times R = (0.01)^2 \times 150 = 0.015W$.
A standard 1/4W (0.25W) through-hole resistor is more than adequate.

Think of a GPIO output pin like a digital water valve controlled by a micro-timer: it’s either fully open (3.3V) or fully closed (0V), and if you pulse it fast enough using hardware PWM, you can simulate a partially open valve to dim an LED or control a servo's position.

Where You Meet RPi GPIO Pins in Practice

In real-world installations and bench projects, you will rarely wire raw components directly to the header. Here is how RPi GPIO pins are actually deployed in the field:

1. Home Automation and Relay Switching
When using the Pi to control 120V/240V AC loads via a relay board, you never wire the relay coil to the Pi's 5V rail, as the coil's inductive kickback and 70mA+ draw will cause a brownout. Instead, you wire the relay board's VCC to an external 5V phone charger, share the GND with the Pi, and connect the Pi's 3.3V GPIO pin to the relay's IN pin. Note: Many cheap optocoupler relay boards require 5V logic to trigger reliably; if using one, you must route the Pi's GPIO through a bidirectional logic level shifter (like the BSS138-based Adafruit 4-channel shifter) to step the 3.3V signal up to 5V.

2. Environmental Sensor Arrays (I2C)
When wiring a BME280 temperature/humidity sensor, you use the dedicated I2C pins (GPIO 2 and GPIO 3). Because the Raspberry Pi already includes 1.8kΩ pull-up resistors on these specific pins, you do not need to add external pull-ups on your breadboard. You simply wire SDA to SDA, SCL to SCL, VCC to 3.3V, and GND to GND, then poll the sensor via the smbus2 Python library.

3. Pi 5 Specifics: The RTC and Power Button
If you are working with the Raspberry Pi 5, the official hardware documentation highlights new dedicated pins on the J2 (RTC battery) and J5 (UART/Power) headers. While the main 40-pin header remains identical, the Pi 5 introduces a dedicated physical power button pin and an RTC battery connector, changing how you design custom carrier boards for low-power, battery-backed IoT deployments.

Frequently Asked Questions

Can I power a servo motor directly from RPi GPIO pins?

No. While a GPIO pin can output the 50Hz PWM signal required to tell a servo where to move, the servo's power rails (typically red and brown/black wires) must be connected to a dedicated 5V or 6V Battery Eliminator Circuit (BEC) or external power supply. A standard SG90 micro servo can draw over 500mA under stall conditions, which will instantly trip the Pi's polyfuse or cause a system brownout if pulled from the Pi's 5V rail, and would physically melt the SoC if pulled from a 3.3V GPIO pin.

Why does my Raspberry Pi reboot when I connect a sensor to a GPIO pin?

This is almost always a power integrity issue. If you are powering multiple sensors or LEDs directly from the Pi's 3.3V or 5V header pins, you are likely exceeding the total current capacity of the onboard voltage regulator or the USB-C input limit. When the voltage drops below the SoC's minimum threshold (typically around 4.63V on the 5V rail), the brownout detector triggers an immediate reboot to protect the filesystem. Use a multimeter to measure the 5V and GND pins while plugging in your sensor; if it dips, you need an external power supply.

Do I need to enable pull-up or pull-down resistors in software?

Yes, if you are reading a simple push-button or a reed switch. A GPIO pin configured as an input without a pull resistor is "floating," meaning it will pick up ambient electromagnetic noise and return erratic True/False values. The Broadcom SoC has internal ~50kΩ pull-up and pull-down resistors that can be enabled via the gpiozero library (e.g., Button(17, pull_up=True)). However, in electrically noisy environments (like near AC motors or long wire runs), you should bypass the internal resistors and solder a physical 10kΩ external pull-down resistor to ensure a rock-solid logic low.

What is the difference between BOARD and BCM numbering in Python?

BOARD numbering refers to the physical pin location on the header (e.g., Pin 11). BCM numbering refers to the Broadcom SoC's internal channel designation for that pin (e.g., GPIO 17). Because physical pin layouts are identical across generations but Broadcom channel mappings occasionally shifted in early Pi history, modern best practice is to exclusively use BCM numbering. It matches the official schematics, the gpiozero default behavior, and the pinout diagrams printed on most HATs.