🧰 4. Raspberry Pi – GPIO & Hardware Integration
Estimated reading: 4 minutes 346 views

Raspberry Pi – GPIO Connector Overview (2025 Beginner’s Guide to Pins & Projects)


Introduction – What Is the GPIO Connector on Raspberry Pi?

The GPIO (General Purpose Input/Output) header on Raspberry Pi is what turns it from a mini-computer into a powerful physical computing platform. It lets you interface with LEDs, sensors, motors, buttons, and other electronic components directly through Python or shell scripts.

In this guide, you’ll learn:

  • GPIO layout and pin numbering schemes
  • Different pin types (power, ground, data)
  • Safe voltage levels and precautions
  • Tools and libraries to use GPIO
  • Example project: Blinking an LED

GPIO Pin Header – What It Looks Like

Most Raspberry Pi models (Pi 2/3/4/Zero/5) include a 40-pin GPIO header with the following layout:

GPIO Pin Layout (Top View)
1️⃣ Pin 1 = 3.3V
2️⃣ Pin 2 = 5V
3️⃣ Pin 3 = GPIO2 (SDA1, I2C)
4️⃣ Pin 4 = 5V
5️⃣ Pin 5 = GPIO3 (SCL1, I2C)
… and so on up to Pin 40

Pins include:

  • Power (3.3V, 5V)
  • Ground (GND)
  • Digital I/O Pins (GPIO)
  • Special interfaces (I2C, SPI, UART, PWM)

GPIO Pin Numbering – Two Modes

There are two ways to number pins:

ModeDescriptionUse In Code
BoardPhysical pin numbers (1–40)GPIO.setmode(GPIO.BOARD)
BCMBroadcom SoC numbers (e.g., GPIO17)GPIO.setmode(GPIO.BCM)

BCM mode is preferred in most Python libraries and tutorials.


GPIO Pin Types – Categorized Table

Type Pins (Typical) Description
Power1 (3.3V), 2/4 (5V), 17 (3.3V)Provide voltage to sensors/LEDs
Ground (GND)6, 9, 14, 20, 25, 30, 34, 39Ground reference
GPIO (Digital)7, 11, 13, 15, 16, 18, etc.Input/output for sensors, buttons, etc.
PWM12, 32, 33For motor/LED dimming (software PWM)
I2C3 (SDA), 5 (SCL)Interfacing with I2C sensors/modules
SPI19 (MOSI), 21 (MISO), 23 (SCLK)High-speed communication
UART8 (TXD), 10 (RXD)Serial communication (e.g., GPS modules)

GPIO Voltage Limits – Stay Safe

  • GPIO pins are 3.3V logic
  • Do NOT connect 5V directly to GPIO pins
  • Always use resistors with LEDs, level shifters with 5V components

Example:
Use 330Ω resistor with LED to avoid overloading the GPIO


Access GPIO with Python – Setup

Install GPIO library:

sudo apt update
sudo apt install python3-gpiozero

Import in your script:

from gpiozero import LED
from time import sleep

led = LED(17)  # GPIO17 (BCM mode)

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)

Run it:

python3 led_blink.py

This code blinks an LED connected to GPIO17 every second.


Tools to Visualize GPIO Pins

Tool Use Case
pinoutBuilt-in command for GPIO layout
pinout.xyzVisual web-based GPIO map
GPIO Extension BoardMakes pin access safer & easier

GPIO Troubleshooting Tips

  • LED not lighting up? ➜ Check polarity and GPIO number
  • Pi shuts down? ➜ You may have shorted 5V to GND
  • PWM not working? ➜ Make sure you’re using correct PWM-capable pins

Beginner-Friendly Project – Pushbutton + LED

Component Description
GPIO17Connect to LED (via 330Ω)
GPIO18Connect to pushbutton

Python Code:

from gpiozero import LED, Button
from signal import pause

led = LED(17)
button = Button(18)

button.when_pressed = led.on
button.when_released = led.off

pause()

Press button ➜ LED turns on. Release ➜ LED turns off.


Summary – Recap & Next Steps

GPIO is where software meets hardware on Raspberry Pi. Whether you’re controlling LEDs, motors, or sensors, learning how to use GPIO pins opens up a world of interactive electronics.

Key takeaways:

  • GPIO header includes power, ground, digital, and special function pins
  • Use gpiozero or RPi.GPIO to control hardware via Python
  • Avoid overvoltage (only 3.3V logic!) and short circuits
  • Try basic projects like blinking LEDs or pushbuttons to start

Real-world relevance: GPIO is used in robotics, automation, wearables, smart home setups, and STEM education.


FAQs – Raspberry Pi GPIO Connector

How many GPIO pins does Raspberry Pi have?

26 GPIO-capable pins on the 40-pin header (including power, GND, I2C, SPI, UART, etc.)


What’s the safest way to connect hardware to GPIO?

Use resistors, transistors, or logic level shifters. Avoid direct 5V inputs to GPIO.


Can I use GPIO in Bash or other languages?

Yes. GPIO can be controlled via shell scripts, Node.js, or C/C++ using libraries like wiringPi.


Are all GPIO pins the same?

No. Some support PWM, I2C, SPI, or UART. Refer to pinout maps to avoid confusion.


How can I test if GPIO is working?

Use the gpiozero Python library or command-line tools like raspi-gpio or pinout.


Share Now :
Share

🧩 Raspberry Pi – GPIO Connector Overview

Or Copy Link

CONTENTS
Scroll to Top