#include <WiFi.h>
#include <PubSubClient.h>
// Replace with your network credentials
const char* ssid = "Wokwi-GUEST";
const char* password = "";
// Replace with your MQTT broker details
const char* mqttServer = "broker.emqx.io";
const int mqttPort = 1883;
// Replace with your LED pin
const int ledPin = 5;
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
// Start Serial Monitor
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
// Set up MQTT client
client.setServer(mqttServer, mqttPort);
}
void loop() {
if (!client.connected()) {
digitalWrite(ledPin, HIGH); // turn the LED on
delay(500); // wait for 500 milliseconds
digitalWrite(ledPin, LOW); // turn the LED off
delay(500);
}
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C