Complete GPIO pinout reference for Raspberry Pi 40-pin header. EdgeFlow uses BCM (Broadcom) pin numbering for all GPIO operations. This guide covers all pin functions, alternate modes, and wiring recommendations.
Interactive Pinout Diagram
Hover over any pin to see its details. Click to copy the pin information.
Pin Functions Reference
Power Pins
3.3V Power (Pins 1, 17)
Regulated 3.3V output from the Pi's onboard regulator. Maximum current draw is approximately 50mA when shared with GPIO. Use for powering 3.3V sensors and logic-level devices.
5V Power (Pins 2, 4)
Direct 5V from the USB power input (minus any voltage drop). Can supply more current for 5V devices like relays, motors, and displays. Current limited by your power supply.
Ground (Pins 6, 9, 14, 20, 25, 30, 34, 39)
Common ground reference for all circuits. Always connect the ground of external devices to one of these pins. Multiple ground pins allow for better current distribution.
I2C Bus (Inter-Integrated Circuit)
I2C is a two-wire serial protocol for connecting multiple devices using just two pins. Each device has a unique address (7-bit, 0x00-0x77). EdgeFlow supports up to 128 devices on a single bus.
| Pin | GPIO | Function | Description |
|---|---|---|---|
| 3 | GPIO2 | SDA (Data) | Bidirectional data line. Connect to SDA on all I2C devices. |
| 5 | GPIO3 | SCL (Clock) | Clock line driven by master (Pi). Connect to SCL on all I2C devices. |
# Enable I2C interface
sudo raspi-config nonint do_i2c 0
# Install I2C tools
sudo apt install -y i2c-tools
# Scan for connected devices
sudo i2cdetect -y 1
# Example output shows device at 0x76 (BME280)
# 0 1 2 3 4 5 6 7 8 9 a b c d e f
# 70: -- -- -- -- -- -- 76 -- SPI Bus (Serial Peripheral Interface)
SPI is a high-speed, full-duplex serial protocol. Unlike I2C, each device needs a separate chip select (CE) line. SPI is faster than I2C and ideal for high-bandwidth devices like displays and ADCs.
| Pin | GPIO | Function | Description |
|---|---|---|---|
| 19 | GPIO10 | MOSI | Master Out Slave In - Data from Pi to device |
| 21 | GPIO9 | MISO | Master In Slave Out - Data from device to Pi |
| 23 | GPIO11 | SCLK | Serial Clock - Clock signal from Pi |
| 24 | GPIO8 | CE0 | Chip Enable 0 - Select device 0 (active low) |
| 26 | GPIO7 | CE1 | Chip Enable 1 - Select device 1 (active low) |
# Enable SPI interface
sudo raspi-config nonint do_spi 0
# Verify SPI devices are available
ls -la /dev/spidev*
# Should show: /dev/spidev0.0 and /dev/spidev0.1 UART (Serial Port)
UART provides asynchronous serial communication. Used for GPS modules, GSM modems, and serial sensors. The Pi has two UARTs: a full-featured PL011 and a mini UART.
| Pin | GPIO | Function | Description |
|---|---|---|---|
| 8 | GPIO14 | TXD | Transmit Data - Connect to device RX |
| 10 | GPIO15 | RXD | Receive Data - Connect to device TX |
⚠️ UART Voltage Warning
The Pi's UART operates at 3.3V logic levels. Connecting 5V serial devices directly will damage the Pi! Use a level shifter for 5V devices.
# Enable serial port (disable login shell over serial)
sudo raspi-config nonint do_serial 2
# The serial port is available at:
# /dev/ttyAMA0 (Pi 4/5) or /dev/serial0 (symlink) 1-Wire Protocol
1-Wire is a single-wire protocol (plus ground) primarily used for DS18B20 temperature sensors. Multiple sensors can share the same data pin, each identified by a unique 64-bit ROM code.
| Pin | GPIO | Function | Description |
|---|---|---|---|
| 7 | GPIO4 | DATA | 1-Wire data line (default, configurable) |
# Enable 1-Wire interface
sudo raspi-config nonint do_onewire 0
# Or add to /boot/config.txt:
# dtoverlay=w1-gpio
# After reboot, sensors appear in:
ls /sys/bus/w1/devices/
# Example: 28-00000xxxxxxx
# Read temperature
cat /sys/bus/w1/devices/28-*/temperature
# Returns temperature in millidegrees (25125 = 25.125°C) PWM (Pulse Width Modulation)
PWM generates variable duty-cycle signals for controlling LED brightness, servo motors, and motor speed. The Pi has 2 hardware PWM channels, each available on multiple pins.
| Pin | GPIO | PWM Channel | Notes |
|---|---|---|---|
| 12 | GPIO18 | PWM0 | Also used for PCM/I2S audio clock |
| 32 | GPIO12 | PWM0 | Alternative pin for PWM channel 0 |
| 33 | GPIO13 | PWM1 | Hardware PWM channel 1 |
| 35 | GPIO19 | PWM1 | Alternative pin for PWM channel 1 |
💡 Software PWM
EdgeFlow can generate software PWM on any GPIO pin, but hardware PWM is more accurate and doesn't consume CPU. Use hardware PWM pins when precision timing is required (servos, precise dimming).
GPIO Electrical Specifications
Voltage Levels
| Logic High (Output) | 3.3V |
| Logic Low (Output) | 0V |
| Input High Threshold | ≥1.3V |
| Input Low Threshold | ≤0.8V |
| Maximum Input Voltage | 3.3V |
Current Limits
| Max per GPIO pin | 16mA |
| Recommended per pin | 8mA |
| Total GPIO current | 50mA |
| 3.3V rail max | ~50mA |
| 5V rail max | PSU limited |
Internal Pull Resistors
| Pull-up resistance | ~50kΩ |
| Pull-down resistance | ~50kΩ |
| I2C pull-ups (GPIO2/3) | 1.8kΩ |
Internal pulls are weak. Use external 4.7kΩ-10kΩ resistors for reliable operation.
Timing (Pi 5)
| GPIO toggle rate | ~30MHz |
| I2C fast mode | 1MHz |
| SPI max clock | 125MHz |
| PWM resolution | 12-bit |
Pi 5 GPIO is ~10× faster than Pi 4 due to RP1 chip.
Common Wiring Diagrams
🌡️ DS18B20 Temperature Sensor
DS18B20 Pi
─────── ────
GND ─────────── GND (Pin 6)
VDD ─────────── 3V3 (Pin 1)
DQ ──┬──────── GPIO4 (Pin 7)
│
4.7kΩ
│
3V3
4.7kΩ pull-up resistor required between DQ and 3.3V
📊 BME280 (I2C Mode)
BME280 Pi
─────── ────
VIN ─────────── 3V3 (Pin 1)
GND ─────────── GND (Pin 6)
SCL ─────────── GPIO3 (Pin 5)
SDA ─────────── GPIO2 (Pin 3)
I2C address: 0x76 (or 0x77 if SDO pin is high)
📟 OLED SSD1306 Display
SSD1306 Pi
─────── ────
VCC ─────────── 3V3 (Pin 1)
GND ─────────── GND (Pin 6)
SCL ─────────── GPIO3 (Pin 5)
SDA ─────────── GPIO2 (Pin 3)
I2C address: 0x3C (or 0x3D)
🔘 Button with Pull-up
Button Pi
─────── ────
One leg ──┬──── GPIO17 (Pin 11)
│
10kΩ
│
3V3
Other leg ───── GND (Pin 6)
Button press reads as LOW. Can use internal pull-up instead.
💡 LED with Resistor
LED Pi
─────── ────
Anode (+) ─330Ω─ GPIO18 (Pin 12)
Cathode (-) ──── GND (Pin 6)
330Ω for standard LED at ~10mA. Adjust for different LEDs.
🔌 Relay Module
Relay Module Pi
─────── ────
VCC ─────────── 5V (Pin 2)
GND ─────────── GND (Pin 6)
IN ─────────── GPIO23 (Pin 16)
Most relay modules are active-low (LOW = relay ON)
EdgeFlow GPIO Nodes
EdgeFlow provides dedicated nodes for GPIO operations:
GPIO Input
Read digital input state (HIGH/LOW). Supports pull-up/pull-down configuration and edge detection (rising, falling, both).
GPIO Output
Set digital output state. Control LEDs, relays, and other digital devices. Supports initial state configuration.
PWM Output
Generate PWM signals for LED dimming, servo control, and motor speed. Configurable frequency and duty cycle (0-255).
I2C Sensors
Built-in support for BME280, BH1750, AHT20, SHT3x, ADS1015, and more. Auto-detection and configuration.
Raspberry Pi 5 GPIO Differences
🆕 Pi 5 RP1 Chip Changes
Raspberry Pi 5 uses a new RP1 I/O controller chip with some differences from earlier models:
- GPIO Chip: Uses
gpiochip4instead ofgpiochip0 - Speed: ~10× faster GPIO toggle rate (~30MHz vs ~3MHz)
- I2C: Supports up to 1MHz fast mode plus
- Pinctrl: More flexible alternate function mapping
EdgeFlow automatically detects your Pi model and configures the correct GPIO interface.
Troubleshooting
❌ GPIO permission denied
sudo usermod -a -G gpio $USER
# Log out and back in ❌ I2C device not detected
# Check wiring, then scan:
sudo i2cdetect -y 1
# Check if I2C is enabled:
ls /dev/i2c* ❌ SPI not working
# Check if SPI is enabled:
ls /dev/spidev*
# Enable if needed:
sudo raspi-config nonint do_spi 0 ❌ 1-Wire sensor not found
# Check 1-Wire devices:
ls /sys/bus/w1/devices/
# Should show 28-xxxx for DS18B20