#include #include #include // Wi-Fi Ayarları const char* ssid = "WIFI"; // Wi-Fi ağ adınızı yazın const char* password = "WIFI"; // Wi-Fi şifrenizi yazın const int currentSensorPin = A0; float calibrationValue = 66.0; float offset = 0; ESP8266WebServer server(80); void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Wi-Fi'ye bağlanılıyor..."); } Serial.println("Wi-Fi bağlantısı tamamlandı."); Serial.print("IP Adresi: "); Serial.println(WiFi.localIP()); // Kalibrasyon offset = 0; for (int i = 0; i < 500; i++) { offset += analogRead(currentSensorPin); delay(10); } offset /= 500.0; server.on("/", handleRoot); server.on("/data", handleData); server.begin(); } void loop() { server.handleClient(); } void handleRoot() { String html = "\ \ \ \ Akım Sensörü Grafiği\ \ \ \

ACS712 Akım Sensörü

\ \ \ \ "; server.send(200, "text/html", html); } void handleData() { float current = readCurrent(); String json = "{\"current\":" + String(current, 2) + "}"; server.send(200, "application/json", json); } float readCurrent() { static float currentSmoothed = 0.0; int sensorValue = analogRead(currentSensorPin); float voltage = ((sensorValue - offset) / 1023.0) * 3.3; float current = voltage / (calibrationValue / 1000.0); currentSmoothed = (currentSmoothed * 0.8) + (current * 0.2); return currentSmoothed; }