Ding Dong, You've Got Mail! A Lab Activity For Teaching The Internet of Things
Ding Dong, You've Got Mail! A Lab Activity For Teaching The Internet of Things
Ding Dong, You've Got Mail! A Lab Activity For Teaching The Internet of Things
Teaching Case
Mark Frydenburg
[email protected]
Computer Information Systems Department
Bentley University
Waltham, MA 02452, USA
Abstract
Connecting ordinary devices to the Internet is a defining characteristic of the Internet of Things. In this
hands-on lab activity, students will connect a wireless doorbell to the Internet using a Raspberry Pi
computer. By modifying and running a program on the Raspberry Pi to send an email or text message
notifying a recipient that someone is at the door, students will gain an appreciation for how the Internet
of Things enables devices to work together to produce new products or solutions. The activity also serves
as a brief introduction to interacting with the Linux operating system on a Raspberry Pi computer.
Working in groups of 3 or 4, students will demonstrate their understanding by completing a collaborative
lab report that summarizes the key takeaways of each step. Little or no programming skills are required.
The experience of physically connecting an everyday object to a device online gives an appreciation of
the potential for automating tasks using the Internet of Things.
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 1
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
Preparing for the Lab Activity Raspberry Pi computers have on-board memory
Complete these steps before working on this and a CPU and graphics processing unit on the
activity: circuit board. Processing speed and amount of
memory vary depending on the Raspberry Pi
Read this description before coming to
model used. SD (Secure Digital) cards store the
class on the day we will complete it, so
operating system and other files. Most models
that you will be familiar with the steps.
have wired Internet, Wi-Fi, and Bluetooth
That will save you a lot of time.
connectivity. For simplicity, this activity uses a
Identify the three other people who are in
wired Internet connection, although it is possible
your group.
to access the Internet on a Raspberry Pi using
Create a Google Doc containing the blank
Wi-Fi via a USB dongle or on-board Wi-Fi,
lab report template for this assignment.
depending upon the model. (Sims, 2014)
(You can find this document at
http://bit.ly/doorbellreport . Share it with
A Raspberry Pi contains several ports and plugs
your group members and with your
to connect a variety of cables and devices, as
instructor at the email provided.
shown in Appendix 1, Figure 2. The Raspberry
Pi connects to other devices through its general
2. GETTING STARTED purpose input/output (GPIO) pins which may
send or receive signals from connected devices.
Examine the kit containing the equipment for You can program the pins to interact with
this lab activity. Make sure it contains all of devices, sensors, and other signals. Some pins
these items, shown in Appendix 1, Figure 1: are "ground" pins that do not receive current.
Appendix 1, Figure 3 shows the pins and their
Raspberry Pi with camera installed (or names. To orient the Raspberry Pi correctly,
USB webcam) hold it so that the GPIO pins are at the right
Power supply with micro-USB cable edge.
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 2
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
For Your Lab Report: Know Your Pi What type Follow these steps to set up your Raspberry Pi.
of cables or devices might you connect or attach
to each of the ports or pins, numbered 1 – 8 of 1. Connect the keyboard, mouse, Ethernet,
Appendix 1, Figure 2? and HDMI cables to the appropriate ports
(Connect an external USB webcam if you
For Your Lab Report: GPIO Pins Your are not using the built in Pi camera).
Raspberry Pi has two pre-connected wires. What 2. Verify that the MicroSD card is inserted.
are the pin numbers and GPIO names of the pins 3. Turn on the monitor, and make sure input
to which they are connected? is set to come from the attached HDMI
cable.
4. CONNECT THE DOORBELL TO THE 4. Connect the power cable to the Raspberry
RASPBERRY PI Pi and watch it boot.
5. Sign in to the Raspberry Pi using
Appendix 1, Figure 4 shows the inside of the username pi and password raspberry .
wireless doorbell receiver. To simplify the 6. Type the command startx to load a
process of connecting the doorbell to the graphical user interface.
Raspberry Pi, and avoid damaging the wiring 7. Open a file manager app and navigate to
inside the receiver box, a red (positive) and Desktop. You should see a folder named
black (ground) wire have been soldered to the StarterFiles. Copy those files to a new
corresponding wires inside the doorbell receiver. folder on the desktop named Doorbell. Be
careful that you name the Doorbell folder
You will connect the doorbell chime to the with a capital D.
Raspberry Pi via the soldered red (positive) and 8. Open the Doorbell folder and verify that
black (negative) wires soldered to the doorbell's it contains three files: webcam.jpg,
speaker so that you can easily connect them to sendnotify.py, wait_doorbell.py .
the Raspberry Pi without concern about
damaging the fragile wiring inside. When the For Your Lab Report: Path A path describes the
speaker chimes after pressing the doorbell location of a file in a computer's storage. What is
buzzer, wires attached to the speaker will carry the path to the Doorbell folder that you created,
the current to the Raspberry Pi through the clip stored on your Raspberry Pi?
wires that you attach to connect both devices.
For Your Lab Report: User Interface How does
Your kit contains three clip lead wires: two of the user interface for the version of Linux on the
one color, and one of another. The two clips of Raspberry Pi resemble that of other operating
the same color will serve as the positive wires systems with which you are familiar? How is it
transferring the electrical current, the one clip of different?
the other color will serve as a "ground" wire
completing the circuit. 6. TEST THE CAMERA
Clip one end of each positive wire (for which you Locate the LXTerminal application's icon on the
have two clips of the same color) to the ends of Raspberry Pi desktop. Click on the icon to open
a 220 ohm resistor. A resistor reduces current a window running LXTerminal. You can type
flow, and, acts to lower voltage levels within commands into the LXTerminal app to run
circuits. Use the clip of the same color connected programs on the Raspberry Pi.
to the other end of the resistor, to the wire
coming from the Pi that is connected to the GPIO Type one of these commands to take a picture.
pin closest to the end of the Raspberry Pi that Be careful to include spaces after the command
has USB ports. name and the letter after each option specified
by a minus sign (-). Be sure to smile!
Clip the other (Ground) wire to connect the
speaker with the wire attached to a Ground pin
If you are using the built-in Raspberry Pi
(the pin closest to the end of the Raspberry Pi
camera, type this command all on one
that does not have USB ports) on your Raspberry
line in the terminal window to take a
Pi. The completed setup is shown in the diagram
picture: raspistill -h 300 -w 400 -n -o
in Appendix 1, Figure 5.
/home/pi/Desktop/Doorbell/webcam.jpg
If you are using a USB webcam, type this
5. SET UP THE RASPBERRY PI
command all on one line in the terminal
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 3
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
window to take a picture: fswebcam -r 7 to get a sense of how it works. You can open
960x720 -d /dev/video0 this file in a text editor app on the Raspberry Pi.
/home/pi/Desktop/Doorbell/webcam.jpg
The sendnotify.py program contains steps to set
Look in the Doorbell folder and click the up the contents of an email message, and then
webcam.jpg file to view the picture. Make sure it send that message. The program calls sendMail
has the photo you just captured. (in line 51) to send an email message with an
attachment to a recipient. Lines 14-46 specify
If you receive a permission denied error when the steps for the Raspberry Pi to send an email
running either webcam command, try typing it message from a sender's email address. Lines 55-
again, and preceded with the keyword sudo. In 59 specify the content of that email message.
Linux, sudo ("super user do") is a program that
gives you permission to run the command that For Your Lab Report: sendnotify.py In
follows with "super user" (often higher) addition to a sender's email address, what four
privileges. pieces of information are necessary for the
sendnotify.py program to send an email message
For Your Lab Report: Camera Where is the to a recipient? Where does the program get this
picture stored? What happens to the picture that information?
was stored previously after you take a new one?
9. TEST THE CONNECTION BETWEEN THE
7. CODE CHECK: wait_doorbell.py DOORBELL AND THE RASPBERRY PI
In this step you will examine the source code from In this step you will test the connection between
wait_doorbell.py, shown in Appendix 1, Figure 5, the doorbell receiver and the Raspberry Pi.
to get a sense of how it works. You can open this
file in a text editor app installed on the Raspberry 1. Open the wait_doorbell.py file in a text
Pi. editor. (The text editor app has an icon
on the desktop.)
The wait_doorbell.py file is a program written in 2. Change line 6 to replace 999 with the
the Python programming language. Its job is to GPIO number of the pin receiving the
wait until someone presses the buzzer on the positive charge. Look at Figure 1 to find
doorbell, and when that happens, take a photo the GPIO number. (This is not the pin
and send it in an email message. The program number!)
runs forever. The only way to stop it is to press 3. Save this change in the text editor.
the Control key and the C key (written as 4. In an LXTerminal window, type cd (for
Control-C) at the same time. change directory) and a space, followed
by the path to the Doorbell folder that
The code statements to take the photo (19 or 22)
you created. Press the ENTER key to
are commented out – that means, they have a #
complete the command. This will change
symbol at the beginning which tells the computer
directory in the command window so you
to ignore those lines. As part of the exercise you
can directly run the programs in the
will remove the # symbols from one of these
Doorbell folder.
lines so that the program runs them. Be careful
5. Type the command sudo python
not to change the indentation of any of the lines
wait_doorbell.py and press the ENTER
of program code.
key to run the program. This command
For Your Lab Report: wait_doorbell.py Which instructs the Raspberry Pi to run the
line of the wait_doorbell.py program causes it to Python program whose code is in the file
run forever until you press Control C? Which wait_doorbell.py.
line's statement checks to see if somebody 6. What do you see on the screen in the
pressed the buzzer? What does the program do terminal window when the program
when that happens? runs?
7. Press the button on the doorbell buzzer.
8. CODE CHECK: sendnotify.py (It is possible and likely that your buzzer
may cause several receivers in the room
In this step you will examine the source code to chime if they operate on the same
from sendnotify.py shown in Appendix 1, Figure frequency. If this happens, press the
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 4
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
sound button on the back of the receiver 7. Save these changes to the
unit.) What information displayed in the wait_doorbell.py file.
terminal window changes when you
sound the doorbell? These steps will verify that the program sends,
8. The program will run forever. Press the and the user receives email messages.
Control key and the C key at the same
time (Control C) to end the program For Your Lab Report: Commented Out What
and return to the terminal prompt. does the statement at line 19 or 22 that is not
commented out, do?
For Your Lab Report: wait_doorbell.py
Terminal Window When running the On another computer or mobile device, one
wait_doorbell.py program, what does the person in your group should sign into Gmail
terminal window show when you are not pressing using the doorbell email sender address and
the buzzer? How does the contents of the password, provided by your instructor. Please
terminal window change when you press the note: If you already signed into Google with
buzzer? your own account because you are working on
the lab report, then you will need to sign in using
10. TEST SENDING AN EMAIL MESSAGE a different browser or using private browsing, so
WITH A PHOTO ATTACHED you can access your account and the doorbell
email account in its own browser window.
If the values in the terminal window change
when you press the doorbell's buzzer, this should Delete all sent mail from the doorbell sender
convince you that the Raspberry Pi is receiving account, so you can determine easily if the
input from the doorbell's receiver through the program is sending mail when you run the
wires you connected to it. Now you will configure program. Navigate to the SENT folder and
the sendnotify.py program to send an email monitor it when you run the program.
message containing the photo as an attachment.
The program on the Raspberry Pi should be able
1. Open the file sendnotify.py in another to send email messages from the doorbell sender
text editor window. Gmail address because security settings for that
2. Replace the values for USERNAME and address are set to allow apps to send email
PASSWORD in lines 11 and 12 to show messages. Please note: If it is not working, you
the sender's username and password. may need to check the settings on that account.
This will be your doorbell email sender From the doorbell sender Gmail account, visit
address and password provided by your https://www.google.com/settings/security/lesss
instructor. ecureapps and turn on access for less secure
3. Select one member of your group as the apps.
person to receive an email notification.
Replace the recipient's email address at On the recipient's own computer or mobile
the bottom of the program the device, the recipient should sign into his or her
recipient's personal Gmail address. personal Gmail at the address specified to check
4. Save the changes to send_notify.py. if the email messages from the doorbell email
account have arrived.
5. The # symbol starting a line of code in a
Python program indicates a comment.
Navigate to the recipient's INBOX folder in Gmail
The program will skip that line when it
and monitor any new messages that may appear
runs. In the wait_doorbell.py program,
when you run the program.
remove the # symbols at lines 19 or 22
(depending on which type of camera you
are using). Click in the LXTerminal window, press the UP
ARROW key to reissue the python
6. Remove the # symbol starting line 26 to
wait_doorbell.py command (or retype it) to run
instruct wait_doorbell.py to run the
the program and press ENTER.
sendnotify.py program. Also remove the
# symbol starting the line that prints
11. TEST THE DOORBELL CONNECTION
"Photo captured." This will instruct the
program to print a notification message
when the camera takes a photo. With the wait_doorbell.py program running,
press the buzzer on the doorbell.
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 5
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
Check the sender's sent mail and the recipient's The email message sent from the
received email. How many messages were sent sender's Gmail account
when you ring the bell? If you received several The email message and attached photo
messages, try adjusting value specified in the received in the recipient's personal Gmail
time delay of line 6 of wait_doorbell.py. account
The text message received on the
Check the sent mail and received mail accounts recipient's mobile device
to see if the program sent an email message.
Take a look at the picture. 13. CLEAN UP
For Your Lab Report: What values do you see Complete these steps to remove the files you
in the LXTerminal window when the created, then disconnect and power off the
wait_doorbell.py program runs? What Raspberry Pi.
information does the program display in the
terminal window before and after you press the 1. Delete the Doorbell folder on the
buzzer? When does a message appear? Why? Raspberry pi desktop containing the files
you modified and the webcam photo.
12. SEND A TEXT MESSAGE 2. Power off the Raspberry Pi.
3. Disconnect the wires, power supply, and
To send a text message via email, you must use connected devices from the Raspberry
a SMS (simple messaging service) to email Pi. Disconnect the clip wires from the
gateway. By sending an email message to an doorbell. Place all of the parts back in the
address containing the mobile number of the plastic bag as you received it.
recipient, the gateway will forward the email-
message as a text message. Substitute a 10-digit For Your Lab Report: (To be answered
cell number for ‘number’ for each carrier's individually) What was the most difficult part of
name. Table 1 shows email gateways for popular this lab activity for you? How did this activity help
cellular carriers. If you have a different carrier, you learn about the Internet of Things? What did
use a search engine to find the gateway email you learn?
address for your carrier.
For Your Lab Report: (To be answered
Table 1. Carriers and Email gateway addresses. individually) What everyday items have you seen
or would you like to see connected to the
Carrier Email Gateway Address Internet? What does or would connecting those
AT&T [email protected] items to the Internet enable you to do?
T-Mobile [email protected]
Verizon [email protected] Review and discuss the answers with your group,
Sprint [email protected] and share the Google Doc with the instructor at
the Gmail address provided.
Copy the code at lines 55 to 58 of sendnotify.py
that sends an email message to a recipient. Paste 14. ACKNOWLEDGEMENTS
it at the bottom of the file, after the existing code.
Replace the recipient's email address with an The author acknowledges Tejas Shah, MSIT
email address containing your ten-digit phone student, who helped debug this lab activity, and
number (with no dashes, spaces, or parentheses) Prof. Bill VanderClock, whose adeptness with a
and the correct email gateway for your mobile soldering iron increased durability of the doorbell
provider. equipment and simplified the activity for
students.
Run send_notify again, press the doorbell buzzer,
and see if you receive both an email message and 15. REFERENCES
a text message on your phone.
Harizanov, M. (2013, July 17). Raspberry Pi
For Your Lab Report: Add these screenshots to email/SMS doorbell notifier + picture of the
your lab report: person ringing it. Retrieved from Martin's
Corner on the Web:
http://harizanov.com/2013/07/raspberry-pi-
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 6
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
emalsms-doorbell-notifier-picture-of-the-
person-ringing-it/
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 7
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
Resistor
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 8
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
Positive Ground
Charge
Appendix 1, Figure 4. Inside a wireless doorbell receiver. Soldered wires connect to ground (black)
and positive charge (red).
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 9
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 10
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
Positive
Charge Ground
resistor
Positive
Charge
Clip Lead
Wires
GPIO Pins
with jumper
wires
preinstalled
Resistor
(b) Wires connected to GPIO pins of Raspberry Pi (c) Clip leads connected to a resistor
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 11
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 12
http://iscap.info
2016 Proceedings of the EDSIG Conference ISSN: 2473-3857
Las Vegas, Nevada USA v2 n4221
__________________________________________________________________________________________________________________________
_________________________________________________
©2016 ISCAP (Information Systems & Computing Academic Professionals) Page 13
http://iscap.info