So what are single-board computers? A single-board computer(SBC), is an entire computer based on a single circuit board. its hardware has almost everything you can expect from a desktop computer. like a processor, RAM, I/O ports, and much much more.
One of the biggest drawbacks of single-board computers is the lack of performance. primarily due to the reason that single-board computers rely on either ARM-based or RISC-V-based processors. which are not as performant as our standard x86-based processors but are extremely power efficient.
BUT! don’t let that fool you into thinking that single-board computers are not performant. The ARM-based processors are the same processors used in our mobile phones. So it can give you an idea that the computers are not as bad as many people assume. At least at the first glance and even apples latest M1 chips are based on the ARM processor architecture. So it really isn’t that big of a problem.
Advantages they offer
Perhaps one of the biggest advantages a single board computer has to offer are the GPIO pins
So what are the GPIO pins? The GPIO(general purpose input-output) pins are small metal pins. It’s used as a method for input and output for the SBC to communicate with hardware not built into itself, but also these pins can be programmed to do anything you can imagine. for instance, we can use a group of them to turn on an LED or make the LED blink after each second and so much more.
This is just a raw example of how SBCs can be used to make entire IoT projects like robots
Why do we use SBCs?
There are many different uses for SBCs like a small home computer, an IoT project(such as a robot), and a lot of different things.
Single-board computers are used everywhere nowadays and a good example of that is the raspberry pi (a small credit-card-sized single-board computer that can fit in your palm)
Other than that SBCs can be used as complete computers. Most SBCs have enough performance to be used as a home computer such as a Raspberry Pi
- Raspberry Pi
- Banana Pi
- Nano PI
- ASUS Tinker Board
- NVIDIA Jetson Series
These are one of the most popular single-board computers and perhaps The best of them all is the Raspberry Pi
Different parts of an SBC
A diagram of a raspberry pi with all the parts labeled that we will need to interact with
One core difference between a desktop and an SBC is that an SBC uses an SD card for its primary storage medium, and most of them don’t have any built-in storage medium the SD card will most likely have an operating system on it most commonly uses Linux(raspbian for the raspberry pi) although you can use other distros like ubuntu IOT or Debian if you like.
This is raspbian running on my raspberry pi
How to interact with an SBC
Most SBCs work with an operating system most commonly Linux and in the raspberry pi’s case. It uses something called raspbian. which is a Debian-based Linux distribution made for the raspberry pi.
The operating system is installed on the SD card of the raspberry pi. it can be used to interact with the raspberry pi’s hardware.
You’d have to use regular I/O devices with your raspberry pi like a mouse keyboard and monitor.
After connecting all of these things you can install the operating system of your choice on your raspberry pi.
You first install the operating system on your raspberry pi. then you use a language like C, C++, or python to interact with the GPIO pins on the raspberry pi.
In my case, I am using python (you can learn more about python in our python series). The first step is to install all the necessary dependencies for python to interact with the GPIO pins in the raspberry pi or your preferred operating system.
$ sudo apt-get install python-rpi.gpio python3-rpi.gpio
It’s how I connected the pins of the raspberry pi to a breadboard an led and a resistor with the help of two wires and made the LED blink.
This is the placement of the GPIO pins on the Raspberry Pi.
It has 2 5v power pins 2 3v pins, ground and the rest are the GPIO pins.
To initialize the GPIO ports on the Raspberry Pi. We need to first import the Python library, initialize the library and set up pin 8 as an output pin.
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library from time import sleep # Import the sleep function from the time module GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numbering GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (off)
Next, we need to turn the LED on and off in 1-second intervals by setting the output pin to either high (on) or low (off). We do this inside an infinite loop so our program keeps executing until we manually stop it.
while True: # Run forever GPIO.output(8, GPIO.HIGH) # Turn on sleep(1) # Sleep for 1 second GPIO.output(8, GPIO.LOW) # Turn off sleep(1) # Sleep for 1 second
Combining the initialization and the blink code should give you the following full Python program:
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library from time import sleep # Import the sleep function from the time module GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numbering GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and set initial value to low (off) while True: # Run forever GPIO.output(8, GPIO.HIGH) # Turn on sleep(1) # Sleep for 1 second GPIO.output(8, GPIO.LOW) # Turn off sleep(1) # Sleep for 1 second
$ python3 blinking_led.py
This is just an extremely simple program. that serves as an example of how you can use a raspberry pi or any SBC. and how these tiny computers can do so much work.
So in conclusion we learned how SBCs work. how we can interact with them, and how this tiny machine can do so much work for you