hobbybench

Raspberry Pi 40-Pin GPIO Header Pinout

40-pin header, every model since the Pi B+ (2014), including Pi 4 and Pi 5. Check your board against its silkscreen before wiring power.

Raspberry Pi
microUSBHDMImicroUSBHDMIUSB-CHDMI0HDMI1AV jackAV jackPCIecompositeaudioEthernet 10/1002x USBEthernet2x USB2x USB2x USB 2.02x USB 3.0EthernetEthernet2x USB 3.02x USB 2.0SD cardmicroSDSoCRAMRaspberry Pi 1 BRaspberry Pi 1 B+Raspberry Pi 2 BRaspberry Pi 3 B+Raspberry Pi 4 BRaspberry Pi 5ODD PINS 1-25EVEN PINS 2-26ODD PINS 1-39EVEN PINS 2-4013V325V3GPIO2SDA145V5GPIO3SCL16GND7GPIO41-Wire8GPIO14TXD9GND10GPIO15RXD11GPIO1712GPIO18PWM0PCM_CLK13GPIO2714GND15GPIO2216GPIO23173V318GPIO2419GPIO10MOSI20GND21GPIO9MISO22GPIO2523GPIO11SCLK24GPIO8CE025GND26GPIO7CE127ID_SDHAT EEPROM28ID_SCHAT EEPROM29GPIO530GND31GPIO632GPIO12PWM033GPIO13PWM134GND35GPIO19PCM_FS36GPIO1637GPIO2638GPIO20PCM_DIN39GND40GPIO21PCM_DOUT
PowerGroundGPIOControlDACUARTSPII2C

What changed between the models

The header is the one part that barely moved: pins 1 to 26 have meant the same thing since the 2012 Model B rev 2, and the B+ added pins 27 to 40 on top without disturbing them. Everything else on the board was rearranged more than once.

ModelYearHeaderUSBEthernetVideoPowerStorageWireless
1 Model B201226-pin210/100HDMI + compositemicro USBSD cardnone
1 Model B+201440-pin410/100HDMI + AV jackmicro USBmicroSDnone
2 Model B201540-pin410/100HDMI + AV jackmicro USBmicroSDnone
3 Model B201640-pin410/100HDMI + AV jackmicro USBmicroSDWi-Fi n, BT 4.1
3 Model B+201840-pin4gigabit, capped near 300 MbpsHDMI + AV jackmicro USBmicroSDWi-Fi ac, BT 4.2
4 Model B201940-pin2 x 3.0 + 2 x 2.0true gigabit2 x micro HDMI + AV jackUSB-CmicroSDWi-Fi ac, BT 5.0
5202340-pin2 x 3.0 + 2 x 2.0true gigabit2 x micro HDMI, no AV jackUSB-C, 5 V 5 AmicroSDWi-Fi ac, BT 5.0

Three of those differences bite in practice. The Model B's 26-pin header stops at pin 26, so any HAT or diagram that references pin 32 or pin 40 assumes a B+ or later. The Pi 4 is the odd one out for port placement: it swapped the Ethernet and USB sockets to the opposite ends, and the Pi 5 put them back, which is why a case cut for a Pi 4 fits nothing else. And the Pi 5 dropped the analogue AV jack entirely, so composite video and headphone output now need a USB or HDMI device.

The Pi 5 also added parts nothing before it had: a PCIe FFC connector for NVMe, a real power button, an RTC battery header and a dedicated fan connector.

Physical pins versus GPIO numbers

The small numbers inside the header are physical positions: pin 1 top left, pin 2 top right, odd down the left, even down the right. The labels are BCM GPIO numbers, which is what your code uses. When a tutorial says "pin 18", find out which scheme it means before wiring.

3.3 volts, no negotiation

GPIOs are 3.3 V with no protection worth trusting. The 5V pins come straight off the supply: handy for powering accessories, destructive anywhere near an input.

Reserved pins

ID_SD and ID_SC (physical 27 and 28, GPIO0 and GPIO1) are the HAT identification EEPROM bus. Leave them free unless you are building a HAT.

Sources and datasheets

This diagram was cross-checked against the manufacturer documentation below plus at least two independent references before publishing. When they disagreed, the manufacturer won.

More boards and plugs live on the pinouts index.