Dec50132 - Internet Based Controller: Politeknik Tuanku Sultanah Bahiyah Electrical Engineering Department
Dec50132 - Internet Based Controller: Politeknik Tuanku Sultanah Bahiyah Electrical Engineering Department
S4
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 :
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
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
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.
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.
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.
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.
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.
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.
NOTE: You can also use any other app for this procedure, depending on the operating system of your smartphones.
The equivalent settings are applicable.
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.
PART B
10/12
Discussion
Write your discussion on observed result.
Conclusion
Write your conclusion on this practical work.
11/12
12/12