There is no fun or excitement if we don't interact with the real world during the experiments with Embedded Boards. Embedded Boards like Arduino and Raspberry Pi have vast varieties to interact with the real world with fewer efforts. We can easily interface them with Sensors(aka real-world Interface).
Raspberry Pi has 40 pins to interact with Real World. In this section, we will learn about GPIO pins and how to operate it.
Raspberry Pi (all models) has a powerful way to interact with the real world, it is known as General Purpose Input Output pins (GPIO) on one side of the board. Raspberry Pi models after Model 3 have forty (40) GPIO pins. In the older version of Raspberry Pi models, there were 26 GPIO pins, which were increased by 40 in all the latest models.
The beauty of Raspberry Pi GPIO is, one can assign any pin as Input or Output, which can be used by any developer for any use. This way Raspberry Pi has given freedom to design the hardware and software as per the developer's choice. Using this freedom, the developer can design and modify the hardware and develop many IoT based projects. GPIO is the main feature of Raspberry Pi behind the excessive growth of this hardware and its popularity among the developer community.
Before we start working with GPIO, let's understand the electronics behind the GPIO.
Voltages
Any electronics in this world operate at two voltage level - 5v and 3.3v. To provide said voltages to attached sensors, Raspberry Pi has total 4 pins, 2 for each voltages on the board. When we have Positive (+) voltage, it is always required to give ground (-) voltage. Raspberry Pi has a number of ground (-) voltage pins, which one can easily configure. The rest of the pins in GPIO is set to 3.3v, input as well as output.
Input
There is a concept called Pull Up and Pull Down resistors, which helps developers to provide input using GPIO pins. All the pins assigned as INPUT can read either 3.3v or 0v. It depends on the above concept of Pull Up or Pull Down. There are only two pins in (GPIO2 and GPIO3) that have the built-in feature of Pull Up resistor. The rest of the pins in GPIO have Pull Down resistor concept.
Output
The rest of the pins of GPIO are set for OUPUT, which means, it can generate 3.3v or 0v during the activation. Developers can set the values of pins as per their needs and requirement of projects.
Apart from the above classification of GPIO, Raspberry Pi has many other pins that are supported for the external analog and digital communications. As well it helps the developer to provide serial input, PWM communication, etc. The following are details about a few more dedicated pins on the Raspberry Pi Board.
PWM: Pulse Width Modulation
It is divided into two major categories (Software & Hardware).
Hardware Pins: GPIO12, GPIO13, GPIO18, GPIO19.
Software Pins: All GPIO pins.
Serial Pins
It is designed for Serial Communication on Raspberry Pi Boards with external serial devices.
Transmission: TX GPIO14.
Receiving: RX GPIO15
I2C
During communication between low-speed devices, the majority of the time they use I2C in embedded systems. Major microcontrollers, A/D and D/A converters, Input-Output devices/interfaces are using I2C nowadays. All IC manufacturers are using I2C for their better use.
SPI
It is also known as Serial Peripheral Interfaces (SPI), mostly used for the Synchronous Serial Communication for short distance. Raspberry Pi has following pins for SPI.
SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7)
SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17); CE2 (GPIO16)
Raspberry Pi GPIO Pin Out
Raspberry Pi has inbuilt GPIO Pin Out. To check the pinout of current boards, follow the steps.
1. open Terminal Window
2. type pinout
You will be able to see the specification of each GPIO in graphical manner.
NOTE: The above command is not supported in the Raspbian Lite.
You may also like: