40-pin GPIO overview
The Raspberry Pi 3 has a 40-pin GPIO (General Purpose Input/Output) header that lets you connect the Pi to the physical world. This header is shared across Pi 3, Pi 4, and Pi 5 models, making projects portable between generations.
What you can do with GPIO:
- Control LEDs, motors, relays, and other actuators
- Read sensors (temperature, motion, light, distance)
- Communicate with other devices via I2C, SPI, or UART
- Power small accessories directly from the Pi
- Build interactive electronics projects
Pin types
The 40-pin header includes several types of pins:
GPIO Pins: These can be programmed to send or receive signals. They're used to turn things on or off or detect if a button has been pressed. GPIO pins operate at 3.3V logic levels.
Power Pins: Provide constant 3.3V or 5V power to components like sensors or displays.
- 5V pins: Pins 2 and 4 supply 5V directly from the Pi's power input
- 3.3V pins: Pins 1 and 17 supply regulated 3.3V (limited total current)
Ground (GND) Pins: These complete the circuit by connecting your components to the Pi's ground. The ground pins are 6, 9, 14, 20, 25, 30, 34, and 39.
Special Function Pins: Some GPIO pins also support communication protocols like I2C, SPI, and UART, which are used for more advanced components like displays or GPS modules.
Special function pins
Many GPIO pins have alternate functions beyond simple input/output:
I2C (Inter-Integrated Circuit):
- Pins: GPIO 2 (SDA), GPIO 3 (SCL)
- A simple two-wire connection used to communicate with sensors, displays, and other low-speed devices
- Great for connecting multiple devices using just two pins
SPI (Serial Peripheral Interface):
- Pins: GPIO 7 (CE1), GPIO 8 (CE0), GPIO 9 (MISO), GPIO 10 (MOSI), GPIO 11 (SCLK)
- A faster connection used for high-speed communication with things like touchscreens, SD cards, and sensors
- Uses multiple pins but is very reliable for data-heavy devices
UART (Universal Asynchronous Receiver/Transmitter):
- Pins: GPIO 14 (TXD), GPIO 15 (RXD)
- A basic serial connection, often used to communicate with GPS modules, other microcontrollers, or for debugging
- Uses just two pins: one for sending and one for receiving
PWM (Pulse Width Modulation):
- All GPIO pins support software PWM
- GPIO 12, 13, 18, and 19 support hardware PWM for more precise control
- Used for controlling LED brightness, motor speed, or servo position
Pinout command
A reference guide to pinouts can be accessed directly on the Raspberry Pi including the Pi 3. Open the command terminal and type:
pinoutThen press Enter. This displays a visual pinout diagram in the terminal, showing:
- Pin numbers and GPIO numbers
- Power and ground pins
- Special function labels (I2C, SPI, UART)
- Your specific Pi model and revision
This is the fastest way to check the pinout without looking it up online.
Communication protocols
The RP1 GPIO bank (IO_BANK0) supports the following functions:
- 5 UART interfaces
- 6 SPI interfaces
- 4 I2C interfaces
- 2 I2S interfaces (including Clock Producer and Clock Consumer instances)
- Registered IO (RIO) interface
- 24-bit DPI output
- 4-channel PWM output
- Stereo PWM audio output (AUDIO_OUT)
- General-purpose clock input and output (GPCLK)
- eMMC/SDIO bus with a 4-bit interface
- Interrupt generation from pin level or edge transitions
Getting started with GPIO: See our introduction to Raspberry Pi GPIO guide for wiring basics, safety, and beginner projects.