The same 40-pin header sits on every Raspberry Pi from the B+ on: Pi 2, 3, 4, 5, 400/500 and all Zero models. Code uses the GPIO (BCM) numbers, which don't match the physical pin numbers: GPIO17 is pin 11.
Pin 1 (3V3) at the top. Odd pins on the left, even pins on the right along the board edge. On a Pi with the header along its top edge, pin 1 is the bottom-left pin.
| Position | Pin | In code | Functions | Notes |
|---|---|---|---|---|
| Pin 1 | – | – | 3.3 V output for sensors and other low-current parts. Raspberry Pi's documentation gives no current limit for these pins; budget conservatively. | |
| Pin 2 | – | – | Connected to the Pi's 5 V supply. It can power 5 V parts, or power the Pi itself (a PoE+ HAT does this). Never connect it to a GPIO pin. | |
| Pin 3 | GPIO2 | I2C1 SDA | Has a fixed 1.8 kΩ pull-up to 3.3 V on the board, so it reads high when nothing is connected and can't use a pull-down. | |
| Pin 4 | – | – | Connected to the Pi's 5 V supply. It can power 5 V parts, or power the Pi itself (a PoE+ HAT does this). Never connect it to a GPIO pin. | |
| Pin 5 | GPIO3 | I2C1 SCL | Has a fixed 1.8 kΩ pull-up to 3.3 V on the board, so it reads high when nothing is connected and can't use a pull-down. | |
| Pin 6 | – | – | ||
| Pin 7 | GPIO4 | –GPCLK0 | ||
| Pin 8 | GPIO14 | UART TX (TXD) | ||
| Pin 9 | – | – | ||
| Pin 10 | GPIO15 | UART RX (RXD) | ||
| Pin 11 | GPIO17 | SPI1 CE1 | ||
| Pin 12 | GPIO18 | PWM0, SPI1 CE0PCM_CLK | Hardware PWM channel 0, the same channel as GPIO12 on a Pi 4 and earlier. | |
| Pin 13 | GPIO27 | – | ||
| Pin 14 | – | – | ||
| Pin 15 | GPIO22 | – | ||
| Pin 16 | GPIO23 | – | ||
| Pin 17 | – | – | 3.3 V output for sensors and other low-current parts. Raspberry Pi's documentation gives no current limit for these pins; budget conservatively. | |
| Pin 18 | GPIO24 | – | ||
| Pin 19 | GPIO10 | SPI0 MOSI | ||
| Pin 20 | – | – | ||
| Pin 21 | GPIO9 | SPI0 MISO | ||
| Pin 22 | GPIO25 | – | ||
| Pin 23 | GPIO11 | SPI0 SCLK | ||
| Pin 24 | GPIO8 | SPI0 CE0 | ||
| Pin 25 | – | – | ||
| Pin 26 | GPIO7 | SPI0 CE1 | ||
| Pin 27 | GPIO0 | ID_SD (I2C0 SDA) | HAT IDReserved for the ID EEPROM on HAT boards: the Pi reads it at boot to identify the HAT. Leave it unconnected unless you are building a HAT with an ID EEPROM. | |
| Pin 28 | GPIO1 | ID_SC (I2C0 SCL) | HAT IDReserved for the ID EEPROM on HAT boards: the Pi reads it at boot to identify the HAT. Leave it unconnected unless you are building a HAT with an ID EEPROM. | |
| Pin 29 | GPIO5 | –GPCLK1 | ||
| Pin 30 | – | – | ||
| Pin 31 | GPIO6 | –GPCLK2 | ||
| Pin 32 | GPIO12 | PWM0 | ||
| Pin 33 | GPIO13 | PWM1 | ||
| Pin 34 | – | – | ||
| Pin 35 | GPIO19 | PWM1, SPI1 MISOPCM_FS | Hardware PWM channel 1, the same channel as GPIO13 on a Pi 4 and earlier. | |
| Pin 36 | GPIO16 | SPI1 CE2 | ||
| Pin 37 | GPIO26 | – | ||
| Pin 38 | GPIO20 | SPI1 MOSIPCM_DIN | ||
| Pin 39 | – | – | ||
| Pin 40 | GPIO21 | SPI1 SCLKPCM_DOUT |
Every board is drawn from the top, the way you see it on the bench, with the pins in their real order. Red pins are power, black are ground, grey are control pins such as reset, and green are general-purpose I/O. A yellow ring marks a pin with a catch: a strapping pin that changes how the chip boots, a pin wired to flash or USB, or an input-only pin.
Pick a function above the drawing (I2C, SPI, ADC…) to light up the pins that can do it and see each pin's name for that function. Pins marked default are the ones the board's own documentation uses; on the ESP32 and the Pico most peripherals can move to other pins in software.
The label printed on the board, the physical pin number and the number you type in code are often three different things. On a Raspberry Pi, physical pin 11 is GPIO17. On an ESP32 the board says IO32 and the code says 32. The table under each drawing lists all three.
| Board | Logic level | 5 V on a GPIO? | Current per pin | All pins together |
|---|---|---|---|---|
| ESP32-DevKitC | 3.3 V | No (3.6 V max) | ~20 mA default, ~40 mA max drive | 1,200 mA (abs. max) |
| Arduino Uno R3, Nano | 5 V | Yes | 20 mA (40 mA abs. max) | 200 mA (abs. max) |
| Raspberry Pi Pico | 3.3 V | No | 2–12 mA, 4 mA default | 50 mA |
| Raspberry Pi (40-pin header) | 3.3 V | No | 16 mA | 50 mA |
The ESP32, the Pico and the Raspberry Pi run their pins at 3.3 V and none of them is 5 V tolerant. A 5 V sensor output on one of their GPIOs needs a level shifter or a resistor divider. The Arduino Uno and Nano run at 5 V; most 3.3 V modules need their inputs shifted down when you connect them to an Arduino.
The current limits are for the I/O pins, not for driving motors or relays. A small indicator LED is fine on any of these boards with a series resistor that keeps it under the pin's limit; anything bigger goes through a transistor or a driver. The LED resistor calculator works out the resistor.
GrandpaCAD's chat picks real parts, draws the schematic, routes the PCB and checks it against JLCPCB's rules. You get Gerbers, BOM, pick-and-place, a KiCad project and a 3D board, plus a printed case if you want one.
"Raspberry Pi HAT with a real-time clock and a fan header"