#include #include const char *ssid = "Solace"; const char *password = "damnbro"; WebServer server(80); const char welcomePage[] PROGMEM = R"rawliteral( Welcome to ESP32

Welcome to your ESP32 Server

You are successfully connected to the ESP32's Wi-Fi network!

Device IP Address: %IP%

Supply Voltage: %VOLTAGE% V

Free Heap: %HEAP% bytes

CPU Frequency: %FREQ% MHz

Chip Temperature: %TEMP% °C

)rawliteral"; void setup() { Serial.begin(115200); delay(10); WiFi.mode(WIFI_STA); Serial.print("Connecting to Wi-Fi: "); Serial.println(ssid); WiFi.begin(ssid, password); waitForConnection(); } void waitForConnection() { Serial.println("Attempting to connect..."); int attempts = 0; while (WiFi.status() != WL_CONNECTED && attempts < 30) { delay(1000); Serial.print("Attempt "); Serial.print(attempts + 1); Serial.println("..."); attempts++; } if (WiFi.status() == WL_CONNECTED) { Serial.println("\nConnected to Wi-Fi!"); Serial.print("IP Address: "); Serial.println(WiFi.localIP()); server.on("/", handleRoot); server.begin(); Serial.println("Web server started. Open http:/// in your browser."); } else { Serial.println("\nFailed to connect to Wi-Fi. Please check your credentials."); } } void handleRoot() { if (WiFi.status() == WL_CONNECTED) { float voltage = getSupplyVoltage(); String html = welcomePage; html.replace("%IP%", WiFi.localIP().toString()); html.replace("%VOLTAGE%", String(voltage, 2)); html.replace("%HEAP%", String(ESP.getFreeHeap())); html.replace("%FREQ%", String(ESP.getCpuFreqMHz())); html.replace("%TEMP%", String(temperatureRead())); server.send(200, "text/html", html); Serial.println("Served the welcome page."); } else { server.send(500, "text/plain", "WiFi not connected"); } } float getSupplyVoltage() { int adcValue = analogRead(35); float voltage = (adcValue / 4095.0) * 3.3; return voltage; } void loop() { server.handleClient(); }