ESP32 S3 - MQTT

The ESP32 S3 is a powerful Wi-Fi-enabled microcontroller that pairs naturally with the MQTT protocol to build lightweight, responsive IoT messaging systems. In this tutorial you will learn how to use the ESP32 S3 to connect to an MQTT broker, publish sensor data, and subscribe to incoming commands — the two core operations that underpin virtually every IoT application.

What you'll build:

  1. An ESP32 S3 that connects to an online Mosquitto MQTT broker and exchanges loopback messages over the internet.
  2. An ESP32 S3 that connects to a local Mosquitto broker installed on your PC and sends data bidirectionally.
  3. A Serial Monitor view showing timestamped publish and receive events.
  4. A working foundation you can extend to AWS IoT, multi-device communication, and cloud dashboards.
ESP32 S3 MQTT - publish and subscribe messages with an MQTT broker over WiFi

We will cover two distinct scenarios: ESP32 S3 with an online MQTT broker, and ESP32 S3 with an MQTT broker installed on your PC.

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×Alternatively, ESP32 S3 SuperMini Dev Module
1×Alternatively, ESP32 S3 Uno-form Board
1×Alternatively, ESP32 S3 Camera Board
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Recommended: Screw Terminal Expansion Board for ESP32 S3
1×Recommended: Breakout Expansion Board for ESP32 S3
1×Recommended: Power Splitter for ESP32 S3

Or you can buy the following kits:

1×DIYables ESP32 S3 Starter Kit (ESP32 S3 included)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of ESP32 S3 and MQTT

MQTT (Message Queuing Telemetry Transport) is a lightweight publish-subscribe messaging protocol designed for constrained devices and low-bandwidth, high-latency networks — making it an ideal fit for the ESP32 S3. The ESP32 S3 connects to a broker as a client and can simultaneously publish data to topics and subscribe to topics to receive commands or data from other devices or services.

Here are some ways ESP32 S3 can work with MQTT:

  • Connect ESP32 S3 to an online MQTT broker like Mosquitto or AWS IoT.
  • Connect ESP32 S3 to an MQTT broker installed on your computer, such as Mosquitto or HiveMQ.
  • Connect ESP32 S3 to an MQTT broker running on your Raspberry Pi, for example, Mosquitto.
  • Connect ESP32 S3 to a cloud-based MQTT broker, like Mosquitto or HiveMQ on AWS EC2.

Key Concepts

  • Broker: the central server that routes messages between clients.
  • Topic: a UTF-8 string used to filter and route messages (e.g. esp32-s3-001/send).
  • Publish: the act of sending a message to a topic.
  • Subscribe: registering interest in a topic so the broker forwards matching messages to you.

Once you have finished this tutorial, you can explore related topics:

Connect ESP32 S3 to an Online MQTT Broker

In this part, we will learn how to connect ESP32 S3 to test.mosquitto.org, a public online MQTT broker provided by Mosquitto. Please note that this broker is intended for testing purposes only and should not be used in production applications.

ESP32 S3 Code

