EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #189 background imageLoading...
Page #189 background image
SunFounder ESP32 Starter Kit
(continued from previous page)
for (int i = 0; i < length; i++) {
Serial.print((char)message[i]);
messageTemp += (char)message[i];
}
Serial.println();
// If a message is received on the topic "SF/LED", you check if the
˓message is either "on" or "off".
// Changes the output state according to the message
if (String(topic) == "SF/LED") {
Serial.print("Changing state to ");
if (messageTemp == "on") {
Serial.println("on");
digitalWrite(ledPin, HIGH);
} else if (messageTemp == "off") {
Serial.println("off");
digitalWrite(ledPin, LOW);
}
}
}
3. After selecting the correct board (ESP32 Dev Module) and port, click the Upload button.
4. Open the serial monitor and if the following information is printed, it indicates a successful connection to the
MQTT server.
WiFi connected
IP address:
192.168.18.77
Attempting MQTT connection...connected
Message Publication via HiveMQ
HiveMQ is a messaging platform that functions as an MQTT broker, facilitating fast, efficient, and reliable data transfer
to IoT devices.
Our code specifically utilizes the MQTT broker provided by HiveMQ. We have included the address of the HiveMQ
MQTT broker in the code as follows:
// Add your MQTT Broker address, example:
const char* mqtt_server = "broker.hivemq.com";
1. At present, open the in your web browser.
2. Connect the client to the default public proxy.
1.47. 8.4 IoT Communication with MQTT 183

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish