#include #include #include #include const char *ssid = "FunESP32"; const char *password = ""; const int ledPin = 2; const int servoPin = 15; WebServer server(80); DNSServer dnsServer; bool ledState = false; int currentFrequency = 1000; Servo myServo; 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()); myServo.attach(servoPin); server.on("/", handleRoot); server.on("/setLed", handleSetLed); server.on("/setFrequency", handleSetFrequency); server.on("/setServoSpeed", handleSetServoSpeed); 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 Control

"; html += "

LED Control

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

Flash Frequency (ms)

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

Servo Speed Control

"; html += "
"; html += "50%
"; 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"); } void handleSetServoSpeed() { if (server.hasArg("speed")) { int speedValue = server.arg("speed").toInt(); int servoPosition; if (speedValue <= 50) { servoPosition = map(speedValue, 0, 50, 180, 90); } else { servoPosition = map(speedValue, 51, 100, 90, 0); } myServo.write(servoPosition); Serial.print("Servo Speed set to: "); Serial.println(servoPosition); } server.send(200, "text/plain", "Servo speed updated"); }