#include <WiFi.h>
#include <PubSubClient.h>
WiFiClient espClient;
PubSubClient client(espClient);
void setup()
{
WiFi.mode(WIFI_STA);
WiFi.begin("Wokwi-GUEST", "");
client.setServer("broker.emqx.io", 1883);
Serial.begin(9600);
}
void loop()
{
client.connect("clientId-123");
Serial.println("ESP32 is Connected with MQTT!");
client.publish("testtopic/iot","I'm coder");
}