The following code connects the ESP32 S3 to the online broker, subscribes to a loopback topic, and periodically publishes JSON messages to that same topic so you can observe both directions of communication in the Serial Monitor.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-mqtt */ /* * This ESP32-S3 code is created by esp32io.com * * This ESP32-S3 code is released in the public domain * * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-s3-mqtt */ #include <WiFi.h> #include <MQTTClient.h> #include <ArduinoJson.h> const char WIFI_SSID[] = "YOUR_WIFI_SSID"; // CHANGE TO YOUR WIFI SSID const char WIFI_PASSWORD[] = "YOUR_WIFI_PASSWORD"; // CHANGE TO YOUR WIFI PASSWORD const char MQTT_BROKER_ADRRESS[] = "test.mosquitto.org"; // CHANGE TO MQTT BROKER'S ADDRESS const int MQTT_PORT = 1883; const char MQTT_CLIENT_ID[] = "YOUR-NAME-esp32-s3-001"; // CHANGE IT AS YOU DESIRE const char MQTT_USERNAME[] = ""; // CHANGE IT IF REQUIRED, empty if not required const char MQTT_PASSWORD[] = ""; // CHANGE IT IF REQUIRED, empty if not required // The MQTT topics that ESP32 S3 should publish/subscribe const char PUBLISH_TOPIC[] = "YOUR-NAME-esp32-s3-001/loopback"; // CHANGE IT AS YOU DESIRE const char SUBSCRIBE_TOPIC[] = "YOUR-NAME-esp32-s3-001/loopback"; // CHANGE IT AS YOU DESIRE const int PUBLISH_INTERVAL = 5000; // 5 seconds WiFiClient network; MQTTClient mqtt = MQTTClient(256); unsigned long lastPublishTime = 0; void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.println("ESP32 S3 - Connecting to Wi-Fi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); connectToMQTT(); } void loop() { mqtt.loop(); if (millis() - lastPublishTime > PUBLISH_INTERVAL) { sendToMQTT(); lastPublishTime = millis(); } } void connectToMQTT() { // Connect to the MQTT broker mqtt.begin(MQTT_BROKER_ADRRESS, MQTT_PORT, network); // Create a handler for incoming messages mqtt.onMessage(messageHandler); Serial.print("ESP32 S3 - Connecting to MQTT broker"); while (!mqtt.connect(MQTT_CLIENT_ID, MQTT_USERNAME, MQTT_PASSWORD)) { Serial.print("."); delay(100); } Serial.println(); if (!mqtt.connected()) { Serial.println("ESP32 S3 - MQTT broker Timeout!"); return; } // Subscribe to a topic, the incoming messages are processed by messageHandler() function if (mqtt.subscribe(SUBSCRIBE_TOPIC)) Serial.print("ESP32 S3 - Subscribed to the topic: "); else Serial.print("ESP32 S3 - Failed to subscribe to the topic: "); Serial.println(SUBSCRIBE_TOPIC); Serial.println("ESP32 S3 - MQTT broker Connected!"); } void sendToMQTT() { StaticJsonDocument<200> message; message["timestamp"] = millis(); message["data"] = analogRead(1); // ESP32-S3 pin GPIO1 (ADC1_CH0). Or you can read data from other sensors char messageBuffer[512]; serializeJson(message, messageBuffer); mqtt.publish(PUBLISH_TOPIC, messageBuffer); Serial.println("ESP32 S3 - sent to MQTT:"); Serial.print("- topic: "); Serial.println(PUBLISH_TOPIC); Serial.print("- payload:"); Serial.println(messageBuffer); } void messageHandler(String &topic, String &payload) { Serial.println("ESP32 S3 - received from MQTT:"); Serial.println("- topic: " + topic); Serial.println("- payload:"); Serial.println(payload); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Connect the ESP32 S3 board to your PC via a USB cable.
  3. Open Arduino IDE on your PC.
  4. Select the right ESP32 S3 board and COM port.
  5. Open the Library Manager by clicking on the Library Manager icon on the left navigation bar of Arduino IDE.
  6. Type MQTT in the search box, then look for the MQTT library by Joel Gaehwiler.
  7. Click Install to install the MQTT library.
  • Search for MQTT created by Joel Gaehwiler and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Library Manager
Type:
All
Topic:
All
MQTT by Joel Gaehwiler
This library bundles the lwmqtt client and adds a thin wrapper to get an Arduino like API. More info
2.5.2
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Type ArduinoJson in the search box, then look for the ArduinoJson library by Benoit Blanchon.
  2. Click Install to install the ArduinoJson library.
  • Search for ArduinoJson created by Benoit Blanchon and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Library Manager
Type:
All
Topic:
All
ArduinoJson by Benoit Blanchon
⭐ 6953 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented. More info
7.4.2
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Copy the above code and open it with Arduino IDE.
  2. Replace the Wi-Fi information (SSID and password) in the code with your own.
  3. In the code, you will see the word YOUR-NAME three times. Replace this with your name or random alphabet characters (no spaces). This is necessary to avoid conflicts when multiple users run the code simultaneously — the MQTT client IDs and topics must be unique.
  4. Click Upload on Arduino IDE to upload code to ESP32 S3.
  5. Open the Serial Monitor and observe the output.
  6. Pro Tip: If the ESP32 S3 fails to connect to the broker, check that your Wi-Fi credentials are correct and that your network allows outbound connections on port 1883.

Serial Monitor Output

