What is the Raspberry Pi GPIO?

Raspberry Pi GPIO pins

What is the GPIO?

The GPIO (General Purpose Input/Output) is the row of pins along the top edge of the Raspberry Pi board. The picture above shows the GPIO pins on a Raspberry Pi 4.

These pins are used to connect components such as sensors to the Raspberry Pi, and as the name implies, these pins can be set as input or output (via software).

GPIO Pin Numbering

Unfortunately there are no numbers printed on the board next to the pins and to make things even more complicated, especially for beginners like me, there are several different GPIO numbering systems.

I didn't realise this at first and wasted quite a lot of time wiring up components to the wrong pins!

The two most common pin numbering systems are:

  • Physical pin numbers: also known as BOARD
  • GPIO numbers: also known as Broadcom (BCM)

It doesn't matter which one you use as long as your wiring corresponds with the system specified in any software you are using.

Before we get into the detail of pin numbering, let's look at a really useful tool:

The "pinout" tool

There is a great tool, called pinout, which provides a graphical reference for the GPIO pins on your Pi. This tool comes installed on the default Raspberry Pi OS, and can be run by just entering pinout in a terminal window.

Below you can see the result of running pinout on my Raspberry Pi 4:

Raspberry Pi pinout command output

The top part of the output, in green, shows the physical board and location of the GPIO pins, in this case on the top left of the Pi board. You can use the other labels, such as "pwr" (power port) and "HDMI" (HMDI ports) to orientate your Pi.

Looking more closely at the pins we can see the bottom left pin is a blue 1. This pin corresponds to the pin numbered (1) in the diagram below.

If we now rotate our Raspberry Pi so the power and HDMI ports are on the left the Pi will be orientated to match the pin diagram:

Raspberry Pi GPIO pin numbering

We can now easily see which pin on our board corresponds to which pin in the diagram.

The numbers in gray (and in brackets) down the middle of the diagram are the board pin numbers (BOARD) which range from 1 to 40. These are also known as the "physical" pin numbers.

The labels mainly in green, with others in red, blue and gray, show the GPIO numbering system. The green labels are the GPIO or BCM pin names.

For example, physical pin 3 is also known as GPIO02.