#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <DS1307RTC.h>
#include <TimeLib.h>
#include <Wire.h>
#include <ESP32Servo.h> // Change to ESP32Servo
// Your WiFi Credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName"; // Fill in your WIFI SSID
char pass[] = "YourPassword"; // Fill in SSID Password
// ===================== Feeding Schedule ======================
// (Keep your existing feeding schedule code)
// Your pin configurations and other variable declarations
// (Keep your existing variable declarations)
Servo food;
// ================================ SETUP AND LOOP ================================
void setup() {
Serial.begin(115200);
Serial.print("Connecting to WiFi");
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println(" Connected!");
setupWebServer(); // Setup the web server
// Remove setupBlynk(); if not using Blynk
// Your existing setup code
}
void loop() {
// Your existing loop code
handleWebServer(); // Handle web server requests
// Remove Blynk.run(); and timer.run(); if not using Blynk
}
// ===================== Web Server Handling ============================
AsyncWebServer server(80); // Create an instance of the web server
void setupWebServer() {
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
String html = "<html><body>";
// Add your HTML code here to display data
html += "<p>Moisture Level: " + String(moistureValue) + "</p>";
html += "<p>Water Level: " + String(WaterLevel) + "</p>";
html += "<p>Ph Level: " + String(PhValue) + "</p>";
// Add more data as needed
html += "</body></html>";
request->send(200, "text/html", html);
});
// Add more routes or handlers as needed
server.begin();
}
void handleWebServer() {
server.handleClient();
}