40-pin GPIO overview
The Raspberry Pi Zero and Zero 2 W have a 40-pin GPIO (General Purpose Input/Output) header that lets you connect the Pi to the physical world. This header uses the same layout as the Pi 3, Pi 4, and Pi 5, making projects portable between Zero and full-size Pi boards.
Important note: The Pi Zero and Zero W come with the GPIO header unpopulated (no pins installed). You need to solder a 40-pin header yourself or purchase a Pi Zero with headers pre-installed (Pi Zero WH variant).
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. The Raspberry Pi Zero has two 5V pins (2 and 4), and two 3.3V pins (1 and 17).
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):
- 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):
- 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):
- 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
Pinout command
A reference guide to pinouts can be accessed directly on the Raspberry Pi including the Pi Zero. Open the command terminal and type:
pinoutThen press Enter. This displays a visual pinout diagram in the terminal, showing pin numbers, GPIO numbers, power/ground pins, and special function labels.
Getting started with Pi Zero: See our Raspberry Pi Zero quick start guide and introduction to Raspberry Pi GPIO for wiring basics and safety.