This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:iot-open:practical:hardware:sut:esp32:iot_3 [2024/04/21 15:00] – [Steps] pczekalski | en:iot-open:practical:hardware:sut:esp32:iot_3 [2024/04/28 16:45] (current) – [Suggested Readings and Knowledge Resources] pczekalski | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <todo @pczekalski> | ||
====== IOT3: Connecting to the MQTT and publishing data ====== | ====== 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. | In the following scenario, you will learn how to connect to the MQTT broker and publish a message. | ||
Line 21: | Line 20: | ||
* [[en: | * [[en: | ||
* [[en: | * [[en: | ||
- | * [[en: | + | * [[en: |
+ | * [[en: | ||
===== Hands-on Lab Scenario ===== | ===== Hands-on Lab Scenario ===== | ||
+ | Note - this scenario can be used in pair with [[[en: | ||
==== Task to be implemented ==== | ==== Task to be implemented ==== | ||
Line 90: | Line 91: | ||
int status = client.state(); | int status = client.state(); | ||
//present it on the display to trace/ | //present it on the display to trace/ | ||
- | | + | |
} | } | ||
</ | </ | ||
Line 109: | Line 110: | ||
#define MQTT_CONNECT_UNAUTHORIZED | #define MQTT_CONNECT_UNAUTHORIZED | ||
</ | </ | ||
+ | |||
+ | <note tip>In many code samples, including those provided along with this MQTT client library, there is a '' | ||
==== Result validation ==== | ==== Result validation ==== | ||
You should be able to connect to the WiFi and MQTT broker (verified by the status present on the selected display) and then publish a message (once or periodically). Depending on whether you're fully remote or able to access our networks with an additional device, you need to implement a subscriber (as present in the scenario [[[en: | You should be able to connect to the WiFi and MQTT broker (verified by the status present on the selected display) and then publish a message (once or periodically). Depending on whether you're fully remote or able to access our networks with an additional device, you need to implement a subscriber (as present in the scenario [[[en: | ||
===== FAQ ===== | ===== FAQ ===== | ||
**My MQTT client disconnects randomly**: The most common reason is you're using a non-unique MQTT client name. Please change it to some other (even random generated) and give it another try.\\ | **My MQTT client disconnects randomly**: The most common reason is you're using a non-unique MQTT client name. Please change it to some other (even random generated) and give it another try.\\ | ||
- | **How do I observe messages that I send?**: Use a software client, such as [[http:// | + | **How do I observe messages that I send?**: Use a software client, such as [[http:// |
**Do I need to authorise to publish and subscribe? | **Do I need to authorise to publish and subscribe? | ||