

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rdf:RDF[
	<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
	<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
	<!ENTITY owl 'http://www.w3.org/2002/07/owl#'>
	<!ENTITY swivt 'http://semantic-mediawiki.org/swivt/1.0#'>
	<!ENTITY wiki 'http://https://wikifab.org/wiki/Special:URIResolver/'>
	<!ENTITY category 'http://https://wikifab.org/wiki/Special:URIResolver/Category-3A'>
	<!ENTITY property 'http://https://wikifab.org/wiki/Special:URIResolver/Property-3A'>
	<!ENTITY wikiurl 'https://wikifab.org/wiki/'>
]>

<rdf:RDF
	xmlns:rdf="&rdf;"
	xmlns:rdfs="&rdfs;"
	xmlns:owl ="&owl;"
	xmlns:swivt="&swivt;"
	xmlns:wiki="&wiki;"
	xmlns:category="&category;"
	xmlns:property="&property;">

	<owl:Ontology rdf:about="https://wikifab.org/wiki/Special:ExportRDF/ESP32_MQTT">
		<swivt:creationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2026-04-04T06:05:42+02:00</swivt:creationDate>
		<owl:imports rdf:resource="http://semantic-mediawiki.org/swivt/1.0"/>
	</owl:Ontology>
	<swivt:Subject rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/ESP32_MQTT">
		<rdf:type rdf:resource="http://https://wikifab.org/wiki/Special:URIResolver/Category-3ATutorials"/>
		<rdfs:label>ESP32 MQTT</rdfs:label>
		<rdfs:isDefinedBy rdf:resource="https://wikifab.org/wiki/Special:ExportRDF/ESP32_MQTT"/>
		<swivt:page rdf:resource="https://wikifab.org/wiki/ESP32_MQTT"/>
		<swivt:wikiNamespace rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</swivt:wikiNamespace>
		<swivt:wikiPageContentLanguage rdf:datatype="http://www.w3.org/2001/XMLSchema#string">en</swivt:wikiPageContentLanguage>
		<property:Area rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Electronics</property:Area>
		<property:Area rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Robotics</property:Area>
		<property:Complete rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Draft</property:Complete>
		<property:Cost rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0</property:Cost>
		<property:Currency rdf:datatype="http://www.w3.org/2001/XMLSchema#string">USD ($)</property:Currency>
		<property:Description rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Use the ESP32's wifi module to communicate with a computer</property:Description>
		<property:Difficulty rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Easy</property:Difficulty>
		<property:Duration rdf:datatype="http://www.w3.org/2001/XMLSchema#double">15</property:Duration>
		<property:Duration-2Dtype rdf:datatype="http://www.w3.org/2001/XMLSchema#string">minute(s)</property:Duration-2Dtype>
		<property:Introduction rdf:datatype="http://www.w3.org/2001/XMLSchema#string">'''Introduction &amp; Goals:'''


This project utilizes the Wifi module on an ESP32 along with the Publish/Subscribe (PubSub) library on the Arduino IDE to communicate with other Internet of Things (IoT) devices. In this specific tutorial, we learn how to use the ESP32 to  communicate with your personal device in a bidirectional way.


GOALS:

#Learn what Message Queuing Telemetry Transport (MQTT) is
#Set up esp32 dev library and pubSub along with MQTT to exchange messages</property:Introduction>
		<property:IsTranslation rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</property:IsTranslation>
		<property:Language rdf:datatype="http://www.w3.org/2001/XMLSchema#string">en</property:Language>
		<property:Licences rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Attribution (CC BY)</property:Licences>
		<property:Main_Picture rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ESP32_DHT22_IFTTT_306268167_427924746149632_7414040424516888266_n.jpg</property:Main_Picture>
		<property:Notes rdf:datatype="http://www.w3.org/2001/XMLSchema#string">'''Real World Use Cases:'''