The Serial Monitor will display timestamped publish and receive events similar to the following:

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
ESP32 S3 - Connecting to MQTT broker ESP32 S3 - Subscribed to the topic: YOUR-NAME-esp32-s3-001/loopback ESP32 S3 - MQTT broker Connected! ESP32 S3 - sent to MQTT: - topic: YOUR-NAME-esp32-s3-001/loopback - payload:{"timestamp":1750000000,"data":255} ESP32 S3 - received from MQTT: - topic: YOUR-NAME-esp32-s3-001/loopback - payload: {"timestamp":1750000000,"data":255} ESP32 S3 - sent to MQTT: - topic: YOUR-NAME-esp32-s3-001/loopback - payload:{"timestamp":1750005120,"data":259} ESP32 S3 - received from MQTT: - topic: YOUR-NAME-esp32-s3-001/loopback - payload: {"timestamp":1750005120,"data":259}
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

As you can observe, the ESP32 S3 publishes messages to the MQTT broker and then receives the same message back. This occurs because the code subscribes to the same topic it publishes to. If you prefer the ESP32 S3 not to receive its own messages, simply subscribe to a different topic from the one you publish to.

Connect ESP32 S3 to the MQTT Broker Installed on Your PC

Installing Mosquitto MQTT Broker

  • Download the Mosquitto MQTT Broker.
  • Install it on the D: drive instead of the C: drive. Avoiding the C: drive prevents potential permission issues.

Run Mosquitto MQTT Broker

Now, let's verify that the MQTT broker is functioning properly by following these steps:

  • Navigate to the directory where Mosquitto was installed. For example: D:\Draft\mosquitto>
  • Create a new file named test.conf, copy the content below, and save it in that directory:
listener 1883 allow_anonymous true
  • Run a Command Prompt as Administrator on your PC. Let's call it Broker Window. Do not close it until the end of the tutorial.
Windows command prompt administrator
  • Run the below commands one by one:
cd /d D:\Draft\mosquitto mosquitto -v -c test.conf
  • You will see:
Command Prompt
Microsoft Windows [Version 10.0.19045.3930] (c) Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>cd /d D:\Draft\mosquitto D:\Draft\mosquitto>mosquitto -v -c test.conf 1710918939: mosquitto version 2.0.18 starting 1710918939: Config loaded from test.conf. 1710918939: Opening ipv6 listen socket on port 1883. 1710918939: Opening ipv4 listen socket on port 1883. 1710918939: mosquitto version 2.0.18 running
  • Open another Command Prompt as Administrator on your PC.
  • Find the IP address of your PC by running the below command:
ipconfig
Command Prompt
C:\WINDOWS\system32>ipconfig Windows IP Configuration Ethernet adapter: Subnet Mask . . . . . . . . . . . : 255.0.0.0 IPv4 Address. . . . . . . . . . . : 192.168.0.26 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :
  • Write down the IP address for later use. In the above example: 192.168.0.26

Test if the Mosquitto Broker Works

  • Open another Command Prompt as Administrator on your PC. Let's call it Subscriber Window.
  • Subscribe to a topic by running the below commands one by one (replace with your IP address):
cd /d D:\Draft\mosquitto mosquitto_sub -h 192.168.0.26 -p 1883 -t esp32-s3-001/send
  • Open another Command Prompt as Administrator on your PC. Let's call it Publisher Window.
  • Publish a message to the same topic by running the below commands one by one (replace with your IP address):
cd /d D:\Draft\mosquitto mosquitto_pub -h 192.168.0.26 -p 1883 -t esp32-s3-001/send -m "Hello, MQTT!"
  • You will see:
Command Prompt
Microsoft Windows [Version 10.0.19045.3930] (c) Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>cd /d D:\Draft\mosquitto D:\Draft\mosquitto>mosquitto_pub -h 192.168.0.26 -p 1883 -t esp32-s3-001/send -m "Hello, MQTT!" D:\Draft\mosquitto>

You will see that the message is forwarded to the Subscriber Window as follows:

Command Prompt
Microsoft Windows [Version 10.0.19045.3930] (c) Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>cd /d D:\Draft\mosquitto D:\Draft\mosquitto>mosquitto_sub -h 192.168.0.26 -p 1883 -t esp32-s3-001/send Hello, MQTT!

Now, you have successfully installed the Mosquitto MQTT broker on your PC. Please do NOT close three windows: Broker Window, Subscriber Window, and Publisher Window. We will use them in the next steps.

ESP32 S3 Code

