[go: up one dir, main page]

0% found this document useful (0 votes)
118 views12 pages

Dec50132 - Internet Based Controller: Politeknik Tuanku Sultanah Bahiyah Electrical Engineering Department

The document discusses a practical work on using the Message Queuing Telemetry Transport (MQTT) protocol via smartphones. The objectives are to write code to establish an internet connection using an MQTT client, publish and subscribe to MQTT messages, and create an IoT application to monitor sensor readings using Node-Red dashboard. Students will use an Android phone app and internet connection. The theory section provides an overview of MQTT, describing it as a lightweight messaging protocol that uses publish/subscribe operations to exchange data between clients and servers, making it well-suited for IoT/machine-to-machine communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views12 pages

Dec50132 - Internet Based Controller: Politeknik Tuanku Sultanah Bahiyah Electrical Engineering Department

The document discusses a practical work on using the Message Queuing Telemetry Transport (MQTT) protocol via smartphones. The objectives are to write code to establish an internet connection using an MQTT client, publish and subscribe to MQTT messages, and create an IoT application to monitor sensor readings using Node-Red dashboard. Students will use an Android phone app and internet connection. The theory section provides an overview of MQTT, describing it as a lightweight messaging protocol that uses publish/subscribe operations to exchange data between clients and servers, making it well-suited for IoT/machine-to-machine communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

POLITEKNIK TUANKU SULTANAH BAHIYAH

ELECTRICAL ENGINEERING DEPARTMENT

TITLE MESSAGE QUEUING TELEMETRY TRANSPORT (MQTT)


PRACTICAL 4
1 2 3 5 6 CLASS DTK4B / S1
WORK
SESSION II 2022/2023

DEC50132 - INTERNET BASED CONTROLLER

Student’s Name ID Number Total Marks

S1 NURUL HAFIDAH BINTI ABDULLAH 16DTK21F1003

S2 AHSSVINDREN A/L LETCHUMANAN 16DTK21F1035

S3 NUR NATASHA AMIRA BINTI MOHD NAJIB 16DTK21F1037

S4

Lecturer’s Name MOHD. ZAKI DOI

1/12
DEPARTMENT OF ELECTRICAL ENGINEERING
DEC50132 - INTERNET BASED CONTROLLER

PROGRAMME : DTK
PRACTICAL WORK : 4
TITLE : MESSAGE QUEUING TELEMETRY TRANSPORT (MQTT) via SMARTPHONES
LECTURER NAME : MOHD. ZAKI DOI
DATE :

# GROUP MEMBERS REGISTRATION NO.


S1 NURUL HAFIDAH BINTI ABDULLAH 16DTK21F1003
S2 AHSSVINDREN A/L LETCHUMANAN 16DTK21F1035
S3 NUR NATASHA AMIRA BINTI MOHD NAJIB 16DTK21F1037
S4

SCORE
PRACTICAL SKILL (CLO2, PLO5, P4) ATTAINMENT LAB REPORT ATTAINMENT
S1  Results 
1) Able to connect the circuit S2  Discussion 
independently. S3  Conclusion 
S4 
S1 
5) Able to identify relevant pin and S2 
suitable identifier/ variable
independently. S3 
S4 
S1 
S2 
9) Able to code independently.
S3 
S4 

ASSESSMENT SCORE WEIGHTAGE


Practical Skill (PS) @ 70% Lab Report (LR) @ 30% Total (100%)
S1 S1
S2 S2
PS = Score / 15 * 70 LR = Score / 15 * 30
S3 S3
S4 S4

PRACTICAL SKILL RUBRIC (PLO2, LD2)

Score Description

2/12
5 Student can complete all tasks assigned WITHOUT errors
4 Student can complete all tasks assigned with A FEW errors
3 Student can complete all tasks assigned with MORE errors
2 Student can complete partial tasks assigned WITHOUT errors
1 Student can complete partial tasks assigned with A FEW errors

