Raspberry Pi: An Effective Vehicle in Teaching the Internet of Things in Computer Science and Engineering

Abstract: The Raspberry Pi is being increasingly adopted as a suitable platform in both research
and applications of the Internet of Things (IoT). This study presents a novel project-based teaching
and learning approach devised in an Internet of Things course for undergraduate students in the
computer science major, where the Raspberry Pi platform is used as an effective vehicle to greatly
enhance students’ learning performance and experience. The devised course begins with learning
simple hardware and moves to building a whole prototype system. This paper illustrates the outcome
of the proposed approach by demonstrating the prototype IoT systems designed and developed by
students at the end of one such IoT course. Furthermore, this study provides insights and lessons
regarding how to facilitate the use of the Raspberry Pi platform to successfully achieve the goals of
project-based teaching and learning in IoT.

Introduction

The Internet of Things (IoT) has been envisioned as the next wave in the era of cyber technology,
in which millions of smart devices (including various sensors and actuators) are wirelessly connected
and integrated via the Internet [1]. This emerging paradigm will fundamentally create and boost a
number of new applications across many fields, including environmental monitoring [2], precision
agriculture [3], smart grids [4], smart cities [5] and e-health systems [6]. It is of critical importance to
provide the next generation of computer scientists and engineers an opportunity to not only understand
the concepts and principles of IoT, but also to study the practical development of IoT solidly, so that
students can learn how to apply theories to real applications. Many universities have started to
introduce IoT courses into their undergraduate curriculum [7–11].
Project-based learning (PBL) can provide great opportunities for students to enhance their
engineering understanding and skills [12–17]. Students can not only gain theoretical knowledge
from lectures, but also obtain valuable hands-on experience in real-world project practice, where they
can actively improve their abilities in self-motivated learning, self-efficacy beliefs [15], problem solving,
adaptation to interdisciplinary thinking and collaborative learning [16]. The PBL approach also helps
with improving the achievement of low-performing students [17].
Real-world projects demand real resources. For example, wireless communication-enabled tiny
computers are essential for students to program and experiment with in any IoT project. The invention
of the Raspberry Pi, an inexpensive, tiny and relatively powerful computer board, not only provides a
great building block to facilitate research and various IoT application developments, but also provides
a desirable hardware platform for the project-based learning paradigm in computer science and

engineering education. Educators have exploited Raspberry Pi either as a single device [10,18] or as
the basis of more sophisticated learning systems [7,8,19–21] for their IoT education. Bruce et al. [10]
and Jamieson et al. [18] described valuable experiences and case studies of using Raspberry Pi in
undergraduate study. Sobota et al. [19] coupled a Raspberry Pi with an Arduino to build an inexpensive
platform for students to run control algorithms. Buzz-Board [7] and DC Motor Kit [21] are more
powerful education systems that are designed based on Raspberry Pi. As an affordable solution,
Raspberry Pi has also been adopted as an educational computing system in many countries.
This paper presents the project-based teaching experience of using Raspberry Pi for the
“Introduction to Internet of Things.” This IoT course is offered for undergraduate students in the
Department of Computer and Information Science (CSCI) at Indiana University Purdue University
Indianapolis (IUPUI). In previous years, course projects were based on simulations; in fall 2015,
the Raspberry Pi computer boards and various peripherals were used to enrich students’ hands-on
experiences on IoT projects. To maximize the effectiveness of the project-based learning paradigm,
the class projects were carefully designed. Students without any previous hardware experience are
guided to finish a complete IoT prototype system at the end of the course, including both hardware
and software development.
The reminder of paper is organized as follows. Section 2 gives an overview of the Raspberry Pi
platform. Section 3 provides the design of class projects based on Raspberry Pi. Section 4 demonstrates
the outcome of our approach by presenting several final projects that students completed by the end of
the course. Section 5 shares some lessons learned from our experience. Finally, Section 6 concludes
the paper.

2. An Overview of Raspberry Pi

The Raspberry Pi [22] is a single-board computer introduced in 2012 (Figure 1) with the
intention to promote the study of computer science and related topics in schools and in developing
countries [22]. It is powered by an ARM-based processor, which operates on 700 MHz–1.2 GHz, with
a memory of 256 MB–1 GB, depending on different models. The major components include HDMI,
USB ports, Ethernet ports and SD card. The default operating system on a Raspberry Pi is Raspbian,
a Debian-based Linux distribution; Raspberry Pi 2 and 3 can also run Window 10 IoT core.

