Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Raspberry Pi

Raspberry Pi GPIO Pinout: Complete Reference Guide

Raspberry Pi GPIO Pinout: Complete Reference Guide

April 1, 2026 /Posted by / 0

The Raspberry Pi GPIO pinout is your interface between software and the physical world — 40 pins that connect to sensors, LEDs, motors, displays, and communication buses. This complete reference guide covers every pin’s function, voltage levels, and safe usage practices across all Raspberry Pi models with the 40-pin header.

Table of Contents

  • GPIO Header Overview
  • Complete Pinout Map
  • Power Pins: 3.3V, 5V, and Ground
  • Digital I/O: Input and Output
  • I2C Interface
  • SPI Interface
  • UART (Serial) Interface
  • PWM (Pulse Width Modulation)
  • Safety Rules and Common Mistakes
  • Frequently Asked Questions
  • Conclusion

GPIO Header Overview

Every Raspberry Pi from the Model B+ onwards (including Pi 2, 3, 4, 5, Zero, and Zero 2) uses the same 40-pin GPIO header. The pinout is identical across all these models, making hardware designs and HATs universally compatible.

The 40-pin header provides:

  • 26 GPIO pins — configurable as digital input or output
  • 2x 5V power pins — connected directly to the Pi’s power rail
  • 2x 3.3V power pins — regulated 3.3V output (up to ~50mA per pin total)
  • 8x Ground pins — common ground reference
  • 2x ID EEPROM pins — reserved for HAT identification (GPIO 0 and GPIO 1)

All GPIO pins operate at 3.3V logic. This is critical: connecting a 5V signal directly to a GPIO pin can permanently damage the Pi’s processor. More on this in the safety section.

Complete Pinout Map

The 40-pin header has two numbering systems: physical pin numbers (1-40, as printed on the board) and BCM GPIO numbers (the numbers used in software). Always use BCM GPIO numbers in your code.

Pin Function | Function Pin
1 (3.3V) 3.3V Power | 5V Power 2 (5V)
3 (GPIO 2) I2C1 SDA | 5V Power 4 (5V)
5 (GPIO 3) I2C1 SCL | Ground 6 (GND)
7 (GPIO 4) GPCLK0 | UART TX 8 (GPIO 14)
9 (GND) Ground | UART RX 10 (GPIO 15)
11 (GPIO 17) GPIO | GPIO (PWM0) 12 (GPIO 18)
13 (GPIO 27) GPIO | Ground 14 (GND)
15 (GPIO 22) GPIO | GPIO 16 (GPIO 23)
17 (3.3V) 3.3V Power | GPIO 18 (GPIO 24)
19 (GPIO 10) SPI0 MOSI | Ground 20 (GND)
21 (GPIO 9) SPI0 MISO | GPIO 22 (GPIO 25)
23 (GPIO 11) SPI0 SCLK | SPI0 CE0 24 (GPIO 8)
25 (GND) Ground | SPI0 CE1 26 (GPIO 7)
27 (GPIO 0) ID EEPROM SDA | ID EEPROM SCL 28 (GPIO 1)
29 (GPIO 5) GPIO | Ground 30 (GND)
31 (GPIO 6) GPIO | GPIO (PWM0) 32 (GPIO 12)
33 (GPIO 13) PWM1 | Ground 34 (GND)
35 (GPIO 19) SPI1 MISO/PWM1 | GPIO 36 (GPIO 16)
37 (GPIO 26) GPIO | SPI1 MOSI 38 (GPIO 20)
39 (GND) Ground | SPI1 SCLK 40 (GPIO 21)

Power Pins: 3.3V, 5V, and Ground

5V pins (Physical 2, 4): Connected directly to the USB power input. Provides the full input voltage (nominally 5V) at up to 1.5A (combined, after accounting for the Pi’s own consumption). Use these to power 5V peripherals like sensors and small displays.

3.3V pins (Physical 1, 17): Regulated 3.3V output from the Pi’s onboard regulator. Maximum combined current draw from these pins is approximately 50mA on Pi 4/5, though most of this is already consumed by the Pi’s internal circuits. Suitable for powering low-power sensors (BME280, MCP3008) but not motors or high-power devices.

