#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <LiquidCrystal_I2C.h>
// Replace with your network credentials
const char* ssid = "Rajj";
const char* password = "rajj4321";
// Create an instance of the web server
WebServer server(80);
// Create an instance of the LCD display
LiquidCrystal_I2C lcd(0x3F,16,2);
void setup() {
Serial.begin(115200);
// Initialize the LCD display
lcd.init();
lcd.backlight();
lcd.setCursor(2, 0);
lcd.print("Hello, Rajj!");
// Connect to Wi-Fi network
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
// Print the ESP32's IP address
Serial.println(WiFi.localIP());
// Start the web server
server.on("/", handleRoot);
server.begin();
Serial.println("Web server started.");
}
void loop() {
server.handleClient();
}
void handleRoot() {
// Get the value of millis()
unsigned long millisValue = millis();
// Display the message on the LCD display
lcd.setCursor(7, 1);
lcd.print(millis() / 1000);
// Send the message to the client as an HTTP response
String message = "<h1>I just made this project RAJJ YT</h1>";
message += "<p>Millis value: ";
message += millisValue / 1000;
message += "</p>";
message += "<meta http-equiv='refresh' content='1'>";
server.send(200, "text/html", message);
}