Professional Documents
Culture Documents
Cps 210 Finalpaper
Cps 210 Finalpaper
Cps 210 Finalpaper
Savannah Limarenko
Introduction
Since the beginning of human history, technology has been developed to help improve
day-to-day life. Starting from making tools that made farming an easier task to the Industrial
Revolution and the expansion of electricity, technology has rapidly changed over the years.
Technology has grown much more advanced over the centuries, and in today’s day and age there
are many aspects of technology both internal and external, that did not previously exist. There
are the physical components to technology which must be arranged in the correct order and taken
care of in order to run properly. Then in the modern day and what is typically thought of as
technology, there is code that tells the physical components what to do. Due to this, the internal
and external are deeply connected. A prime example of working with these two aspects of
computing is a Raspberry Pi. Raspberry Pi’s have incredible computing power and can be used to
make many interesting projects. For any of these projects to work it is necessary to combine
software and hardware. One such project, that highlights the use of both software and hardware,
that will be explored in this paper is an air quality monitor by David Gherghita and Ioan
Herisanu.
To begin with, what is a Raspberry Pi? From the Raspberry Pi foundation a Raspberry Pi
is defined as “a low cost, credit-card sized computer” (Raspberry Pi, 2023). It is a single circuit
board that contains all the hardware necessary to function as a computer. Though, this circuit is
not like the computers that most people are used to. Typically, laptops or desktops are what
people consider computers. However, a Raspberry Pi has all the same functionality as a typical
computer. All that the user needs to do is simply plug it into a standard monitor and get to work.
As a matter of fact, all the coding necessary for a project can be done directly on the Raspberry
Pi. This computer also comes with many additions that just a circuit including “USB-C and other
power supplies and camera modules” (DigitalTrends, 2022). These accessories make the
Raspberry Pi much more powerful in its capabilities, than if it did not have these accessories.
A Raspberry Pi like all modern computers has a specific architecture design. This mostly
includes a CPU, GPU, I/O components, as well as some form of storage. Across the various
models of Raspberry Pi’s, they all have a Broadcom BCM2835 chip, with a ARMv6 single core
processor, a Dual Core VideoCore IV Multimedia Co-Processor GPU (Lor & Zheng). The Arm
CPU processors use RISC architectures, which are used often nowadays in smaller computers
such as phones (ARM, 2023). RISC processors use simpler instructions which make them easier
to decode, meaning less transistors are necessary (Ivankov, 2020). This has a particular
advantage for the Raspberry Pi given its small size, the less hardware necessary the better.
The next important component to consider in any computer is storage. According to the
book “Learning Computer Architecture with Raspberry Pi”, a Raspberry Pi uses a “format flash
card for its primary non-volatile storage” (Upton et al., 2016). This essentially means something
like an SD card, USB thumb drive, etc… The Raspberry Pi storage specifically is either in the
form of an SD Card or a Micro SD Card. It has very little RAM capabilities since it is considered
to be a microcomputer. Because of this the use of SD cards in the system becomes invaluable
with how much more storage is added to the overall system (DigitalTrends, 2022).
average Raspberry Pi, there are many input/output possibilities. It contains an HDMI jack, a
3.5mm audio jack, camera interface ports, as well as ethernet and USB slots (Lor & Zheng). It
becomes evident quite quickly that there is a large variety of input and output options available
to the user. This once again makes the Raspberry Pi a powerful tool as it can handle many types
of inputs and outputs, and is not being limited by the fact that it can’t take certain types of input.
Now that it has been made clear how a Raspberry Pi works, it is time to discuss the tools
necessary to develop a project. A Raspberry Pi can run many different operating systems. Among
these there is “Raspbian OS, Ubuntu Mate…LibreElec, the non-Linux based Risc OS… also run
Windows 10 IoT Core” (Heath, 2019). However, Raspbian is the often the most recommended
operating system from the Raspberry Pi Foundation. Due to the Raspberry Pi’s capabilities, it can
be used in a variety of different languages, and therefore many IDE’s. There is Geany, which is
like a text editor and can be used with a variety of languages, similar to Notepad on the windows
system. There is also BlueJ to be used specifically with Java, as well as Thonny for Python and
Code::Blocks for C and C++ (Wate, 2021). The fact that a Raspberry Pi can be programmed
using a variety of different languages makes it a powerful tool especially for those just learning
to code for the first time. It gives the user flexibility in what they want to use, which is powerful
to be able to learn how to code similar projects in an array of different languages. While it is
The project that this paper will choose to focus on, the Air Quality Monitor uses the Rust
Programming Languages, specifically Python, Microsoft Azure, and Yocto Project for the
development of the project. The reason that these applications were chosen for this project
mostly relies on the hardware. The hardware used Azure to upload its data into a cloud, that was
then able to be read using the Rust language (Gherghita & Herisanu, 2020).
Development of a Project
There are many ways to develop a project using a Raspberry Pi. In order to start any
project there is some necessary hardware. To be able to code, a monitor will be needed to hook
up to the Raspberry Pi as well as a mouse and keyboard (Schooneveld, 2020). This means that by
extension HDMI cables will be required, otherwise there would be no way to actually hook up
the Raspberry Pi to the monitor and keyboard. The last thing that will be necessary in order to
start a project will be a power supply. This will typically be hooked up using the USB port on the
Choosing a project and starting it can be very difficult to do. However, due to the
Raspberry Pi’s increasing popularity over the years, many companies have built project kits that
can be purchased instead of starting completely from scratch. These project kits are a great
introduction to using a Raspberry Pi. In fact, there are many advantages to using a project kit.
Project kits do one of the hardest parts of a project, which is coming up with the idea for a
project. Often when just learning to program it can be difficult to come up with a project, these
kits help to take away that pressure. Project kits also come with all the necessary materials to
build a project with a Raspberry Pi. When starting out, not everyone has access to the necessary
materials for a project. These kits make it much easier to know that the user has all the proper
materials. The last advantage of using a project kit is it comes with step-by-step instructions
(ScienceBuddies, 2023). When getting started it can be very overwhelming to know where to
start, and how to develop a project if you have never done so before. Kits provide instructions so
that the skills necessary to do projects in the future can be learned, such as hooking up the
project. In fact, many of those who are more experienced will make their project from the ground
up. This often means using breadboards. “A breadboard is an essential tool when building
circuits. It allows you to quickly prototype your circuit without having to solder components
together” (Schooneveld, 2020). This fact that you do not have to solder together components
makes a breadboard very powerful. It also means that if there were a mistake to occur, or just
when the user is done with a project and wants to reuse the materials, they can easily be
disassembled and rebuilt. Since Raspberry Pi’s are meant to be used for learning purposes, the
The Air Quality Monitor project uses a breadboard (Gherghita & Herisanu, 2020). It was
made for those who have more experience using a Raspberry Pi, so the need for a kit is
diminished. Another reason that a breadboard may have been preferred for this type of project is
to make it easier to connect the Raspberry Pi to the sensor that gathers the information on the air
quality. Using a breadboard simplifies this process tremendously and allows for easier access to
The Air Quality Monitor project was designed by David Gherghita and Ioan Herisanu and
matter sensor to a Raspberry Pi and obtain easy-to-read graphs based on the read data using
Microsoft Azure” (Gherghita & Herisanu, 2020). The reason that this particular project was
chosen for this project was the highlighted interconnection of hardware and software. The focus
of this class. In order to complete this project, it is pertinent that the user knows some
background information on coding and accessing hardware. Though, the article describes in great
detail how to do these things, it will be much easier if the user already has some background
knowledge.
Before the project can begin there were materials required to build it. (Gherghita and
Herisanu list these materials at the beginning of the article. They used Sensirion SPS30 for their
sensor, a Raspberry Pi 4 Model B, a generic breadboard, jumper wires, the Rust Programming
Language, Microsoft Azure, and Yocto Project (Gherghita & Herisanu, 2020). It is clear that
there are many internal and external components to be taken into consideration here. Listing out
the materials here is very helpful to the reader who most likely hopes to build this project. It is
like how recipes will list all the necessary ingredients at the beginning of the recipe, making it
easier for others to follow along, something that is a good practice in the science field. It should
be as easy as possible to follow along with what someone else has done.
The first step of this project is to build the circuit with the Raspberry Pi. The circuit itself
is labeled in Figure 1 (Gherghita & Herisanu, 2020). This circuit was built using a standard
breadboard. The circuit mainly consists of connecting to the proper pins of the Raspberry Pi to
the resistors on the breadboard, that the wires of the sensor were then connected to. It is a pretty
From there, the next step was to code the Raspberry Pi. It is important to note that before
the coding could commence, Gherghita and Herisanu had to “build a minimal Linux distribution
using the Yocto project” (Gherghita & Herisanu, 2020). How they managed to do this was
complicated at best. They needed to “Clone the Raspberry Pi BSP…Build and copy the image to
the SD card using the instructions from the repo…” (Gherghita & Herisanu, 2020). Linked in the
article are the github links necessary to find the Raspberry Pi BSP and so on. Which once again
comes back to making the project easily replicable, as they provide quick and easy links to their
references.
Once the Linux system was built by Gherghita and Herisanu the next steps were to read
the data, then send that data into the cloud (Gherghita & Herisanu, 2020). Using Microsoft
Azure, they were then able to add the sensor to the cloud. This was done by clicking on IoT
devices and adding a new device, which is very straightforward (Gherghita & Herisanu, 2020).
The Rust and Python code provided in Figure 2 were then implemented. Essentially, all that code
does is make it so that now the data is being received and is able to be turned into graphs in the
near future. This data can be turned into graphs using “Stream Analytics job of type Power Bi,”
(Gherghita & Herisanu, 2020). The code in order to do this can be found in Figure 3, once again
provided by Gherghita and Herisanu (Gherghita & Herisanu, 2020). That is the end of the
project. It seems rather daunting at first, but once the idea becomes more flushed out, the easier it
seems. There are many moving parts, and many places that it is important to know just how the
software will affect the hardware’s performance. Gherghita and Herisanu, however, do a fantastic
job of making the project easily accessible to a large audience and making coding that much
more approachable.
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let delay = Delay;
let mut sensor = Sps30::new_sps30(dev, delay);
println!("{}", result.mass_pm1_0);
println!("{}", result.mass_pm2_5);
println!("{}", result.mass_pm4_0);
println!("{}", result.mass_pm10);
println!("{}", result.number_pm0_5);
println!("{}", result.number_pm1_0);
println!("{}", result.number_pm2_5);
println!("{}", result.number_pm4_0);
println!("{}", result.number_pm10);
println!("{}", result.typical_size);
}
#!/usr/bin/python3.8
import os
import asyncio
from azure.iot.device.aio import IoTHubDeviceClient
from azure.iot.device import Message
import time
import subprocess
while True:
# Read data from sensor
cmd = ['sensor-read/target/release/sensor-read']
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
results = []
for line in process.stdout:
results.append(float(line))
# Send message
msg = Message('{\
"mass_pm1.0": %f,\
"mass_pm2.5": %f,\
"mass_pm4.0": %f,\
"mass_pm10": %f,\
"number_pm0.5": %f,\
"number_pm1.0": %f,\
"number_pm2.5": %f,\
"number_pm4.0": %f,\
"number_pm10": %f,\
"typical_size": %f,\
}' % tuple(results))
await device_client.send_message(msg)
time.sleep(15)
if __name__ == "__main__":
asyncio.run(main())
Figure 2: Rust and Python Code used in Air Quality Monitor
learning about both hardware and software. There are many aspects to it, that make it a
simplified computer to learn with, as well as provide many chances to learn how to build
hardware. Gherghita and Herisanu’s air quality monitor is a prime example of the opportunities
that a Raspberry Pi provides. It shows just how much the hardware and software of a project
relate to together, being the majority of the coding necessary for this project. Raspberry Pi’s are a
great tool for learning to make those connections with both software and hardware.
References
Arm Ltd. (n.d.). CPU Architecture. Arm | the Architecture for the Digital World.
https://www.arm.com/architecture/cpu
Buddies, S. (2023, March 13). Getting Started with your Raspberry Pi Projects Kit. Science
Buddies. https://www.sciencebuddies.org/science-fair-projects/project-ideas/raspberry-pi
https://geekflare.com/raspberry-pi-use-cases-accessories/#:~:text=OS%20You%20Can
%20Run%20on%20Raspberry%20Pi%201,4%20%234.%20Lakka%20. . .
%205%20%235.%20RetroPie%20
Chris. (2022, October 16). 7 Ways to Collect Data with Raspberry Pi (and how to set them up).
%20guide%20I%E2%80%99ve%20looked%20at%20how%20a,including%20over
%20the%20internet%20or%20via%20USB%20storage
Contributor, G. (2022). What is a Raspberry Pi and what can I do with it in 2022? Digital
Trends. https://www.digitaltrends.com/computing/what-is-a-raspberry-pi/
David Gherghita, & Herisanu, I. (2020, October 16). Air Quality Monitor using Raspberry Pi 4,
monitor-using-raspberry-pi-4-sps30-and-azure-03cb42
Heath, N. (2020, October 2). What is the Raspberry Pi 4? Everything you need to know about the
pi-4-everything-you-need-to-know-about-the-tiny-low-cost-computer/
Ivankov, A. (2022, January 11). Advantages and Disadvantages of RISC - Profolus. Profolus.
https://www.profolus.com/topics/advantages-and-disadvantages-of-risc/
http://meseec.ce.rit.edu/551-projects/spring2017/2-3.pdf#:~:text=Raspberry%20Pi
%20has%20an%20ARMv6%20700%20MHz%20single-core,Raspbian%2C%20a
%20lightweight%20linux%20OS%20based%20on%20Debian.
Python, R. (2023). Build Physical Projects With Python on the Raspberry Pi. realpython.com.
https://realpython.com/python-raspberry-pi/
Upton, E., Duntemann, J., Roberts, R. J., Mamtora, T., & Everard, B. (2016). Learning Computer
https://doi.org/10.1002/9781119415534.ch6
Wate, Y. (2021). 5 Great Raspberry Pi IDEs For Programmers and Students. MUO.
https://www.makeuseof.com/great-raspberry-pi-ides-for-programmers-and-students/
#:~:text=5%20Great%20Raspberry%20Pi%20IDEs%20For%20Programmers
%20and,Raspberry%20Pi.%20. . .%205%205.%20Lazarus%20IDE%20
What is a Raspberry Pi? (2015, August 20). Raspberry Pi Foundation.
https://www.raspberrypi.org/help/what-%20is-a-raspberry-pi/