The following code connects the ESP32 S3 to your local broker, subscribes to a receive topic, and periodically publishes JSON messages to a separate send topic — demonstrating true bidirectional communication between the board and the PC.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-mqtt */ /* * This ESP32-S3 code is created by esp32io.com * * This ESP32-S3 code is released in the public domain * * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-s3-mqtt */ #include <WiFi.h> #include <MQTTClient.h> #include <ArduinoJson.h> #define CLIENT_ID "ESP32-S3-001" // CHANGE IT AS YOU DESIRE const char WIFI_SSID[] = "YOUR_WIFI_SSID"; // CHANGE TO YOUR WIFI SSID const char WIFI_PASSWORD[] = "YOUR_WIFI_PASSWORD"; // CHANGE TO YOUR WIFI PASSWORD const char MQTT_BROKER_ADRRESS[] = "192.168.0.26"; // CHANGE TO MQTT BROKER'S IP ADDRESS const int MQTT_PORT = 1883; const char MQTT_USERNAME[] = ""; // CHANGE IT IF REQUIRED const char MQTT_PASSWORD[] = ""; // CHANGE IT IF REQUIRED // The MQTT topics that this device should publish/subscribe #define PUBLISH_TOPIC "esp32-s3-001/send" #define SUBSCRIBE_TOPIC "esp32-s3-001/receive" #define PUBLISH_INTERVAL 5000 // 4 seconds WiFiClient network; MQTTClient mqtt = MQTTClient(256); unsigned long lastPublishTime = 0; void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.println("ESP32 S3 - Connecting to Wi-Fi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); connectToMQTT(); } void loop() { mqtt.loop(); if (millis() - lastPublishTime > PUBLISH_INTERVAL) { sendToMQTT(); lastPublishTime = millis(); } } void connectToMQTT() { // Connect to the MQTT broker mqtt.begin(MQTT_BROKER_ADRRESS, MQTT_PORT, network); // Create a handler for incoming messages mqtt.onMessage(messageHandler); Serial.print("ESP32 S3 - Connecting to MQTT broker"); while (!mqtt.connect(CLIENT_ID, MQTT_USERNAME, MQTT_PASSWORD)) { Serial.print("."); delay(100); } Serial.println(); if (!mqtt.connected()) { Serial.println("ESP32 S3 - MQTT broker Timeout!"); return; } // Subscribe to a topic, the incoming messages are processed by messageHandler() function if (mqtt.subscribe(SUBSCRIBE_TOPIC)) Serial.print("ESP32 S3 - Subscribed to the topic: "); else Serial.print("ESP32 S3 - Failed to subscribe to the topic: "); Serial.println(SUBSCRIBE_TOPIC); Serial.println("ESP32 S3 - MQTT broker Connected!"); } void sendToMQTT() { StaticJsonDocument<200> message; message["timestamp"] = millis(); message["data"] = analogRead(1); // ESP32-S3 pin GPIO1 (ADC1_CH0). Or you can read data from other sensors char messageBuffer[512]; serializeJson(message, messageBuffer); mqtt.publish(PUBLISH_TOPIC, messageBuffer); Serial.println("ESP32 S3 - sent to MQTT:"); Serial.print("- topic: "); Serial.println(PUBLISH_TOPIC); Serial.print("- payload:"); Serial.println(messageBuffer); } void messageHandler(String &topic, String &payload) { Serial.println("ESP32 S3 - received from MQTT:"); Serial.println("- topic: " + topic); Serial.println("- payload:"); Serial.println(payload); // You can process the incoming data as json object, then control something /* StaticJsonDocument<200> doc; deserializeJson(doc, payload); const char* message = doc["message"]; */ }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Copy the above code and open it with Arduino IDE.
  3. Replace the Wi-Fi information (SSID and password) in the code with your own.
  4. Replace the MQTT broker address in the code with your PC's IP address (domain name or IP address).
  5. Click Upload on Arduino IDE to upload code to ESP32 S3.
  6. Pro Tip: Ensure your PC firewall allows inbound connections on port 1883 so the ESP32 S3 can reach the local broker without being blocked.

Send Message from ESP32 S3 to PC via MQTT