# https://www.pubnub.com/blog/what-is-mqtt-use-cases/
# https://www.influxdata.com/blog/mqtt-use-cases/</property:Notes>
		<property:SourceLanguage rdf:datatype="http://www.w3.org/2001/XMLSchema#string">none</property:SourceLanguage>
		<property:Step_Content rdf:datatype="http://www.w3.org/2001/XMLSchema#string">&lt;nowiki&gt;Copy the full code into your IDE. Feel free to change things like the text it prints, etc&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mw-highlight mw-content-ltr" dir="ltr"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt; 1 &lt;/span&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&lt;WiFi.h&gt;&lt;/span&gt;&lt;span class="cp"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 2 &lt;/span&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&lt;PubSubClient.h&gt;&lt;/span&gt;&lt;span class="cp"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 3 &lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 4 &lt;/span&gt;&lt;span class="c1"&gt;// WiFi&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 5 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ssid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"xxxxx"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Enter your Wi-Fi name&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 6 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"xxxxx"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Enter Wi-Fi password&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 7 &lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 8 &lt;/span&gt;&lt;span class="c1"&gt;// MQTT Broker&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt; 9 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mqtt_broker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"broker.emqx.io"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;10 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;topic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"emqx/esp32"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;11 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mqtt_username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"emqx"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;12 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;mqtt_password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"public"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;13 &lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;mqtt_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1883&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;14 &lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;15 &lt;/span&gt;&lt;span class="n"&gt;WiFiClient&lt;/span&gt; &lt;span class="n"&gt;espClient&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;16 &lt;/span&gt;&lt;span class="n"&gt;PubSubClient&lt;/span&gt; &lt;span class="nf"&gt;client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;espClient&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;17 &lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;18 &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;19 &lt;/span&gt;    &lt;span class="c1"&gt;// Set software serial baud to 115200;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;20 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;115200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;21 &lt;/span&gt;    &lt;span class="c1"&gt;// Connecting to a WiFi network&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;22 &lt;/span&gt;    &lt;span class="n"&gt;WiFi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;23 &lt;/span&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;WiFi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;WL_CONNECTED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;24 &lt;/span&gt;        &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;25 &lt;/span&gt;        &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Connecting to WiFi.."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;26 &lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;27 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Connected to the Wi-Fi network"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;28 &lt;/span&gt;    &lt;span class="c1"&gt;//connecting to a mqtt broker&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;29 &lt;/span&gt;    &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mqtt_broker&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mqtt_port&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;30 &lt;/span&gt;    &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;31 &lt;/span&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;connected&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;32 &lt;/span&gt;        &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;client_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"esp32-client-"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;33 &lt;/span&gt;        &lt;span class="n"&gt;client_id&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;WiFi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;macAddress&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;34 &lt;/span&gt;        &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"The client %s connects to the public MQTT broker&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_str&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;35 &lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_str&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;mqtt_username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mqtt_password&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;36 &lt;/span&gt;            &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Public EMQX MQTT broker connected"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;37 &lt;/span&gt;        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;38 &lt;/span&gt;            &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"failed with state "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;39 &lt;/span&gt;            &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;40 &lt;/span&gt;            &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;41 &lt;/span&gt;        &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;42 &lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;43 &lt;/span&gt;    &lt;span class="c1"&gt;// Publish and subscribe&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;44 &lt;/span&gt;    &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;publish&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hi, I'm ESP32 ^^"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;45 &lt;/span&gt;    &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;46 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;47 &lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;48 &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;byte&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;49 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Message arrived in topic: "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;50 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;51 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Message:"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;52 &lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&lt;&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;53 &lt;/span&gt;        &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;54 &lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;55 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;56 &lt;/span&gt;    &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"-----------------------"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;57 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;58 &lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;59 &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;60 &lt;/span&gt;    &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span class="lineno"&gt;61 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/nowiki&gt;</property:Step_Content>
		<property:Step_Content rdf:datatype="http://www.w3.org/2001/XMLSchema#string"># Please follow these steps to upload the complete code using Arduino and power on the ESP32:
