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:
Other Tools and Components:
*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.
sudo apt - get install git - core
git clone git: // git. drogon. net / wiringPi
The version number of WiringPi and information about your Raspberry Pi model reveals the command gpio -v:
gpio version: 2.26
Copyright (c) 2012-2015 Gordon Henderson Raspberry Pi details:
Type: Model 2, Revision: 1.1, Memory: 1024 MB, Maker: Sony
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