0% found this document useful (0 votes)
13 views9 pages

IoT Edge Server Setup with Raspberry Pi

This tutorial focuses on setting up an edge server using a virtual Raspberry Pi for IoT applications, emphasizing local data processing to reduce latency and enhance security. It guides users through installing necessary software, familiarizing themselves with Linux command line operations, and sending messages from Arduino to Raspberry Pi. Additionally, it covers reading Arduino data using a Python script to process interrupts and log relevant information.

Uploaded by

LAT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views9 pages

IoT Edge Server Setup with Raspberry Pi

This tutorial focuses on setting up an edge server using a virtual Raspberry Pi for IoT applications, emphasizing local data processing to reduce latency and enhance security. It guides users through installing necessary software, familiarizing themselves with Linux command line operations, and sending messages from Arduino to Raspberry Pi. Additionally, it covers reading Arduino data using a Python script to process interrupts and log relevant information.

Uploaded by

LAT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SWE30011 - IoT Programming

Week 5 Tutorial

Edge Server

Objective

In this tutorial, we will focus on the installation and exploration of edge server in IoT applications. An edge server acts
as a bridge between devices generating data (like sensors) and the cloud. It processes data locally, close to where it is
generated, which reduces latency, minimizes bandwidth use, and enhances the privacy and security of the data. This
capability is crucial in IoT applications where real-time processing and decision-making are necessary. For this
tutorial, we will use a virtual Raspberry Pi to implement the edge server. The Raspberry Pi is a small, affordable
computer that can be used for a variety of IoT applications. With its capability to run full operating systems and host
multiple applications, it is an ideal choice for simulating real-world IoT edge computing scenarios. The operating
system we will use for our virtual Raspberry Pi is Debian, a Linux-based system known for its stability and reliability.
Debian's extensive software repositories and robust package management features make it a suitable platform for
developing and deploying edge computing solutions.
Task 1
Virtual Raspberry Pi Setup

In order to set up the edge server on a virtual Raspberry Pi, we need to download the following components:

1- Oracle VM VirtualBox: Oracle VM VirtualBox is a versatile, open-source virtualization tool developed by


Oracle Corporation that enables users to run multiple operating systems on a single physical machine. It is
particularly useful for setting up virtual edge servers. For example, VirtualBox can simulate a Raspberry Pi
environment by running a Raspberry Pi operating system such as Debian within a virtual machine. This setup
facilitates the development and testing of IoT applications intended for Raspberry Pi devices, which are widely
used as low-cost, energy-efficient edge servers in IoT deployments.
Download Link:
[Link]

2- Raspberry Pi Desktop: Raspberry Pi Desktop is a Debian-based Linux distribution formerly known as


Raspbian, designed for Raspberry Pi devices but also available for PCs and Macs. It provides a user-friendly
graphical interface and comes equipped with essential software.
Download Link:
[Link]

To install the Raspberry Pi Desktop please follow the instructions provided in the Task 1 video in week 6
resources folder
Task 2
Getting Familiar with Linux Command Line

After successfully running the Raspberry Pi Desktop, we will now explore some fundamental Linux command-
line operation. To begin, first create a folder on the desktop called parent and then create a folder inside the
parent folder called child. Then click on the terminal icon in the top menu to open a terminal window. Upon
opening, the terminal will start in the home directory by default.

To list the contents of the current directory we can use ls command. In the terminal type ls and press enter. As
you can notice the contents of the home directory is listed.
Task 2
Getting Familiar with Linux Command Line

Now let’s move to the child folder directory. The command for changing directory is cd. In the terminal type cd
Desktop and the current directory will move to desktop. Now let’s use the same command to move to the child
folder inside the parent folder.

If you already know the full path you can enter it as a full address using cd command. For example, using cd
Desktop/parent/child will change the directory to child folder from home directory.

To move one level up in the directory cd .. command can be used. Use cd .. command in the child folder
directory to move back to the parent folder directory.

Using cd command without any other input will return the directory to the home directory.

To check if an application is installed in virtual Raspberry Pi. We can use the --version command after the
application name. Let’s try to check if python is installed in the Raspberry Pi by using python --version
command. The command should return the version of the python.

To check if an application is installed and where it is installed, we can use which command before the name of
the application. This time type which python to see the outcome of the command. To clear the terminal
window, you can use clear command.
Task 3
Sending a Message from Arduino to Raspberry Pi

In this task we aim to send a message “IoT programming is fun !” from Arduino to the Raspberry Pi. To do so,
first we need to enable serial communication in the setup function of the Arduino code using the following
code:

[Link](9600);

The number passed to the function (in this case 9600) refers to the baudrate which is the speed of data
transmission in bits per second (bps). After enabling the serial communication, we will print the “IoT
Programming is fun !” message every 3 seconds in the loop function using the following codes:

[Link]("“IoT programming is fun !");


delay(3000);
To see the output of the code, from the tools menu in Arduino IDE select the serial monitor. The message
should print on serial output every 3 seconds.
Task 3
Sending a Message from Arduino to Raspberry Pi

Now let’s send the message to the Raspberry Pi and print it on the terminal. First shut down the Raspberry Pi.
Then click on the virtual machine and click the settings in the menu. In the settings click on the USB option.
Then click the add icon on the right-side menu and select the Arduino option and click ok.
Task 3
Sending a Message from Arduino to Raspberry Pi

Now run the Raspberry Pi. Open the terminal and run the ls /dev/tty* command. This command lists all the
available terminal interfaces on your system. The Arduino serial port is usually /dev/ttyACM0 or
/dev/ttyUSB0. To read the message from Arduino you can use cat command along with the Arduino serial
port. The cat command reads and display the data stream. Execute cat /dev/ttyACM0 command to check the
output.
Task 4
Reading Arduino Data using Python Script

In this task, we will use a Python script to perform data processing on the edge server. Simultaneously, on the
Arduino, we will configure a push button linked to an interrupt. Each time the button is pressed, it will trigger
an interrupt, causing the message "Interrupt triggered" to be displayed on the Arduino's serial output.
Task 4
Reading Arduino Data using Python Script

On the edge server side, we will develop a Python script that responds whenever an "interrupt triggered"
message is received from the Arduino. The script will record the time, date, and day of the interrupt, along with
the interrupt number provided by the Arduino. After every 10 interrupts, the script will compile and display this
data on the terminal. To write a python script from the menu click on the raspberry pi icon, click programming
and then select the Thonny Python IDE. Write the pyrgom script and save the code on Desktop as [Link].
Then in the terminal change the directory to desktop and run the python [Link] command.

You might also like