#include #include #include const char *ssid = "FunESP32"; const char *password = ""; const int ledPin = 2; WebServer server(80); DNSServer dnsServer; bool ledState = false; int currentFrequency = 1000; void setup() { Serial.begin(115200); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); WiFi.softAP(ssid, password); Serial.print("AP IP Address: "); Serial.println(WiFi.softAPIP()); dnsServer.start(53, "*", WiFi.softAPIP()); server.on("/", handleRoot); server.on("/setLed", handleSetLed); server.on("/setFrequency", handleSetFrequency); server.onNotFound(handleNotFound); server.begin(); Serial.println("Web server started"); } void loop() { dnsServer.processNextRequest(); server.handleClient(); if (ledState) { digitalWrite(ledPin, HIGH); delay(currentFrequency / 2); digitalWrite(ledPin, LOW); delay(currentFrequency / 2); } else { digitalWrite(ledPin, LOW); } } void handleRoot() { String html = ""; html += ""; html += ""; html += "
"; html += "

ESP32 LED Control

"; html += "

LED Control

"; html += ""; html += "

Flash Frequency (ms)

"; html += "
"; html += "" + String(currentFrequency) + " ms
"; html += "

Chip Details

"; html += "

Chip Model: " + String(ESP.getChipModel()) + "

"; html += "

Chip Revision: " + String(ESP.getChipRevision()) + "

"; html += "

Free Heap Size: " + String(ESP.getFreeHeap()) + " bytes

"; html += "

CPU Frequency: " + String(ESP.getCpuFreqMHz()) + " MHz

"; html += "

Flash Chip Size: " + String(ESP.getFlashChipSize()) + " bytes

"; html += "

Flash Chip Speed: " + String(ESP.getFlashChipSpeed()) + " Hz

"; float temperature = getTemperature(); html += "

Temperature

"; html += "

Temperature: " + String(temperature) + " °C

"; float voltage = getVoltage(); html += "

Supply Voltage

"; html += "

Voltage: " + String(voltage) + " V

"; int32_t rssi = WiFi.RSSI(); html += "

Wi-Fi Signal Strength

"; html += "

Signal Strength (RSSI): " + String(rssi) + " dBm

"; html += ""; html += "
"; server.send(200, "text/html", html); } float getTemperature() { return temperatureRead(); } float getVoltage() { int adcValue = analogRead(34); return (1.1 * 4096) / adcValue; } void handleNotFound() { server.sendHeader("Location", "/"); server.send(302, "text/plain", "Redirecting..."); } void handleSetLed() { if (server.hasArg("state")) { ledState = server.arg("state") == "1"; if (ledState) { Serial.println("LED ON"); } else { Serial.println("LED OFF"); } } server.send(200, "text/plain", "LED state updated"); } void handleSetFrequency() { if (server.hasArg("freq")) { currentFrequency = server.arg("freq").toInt(); Serial.print("Flash Frequency set to: "); Serial.println(currentFrequency); } server.send(200, "text/plain", "Frequency updated"); }