LAB REPORT RUBRIC

Report Component Excellent Very Good Good Fair Unsatisfactory


(PLO2, LD2) 5 4 3 2 1
Professional
looking and
Accurate
Results accurate
Accurate representations
 Results in the representation
representation of the data in Incomplete Data are not
form of data, of the data in
of the data in written form, result, major shown OR are
calculation, tables and/or
tables and/or but no graphs mistakes. inaccurate.
waveform, graphs. Graphs
graphs. or tables are
graph etc. and tables are
presented.
labelled and
titled.
Analysis / All point of Some points of
Most points of Some points of
Discussion discussion on discussion on Very few points
discussion on discussion on
 Ability to the results results obtained of discussion,
results obtained results obtained
present, obtained covered and but not properly
covered and covered and
interpret and covered and not properly elaborated.
elaborated. elaborated.
analyse result. elaborated. elaborated.

Conclusion
includes
Conclusion The closing
whether the
 Provide answers The closing The closing paragraph do
findings
to objectives paragraph paragraph not attempt to
supported the No conclusion
stated summarizes and attempts to summarize the
hypothesis, was included in
earlier. draws a summarize but experiment OR
possible sources the report.
 Ability to learn sufficient draws a weak shows little
of error, and
something from conclusion. conclusion. effort and
what was
the experiment. reflection.
learned from
the experiment.

MESSAGE QUEUING TELEMETRY TRANSPORT (MQTT) via SMARTPHONES


Objectives

3/12
Upon completion of this practical work, students should be able to:
1. Write code to established internet connection (MQTT Client).
2. Write code to publish and subscribe MQTT.
3. Apply writing simple IoT application for monitoring sensor reading with Node-Red dashboard.
Equipment
1. Android phone with IOT MQTTPanel app.
2. Internet connection (access point dedicated to the laboratory).
Theory

MQTT is one of the most commonly used protocols in IoT projects. It stands for Message Queuing Telemetry
Transport. In addition, it is designed as a lightweight messaging protocol that uses publish/subscribe operations to
exchange data between clients and the server. Furthermore, its small size, low power usage, minimized data
packets and ease of implementation make the protocol ideal of the “machine-to-machine” or “Internet of Things”
world.

How do these devices communicate with each other?


Certainly, web browsers use HTTP protocol to communicate with the servers on the internet. Likewise, IoT devices
use specific protocols to communicate (send and receive data) over the internet to each other.
And here are some of the most known IoT protocols:
 CoAP (Constrained Application Protocol)
 AMQP (Advanced Message Queuing Protocol)
 DDS (Data Distribution Service)
 STOMP (Simple Text Oriented Messaging Protocol)
 MQTT (Message Queue Telemetry Transport)
The last one is the most used protocol in IoT projects. That’s due to its fast, lightweight and easy to implement.

Why MQTT?
MQTT has unique features you can hardly find in other protocols, like: It’s a lightweight protocol. So, it’s easy to
implement in software and fast in data transmission. It’s based on a messaging technique. Of course, you know
how fast your messenger/WhatsApp message delivery is. Likewise, the MQTT protocol.
Minimized data packets. Hence, low network usage.
Low power usage. As a result, it saves the connected device’s battery.
It’s real time! That’s is specifically what makes it perfect for IoT applications.

How MQTT works?


Like any other internet protocol, MQTT is based on clients and a server. Likewise, the server is the guy who is
responsible for handling the client’s requests of receiving or sending data between each other. MQTT server is
called a broker and the clients are simply the connected devices. So, When a device (a client) wants to send data to
the broker, we call this operation a “publish”. When a device (a client) wants to receive data from the broker, we

4/12
call this operation a “subscribe”.

In addition, these clients are publishing and subscribing to topics. So, the broker here is the one that handles the
publishing/subscribing actions to the target topics.

