Hi,
I am trying to create a home energy monitor using my ESP32 and the SCT013 [50A/1V] CT sensor (It gives a reading of 1v when 50 amps of current goes through a wire).
I used the following guide to help me out however, the readings I get are not accurate at all. They are off by a huge margin. Even if I do not clamp my CT sensor to any wire, it still gives me some sort of reading (between 0.20 and 0.30) and not 0.
I don’t have any sort of engineering experience and am pretty lost here. I just did whatever the guide told me to do.
I searched it up a bit, and found out the issue may be the calibration number I pass in the .current() method of the EnergyMonitor object, but have no idea as to how I am supposed to calculate that number.
I have attached the circuit diagram I used and the code I uploaded to the esp32. Any help would be appreciated.
Source Code:
#include <Arduino.h>
#include "EmonLib.h"
#include <driver/adc.h>
#define HOME_VOLTAGE 220
#define ADC_INPUT 34
#define ADC_BITS 10
#define ADC_COUNTS (1<<ADC_BITS)
EnergyMonitor emon1;
unsigned long lastMeasurement = 0;
unsigned long timeFinishedSetup = 0;
void setup() {
adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_11);
analogReadResolution(10);
Serial.begin(115200);
emon1.current(ADC_INPUT, 30);
timeFinishedSetup = millis();
}
void loop() {
unsigned long currentMillis = millis();
if(currentMillis - lastMeasurement > 1000) {
double amps = emon1.calcIrms(1480);
lastMeasurement = millis();
if(millis() - timeFinishedSetup < 10000){
// Readings are unstable at this point so wait
} else{
Serial.println(amps);
}
}
}
Circuit Diagram:
