Installation of WiringPi

Installation of WiringPi for accessing GPIO



WiringPi is a library written in C used to access GPIO pins on Raspberry for BCM2835 (Broadcom Processor) SoC (System on Chip).
There are various libraries are available to access GPIO in C like bcm 2835, sysfs, pigpio, etc. Here, we are using WiringPi library for Raspberry Pi GPIO access using C program.

To use wiringPi, first we should install it on Raspberry Pi. This installation can be done in two ways, select any one of the way whichever is suitable for you

WiringPi Library Installation Way 1


This way of installing WiringPi library will use git.
Follow the following steps to install it on Raspberry Pi,
Make sure our Raspbian is updated. So, first check for any update and upgrade on Raspberry Pi.

sudo apt-get update
sudo apt-get upgrade

Now, we can use git to download WiringPi library. For that we should install git on Raspberry Pi if already not installed.  
sudo apt-get install git-core

pi@raspberrypi ~$ git clone git://git.drogon.net/wiringPi
pi@raspberrypi ~$ cd wiringPi
pi@raspberrypi ~/wiringPi $ git pull origin
pi@raspberrypi ~/wiringPi $ ./build

Installation of WiringPi library is done.


WiringPi Library Installation Way 2

We can install WiringPi library in other way also. To install WiringPi library on Raspberry Pi, first we should download it. We can download WiringPi Library here.

On above link, there are more files to download. Just download file which is at the top, is the latest updated file. By clicking on snapshot, we can download it.

Transfer the downloaded zip file to Raspberry Pi using WinSCP.
Go to that location on terminal and follow the (commands) given below to install the above downloaded library,

cd 
tar xfz downloaded_filename.tar.gz
cd downloaded_filename
./build


Testing the setup

Now, we can check/test the installation of WiringPi library as follows,
Type command on terminal.

gpio -v


The above screenshot tells that the WiringPi library is installed successfully.

Now, we can access GPIO using WiringPi library. But, the pin numbering used in Wiring Pi library is different than GPIO numbering (BCM) and Physical numbering(BOARD).

To get information about pin numbering on our respective Raspberry Pi version, we can use following command:

gpio readall



The above screenshot shows pin numbering as per WiringPi, BCM (GPIO numbering) and Physical numbering(Board).