Instructor Notes

This is a placeholder file. Please add content here.

An Introduction to the Internet of Things


Instructor Note

Notes for the instructor



The Arduino IDE


Instructor Note

Remember: system (sudo) python version needs pyserial installed.

To install you need pip (Linux): sudo apt-get install python3-pip

To install pyserial: sudo pip3 install pyserial



Understanding the code


Connecting the first sensor


Connecting the second sensor


Combining the two circuits


Using MQTT for the Internet of Things


Instructor Note

To avoid the requirement of Internet access for this lesson it is possible to set up and access point and MQTT broker using a Raspberry Pi. It could be done with any available computer, really, but the RPi makes for a simple solution that one can prepare beforehand and keep just for this purpose. It is small and easy to take along to a workshop.

This has only been tested with a RPi 4 with 2GB of RAM. Older RPis should work.

  1. Using the Raspberry Pi Imager, select the Raspberry Pi OS Lite version of the operating system.
  2. Using the settinngs menu, enable SSH and configure the wireless LAN. The settings are very much determined by your Internet connectivity and network setup so it might be worth looking at documentation on the Internet for your specific circumstances. Make sure you set the Wireless LAN coutry and the locale settings.
  3. Write the operating system to a micro-SD card and start up the RPi. You should be able to ssh into the RPi at this point
  4. To create an access point we will use the software developed by the open-source project RaspAP (https://raspap.com/)
  5. To install RaspAP:

BASH

sudo apt-get update
sudo apt-get full-upgrade
sudo reboot

After the reboot log into the RPi again

BASH

curl -sL https://install.raspap.com | bash
  1. You should now be able to connect to the Access point with the following information:
    IP address: 10.3.141.1
    Username: admin
    Password: secret
    DHCP range: 10.3.141.50 — 10.3.141.255
    SSID: raspi-webgui
    Password: ChangeMe
  1. Using a browser navigate to 10.3.141.1 and log in using as user admin with password secret. Change the IP address to 192.168.0.1 and the DHCP range to 192.168.0.50 - 192.168.0.255. You don’t have to do this but if you don’t you’ll have to adapt the IP address for the MQTT server in the lesson.
  2. Reboot the RPi
  3. Log into the RPi again. We now have to install Mosquitto which is the MQTT broker and client
  4. In the terminal type the following command:

BASH

sudo apt install -y mosquitto mosquitto-clients
  1. Reboot again just to be sure
  2. Your RPi should now be running RaspAP for students to connect to for an Access Point and it should be running the Mosquitto broker.


Subscribing to an MQTT topic