# ESP32 + SCT-13-030 giving graph reversed

**URL:** <https://community.openenergymonitor.org/t/esp32-sct-13-030-giving-graph-reversed/19328>\
**Category:** emonTx\
**Tags:** esp32\
**Created:** [24 December 2021 07:38 UTC](https://community.openenergymonitor.org/t/esp32-sct-13-030-giving-graph-reversed/19328 "2021-12-24T07:38:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![codetiger](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/codetiger/32/19958_2.png) [@codetiger](https://community.openenergymonitor.org/u/codetiger)\
**Post date:** [24 December 2021 07:38 UTC](https://community.openenergymonitor.org/t/esp32-sct-13-030-giving-graph-reversed/19328/1 "2021-12-24T07:38:00Z")

</div>

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.

```auto
#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.

 ![Screenshot 2021-12-24 at 12.56.37 PM](https://community.openenergymonitor.org/uploads/default/original/3X/1/3/1392debd0b4f37c640a259020f7834a22a814f94.png)

Am I doing anything wrong here.

---

<div class="post-metadata">

**Author:** ![codetiger](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/codetiger/32/19958_2.png) [@codetiger](https://community.openenergymonitor.org/u/codetiger)\
**Post date:** [27 December 2021 05:18 UTC](https://community.openenergymonitor.org/t/esp32-sct-13-030-giving-graph-reversed/19328/2 "2021-12-27T05:18:27Z")

</div>

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 |&nbsp;Savjee.be](https://savjee.be/2019/07/Home-Energy-Monitor-ESP32-CT-Sensor-Emonlib/)

---

<div class="post-metadata">

**Author:** ![codetiger](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/codetiger/32/19958_2.png) [@codetiger](https://community.openenergymonitor.org/u/codetiger)\
**Post date:** [28 December 2021 07:01 UTC](https://community.openenergymonitor.org/t/esp32-sct-13-030-giving-graph-reversed/19328/3 "2021-12-28T07:01:26Z")

</div>

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](https://github.com/codetiger/PowerConsumptionMonitor-ESP32)
