Hi all,
I’ve been reading a lot from this forum and trying to build a Energy monitoring system for my home. I am using a ESP32 connected with SCT-13-030 using the wiring diagram shown on this website. Sketch file code am using is copied below.
#include <WiFi.h>
#include <WebServer.h>
#include "EmonLib.h"
#define ADC_INPUT 34
#define INDICATE_PIN 2
const char* ssid = "wifissid";
const char* password = "password";
EnergyMonitor emon1;
WebServer httpServer(80);
void handle_request() {
double amps = emon1.calcIrms(1480);
Serial.println(amps);
String HTMLData = "current{label=\"phase1\"} " + String(amps);
httpServer.send(200, "text/html", HTMLData);
digitalWrite(INDICATE_PIN, HIGH);
delay(10);
digitalWrite(INDICATE_PIN, LOW);
}
void setup() {
analogReadResolution(ADC_BITS);
pinMode(ADC_INPUT, INPUT);
pinMode(INDICATE_PIN, OUTPUT);
Serial.begin(115200);
Serial.println("Tring to connect to Wifi SSID: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected successfully");
Serial.print("Assigned IP: ");
Serial.println(WiFi.localIP());
httpServer.on("/", handle_request);
httpServer.begin();
Serial.println("HTTP server started");
delay(100);
emon1.current(ADC_INPUT, 30);
}
void loop() {
httpServer.handleClient();
}
My graph looks reverse. When I switch ON my TV the graph goes close to zero and when I don’t have any load it looks 12amps.
Am I doing anything wrong here.