ESP32 + SCT-13-030 giving graph reversed

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.

Some updates. I tested my soldering and wiring many times and does not seem to have a problem. I’ve a few doubts.

  1. Does the CT sensor SCT-13-030 have polarity? I assume “No” as my understanding is, it has a transformer and burden resistors built in.
  2. I did calibrate ADC in my ESP32 and it seems to work fine with a lookup table. So it is the wiring which should have issues.

My wiring is done based on this article: DIY Home Energy Monitor: ESP32 + CT Sensors + Emonlib | Savjee.be

I fixed the issue. The issue was actually a soldering connection failure which led to disconnect in the circuit. The ground was not correctly linked to ESP32 ground pin. Sorry for bothering. Meanwhile, I’ve also improved the accuracy by using Lookup table which I calibrated for my ESP32.

Code can be found here: GitHub - codetiger/PowerConsumptionMonitor-ESP32: Power consumption monitor using ESP32 and SCT-013

1 Like