Figure 1. Raspberry Pi 2 Model B.

In addition to the major components, Raspberry Pi is equipped with numerous interfaces to interact with small electronic devices. The display serial interface (DSI) can be used to connect to a touch screen; the camera serial interface (CSI) can be used to capture pictures or videos; sensors or/and actuators can be attached to the general purpose input/output (GPIO) pins to monitor and react to the environmental change. The advantage of Raspberry Pi is that it provides a general programming environment (e.g., Linux) and allows direct control of the hardware through the interfaces. This makes it a perfect platform for development in IoT.

Tutorials are available online to teach beginners the basics of computer programming. Step-by-step
guides for many real projects (e.g., magic mirror and robot car) are also provided by either the
community or device venders. Raspberry Pi adopts Python as a main programming language, but also
supports other mainstream programming languages, such as C/C++, Java, Perl and Ruby.
Raspberry Pi has been gaining popularity all over the world for its small size, low price, powerful
computation capability and versatility. At a cost of $25–$35, eight million devices had been sold by
February 2016 [22].

3. Project Design

The success of any project-based teaching and learning paradigm lies in the appropriate design
of the project series, through which the students are required to work. This project design should
carefully take the students’ background into consideration. Designed projects should be challenging
enough to keep students motivated and interested, but not so difficult that students cannot complete
them. In this section, we first briefly describe the course outline and then present the design of a series
of course projects to realize our project-based teaching paradigm. The hardware for the students to
use includes CanaKit Raspberry Pi 2 Ultimate Starter Kit [23], Osoyoo Sensor Modules Kit [24], and
Elegoo Sensor Module Kit [25].

3.1. Course Outline

The Introduction to Internet of Things (CSCI 49000) at IUPUI is a three-credit hour one-semester
course for undergraduate students in the Department of Computer and Information Science.
This course covers the basic concepts and fundamental principles of the Internet of Things and
wireless networks of smart devices. Topics include the concept and architecture of the Internet of
Things, communication mechanisms, IP stack, 6LoWPAN adaptation, protocols, operating systems,
sensors and actuators and IoT applications. The students taking this class are not required to have any
hardware experience or/and embedded systems background.

3.2. Project Design

We take a novel project-based teaching and learning approach in which project work is designed
as a semester-long activity. To help students to get started and gradually learn more as the class moves
forward, we apply the “divide and conquer” methodology to project design. A series of three projects
are designed and described in Sections 3.2.1–3.2.3, respectively. Each project is conducted by a team of
two students or an individual, according to the students’ preference.

3.2.1. Project 1: Hardware and Software Platform for a Single-Node System

For most students, the Raspberry Pi is a totally new computation platform, which is quite different
from their own computers, smart phones or tablets. It is a necessity to then make students familiar
with the hardware platform and the basic software development environment; this is the main purpose
of the first project. In the first step of this project, students are asked to go through the Raspberry Pi
system installation and configuration guide, and to run the Blink application, toggling an LED through
a GPIO pin. In Step 2, by learning the code logic and circuit of the Blink application, students are asked
to build an application with four LEDs and two buttons, in which buttons are used to increase/decrease
the frequency of the LED’s blinking, and three LEDs are used to display the frequency level. In Step 3,
students are required to use a temperature sensor and turn on/off an LED if the temperature is
above/below a threshold. Students are encouraged to mimic the example code to build their own
application, once they learn the usage of GPIO pins in both directions. Upon the successful completion
of Project 1, students will have learned how to build a simple single-node (i.e., smart device) system
with sensors/actuators based on the Raspberry Pi platform.

3.2.2. Project 2: Networking Individual Node(s) to the Internet via IoT Application Protocols

Project 2 aims at helping students learn IoT-specific protocols. IoT devices are particularly resource
constrained when compared to general purpose computers and devices. New application protocols
are specifically designed and developed for IoT devices to reduce computation and bandwidth usage,
such as the Constrained Application Protocol (CoAP) [26] and Message Queuing Telemetry Transport
(MQTT) [27]. In Project 2, students learn IoT protocols and the philosophy behind them. We select
CoAP [26] as our learning tool for its relatively mature implementation, strong support from the
Eclipse Foundation [28] and ease of testing using a Firefox client. Each team is asked to run the hello
world CoAP server application, which replies with a string to any CoAP client. Then, the team is
required to attach sensors (of their own selection) to the Raspberry Pi and to add sensor readings
as resources to the CoAP server. The sensor readings can be queried using a graphical user agent,
Copper [29], which is an add-on for Firefox. In step three, each team is asked to analyze the resource
usage of CoAP on Raspberry Pi (e.g., code size, memory usage and response time) and to learn the
differences between CoAP and HTTP.