## Connect the ESP32 to your computer using a USB cable.
## Open the Arduino IDE and select the appropriate board and port from the "Tools" menu.
## Copy and paste the complete code into the Arduino IDE.
## Click the "Upload" button (or use the shortcut Ctrl+U) to compile and upload the code to the ESP32.
## Wait for the upload process to finish, ensuring there are no errors.
## Once the code is uploaded, disconnect the ESP32 from the computer.
## Power on the ESP32 by connecting it to a suitable power source.
# Open the serial monitor and set the baud rate to 115200. Then, check the connection status of the ESP32 by monitoring the output in the serial monitor.
# Use the MQTTX client to establish a connection with the MQTT broker and publish messages such as &lt;code&gt;Hi, I'm MQTTX&lt;/code&gt; to the ESP32.</property:Step_Content>
		<property:Step_Content rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Ensure that the ESP32 dev library is installed, then go to libraries in the Arduino IDE and download PubSubClient. PubSub, short for Publish/Subscribe, is a messaging pattern where senders (publishers) distribute messages to receivers (subscribers) without directly communicating with them. Publishers send messages to a central hub (broker), which then distributes them to all interested subscribers based on their topic subscriptions. This is useful to conserve data when trying to share information, because rather than multiple different connections between the publisher and each subscriber, the publisher only needs to send the information once.</property:Step_Content>
		<property:Step_Content rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Before we begin, we need to ensure you have an MQTT broker to communicate and test with. We can download  [https://mqttx.app/ MQTTX] (the front-end broker) to ensure communication. MQTT  is a lightweight messaging protocol designed for efficient communication between devices in low-bandwidth, high-latency networks. It uses a publish-subscribe model, which we will go over later.

&lt;br/&gt;</property:Step_Content>
		<property:Step_Title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Prepare an MQTT Broker</property:Step_Title>
		<property:Step_Title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Install ESP32 Development Board &amp; other dependancies</property:Step_Title>
		<property:Step_Title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Full Code</property:Step_Title>
		<property:Step_Title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Running and Testing</property:Step_Title>
		<property:Type rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Creation</property:Type>
		<swivt:wikiPageModificationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-02-10T21:00:21Z</swivt:wikiPageModificationDate>
		<property:Modification_date-23aux rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2460351.3752431</property:Modification_date-23aux>
		<swivt:wikiPageSortKey rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ESP32 MQTT</swivt:wikiPageSortKey>
		<property:Comments rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0</property:Comments>
		<property:Page_creator rdf:resource="&wiki;Utilisateur-3ADisisid"/>
		<property:I_did_it rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0</property:I_did_it>
		<property:Favorites rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0</property:Favorites>
	</swivt:Subject>
	<owl:DatatypeProperty rdf:about="http://semantic-mediawiki.org/swivt/1.0#creationDate" />
	<owl:Class rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Category-3ATutorials" />
	<owl:ObjectProperty rdf:about="http://semantic-mediawiki.org/swivt/1.0#page" />
	<owl:DatatypeProperty rdf:about="http://semantic-mediawiki.org/swivt/1.0#wikiNamespace" />
	<owl:DatatypeProperty rdf:about="http://semantic-mediawiki.org/swivt/1.0#wikiPageContentLanguage" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AArea" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AComplete" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ACost" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ACurrency" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ADescription" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ADifficulty" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ADuration" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ADuration-2Dtype" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AIntroduction" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AIsTranslation" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ALanguage" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ALicences" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AMain_Picture" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ANotes" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3ASourceLanguage" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AStep_Content" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AStep_Title" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AType" />
	<owl:DatatypeProperty rdf:about="http://semantic-mediawiki.org/swivt/1.0#wikiPageModificationDate" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AModification_date-23aux" />
	<owl:DatatypeProperty rdf:about="http://semantic-mediawiki.org/swivt/1.0#wikiPageSortKey" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AComments" />
	<owl:ObjectProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3APage_creator" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AI_did_it" />
	<owl:DatatypeProperty rdf:about="http://https://wikifab.org/wiki/Special:URIResolver/Property-3AFavorites" />
	<!-- Created by Semantic MediaWiki, https://www.semantic-mediawiki.org/ -->
</rdf:RDF>