The Raspberry Pi is equipped with a set of input/output or GPIO (general-purpose input/output) pins. This powerful feature significantly expands the Raspberry Pi’s abilities to communicate with other devices. These pins are connected directly the to CPU of the Raspberry Pi.
The newer Raspberry Model B, including the Raspberry Pi 2 & 3 have a total of 40 GOI pins, while the older Model A boards have a total of 26 pins. The Raspberry Pi Zero and Raspberry Pi Zero W has 40 unpopulated/headerless pins (holes). Pins are aligned as two equal rows (i.e. 2x 20 or 2x 13).
The pins include 5V (2), 3.3V (2), ground (5 for A & 8 for B) and a few other pins mentioned below. Apart from sensing high and low signals, some of the GPIO pins also doubles for other functions.
Through, for example, Linux Bash and Python programming, complex logic to and from these pins can be programmed to interact with various microelectronic components such as LEDs, switches, buttons, communication and display modules. The networking capabilities and the control of various USB devices makes the possibilities almost endless.
Raspberry Pi GPIO specifications
Operating voltage (logic level): 3.3V DC
Input voltage: 5V DC
Power source: 5V via Micro-B or GPIO I/O pins
Digital I/O (read/write) pins: 22
Interrupt pins: all
Analog input pins:
Operating current (per I/O pin): ~8 mA (15 mA max) (50 mA max all)
Interfaces: Serial/UART (GPIO 14 & 15), SPI, I2C
Breadboard friendly: na
Pin size: male, 5 x 2.54 mm
Raspberry Pi model B GPIO pinout
A GPIO pin designated as an output pin can be set to HIGH (3.3V) or LOW (0V).
A GPIO pin designated as an input pin can be read as HIGH (3.3V) or LOW (0V). This is made easier with the use of internal pull-up or pull-down resistors. Pins GPIO2 and GPIO3 have fixed pull-up resistors, but for other pins this can be configured in software.
On the Raspberry Pi, each GPIO pin can also be configured as an interrupt pin.
The Raspberry Pi is capable of serial communication with other devices. Tx (GPIO14) and Rx (GPIO15) pins uses 0 and 3.3 V TTL (transistor-transistor logic) to produce its signal. Also read using the UART interface for more advanced information on how to set up serial communication on the Raspberry Pi.
Raspberry Pi GPIO libraries
There are currently a couple of libraries available to be able to utilise the GPIO pins of the Raspberry Pi. GPIO Zero (which is included by default in the Raspbian image) and Wiring Pi are fairly comprehensive. Other, less developed libraries include RPi.GPIO, pi-gpio and raspberry-gpio-python.