What Are Raspberry Pi GPIO Pins?

In this article, we will tell you everything you need to know about the Pi’s GPIO pins: what they can do, how to use them, and mistakes to avoid while using them.

A note before we begin: Different revisions of the Pi can vary with their pins! Before attaching anything to your board, make sure you are using the correct ones. A quick way to check is to type pinout into your Raspberry Pi’s terminal, which will bring up a diagram of your current setup.

The GPIO pins are integrated into the circuit board of the computer. Their behavior can be controlled by the user to allow them to read data from sensors, and control components like LEDs, motors, and displays. Older models of the Pi had 26 GPIO pins, while the newer models all have 40. This chart shows what each pin does:

In the labelled diagram above, you can see that there are different types of GPIO pins which serve different purposes. You can find an interactive version of this chart at pinout.xyz It also outlines one of the first confusing things you will have to contend with. Each pin has two numbers attached to it. Its BOARD number (the numbers in the circle) and its BCM (Broadcom SOC channel) number. You can choose which convention to use when you write your Python code:

You can only use one convention in each project, so choose one and stick to it. Neither convention is “right”, so go with whichever one makes most sense to you. It is worth noting however, that certain peripherals rely on GPIO/BCM numbering.

For this article, we will stick to BOARD numbering. So what do the pins actually do?

Power Pins

Let’s start with the power pins. The Raspberry Pi can provide both 5v (pins 2 and 4) and 3.3v (pins 1 and 17) power. It also provides a ground (GND) for circuits on pins 6, 9, 14, 20, 25, 30, 34, and 39.

Unfortunately, there is no single answer to how much current the 5v power pins can draw as it is reliant on what power supply you are using, and what other components you have attached to your Pi. The Raspberry Pi 3 will only draw 2.5A from its power supply, and requires around 750mA for boot up and normal headless operation. This means that if you are using a 2.5A power supply, the 5v pins can supply a total current of around 1.7A maximum. Annoyingly, this varies between models of Pi however, as this table shows:

Image Credit: raspberrypi.org

For most users just starting out with the Pi, this will not be a problem, but it is something to bear in mind as you spend more time with the GPIO pins.

The 3.3v pins are somewhat simpler, with recent Raspberry Pi revisions (Model B+ onwards) providing up to 500mA total, and older models providing just 50mA. Note that this current is shared throughout all of the other GPIO pins too!

So these pins can provide power to your components, but that is all they do. The real fun stuff comes from the rest of the pins.

Standard GPIO

On the chart above, ignoring the power pins, you’ll see that some are marked in different colors. The green pins are standard GPIO pins, and these are what you will use for most beginner projects. These pins are capable of a 3.3v output, also referred to as setting the pin HIGH in code. When an output pin is LOW this means that it is simply providing 0v.

They are also capable of taking an input of up to 3.3v, which the pin reads as HIGH.

Do not provide the pins with greater than 3.3v: this is a quick way to fry your Pi!

It allows devices to communicate with the Raspberry Pi synchronously, meaning much more data can pass between the master and slave devices. If you have ever used a small touch screen for your Pi, this is how they communicated.

There are various devices and extension HATs for the Raspberry Pi which use SPI, and it can open up your projects to much more hardware than the regular GPIO pins can sustain. It does however, require quite a lot of wiring to get it working. There is an in depth overview of SPI on the Raspberry Pi foundation website.

Pins 19, 21, 23, 24, 25 and 26 (GPIO 10, 9, 11, 8, GND, and GPIO 26) are used to connect to an SPI device, and they are all required for smooth operation. A good way to avoid all the spaghetti is to buy a premade extension such as the Sense HAT, which fits on top of your board and provides it with an LED matrix and a wide array on sensors. It’s been a favourite for several years now, and was even used on the International Space Station to do some experiments!

The SPI protocol is not enabled as standard on Raspbian, but it can be enabled in the raspi-config file, along with I2C.

I2C

I2C (Inter-Integrated Circuit) is similar to SPI, but is generally considered to be easier to set up and to use. It communicates asynchronously, and is capable of sustaining as many different devices as needed provided they each have unique address places on the I2C bus. Due to this addressing system, the Pi only needs two I2C pins—pin 3 (GPIO 2) and pin 5 (GPIO 3), making it much simpler to use than SPI.

The small footprint of I2C opens up a huge range of possibilities. With standard GPIO pins, setting up an LCD screen and some buttons would take up almost every pin, using an I2C device such as the Adafruit Negative LCD controller brings it down to just two pins!

Pins 27 and 28 (marked ID_SD and ID_SC) are also I2C. There are used by the Pi for internal functions, and also some HAT boards. As a general rule, don’t mess with them unless you really know what you are doing!

Raspberry Pi: A GPIO Pin for Everything!

The Raspberry Pi is the Swiss Army Knife of modern computing. Along with a huge amount of awesome day to day uses, it also opens anyone up to the possibility of making their own cool creations.

Ian Buckley started out with a degree in Music composition, before devoting his time to DIY tech and coding. He now works as a freelance journalist, performer and video producer living in Berlin, Germany. When he's not writing or on stage, he's tinkering with DIY electronics or code in the hope of becoming a mad scientist.