Introduction to Physical Computing on the Raspberry Pi 4

In this blog, you will get started with the basics of physical computing on the Raspberry Pi 4. In layman’s terms, physical computing refers to the creation of devices that interact with the world around them.

Such a device would be able to sense its environment, process the data, and perform some action. The functions of any physical computing project can be split in three ways. The computer first measures the inputs through sensors, and then it uses software to think about what it will do with those measurements, then it makes something happen as a response with an actuator.

For example, the sensor can be as simple as a push-button, a temperature sensor, or a Pi Camera Module. It doesn’t even need to be physical hardware. For instance, a feed of the temperature in your city from the internet or the current time from the Pi’s clock could both be inputs. Finally, with the inputs read and the decisions made by the software, the computer must do something. For that, it needs output devices. That is the things that transfer from the software to the real world. These can be as simple as an LED, a servo, or even a mechanism of a 3D printer. Again, they don’t even need to be physical – for example, a piece of software that can send a Tweet as its output can also be an output device. Thus “sense – think -act” cycle becomes the core working principle of physical computation.

To do physical computing on the Raspberry Pi 4, the creators have provided pins on the top edge of the Pi 4. This is the most powerful feature of the Raspberry Pi 4. These pins are called General Purpose Input/Output pins or GPIO in short.

The GPIO pins are a physical getaway between the Pi 4 and the outside world. Understanding the functions of these pins are crucial for anyone working with the Raspberry Pi 4. If you count, you can see that there are 40 pins on the Raspberry Pi 4, split equally across two rows.

Please download the pinout diagram given here and take a color printout, before we learn the functions of each pin.

While programming on the Pi 4, if you need access to the pinout diagram right on the terminal, you can just enter pinout on the terminal, and you will see the pinout description. Basically, there are two types of pins on the Pi, and they are GPIO pins and Power Pins. The power pins include two 5 Volt pins, two 3.3 Volt pins, and eight ground pins.

Now, If you subtract the power pins from the total pins, you will get the number of GPIO pins, which is 28 in number. These GPIOs are on-off pins that you can either use as outputs or inputs. Use can use one anywhere a simple ON or OFF condition is required, for example, to turn on or off an LED.

Sometimes you need to do more than just switching ON & OFF the pins. Most of the GPIO pins come with a secondary function that allows them to interface with different kinds of devices like I2C, SPI, or UART devices. For I2C and UART, we will need 2 GPIO pins, whereas, for SPI, a minimum of 4 GPIO pins are needed.

Now, keeping that in mind, if you take a look at this pinout diagram, it’s clear that we have 6 I2C Bus implementations, 5 UART Bus Implementations & 6 SPI Bus implementations on the Pi 4.

The way they packed in many functionalities to each GPIO pins is by using the concept of multiplexing. The only disadvantage of multiplexed GPIO is that at a time, only one function can be used. You can refer to the following table, which will give you a much clearer idea of all the multiplexed features of the GPIO.

You will find this useful when you start building your own physical computing project.

Learn Technology in 5 Minutes is a unique video series aimed at demystifying cutting edge technologies in the field of AI, IoT & Embedded Systems. Invest just 5 minutes of your time every day and within a year you will have wide breadth and depth of knowledge on various topics.