Example: Let's say there is a device that has a temperature sensor. Certainly, it wants to send his readings to the
broker. On the other side, a phone/desktop application wants to receive this temperature value. Therefore, 2 things
will happen: The device defines the topic it wants to publish on, ex: "temp". Then, it publishes the message
"temperature value". The phone/desktop application subscribes to the topic "temp". Then, it receives the message
that the device has published, which is the temperature value. Again, the broker role here is to take the message
"temperature value and deliver it to phone/desktop application. subscribe 21.3 C 21.30 MOTT broker publish
subscribe Temperature sensor 21.30 Schematic data flow from sensor (machine) to devise machine) MQTT
Components: That takes us to the MQTT components, which are 5 as follows: Broker, which is the server that
handles the data transmission between the clients. A topic, which is the place a device wants to put or retrieve a
message to/from. The message, which is the data that a device receives "when subscribing" from a topic or send
"when publishing to a topic. Publish, is the process a device does to send its message to the broker. Subscribe,
where a device does to retrieve a message from the broker.

How many devices you can connect to a broker?


The number of connected devices “clients” to the broker depends on the broker service provider. In fact, it can
reach a massive number of clients those are publishing and subscribing all the time. but the amazing part of this
isn’t only the huge number of these connected devices but also any the fact that any device can get any other
device’s data at any time. As a result, the applications based on these quickly shared data are limitless.

Procedure
Part A - Using Android App to Connect to MQTT Broker.

5/12
1. Go the Google Play Store to download and install IoT MQTT Panel app.
2. Launch the app. Tap on “Setup a Connection” set the new connection for first time use.

 Name the connection using any name you prefer.


 Type broker.hivemq.com in Broker Web / IP address.
 Port number and network protocol should already be set as 1883 and TCP.

3. Tap on “+” on the right side of “Add Dashboard” to add a new MQT Panel dashboard.
4. Name the dashboard and tap “Save”. Tap “Create” to finish this step. Record your result.

5. Tap on your newly created connection to open it. Tap “Add Panel” and select “Gauge”. Set the following as:
 “Panel Name” as Ruang Tamu and “Topic” as rumahSaya.
 “Payload min” = 0 and “Payload max” = 100.

6/12
 “Unit” as Celcius.

6. Tap “Create”. Record your result.


7. Add another panel using “Text Input”. Name the panel as Suhu Ruang Tamu and use the same topic as Step 5.
Tap “Create” to finish this step.

8. Observe and record the results in both your Node-RED dashboard.

NOTE: You can also use any other app for this procedure, depending on the operating system of your smartphones.
The equivalent settings are applicable.

PART B - Problem Based Learning

Build an interface like the example below in your MQTT Panel. Submit a video to show your system operations.
Please include the MQTT Panel dashboard configuration and the output.

7/12
Result
Observations and Results:

PART A

i. Go the Google Play Store to download and install IoT MQTT Panel app.

ii. Launch the app. Tap on “Setup a Connection” set the new connection for first time use.

8/12
 Name the connection using any name you prefer.
 Type broker.hivemq.com in Broker Web / IP address.
 Port number and network protocol should already be set as 1883 and TCP.

iii. Tap on “+” on the right side of “Add Dashboard” to add a new MQT Panel dashboard.

iv. Name the dashboard and tap “Save”. Tap “Create” to finish this step. Record your result.

v. Tap on your newly created connection to open it. Tap “Add Panel” and select “Gauge”. Set the following
as:
 “Panel Name” as Ruang Tamu and “Topic” as rumahSaya.

9/12
 “Payload min” = 0 and “Payload max” = 100.
 “Unit” as Celcius.

vi. Tap “Create”. Record your result.


vii. Add another panel using “Text Input”. Name the panel as Suhu Ruang Tamu and use the same topic as
Step 5. Tap “Create” to finish this step.

PART B

10/12
Discussion
Write your discussion on observed result.

Conclusion
Write your conclusion on this practical work.

11/12
12/12

You might also like