Discover Which GPIO Pins Are Available on Your Raspberry Pi Model

A step-by-step guide to finding the ports and header pins available on your Raspberry Pi model using command line interface. …


Updated September 14, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


A step-by-step guide to finding the ports and header pins available on your Raspberry Pi model using command line interface.

Raspberry Pi offers a wide range of models with different specifications, including different numbers of GPIO (General Purpose Input/Output) pins. It’s important to know which pins are available on your particular Raspberry Pi model if you want to use them for projects that require hardware interfacing. This guide will show you how to check the ports and header pins on your Raspberry Pi using command line interface (CLI).

  1. Open a terminal window by pressing Ctrl + Alt + T or navigating to the menu bar and selecting “Accessories” > “Terminal.”
  2. Type uname -a and press Enter to get information about your Raspberry Pi’s hardware and operating system:
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:23 BST 2019 armv7l GNU/Linux

This command will display information about your Raspberry Pi’s operating system and hardware, including the model name (e.g., raspberrypi).

  1. To check which ports are available on your Raspberry Pi, use the following command:
pi@raspberrypi:~ $ gpio readall

This will output a list of GPIO pins and their header pin numbers, along with any connected devices. For example:

 +-----+-----+---------+------+---+---Pi 3B+---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT5 | TxD0    | 14  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT5 | RxD0    | 15  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 17  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 21  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 22  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 23  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
...

In this example, we can see that the Raspberry Pi model is a “Pi 3B+” and there are 40 GPIO pins available. The first column shows the Broadcom SoC (System on Chip) pin number, the second shows the wiringPi pin number, and the third column lists the header pin numbers and their corresponding functions.

Note that not all pins will have a function assigned to them by default. To assign or change a function for a GPIO pin, you can use the gpio command-line tool:

pi@raspberrypi:~ $ gpio -g mode <pin> <mode>

Replace <pin> with the BCM number of the pin you want to modify and <mode> with the desired function (e.g., IN for input, OUT for output). For example, to set GPIO pin 17 as an output:

pi@raspberrypi:~ $ gpio -g mode 17 out

Now you know how to check Raspberry Pi ports and header pins using command line interface! You can use this information to plan your projects and connect external hardware components.