JavaScript For IoT

Diary of a JavaScript developer on the magical world of IoT and electronics. Join me as we share knowledge.
Let's learn together!

GPIO Pins

The Raspberry Pi board has 40 pins that we can use to interact with the world, but there is no standard way of referring to them! Technically there are few standard ways

There is tons of literature on the pin names, I guess everybody finds the lack of a single standard way of referring to them confusing, but the image below is the one I like the best comes from the actual Raspberry Pi documentation

Documentation GPIO pins

This image shows the name or names of each pin. Inside the small circles, there is a number indicating the physical location of such pins on the Raspberry Pi board. You may need to click on the image to zoom in and read those names/numbers ;-)

Rather than manually converting the pins every time, I have created this JavaScript file, which I use on my projects and we are going to use on future projects.

Raspberry Pi can provide you with some of this information if you run the gpio readall or the pinout commands from the terminal. After collecting information from different sources, I built the table below, which hopefully helps you. It sure has helped me!

Physical Names WiringPi BCM GPIO
1 3.3v      
2 5v      
3 SDA.1 8 2  
4 5v      
5 SCL.1 9 3  
6 Ground, 0v      
7 GPIO.4 7 4 4
8 GPIO.14, TxD 15 14 14
9 Ground, 0v      
10 GPIO.15, RxD 16 15 15
11 GPIO.17, ce1 0 17 17
12 GPIO.18, ce0 1 18 18
13 GPIO.27 2 27 27
14 Ground, 0v      
15 GPIO.22 3 22 22
16 GPIO.23 4 23 23
17 3.3v      
18 GPIO.24 5 24 24
19 GPIO.10, MOSI 12 10 10
20 0v      
21 GPIO.9, MISO 13 9 9
22 GPIO.25 6 25 25
23 GPIO.11, SCLK 14 11 11
24 GPIO.8, CE0 10 8 8
25 Ground, 0v      
26 GPIO.7, CE1 11 7 7
27 GPIO.0, SDA0, ID_SD 30 0 0
28 GPIO.1, SCL0, ID_SC 31 1 1
29 GPIO.5 21 5 5
30 Ground, 0v      
31 GPIO.6 22 6 6
32 GPIO.12 26 12 12
33 GPIO.13 23 13 13
34 Ground, 0v      
35 GPIO.19, miso 24 19 19
36 GPIO.16, ce2 27 16 16
37 GPIO.26 25 26 26
38 GPIO.20, mosi 28 20 20
39 Ground, 0v      
40 GPIO.21, sclk 29 21 21


For more information, please visit these links:


Please help me keep this blog alive and free of ads
Support me with a small contribution by Paypal or, if you prefer, buy me a coffee.

Please leave a comment

Comments are powered by Utterances. A GitHub account is required to comment. Comments are moderated. Be respectful. No swearing or inflammatory language. No spam.

I reserve the right to delete any inappropriate comments. All comments for all pages can be viewed and searched online here.

Opinions expressed in this blog are solely my own and do not express the views or opinions of my employer, wife, son, friends, boss, or anybody else! 😀

To edit or delete your comment:

  1. Click the "Comments" link
  2. Find your comment on this GitHub page and click the 3 dots in the top-right
  3. Click "Edit" or "Delete". Editing or adding a comment from the GitHub page also gives you a nicer editor.