raspberry pi

WiringPi Library for Raspberry Pi GPIO Commands

WiringPi, Description:

WiringPi Library for Raspberry Pi GPIO Commands- The WiringPi project provides the GPIO commands. So you can use individual Read out and change GPIO pins in the terminal or in a bash script. Gpio can also control the popular Gertboard and the PiFace board. WiringPi is basically a C++ library for Raspberry Pi.  The programmers uses the hardware functions of the Raspberry Pi and various additional hardware to control, e.g. the DS1302 chip (Real Time Clock) or various LC displays, digital pins, SPI, UART, etc. WiringPi is a PIN based GPIO access Library which was developed using C language for the BCM2835, BCM2837 SoC, and BCM2836 devices used in all Raspberry Pi Versions.

Amazon Purchase Links:

Raspberry Pi

raspberry pi 4 4gb kit

Wireless Keyboard and Mouse for raspberry pi:

Night vision Camera for Raspberry Pi:

Oled HDMI touch display for raspberry pi:

TOP10 Best Raspberry Pi Kits

Other Tools and Components:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

WiringPi is not available as a Raspbian package. Instead, you need to Download source code from a Git repository and compile it yourself. None Fear: The process is straightforward and takes just a few minutes. The command GPIO is installed in the / usr / local / bin directory.

cd wiringPi

./ build

The version number of WiringPi and information about your Raspberry Pi model reveals the command gpio -v:

GPIO command

This section focuses on the core functions of the gpio command, i.e. on the control of the GPIO pins (see table 1). The mode command also knows the four main modes input, output, clock, and pwm (for Pulse Width Modulation) as well nor the states up, down and tri. This allows the internal pull-up or pull-down Resistors of some GPIO inputs can be controlled (e.g. applies to pins 3 and 5 of the P1 or J8 headers). You can read even more details and commands with man gpio.

Table 1: The most important gpio options and commands

Option / command Importance
-1 Use pin numbers of P1 / J8 header (one, not L)
-g Use BCM GPIO numbering
mode n m Use pin n for mode (in, out, pwm…)
read n Read out signal input at pin n
write n 0/1 Set the signal output on pin n to 0/1
Readall Read out all pins and display them as a table
Reset switch all GPIO pins to input
pwm n Control PWM duty cycle (0-1023, only for GPIO 18 = pin 12)


gpio readall reveals the current status of all GPIO pins. The meaning of the columns is as follows:

  • BCM: This column refers to the nomenclature of the Broadcom CPUBCM2835, but which does not match the usual Raspberry Pi names! If you want to refer to this nomenclature for gpio commands, you must always use the -g option.
  • wPi: This column contains the WiringPi internal numbers of the pins. This numbering applies by default to the gpio command if neither the option -g nor the -l option is used.
  • Name: This column explains the function of the pin. 0v corresponds to GND.
  • Mode: This column indicates whether the pin is used as input or output.
  • V: The column indicates the current state (value) of the pin (high or low).
  • Physical: This column shows the pin numbers of the P1 and J8 headers of the Raspberry

If you refer to these pin numbers in gpio commands, you need to use the -1 option (one, not L). The following output was created on a Raspberry Pi 2:

gpio readall # shows the WiringPi numbering


Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button