Ground pins (Physical 6, 9, 14, 20, 25, 30, 34, 39): Eight ground pins, all connected internally. Use the ground pin nearest to your signal pins to minimise noise. Every circuit connected to the Pi must share a common ground.

Digital I/O: Input and Output

Any GPIO pin can be configured as a digital input (read HIGH/LOW) or digital output (write HIGH/LOW).

Output: HIGH = 3.3V, LOW = 0V. Maximum current per pin: approximately 16mA. This is enough for LEDs (with appropriate resistor) but not for motors or relays — use a transistor or MOSFET for higher-current loads.

Input: Reads 3.3V as HIGH, 0V as LOW. Internal pull-up and pull-down resistors are available (configurable in software). Always use a pull-up or pull-down resistor on input pins to prevent floating state.

Python example with gpiozero (recommended):

from gpiozero import LED, Button
from time import sleep

led = LED(17)       # GPIO 17 as output
button = Button(27) # GPIO 27 as input with pull-up

while True:
    if button.is_pressed:
        led.on()
    else:
        led.off()
    sleep(0.1)
🛒 Recommended: 40-Pin GPIO Extension Board for Raspberry Pi — Makes GPIO pins accessible on a breadboard with clear labelling for easy prototyping.

I2C Interface

I2C (Inter-Integrated Circuit) is a two-wire protocol for connecting multiple sensors and devices on a shared bus.

  • I2C1: GPIO 2 (SDA) and GPIO 3 (SCL) — the primary I2C bus
  • Speed: Default 100 kHz, configurable up to 400 kHz (fast mode)
  • Devices: Up to 127 devices on one bus (each needs a unique address)

Common I2C devices: BME280 (weather), SSD1306 (OLED display), MPU6050 (IMU), ADS1115 (ADC), PCA9685 (servo driver)

Enable I2C: sudo raspi-config > Interface Options > I2C > Enable

Scan for devices: i2cdetect -y 1

SPI Interface

SPI (Serial Peripheral Interface) is faster than I2C and used for devices requiring high throughput.

  • SPI0: MOSI (GPIO 10), MISO (GPIO 9), SCLK (GPIO 11), CE0 (GPIO 8), CE1 (GPIO 7)
  • SPI1: MOSI (GPIO 20), MISO (GPIO 19), SCLK (GPIO 21), CE0-CE2 available
  • Speed: Up to 125 MHz (practical maximum depends on wiring)

Common SPI devices: MCP3008 (ADC), MAX31855 (thermocouple), TFT displays, LoRa modules, NRF24L01 radio

UART (Serial) Interface

UART provides basic serial communication — commonly used for GPS modules, Bluetooth modules, and debugging.

  • TX: GPIO 14 (transmit)
  • RX: GPIO 15 (receive)
  • Baud rate: Configurable (9600, 115200, etc.)

Important: By default, the Pi uses the UART for a serial console (login terminal). Disable this in raspi-config > Interface Options > Serial Port if you want to use UART for your own devices. Disable login shell over serial but keep the serial port hardware enabled.

PWM (Pulse Width Modulation)

PWM controls the average power delivered to a component by rapidly switching the pin on and off. Used for LED brightness, servo motor position, and motor speed control.

  • Hardware PWM: GPIO 12, 13 (PWM0), GPIO 18, 19 (PWM1) — precise, low CPU usage
  • Software PWM: Any GPIO pin via gpiozero or pigpio — less precise, uses CPU

For servo motors, use hardware PWM pins for jitter-free control. For LED dimming, software PWM is adequate.

🛒 Recommended: T-Type GPIO Breakout Board with Cable and Breadboard — Connect GPIO to a breadboard for easy, damage-free prototyping.

Safety Rules and Common Mistakes

Rule 1: 3.3V logic ONLY. GPIO pins are 3.3V. Connecting a 5V sensor output directly to a GPIO pin damages the Pi’s processor permanently. Use a voltage divider (two resistors) or a logic level converter when interfacing with 5V devices.

Rule 2: Maximum 16mA per pin. Drawing more than 16mA from a GPIO pin can damage it. LEDs need a current-limiting resistor (330-1K ohm for typical LEDs). Never connect motors, solenoids, or relays directly to GPIO — use a transistor or driver board.