The ESP32 S3 code publishes data to the MQTT topic esp32-s3-001/send, and the Subscriber Window on the PC subscribes to that topic to receive the data. Open the Serial Monitor and you will see the ESP32 S3 periodically publish a message to the topic.

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
ESP32 S3 - Connecting to MQTT broker ESP32 S3 - Subscribed to the topic: esp32-s3-001/receive ESP32 S3 - MQTT broker Connected! ESP32 S3 - sent to MQTT: - topic: esp32-s3-001/send - payload:{"timestamp":1750000000,"data":311} ESP32 S3 - sent to MQTT: - topic: esp32-s3-001/send - payload:{"timestamp":1750005120,"data":298} ESP32 S3 - sent to MQTT: - topic: esp32-s3-001/send - payload:{"timestamp":1750010240,"data":291} ESP32 S3 - sent to MQTT: - topic: esp32-s3-001/send - payload:{"timestamp":1750015360,"data":286}
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2
  • Check the Subscriber Window, you will see that it receives the messages published by ESP32 S3 as below:
Command Prompt
Microsoft Windows [Version 10.0.19045.3930] (c) Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>cd /d D:\Draft\mosquitto D:\Draft\mosquitto>mosquitto_sub -h 192.168.0.26 -p 1883 -t esp32-s3-001/send Hello, MQTT! {"timestamp":1750000000,"data":311} {"timestamp":1750005120,"data":298} {"timestamp":1750010240,"data":291} {"timestamp":1750015360,"data":286}

Send Message from PC to ESP32 S3 via MQTT

The ESP32 S3 subscribes to the topic esp32-s3-001/receive, and the Publisher Window on the PC publishes a message to that topic to send it to the ESP32 S3.

  • Publish a message to the topic that ESP32 S3 subscribed to by running the following command on the Publisher Window:
mosquitto_pub -h 192.168.0.26 -p 1883 -t esp32-s3-001/receive -m "Hello, ESP32 S3!"
  • You will see this message is received by ESP32 S3 on the Serial Monitor as below:
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
ESP32 S3 - received from MQTT: - topic: esp32-s3-001/receive - payload: Hello, ESP32 S3!
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications

The ESP32 S3 and MQTT combination is a cornerstone of modern IoT systems, enabling everything from simple sensor dashboards to complex multi-device automation. Here are some practical applications you can build on top of what you have learned:

  1. Remote Sensor Monitoring: Publish temperature, humidity, or air-quality readings from ESP32 S3 to a dashboard like Node-RED or Grafana via MQTT.
  2. Remote Device Control: Send commands from a smartphone app to an ESP32 S3 over MQTT to toggle relays, adjust servo positions, or change LED colors.
  3. Multi-Device Coordination: Use a shared MQTT broker to let multiple ESP32 S3 boards coordinate with each other — for example, synchronizing lights across rooms.
  4. Home Automation Hub Integration: Connect ESP32 S3 to Home Assistant or openHAB via MQTT to control smart home devices with custom firmware.
  5. Cloud IoT Pipelines: Forward MQTT messages from a local broker to AWS IoT Core or Azure IoT Hub for cloud-side analytics, alerting, and storage.
  6. Alert and Notification Systems: Subscribe an ESP32 S3 to a motion or leak sensor topic and trigger a relay or buzzer whenever an alert message arrives.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenges

Now that your ESP32 S3 is exchanging MQTT messages, try extending the project with these hands-on challenges. Each one builds on the skills you have just practiced and pushes you toward real-world IoT applications.

  1. Beginner — Change the publish interval: Modify the code to publish a new message every 2 seconds instead of the default interval. Observe the increased message rate in the Serial Monitor and the Subscriber Window.
  2. Beginner — Add a second topic: Subscribe the ESP32 S3 to a second topic (e.g. esp32-s3-001/config) and publish a configuration value from the PC to it. Print the received value to the Serial Monitor.
  3. Intermediate — Publish real sensor data: Wire up a DHT22 temperature and humidity sensor to the ESP32 S3 and publish its readings as a JSON payload to the MQTT broker every 5 seconds.
  4. Intermediate — Control an LED via MQTT: Subscribe the ESP32 S3 to a topic like esp32-s3-001/led. When the payload is "ON" turn the built-in LED on; when it is "OFF" turn it off. Test by publishing from the Publisher Window.
  5. Advanced — Retain messages: Modify the publish call to set the retain flag to true. Restart the ESP32 S3 and observe that it immediately receives the last retained message upon reconnecting, without waiting for a new publish cycle.
  6. Advanced — TLS encryption: Set up the local Mosquitto broker with a self-signed TLS certificate and update the ESP32 S3 code to connect on port 8883 with SSL. Verify that plaintext connections are rejected.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!