This is an old revision of the document!


[pczekalski]Dokończyć

IOT3: Connecting to the MQTT and publishing data

In the following scenario, you will learn how to connect to the MQTT broker and publish a message.

Prerequisites

To implement this scenario, it is necessary to get familiar with at least one of the following scenarios first:

and obligatory:

[pczekalski]Tu trzeba dodać bibliotekę do MQTT, pewnie pub-sub client

Suggested Readings and Knowledge Resources

Hands-on Lab Scenario

Task to be implemented

Connect to the “internal IoT” WiFI access point as presented in the scenario IOT2: Reading IP address of the WiFi—present connection status on the display (for tracing). Once connected to the networking layer, connect to the MQTT broker and present the connection status on the display, then publish an MQTT message.

MQTT clients are identified by their name, so use a unique one, e.g., the end of the IP address assigned, your unique name, etc. It is essential because if you accidentally use someone else's name then you will mess with messages, and your MQTT client will be instantly disconnected when another one with the same name connects!

Start

Check if you can clearly see a full display (of your choice) in your video stream. Book a device and create a dummy Arduino file with void setup()… and void loop()….
Implement a connection to the “internal IoT” network as a client. Refer to the supervisor or the technical documentation on credentials (SSID, passphrase). We do not provide the exact code on how to connect to the WiFi as it is a part of IOT2: Reading IP address of the WiFi scenario.

Steps

Step 1

Include

Result validation

You should be able to connect to the WiFi and present the dynamically assigned IP address by the DHCP server.

Note that due to the dynamic nature of the lab, IP addresses can change both during connection (on lease refresh) or between consecutive connects.

FAQ

I set a hostname, but it does appear on the router level.: There are many possible reasons; one is an active registration in the router (AP) that keeps an old IP address, so you need to wait until it expires; other reason is you have changed the hostname when you were connected to the AP.
Can I use a manually configured IP?: Actually, you can, but we strongly discourage it. This is because you may accidentally overlap this IP address with some other device, router, or other infrastructure, blocking its operation.

Project information


This Intellectual Output was implemented under the Erasmus+ KA2.
Project IOT-OPEN.EU Reloaded – Education-based strengthening of the European universities, companies and labour force in the global IoT market.
Project number: 2022-1-PL01-KA220-HED-000085090.

Erasmus+ Disclaimer
This project has been funded with support from the European Commission.
This publication reflects the views of only the author, and the Commission cannot be held responsible for any use that may be made of the information contained therein.

Copyright Notice
This content was created by the IOT-OPEN.EU Reloaded consortium, 2022,2024.
The content is Copyrighted and distributed under CC BY-NC Creative Commons Licence, free for Non-Commercial use.

en/iot-open/practical/hardware/sut/esp32/iot_3.1713698861.txt.gz · Last modified: 2024/04/21 11:27 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0