Hi. I want to control the consumption of a 230 V AC line. To do this I use an Arduino Mega 256, an ADS1115 and an YMDC SCT-013 10A/1V transformer.
The circuit is the following:

And the sketch:
// ADS1115_Dif_Vpp
#include <Wire.h>
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads; // Crear una instancia del ADS1115
const float FACTOR = 10; //10A/1V
const float multiplier = 0.000125F; // GAIN_ONE => intervalo ADC: ±4,096V => 1 bit = 0,1250mV
float Irms;
float Prms;
void setup()
{
Serial.begin(9600);
ads.setGain(GAIN_ONE); // ±4,096V 1 bit = 0,1250mV
ads.begin(); // Inicializa el ADS1115 en la dirección predeterminada (0x48) como esclavo en el protocolo I2C
}
void printMeasure(String prefix, float value, String postfix) // Define la función printMeasure
{
Serial.print(prefix);
Serial.print(value, 4);
Serial.println(postfix);
}
void loop()
{
Irms=getCorriente();
printMeasure("Irms: ", Irms, "A");
Prms=Irms*230;
printMeasure("Prms: ", Prms, "W");
Serial.println(".");
delay(1000);
}
float getCorriente()
{
int adc0=0;
int Vpp = 0; // Voltage pico positivo
int Vpn = 0; // Voltage pico negativo
float voltage;
float corriente;
long tiempo = millis();
while (millis() - tiempo < 10000)
{
voltage = ads.readADC_Differential_0_1();
if (voltage > Vpp) {
Vpp = voltage;
}
if (voltage < Vpn) {
Vpn = voltage;
}
}
voltage = (Vpp + abs(Vpn))/2; // Voltage pico
voltage = voltage * multiplier;
corriente = voltage * FACTOR;
corriente = corriente / sqrt(2);
return(corriente);
}
I have obtained the following results:
Theoretical equipment power = 0 W
I1 Tester Int. (A) -
Power = I1 x 230 V -
I2 Int. Arduino = 0.0009 A
I1/I2 -
Theoretical equipment power = 76 W
I1 Tester Int. = 0.33 A
Power = I1 x 230 V = 76.13 W
I2 Int. Arduino = 0.08139 A
I1/I2 = 4.07
Theoretical equipment power = unknown
I1 Tester Int. = 4.14 A
Power = I1 x 230V = 952.2W
I2 Int. Arduino = 1.0359 A
I1/I2 = 4
Theoretical equipment power = 2,000 W
I1 Tester Int. = 8.13 A
Power = I1 x 230 V = 1,869.9 W
I2 Int. Arduino = 1.9781 A
I1/I2 = 4.11
Theoretical equipment power = unknown
I1 Tester Int. = 6.32 A
Power = I1 x 230 V = 1,453.6 W
I2 Int. Arduino = 1.5486 A
I1/I2 = 4.08
I don't know why there is a factor of 4 between the real intensity measured with the tester and that measured by the circuit. I have reviewed the program and the connections many times and it seems correct to me.
I have done another measurement with two loads.
Iarduino = 1.98A
Itester = 8.15 A
Itester/Iarduino = 4.10
Vout SCT-013 = 0.799 Vac => 7.99 A
Iarduino = 1.0368 A
Itester = 4.22 A
Itester/Iarduino = 4.07
Vout SCT-013 = 0.415 Vac => 4.15 A
The transformer seems works fine.
Could you take a look at it?
Thank you,