3.2.3. Final Project: A Complete IoT Prototype System

The first two projects train students to understand programming on Raspberry Pi and an
IoT-specific protocol. In the final project, students are asked to demonstrate their skills by developing a
complete IoT prototype system. To encourage and promote students’ creativity, proposals are required
for final projects; modifications to proposals are suggested based on each team’s performance in the
previous projects. Students were encouraged to use electronic elements that were not included in
the previous projects. Section 4 describes and illustrates some of the final projects that students have
completed thus far.

4. Project Demonstration

4.1. Raspberry Pi Stock Ticker

The Raspberry Pi stock ticker system tracks selected stock prices in real time and notifies the user
in multiple ways when the stock price changes within a certain amount. It was a client/server model:
the server side was written in Python, while the client side was written in Java. The system consists of
the following major electronic elements:
• 16 × 2 LCD: Displays two lines of information. The top line displays the stock symbol and
the price difference, with an up or down arrow indicating the increase or decrease in price as
compared to the previous day’s close. The bottom line displays the latest stock price.
• A red LED: Turned on if a stock’s price has decreased from the previous day’s closing price.
• A green LED: Turned on if a stock’s price has increased from the previous day’s closing price.
• A piezo buzzer: Makes a sound when a stock’s price has fallen below a predefined threshold.
• Potentiometer: Adjusts the contrast of the LCD screen.
The stock ticker system monitors the dynamics of selected stocks and generates alert signals.
The user of the stock ticker system can register an email to receive notifications when the stock price
has reached a level of interest. Figure 2 shows the prototype of the system.

Figure 2. A prototype of the stock ticker system. The left side shows stock information in the terminal
of Raspberry Pi. The right side shows the setup of the system: the stock information is displayed in the
LCD, while the red LED indicates the price has dropped from the previous day’s closing price.

4.2. Water Leak Detector

A water leak can cause serious damage if it is not detected early. This project built a water leak
detector to notify a homeowner about a detected water leak using both emails and text messages.
The core element is a soil moisture sensor, which produces different signals according to the presence
or the absence of water. The system can be used to detect a water leak, for instance, in the kitchen
under the sink, near the toilet or near water pipe junctions.
When water is present, the system will send alerts to the user after three consecutive leak
detections. If the leak stops, the system will send “clear” messages to the user after three consecutive
checks. It also implements the request/response communication model, such that the users can request
the water leak status at any time. The system setup and alerting messages are shown in Figure 3.

Figure 3. The prototype of the water leak detector. When a water leak is detected, email and text
messages are sent to the user. When the water leak stops, updated email and text messages are sent to
the user.

4.3. Lock Checker

The lock checker is designed to monitor the status of the door lock and can be used to improve home security.

The major system components are an infrared obstacle avoidance sensor [30] and a touch sensor [31].

The obstacle avoidance sensor is installed on the door frame (Figure 4) to detect the door’s opening or closing by sensing the presence of the door handle.

The touch sensor is attached to the door handle on the inside so that it will be triggered if someone opens or closes the door from inside the room.

Figure 4. The prototype of the lock checker. The obstacle avoidance sensor is attached to the door
frame, and the touch sensor is attached on the door handle.

The obstacle avoidance sensor can determine the lock status of the door; it also generates readings
when people walk through the door. To effectively detect people that enter or leave the room,
a combination of sensor readings are used. For example, if the avoidance sensor is triggered alone,
the door is opened from the outside. On the other hand, if the touch sensor is triggered before the
avoidance sensor is triggered, the door is opened from the inside.

The system used Python to control the sensors, and hosted a website written in PHP to display
the status of the lock, so that the user can check the door status through the Internet. If the door is
unlocked, an email or text message is sent to notify the user.

5. Discussion and Evaluation

5.1. Discussion

