Assignments and Laboratory Exercises

There will ne a pre-departure assignment (Assignment 0) that will be due before the start of the course. Weeks 1-4 will each have an assignment (Assignment 1-4) and Weeks 5-6 will have the final assignment (Assignment 5). Each week, we will work on these assignments in class, but if they are not completed during lecture hours, they need to be completed independently by their respective deadlines. All submissions should be a single PDF file submitted using Sakai.

Assignment 0

  • Task 1: Watch videos V1 and V2. There is no deliverable for this task.
  • Task 2: Read articles A1 and A2. Don't worry about acronyms or terminology that you don't recognize (yet). For this task, provide brief answers (no more than 100 words per response) to the following questions:
    • Question 1: Mark Weiser was called the father of Ubiquitous Computing (which is closely related to the concept of IoT). Describe in no more than 100 words your interpretation of Ubiquitous Computing. Make sure to say something about what it means when technology "disappears".
    • Question 2: We will be able to find IoT examples in all parts of our lives. Use the reading assignments and online search to identify a concrete example of an IoT system (existing or futuristic) in each of the following application areas: home, healthcare, transportation, and community (i.e., four examples in total). For each example, provide a description of what the problem is that the IoT solves, how it solves it, who the users are, and what a risk of the example is (e.g., in terms of ethical concerns, privacy, safety, etc.). Limit each example description to 200 words.
    • Question 3: Provide brief definitions (1-3 sentences) for each of the following concepts: IoT, RFID, WSN, MEMS, hype cycle, IPv4, IPv6, QoS, MAC, LED, cloud computing, edge computing.
  • Task 3: Laboratory assignments will be programmed in Python. Prepare your laptop for programming in the Python environment by following the instructions provided in P1. The suggested Python environment is Jupyter Notebook (described under "Python on the Web"), but you can use any Python development environment you prefer. If you are new to Python, follow the link to the Python tutorials on the P1 page to get some basic Python understanding. There is no deliverable for this task.
  • Task 4: Now that you feel somewhat comfortable with Python, develop two of the following three programs (extra credit for developing all three). Note that while you might find code examples for these assignments on the web, it is highly recommended to attempt to solve them by yourselves to really gain some experience with Python.
    • Subtask 4-1: Implement the game "Guess The Number!". In this game, the computer randomly chooses a number (e.g., between 1 and 20) and asks the player to guess the correct number. After each guess, the computer informs the user if the guess was correct, too high, or too low. The program should also inform the user how many guesses the user needed. After a certain limit (e.g., five guesses), the program stops and informs the user of the correct number.
    • Subtask 4-2: Implement the game "Rock, Paper, Scissors". In this game, the computer randomly chooses one of the three options and then asks the user to make a choice. The computer then informs the user if the game is a tie, if the player won, or if the computer won (clearly indicate the computer's choice and why the computer or player won (e.g. "Scissors cut paper!".
    • Subtask 4-3: Implement the game "Mad Libs". In this game, the computer asks the user for several words (e.g., a singular noun, a plural noun, an adjective, etc.) and then chooses a random story and fills in the gaps of the story with the player's words. Ask the player for at least four different words and implement at least three different stories.
    The deliverable for this task is the complete source code for all three subtasks.
Deliverables: Submit your assignment report as a PDF file to Sakai (if possible) or via email to iot34468@gmail.com (if Sakai is not set up yet). Clearly indicate "Assignment 0" in the subject line (if email submission) and on the document and place your name at the top of the document. The deadline for this assignment is May 18 11.59pm.

Assignment 1

  • Task 1: Write a function “Rechnung” (bill) that takes a list of foods (e.g., ["banana", "orange", "apple"]) as input and computes the total price (only for items in stock) and adjusts the stock accordingly. Write the bill computation as function that takes one parameter (list of foods).
    stock = { "banana": 6,

    "apple": 0,
    "orange": 32,
    "pear": 15 }

    prices = { "banana": 4,

    "apple": 2,
    "orange": 1.5,
    "pear": 3 }

  • Task 2: Continue Task 1 by writing the shopping list into a newly created file, each item in a new line. Then write a second program that reads the file in a loop, line by line and prints each line.
  • Task 3: Write a simple Python program using an editor on your laptop, e.g., a calculator, a game, etc., but something different from Assignment 0. The program should be interactive, i.e., ask the user for input, perform some processing, and present an output. Then copy it onto your RPi via the Ethernet connection. Then ssh into your RPi and run the code.
  • Task 4: Use ssh to log into your RPi and then use IDLE to write another simple Python program (again interactive) and execute it. Copy the program from the RPi to your laptop via the Ethernet connection.
  • Task 5: Raspbian is a Linux/Unix variant. Become familiar with the Unix environment on your RPi, e.g., learn the commands for the following activities and try them on the RPi:
    • Create directories, create subdirectories within these directories, delete directories, change directories, list the content of a directory, and find out what the shortcuts ~, ., and .. mean when you navigate directories.
    • Learn a command-line editor (e.g., nano, vi, vim, or emacs (note: some may be preinstalled, others have to be installed) and write a simple file (on the RPi), save the file, copy that file to another location, rename the file, and delete the file.
Deliverables: The lab report is due by Wednesday, June 6 (midnight) via Sakai. The submission must be a single PDF file; do not forget name and netid on top of the document. The document should provide:
  • Complete source code for Task 1 & 2 (combined)
  • Complete source code for Task 3
  • Complete source code for Task 4
  • End the report with a section called “Problems Encountered:” where you can describe missing features or other problems with your codes, or any problems encountered with using ssh/scp or other Unix commands. If there were no problems, just write “None”.

Assignment 2

  • Task 1: Write a Python program that controls an LED and makes it blink at a rate of three seconds on, one second off. Note that running a Python script that uses GPIO pins requires superuser rights (sudo).
  • Task 2: Add a switch to control the LED, i.e., your Python program should read the switch status and turn on or off the LED blinking from Task 1 accordingly. In addition to time and loop functionality (also needed in Task 1), make sure to also use callbacks when switch activity is detected.
  • Task 3: Add a second switch that controls the blinking rate, i.e., it toggles between a fast (1 second) and slow (3 seconds) blinking rate. Again use a callback function to handle switch activity.
  • Task 4: Connect a PIR sensor to the GPIO pins of the Raspberry Pi. Perform measurements to determine the range of the sensor, i.e., start with a small distance (e.g., a few inches) and see if the motion sensor responds. Repeat these for increasing distances until the sensor stops responding. Report the measured distance.
  • Task 5 (EXTRA CREDIT): Select at least 1 input sensor (not PIR) and 1 output device (LED ok if you use more than just one LED) and make the RPi control the chosen output device in response to activity by the input device (e.g., a temperature sensor as input and two or more LEDs indicating the current temperature in binary code).
Deliverables: The lab report should include the following:
  • Complete source code for Task 1
  • Complete source code for Task 2
  • Complete source code for Task 3
  • Complete source code for Task 4; also indicate your measurement result
  • Optional: Complete source code for Task 5; also describe clearly the functionality and operation of your system (e.g., how to operate the input and how to interpret the output)
  • End the report with a section called “Problems Encountered:” where you can describe missing features or other problems with your codes, or any problems encountered with using ssh/scp or other Unix commands. If there were no problems, just write “None”.

Assignment 3

  • Task 1: Configure Bluetooth on your Pi as shown in class.
  • Task 2: Write a client-server based intruder detection system using 2 Pis, a PIR sensor, and an LED (and/or sounder). You need to collaborate with one or more of your classmates for this task, i.e., you will need to test your client and server programs on two Pis simultaneously. One Pi will have the PIR sensor connected, the second Pi will operate the LED and/or sounder. The server Pi will use a callback function for motion detected by the PIR. The other Pi acts as client and queries the server for the PIR value once every 5 seconds; if an intrusion is detected, the alarm is raised (e.g., flashing LED or activated sounder).
Deliverables: The lab report should include the following:
  • Server code
  • Client code
  • Clearly indicate your Bluetooth address
  • End the report with a section called “Problems Encountered:” where you can describe missing features or other problems with your codes, or any problems encountered with using ssh/scp or other Unix commands. If there were no problems, just write “None”.
In addition, provide a brief video (no longer than 30 seconds each) that shows your Pi and your classmate's Pi work together as intrusion detection system.

Assignment 4

  • Task 1: Sign up for service at CloudMQTT and configure your MQTT broker (use a descriptive name and choose the free plan). Install the Chrome app "MQTTlens", which allows you to publish or monitor data and is very useful for debugging purposes.
  • Task 2: Write an MQTT publisher for your RPi, where your publisher should periodically publish sensor data to the broker. You can use MQTTlens to see if the broker receives the data. You can also first develop the code for your laptop (with fake sensor data) and then test it on your RPi (with real sensor data).
  • Task 3: Write an MQTT subscriber for your RPi, where your subscriber should activate an actuator (LED, etc.) based on data received from the broker. You can again first write and test it on your laptop and then run it on your RPi.
  • Task 4: Work in teams of 2-4 to build a complete IoT system that does something meaningful using at least 2 RPis, 1 sensor device, 1 output device, and the MQTT broker (you will need only one broker). If your system includes PIRs and LEDs only, the maximum score you can receive is 90% for Assignment 4; in order to be able to receive the full score, your solution should have at least one new type of sensor or output device (i.e., a device other than PIR or LED).
Deliverables: The lab report should include the following:
  • Task 1: Provide your MQTT broker information, i.e., hostname, username, password, and port number (note that this is not the username/password you used to sign up for service with CloudMQTT, but the username/password for the actual broker).
  • Task 2: Entire publisher code.
  • Task 3: Entire subscriber code.
  • Task 4: Description of your solution (what IoT system did you implement; what does it do; what sensors and output devices do you use?); brief video demo of your solution (max. 30 seconds); photo of your team with your RPis operating.
  • End the report with a section called “Problems Encountered:” where you can describe missing features or other problems with your codes, or any problems encountered with using ssh/scp or other Unix commands. If there were no problems, just write “None”.


Hardware Resources

  • Kuman Kits (3):
    • Joystick
    • Relay
    • Big sound
    • Small sound
    • Tracking
    • Avoid
    • Flame
    • Linear hall
    • Touch
    • Digital temp
    • Buzzer
    • Passive buzzer
    • Touch
    • RGB LED
    • SMD RGB
    • Two-color LED
    • Two-color
    • Mini Reed
    • Tap module
    • Light blocking
    • Reed switch
    • 7color flash
    • Laser emit
    • Button
    • Shock
    • 7-segment
    • Rotary encoder
    • Analog hall
    • Touch
    • Ball switch
    • Photoresistor
    • Temp and humidity
    • 4 7-segment
    • Hall magnetic
    • TEMP18B20
    • Analog temp
    • IR emission
    • IR receiver
    • Touch
    • Water
  • Smart Home IoT Sensor Kit (1)
    • Voltage detection
    • Gas/smoke
    • Combustible gas
    • CO carbon monoxide
    • Flame
    • Temp
    • Temp and humidity
    • Digital barometric pressure
    • Digital touch
    • Photosensitive light
    • Vibration
    • Sound detection
    • Buzzer alarm
    • 2-channel relay
    • Infrared PIR
    • Water level
  • SunFounder
    • Dual-color LED
    • RGB LED
    • Auto flash LED
    • Relay
    • Laser Emitter
    • Button
    • Tilt-switch
    • Mercury switch
    • IR receiver
    • Active buzzer
    • Passive buzzer
    • Reed switch
    • Photo-interrupter
    • Raindrop sensor
    • Joystick
    • Potentiometer
    • Analog hall
    • Hall switch
    • Analog temp
    • Thermistor
    • Sound sensor
    • Photoresistor
    • Flame
    • Gas
    • Remote control
    • Touch switch
    • Ultrasonic
    • Temp
    • Rotary encoder
    • Humiture
    • IR obstacle
    • LCD
    • Barometer
    • Tracking
  • Adeept
    • Accelerometer
    • Temp and humidity
    • Ultrasonic distance
    • PIR
    • Joystick
    • LCD
    • Servo
    • Stepper motor
    • DC motor
    • Keyboard
    • Light
    • Analog temp
    • Relay
    • Active buzzer
    • Passive buzzer
    • 7-segment display
    • 4 7-segment display
    • LED bar graph
    • Dot matrix display
    • Switch
    • RGB LED
    • Buttons
    • Potentiometer
  • Other components
    • Camera kit
    • RFID sensor
    • Sense HAT (LED matrix, accelerometer, gyroscope, magnetometer, air pressure, etc.
    Resistors:
    • 100
    • 220
    • 330
    • 4k7
    • 10k
    • 47k
    • 100k
    • 1M
    Resources: