Outcomes:After finishing this assignment, you should be able to:
- Configure and implement an MQTT Broker for home automation in PT.
- Subscribe and publish to topics by MQTT Clients.
- Build a functioning IoT application using MQTT protocol in PT.
Requirements: Cisco Packet Tracer version 8.1.1
COE 550 – Intro. to Internet of Things
Instructions:
1. Solution should be uploaded through Blackboard as a compressed zip file named
HW3_NAME_ID.zip where NAME is your name and ID is your student ID. Name the
packet tracer file as HW3.pka.
2. Students are encouraged to discuss the homework in groups, but each student must
write and submit his own program.
3. If cheating or copying is detected, both parties will get zero in the assignment.
4. No late submissions will be accepted.
Outcomes: After finishing this assignment, you should be able to:
1. Configure and implement an MQTT Broker for home automation in PT.
2. Subscribe and publish to topics by MQTT Clients.
3. Build a functioning IoT application using MQTT protocol in PT.
Requirements: Cisco Packet Tracer version 8.1.1
Preparations:
Watch “A Guide for using MQTT in PT” for the Resources folder of the course.
Homework Problems:
Problem 1: (100 points) Home Automation using MQTT
You are required to implement a “Digital Home” using PT with the following specifications:
1. The system includes:
a. A server (hosting an MQTT Broker)
b. A Wireless Router
c. A Roker Switch (ON/OFF)
d. An LED (ON/OFF)
e. A Potentiometer (Variable range)
f. A Dimmable LED (Variable Range)
g. An LCD Display
The system works as follows:
1. Each device is connected to a separate SBC that is running an MQTT client.
2. If the Rocker switch is ON, the LED turns ON.
3. Based on the Potentiometer value, the dimmable LED must be set to the same value
(between 0 and 1023).
4. The LCD Display shows the status of the LED and Dimmable LED. For the Dimmable LED,
choose the following descriptions.
1
COE 550 – Intro. to Internet of Things
Value of LED
0-350
351-700
701-1023
LCD Display message
LOW
MED
HIGH
Here is an example of the LCD Display information:
Hint:
1. Use the included program as a starting point. The program (main.py) uses the
implementation in (mqttclient.py). The program connects to the broker, and subscribes to a
topic. You need to extend the functionality according to the role of the device
(subscriber/publisher).
2. Use the “Help” menu under “Programming” Tab to check the different available Python
APIs.
3. Here is a brief description of some useful APIs from mqttclient.py
API
init()
Use
arg
MQTT CLIENT
Initializes a
TCP client
Argument
type
content
None
broker_add:
String
usr
pwd
String
String
connect(broker_add,usr,pwd)
Connects to
the Broker
subscribe(topic)
Subscribe to
a topic
topic
String
unsubscribe(topic)
Unsubscribe
to a topic
topic
String
publish(topic, payload,
qos):
Publish a
topic
topic
String
payload
qos
String
String
pingreq():
A ping
request
MQTT Broker
None
IP address
of Broker
Username
Password
Topic to
subscribe to
Topic to
unsubscribe
from
Topic to
publish
Message
QoS level
2
COE 550 – Intro. to Internet of Things
add_user(username, password)
Add an
authorized
user to the
broker
username
String
Username
password
String
Password
Testing: The system must respond as described above. All functionalities will be tested.
3