9.
Create a connection from an MQTT capable device/software with an
MQTT broker then send and receive data using it.
Aim:
To connect an MQTT client (using MQTT Explorer) to an MQTT broker (testclient-
cloud.mqtt.cool), then send and receive data.
Components Needed:
MQTT Explorer (a GUI tool to connect to MQTT brokers, send/receive messages,
and monitor MQTT topics).
Internet Connection.
Browser (for connecting to the MQTT broker via testclient-cloud.mqtt.cool).
Procedure:
Step 1: Set up MQTT Broker
We will be using testclient-cloud.mqtt.cool as a public MQTT broker.
1. Open the browser and go to: https://testclient-cloud.mqtt.cool/
2. You will see a web interface to connect to the MQTT broker. No registration or login is
needed since it’s a public broker.
Step 2: Connect MQTT Explorer to the Broker
1. Download and Install MQTT Explorer (if you don't have it already):
o Download it from MQTT Explorer’s official website.
o Install the tool on your system.
2. Open MQTT Explorer and click on File → New Connection.
3. Enter the Connection Details:
o Broker Address: testclient-cloud.mqtt.cool
o Port: 1883 (for non-SSL connections).
o Client ID: (You can leave this as default or enter a custom name).
o Username and Password: These are not required for this public broker.
o Leave other settings as they are (or adjust if needed).
4. Click Connect to establish the connection to the MQTT broker.
Step 3: Subscribe to a Topic in MQTT Explorer
1. Once connected, you can see the Broker connection and the topics available in MQTT
Explorer.
2. To subscribe to a topic:
o Click on the Subscribe button at the top.
o Enter a topic name (e.g., test/topic).
o Click OK to subscribe.
Step 4: Send Data (Publish Message)
1. Publish a message to a topic:
o In MQTT Explorer, go to the Publish section.
o Enter the topic name (e.g., test/topic).
o Enter the message (e.g., Hello from MQTT Explorer!).
o Click Publish to send the message.
2. The subscriber (MQTT Explorer window listening to the topic test/topic) will
automatically display the message you sent.
Step 5: Monitor and Verify Data Exchange
1. Verify the Data Exchange:
o After publishing the message from MQTT Explorer, the message should appear
in the Subscriber section under test/topic.
o You should see the message "Hello from MQTT Explorer!" appear in the
window of MQTT Explorer.
Step 6: Send and Receive Data from the TestClient
1. In TestClient (Browser interface):
o Go to https://testclient-cloud.mqtt.cool/.
o Enter the same broker details (e.g., testclient-cloud.mqtt.cool and port 1883).
o Connect to the broker.
2. Subscribe to a Topic:
o Enter the topic test/topic in the Subscription section.
o Press Subscribe.
3. Publish Message from TestClient:
o To send a message, enter the topic test/topic and message "Hello from
TestClient!".
o Click Publish.
4. Verify Message in MQTT Explorer:
o After publishing from the browser interface (TestClient), you should see the
message "Hello from TestClient!" in the MQTT Explorer's Subscriber section
under test/topic.
Output:
Results:
The experiment successfully connected MQTT Explorer to the MQTT broker, enabling
successful message exchange between MQTT Explorer and TestClient. Real-time data
monitoring and communication through the broker were verified.