Professional Documents
Culture Documents
INTERNSHIP REPORT ON
Submitted By
Vedhesh murthy (1960818)
Performed At
CHRIST UNIVERSITY
(FROM: 15 may 2021 – 14 june 2021)
At last but not the least I would also like to express gratitude to my parents for their
continuous motivation and support.
Vedhesh murthy
B. Tech- Department of EEE
Roll. No- 1960818
School of Engineering & Technology
Christ (Deemed to be University), Bangalore
Implementation of MQTT Protocol
Project Aim:
To get temperature information from the publisher, and send that information
to the subscriber.
Theory:
MQTT is an open and simple client server publish/subscribe message transport
protocol designed for machine-to-machine communication between different
devices in environments of high latency and low network bandwidth.
MQTT is a protocol with a special publish/subscribe implementation. Devices
are not directly talking to each other. Instead, communication is structured
into topics and handled over a central server (broker).
In this protocol, there will one broker, containing the topics, then the publisher,
it can be sensors, phone etc., sends the information to the topics, then the
subscriber subscribes the desired topics, and the subscriber gets the subscribed
information over MQTT broker via internet.
Implementation Tools:
Python, Google colab
Code:
• Publisher:
import paho.mqtt.client as mqtt
from random import randrange, uniform
import time
mqttBroker ="mqtt.eclipseprojects.io"
client = mqtt.Client("Temperature Inside")
client.connect(mqttBroker)
while True:
randNumber = uniform(20.0, 21.0)
client. Publish("TEMPERATURE", randNumber)
print("Just published " + str(randNumber) + " to topic TEMPERATURE")
time.sleep(1)
• Subscriber:
import paho.mqtt.client as mqtt
import time
mqttBroker ="mqtt.eclipseprojects.io"
client = mqtt.Client("Smartphone")
client.connect(mqttBroker)
client.loop_start()
client.subscribe("TEMPERATURE")
client.on_message=on_message
time.sleep(30)
client.loop_stop()
Output:
• Publisher:
• Subscriber:
Procedure:
1. Open Google Colab.
2. Enter the above python code for publisher and subscriber in the
Google Colab, then execute.
3. Then we get the published temperature values, then we get the
subscribers message and the value required.
Result:
The above project on implementation of MQTT is done, an example we
took as temperature values published and subscribed, and verified the
output.