Rule 3: Never short 5V to 3.3V. Connecting the 5V rail to the 3.3V rail or any GPIO pin will likely destroy the Pi’s voltage regulator.

Rule 4: Use pull-up/pull-down resistors on inputs. Floating input pins read random values. Always pull inputs to a known state with a 10K resistor or use the internal pull-up/pull-down in software.

Rule 5: Power off before wiring. Always shut down and disconnect power before making or changing wiring connections. Hot-swapping jumper wires risks accidental shorts.

Common mistakes:

  • Using physical pin numbers instead of BCM GPIO numbers in code
  • Forgetting a current-limiting resistor for LEDs (results in dim/damaged LEDs and excessive pin current)
  • Connecting 5V sensors to 3.3V GPIO inputs without level shifting
  • Not sharing a common ground between the Pi and external circuits
  • Powering the Pi via GPIO 5V pins without adequate protection (no fuse, no reverse polarity protection)

Frequently Asked Questions

Is the GPIO pinout the same on Pi 4 and Pi 5?

Yes. The 40-pin header pinout is identical on Pi 2, 3, 4, 5, Zero, and Zero 2. Software libraries (gpiozero, RPi.GPIO) work the same way. The Pi 5 uses the RP1 chip for GPIO management, which may affect very low-level direct register access, but standard Python libraries handle this transparently.

Can I use GPIO pins while a HAT is connected?

It depends on which pins the HAT uses. Many HATs only use specific pins (I2C, SPI, or a few GPIO), leaving others available. Check the HAT’s documentation for which pins it requires. Use a GPIO stacking header if you need to access pins underneath a HAT.

Why does the Pi not have analogue input pins?

The Broadcom SoC does not include an ADC (analogue-to-digital converter). For analogue readings, add an external ADC like the MCP3008 (8-channel, 10-bit, SPI) or ADS1115 (4-channel, 16-bit, I2C). These cost ₹150-400 and connect via SPI or I2C.

What is the maximum wire length for GPIO connections?

For basic digital I/O, wires up to 20-30cm work without issues. For I2C, keep wires under 1 metre (shorter is better). SPI is sensitive to wire length — keep connections under 20cm. For longer distances, use appropriate bus drivers or switch to serial (UART) or CAN bus protocols.

Can I damage the Pi by incorrect wiring?

Yes. Connecting 5V to a GPIO pin, shorting pins together, or drawing excessive current can permanently damage the processor. Always double-check wiring before powering on. A ₹100 mistake in wiring can destroy a ₹7,000 Pi. Use a multimeter to verify connections when in doubt.

Conclusion

The 40-pin GPIO header is what makes the Raspberry Pi more than just a tiny computer — it is the bridge between digital software and physical electronics. Whether you are blinking an LED for the first time or building an industrial data logger with I2C sensors and SPI displays, understanding the GPIO pinout is fundamental.

Bookmark this reference guide, start with simple digital I/O projects, and progressively explore I2C sensors, SPI devices, and PWM control. The possibilities expand dramatically once you are comfortable with the GPIO interface.

Find Raspberry Pi boards, GPIO accessories, and breakout boards at Zbotic — India’s largest electronics component store.

Tags: GPIO, pinout, Raspberry Pi, Reference, tutorial
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
PCB Reverse Engineering: Cloni...
blog pcb reverse engineering cloning an existing board 612966
blog arduino mega 2560 projects when you need more pins 613022
Arduino Mega 2560 Projects: Wh...

Related posts

Svg%3E
Read more

Raspberry Pi Benchmarks: Performance Testing All Models

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi PoE: Power Over Ethernet Setup Guide

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi GSM HAT: SMS and Cellular IoT

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi RS485: Industrial Sensor Network

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading
Svg%3E
Read more

Raspberry Pi CAN Bus: Vehicle OBD2 Data Reader

April 1, 2026 0
Table of Contents Introduction and Use Cases Hardware Requirements Software Installation Configuration and Setup Testing and Validation Advanced Features Troubleshooting... Continue reading

Add comment Cancel reply

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

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now