This guide breaks down the Raspberry Pi Zero pinout in detail, covering every header pin, its function, and how to use it in real projects. Whether you’re building a retro handheld, a network ad blocker, or a tiny IoT sensor node, understanding the 40-pin GPIO is essential. We’ll walk through power pins, I2C, SPI, UART, PWM, and the special HAT ID pins, plus what to watch out for when wiring.
Power Pins: 5V and 3.3V Rails
The Pi Zero has two 5V pins (physical 2 and 4) and two 3.3V pins (physical 1 and 17). The 5V pins are directly connected to the micro-USB power input, so they can supply whatever the input provides (typically 1A to 2A). The 3.3V pins come from the onboard regulator and can safely source about 50mA total for external circuits—drawing more can cause the Pi to reboot. Always check your total current draw before powering sensors or LEDs from these pins.
Ground Pins: The Return Path
There are eight ground pins on the 40-pin header (physical 6, 9, 14, 20, 25, 30, 34, 39). All are connected to the same ground plane, so you can use any of them for your circuit. It’s good practice to use a ground pin close to the signal pin you’re using to minimize loop area and reduce noise, especially for I2C or SPI. For higher-current loads like motors, use a dedicated ground wire back to the power supply, not through the Pi’s ground.
GPIO 2 and 3: I2C Data and Clock
Physical pins 3 (GPIO2) and 5 (GPIO3) are the I2C data (SDA) and clock (SCL) lines, respectively. They have 1.8kΩ pull-up resistors to 3.3V on the board, so you don’t need external pull-ups for most I2C devices. The Pi Zero’s I2C bus runs at 100kHz by default, but you can enable the 400kHz fast mode in config. These pins are also used for the HAT EEPROM, so be careful if you’re designing a custom HAT—the ID pins are separate, though.
GPIO 14 and 15: UART Transmit and Receive
Physical pins 8 (GPIO14, TXD) and 10 (GPIO15, RXD) are the primary UART. On the Pi Zero, this UART is available on the header by default, unlike some other models where it’s routed to Bluetooth. You can use it for serial console, GPS modules, or communicating with microcontrollers. The logic level is 3.3V, so never connect directly to 5V serial devices without a level shifter. You may need to disable the serial console in raspi-config to use it freely.
GPIO 8, 9, 10, 11: SPI Bus
Physical pins 19 (MOSI), 21 (MISO), 23 (SCLK), and 24 (CE0) form the main SPI0 bus. SPI is great for high-speed communication with displays, ADCs, or SD cards. The Pi Zero supports SPI clock speeds up to 125MHz, though most devices run much slower. You can enable SPI with raspi-config or by adding dtparam=spi=on to config.txt. There’s also a second SPI bus (SPI1) on pins 16, 18, 22, and 26, but it’s less commonly used.
GPIO 18: PWM Output
Physical pin 12 (GPIO18) is one of the hardware PWM channels. It can output a true analog-like signal with variable duty cycle and frequency, perfect for dimming LEDs or controlling servo motors. The other hardware PWM channel is on GPIO13 (physical pin 33). For software PWM, you can use any GPIO, but hardware PWM is more precise and doesn’t load the CPU. The Pi Zero’s PWM is shared with the audio output, so using it may disable analog audio.
HAT ID Pins: GPIO 0 and 1
Physical pins 27 (ID_SD) and 28 (ID_SC) are reserved for HAT identification. When you attach a HAT with an EEPROM, the Pi reads it over I2C on these pins to auto-configure drivers and pin mappings. If you’re not using a HAT, these pins are not general-purpose GPIO—they’re only for the ID EEPROM. You can technically use them as I2C after disabling the HAT auto-detection, but it’s not recommended because it can cause boot issues.
GPIO 22, 23, 24, 25: General Purpose I/O
Physical pins 15 (GPIO22), 16 (GPIO23), 18 (GPIO24), and 22 (GPIO25) are standard GPIO pins with no special hardware functions. They’re ideal for button inputs, LED outputs, or bit-banging custom protocols. Each pin can source or sink up to 16mA, but the total across all GPIO should stay under 50mA. These pins also have configurable pull-up/pull-down resistors (50kΩ) that you can enable in software.
GPIO 5 and 6: I2C and SPI Alternatives
Physical pins 29 (GPIO5) and 31 (GPIO6) are often used as a second I2C bus (I2C1) or as chip selects for SPI. On the Pi Zero, I2C1 is actually the same bus as the main I2C on pins 3 and 5, but you can remap it. GPIO5 and GPIO6 also have hardware PWM options (via the PWM overlay). They’re handy when you run out of the primary pins—for example, using GPIO5 as a chip select for an SPI device while keeping GPIO6 for a button.
GPIO 12 and 13: Additional PWM and Audio
Physical pins 32 (GPIO12) and 33 (GPIO13) are the other hardware PWM channels. They’re also used for the analog audio output (via the 3.5mm jack on other models, but on the Pi Zero you can use PWM to generate sound). If you’re building a simple audio player, these pins can drive a piezo buzzer or a small speaker through an amplifier. Note that using them for PWM will disable the onboard audio if you have it enabled.
How to Choose
When selecting pins for your project, start by listing what interfaces you need: I2C, SPI, UART, or just digital I/O. Use the dedicated pins for those interfaces first, as they’re optimized for speed and have hardware support. For simple buttons and LEDs, any free GPIO works—just avoid pins that you might need later for a HAT or audio. Also consider pin location: if you’re using a HAT, the top row (physical 1-20) is more accessible, while the bottom row (21-40) is closer to the edge. Always double-check your wiring against the pinout diagram, as a single wrong connection can fry the Pi.
Frequently Asked Questions
Q: Can I use the 5V pin to power the Pi Zero?
Yes, you can power the Pi Zero through the 5V pins (physical 2 or 4) instead of the micro-USB port. Just ensure your power supply can deliver at least 1A and that you don’t back-feed the micro-USB input simultaneously.
Q: What is the maximum current per GPIO pin?
Each GPIO pin can safely source or sink 16mA, but the total current across all GPIO pins should not exceed 50mA. For higher currents, use a transistor or a driver IC.
Q: Are the Pi Zero pins 5V tolerant?
No, all GPIO pins are 3.3V logic only. Applying 5V to any pin can damage the SoC. Use a level shifter if you need to interface with 5V devices.
Q: How do I find the pinout on my Pi Zero?
Run pinout in the terminal (if you have the GPIO Zero library installed) or use gpio readall for a full table. The official Raspberry Pi documentation also has a printable pinout diagram.
Q: Can I use all 40 pins at once?
Yes, but you must respect the total current limits and avoid using pins that are reserved for HAT ID or power. In practice, you’ll likely need to share pins for different functions, so plan carefully.
Q: What is the difference between the Pi Zero and Pi Zero 2 W pinout?
They are identical—both have the same 40-pin header with the same functions. The only difference is the processor and wireless capabilities, not the pinout.
Final Thoughts
The Raspberry Pi Zero pinout is the key to unlocking its potential, whether you’re making a wearable, a robot, or a smart home sensor. By understanding each pin’s role and limitations, you can avoid common pitfalls like overloading a 3.3V rail or frying a pin with 5V. Keep this guide handy, and always verify your connections before powering up. Happy making!