The raspberry pi gpio pinout on current boards is a 40-pin header with 3.3V logic, numbered both by physical position and by BCM chip channel. Match the numbering in your code to the pin you actually wired.
Mixing up the two numbering schemes is one way a wired sensor ends up reading nothing. This reference lines up pin positions, functions and electrical limits in one place. For complete builds, see our raspberry pi gpio projects.
What the 40-pin header contains
The Raspberry Pi 4 has a 40-pin GPIO header, and newer boards keep that size. Older models have 26 pins, according to Electronics For You. If you own an older board, a diagram for the 40-pin layout will not line up with your header.

The header’s pins fall into three groups: fixed power, ground, and general-purpose input/output (GPIO) pins that your software controls.

- Power pins. They supply constant 3.3V or 5V to parts such as sensors or displays. The 5V pins are 2 and 4, and the 3.3V pins are 1 and 17.
- Ground pins. Pins 6, 9, 14, 20, 25, 30, 34 and 39 are ground. Pick the one nearest your component so the return wire stays short and easy to trace.
- GPIO pins. The rest of the header carries signals. Most of them have an internal pull-up or pull-down resistor that you can enable in software, as the Pi4J pin guide explains.
Header pin numbers count physical positions along the connector, which is why a printed diagram or a labelled breakout is easier to trust than counting by eye.

Common misunderstandings about GPIO pins
Most wiring mistakes come from a handful of assumptions. The table sets each one against what the pin documentation says and what to do instead.
| Assumption | What holds | Planning use |
|---|---|---|
| The header pin number and the GPIO number are the same thing. | BCM numbering is the Broadcom chip’s internal channel numbering, while header pin numbers are physical positions. | Check which scheme your library expects before you copy a pin number from a diagram. |
| A 5V part can connect straight to a signal pin. | The GPIOs only provide or expect 3.3V, so an output is 0V (low) or 3.3V (high). | Use level shifting for 5V signal lines. |
| The header can power any load. | Drawing too much through the header makes the Pi misbehave and reboot. | Power high-current devices from their own supply. |
| A pin has one permanent job. | Each GPIO has one function selected at a time, so I2C, SPI and UART are selectable functions rather than fixed labels. | Plan which interface owns a pin before you add a second part. |
These points come from the Pi4J pin guide and a community Raspberry Pi 5 pinout reference.
BCM versus BOARD numbering
BCM numbering uses the channel number inside the Broadcom chip. BOARD numbering uses the physical position on the header, the same positions used for the power and ground pins above.
The practical rule is to follow your library. According to Electronics For You, most programming environments, including Python with RPi.GPIO or gpiozero, use BCM numbering. Tutorials written for those libraries will therefore quote BCM numbers, and you must translate them to a physical pin on your header before wiring.
- Choose BCM when you follow library documentation or example code, since the numbers in it already match.
- Choose BOARD when you wire from a printed header diagram and want the code to read like the diagram.
- Never mix the two inside one script. Pick one scheme at the top and write a comment naming it.
For a first small circuit that applies this, our raspberry pi led python guide is a good place to practise matching code numbers to a wired pin.
Default I2C, SPI and UART pins
On 40-pin models the default interface pins sit at fixed header positions, per Electronics For You.
- I2C: pin 3 is SDA and pin 5 is SCL.
- SPI: pins 19, 21, 23, 24 and 26.
- UART: pin 8 is TXD and pin 10 is RXD.
Because each GPIO can have one function selected at a time, a pin you use for one interface is not available for another. Before you add a second part, list which header pins each interface occupies. That is also useful when planning a raspberry pi weather station project, where several interfaces may be in use at once.
On the Raspberry Pi 5, the community pinout reference shows that I2C can be routed with device-tree overlays, for example dtoverlay=i2c0-pi5,pins_8_9. A default assignment is therefore a starting point, not a hard limit, on that board.
Voltage and current limits
GPIO pins on the Raspberry Pi use 3.3V logic. An output is set to 0V for low or 3.3V for high, and the Pi4J guide notes that the pins only provide or expect 3.3V. Treat a 5V signal as out of range and add level shifting between a 5V part and a signal pin.
The Raspberry Pi 5 is more nuanced. The community Pi 5 reference says its GPIO pins can withstand up to 5V when the RP1 chip is powered, and 3.63V when it is unpowered. That is a tolerance rating for surviving a signal, not a reason to design 5V logic into your project, and it does not apply to older boards.
For current, the clearest documented rule is about the header as a whole. High-current devices can leave the Pi unable to behave as expected and cause a reboot, as the Pi4J guide warns. Use GPIO pins to carry signals or very small loads, such as an LED with a series resistor, and give motors and other heavier loads their own supply. Confirm the exact per-pin and total current ratings for your board model in the official Raspberry Pi hardware documentation before driving anything bigger.
Checking pins from the command line
Raspberry Pi OS offers two terminal tools for inspecting the header, so you do not need to count pins on the board.
- pinout: open a terminal, type pinout and press Enter. Vilros describes this as a built-in way to see the layout of your own board.
- gpio readall: this command in the Raspberry Pi OS terminal reports the status of the pins, according to Electronics For You.
Use pinout to confirm which physical position a given function sits on before you connect anything. Use gpio readall when you need to see pin states while a circuit is running.
Frequently asked questions
| Question | Answer |
|---|---|
| Does an older Raspberry Pi have the same header? | No. Electronics For You notes that older models have 26 pins, while newer models have 40. |
| How many I2C, SPI and UART controllers does the Pi 5 expose? | The community Pi 5 reference lists 5 UART, 6 SPI, 4 I2C on the RP1 bank. Which of them reach the 40-pin header depends on how you route them. |
| Is UART ready to use on a new Pi 5? | The same reference reports that UART does not work on the Pi 5 from the factory and needs a firmware update first. |



