Skip to main content

Lab 2—Connecting IoT and Edge with MQTT

  • Chapter
  • First Online:
Network of Things Engineering (NoTE) Lab

Abstract

In Lab 2, we connect Arduinos and Raspberry Pi within a wireless local area network (WLAN) and use MQTT protocol for their communication. This lab module includes a series of tasks that include programming in Arduino IDE and Python. The lab setup is shown in Fig. 5.1, and it includes Arduinos, sensors, actuators, auxiliary components, Raspberry Pi, WiFi router , and workstation machine. This lab also implements a new tool, which is a Mosquitto broker on Raspberry Pi. On Arduinos, MQTT publishers and subscribers are implemented using arduino-mqtt library.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 79.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

Libraries

  1. Arduino JSON library: https://github.com/bblanchon/ArduinoJson

  2. Arduino WiFiNINA library source: https://github.com/arduino-libraries/WiFiNINA

  3. Arduino MQTT library: https://github.com/256dpi/arduino-mqtt

  4. WiFi client Arduino header file: https://github.com/tubskns/notelab-code/blob/master/arduino/WifiClient/WifiClient.h

  5. WiFi client source file: https://github.com/tubskns/notelab-code/blob/master/arduino/WifiClient/WifiClient.cpp

  6. Source code LiquidCrystal_I2C library https://github.com/johnrickman/LiquidCrystal_I2C

  7. Source code DHT11 library: https://github.com/adafruit/DHT-sensor-library

Tools

  1. Docker Engine installation on Ubuntu: https://docs.docker.com/engine/install/ubuntu/

  2. Python: https://www.python.org/downloads/

  3. OpenSSH Server: https://ubuntu.com/server/docs/service-openssh

  4. How to install Arduino IDE: https://www.arduino.cc/en/Guide/Linux

  5. mosquitto-clients (v1.6.9-1): https://packages.ubuntu.com/focal/mosquitto-clients

  6. Eclipse Mosquitto (Docker): https://hub.docker.com/_/eclipse-mosquitto

Other Resources

  1. MQTT client Arduino header file: https://github.com/tubskns/notelab-code/blob/master/arduino/MqttClient/MqttClient.h

  2. MQTT client Arduino source file: https://github.com/tubskns/notelab-code/blob/master/arduino/MqttClient/MqttClient.cpp

  3. MQTT client Arduino sketch: https://github.com/tubskns/notelab-code/blob/master/arduino/MqttClient/MqttClient.ino

  4. MQTT publisher for DHT11 Arduino sketch: https://github.com/tubskns/notelab-code/blob/master/arduino/sensors/temperature/publisher_DHT11/publisher_DHT11.ino

  5. MQTT publisher for DHT11 Arduino sketch: https://github.com/tubskns/notelab-code/blob/master/arduino/actuators/subscriber_temperature/subscriber_temperature.ino

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Admela Jukan .

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Jukan, A., Masip-Bruin, X., Dizdarević, J., Carpio, F. (2023). Lab 2—Connecting IoT and Edge with MQTT. In: Network of Things Engineering (NoTE) Lab. Springer, Cham. https://doi.org/10.1007/978-3-031-20635-1_5

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-20635-1_5

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-20634-4

  • Online ISBN: 978-3-031-20635-1

  • eBook Packages: EngineeringEngineering (R0)

Publish with us

Policies and ethics