We believe that the appropriate design of the projects in PBL is critical to the effectiveness of
the PBL approach itself. This not only requires deep understanding of the scientific and engineering
subjects that students are going to learn, but also needs clear understanding of students’ academic
background. In our case, the subject of the Internet of Things naturally includes two important
aspects: single-node system and networking. The single-node system is different from traditional
computer organization, because it includes sensors and actuators. If students do not really understand
a single-node system, it would be very difficult for them to move on to the networking of individual
nodes to the Internet. On the other hand, students typically did not have any hardware training and
experience before they took this class. In view of this, our strategy was to design a series of projects
for students in an incremental way. The first project only focused on a single-node system, where
students learned how to connect sensors and actuators to the CPU, how to use sensors and actuators
and how to program the node to make it smart. After students could work with a single-node system
confidently, they were allowed to move on to the second project, which focuses on the networking
aspect. In the second project, students learned communications and protocols through their hands-on
project and understood where and how IoT protocols are different from the corresponding traditional
Internet protocols. Having acquired some basic understanding of the IoT concept and system after the
first two projects, students started to work on an IoT system that can be applied to the real world in a
creative and comprehensive way, which is the goal of the third project in the project series. Indeed,
we feel that the design of this series of three projects is the key to our PBL approach, which greatly
enhanced the effectiveness of PBL for our students.

When teaching/tutoring, beginners and experienced learners require different treatments. For
experienced learners, a clear problem statement is usually enough to get them started; for beginners,
the problems and learning materials must be carefully designed in order to help them progress, as hard to find an entry point of necessary background knowledge and learning materials to Raspberry Pi.

The Raspberry Pi official website [32] does not have a systematic tutorial to guide the beginners; for
example, the “Getting Started Guide” only shows how to install the system for the first time. What to
do next is not clear. In this regard, we provided various supports for our students during their projects,
including a detailed CoAP tutorial and a detailed tutorial on how to work on Raspberry Pi with the
laptop screen and keyboard [33].
When teaching/tutoring, beginners and experienced learners require different treatments.
For experienced learners, a clear problem statement is usually enough to get them started; for beginners,
the problems and learning materials must be carefully designed in order to help them progress, as well
as to keep their enthusiasm.
We encountered a networking issue during Project 2 when using Raspberry Pi (running Raspbian)
on campus. By default, Raspbian does not support connecting to a WiFi network that uses enterprise
encryption (e.g., the WiFi on the IUPUI campus uses WAP2 Enterprise). Possible solutions are either
creating another hotspot on campus for Raspberry Pi or changing the network configurations on
Raspbian. We managed to provide both solutions to students.

5.2. Evaluation

During the semester in fall 2015, 13 undergraduate students in the class selected the Raspberry
Pi platform. At the beginning of the class, an informal survey showed that none of students had any
hardware-related experience, and only two of them had used Linux-based systems before. To evaluate
the effectiveness of our approach, we monitored and analyzed the performance of the students after
each project. As an introduction-level project, the main purpose of Project 1 is to help students to build
up their confidence when facing new hardware and development environments. Encouragingly, all
students completed Project 1 successfully. Project 2 requires more on both the new protocol and the
self-selected sensors/actuators, making it more difficult. As a result, 11 students successfully completed
Project 2, whereas the other two students partially finished the project. Among the 11 who completed
the project, seven students understood the basic concepts and usage of the CoAP library very well, and
four students showed a good understanding of the self-selected sensors/actuators. This result indicates
that hardware seems to be more difficult for students to grasp. In the final project, all students were
able to correctly use the sensors/actuators they selected, but several encountered software issues, since
they started to use more complicated open source libraries as the basic service providers. Nine students
completed their proposed prototype systems successfully; two students completed partially, and the
other two students failed. One group showed the ability to build a relatively complex prototype system
(i.e., the Raspberry Pi stock ticker). These results have demonstrated the effectiveness of our approach.

6. Conclusions

In this paper, we present our experience using the Raspberry Pi platform as an effective vehicle to
realize a successful project-based teaching approach in an Internet of Things class for undergraduate
students. We feel that it is important to provide students with such an engaging environment for
learning and experimentation, where the Raspberry Pi platform fits in very well. The outcome of the
class was very positive; and the prototype systems developed by the students show great potential
to be improved to be practical IoT products. We are pleased to observe that through our devised
project-based teaching and learning paradigm in this course, the students have obtained the ability
to finish IoT projects based on the Raspberry Pi platform, to come up with novel IoT ideas and to
implement them successfully.
Acknowledgments: We are grateful to the support of equipment funds from the School of Science at IUPUI
to our computer hardware lab for this class. The project of the Raspberry Pi stock ticker was conducted by
Paul Grziwok Jr. and Ryan Bartelt; the project of the water leak detector was conducted by Kaitlyn Davis and
Josh Luke; and the project of the lock checker was conducted by Denver Huynh.

Source: Raspberry Pi: An Effective Vehicle in Teaching the Internet of Things in Computer Science and Engineering


About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Scroll to Top