Power measurement with SCT-013, ADS1115 and Arduino

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:
ADS1115

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,


зображення

#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads;

void setup() {
  Serial.begin(115200);
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV
  if (!ads.begin()) {
    Serial.println("Failed to initialize ADS.");
    while (1);
  }
}

void loop() {
  static uint32_t start_time = 0;

  if (millis() - start_time > 1000)  {
    start_time += 1000;
    int sensor_max = 0;
    for (int i = 0; i < 10; i++)sensor_max += getMaxValue();

    Serial.println(sensor_max);// with tenth
  }
}

int getMaxValue() {
 const float multiplier = 0.1875F; /* ADS1115  @ +/- 6.144V gain (16-bit results) */
  static int sensorValue = 0; //value read from the sensor
  int sensorMax = 0;
  uint32_t start_time = millis();
  while (millis() - start_time < 20) //sample for 20ms
  {
    sensorValue = abs(ads.readADC_Differential_0_1()* multiplier);
    //if (sensorValue < 3) sensorValue = 0;
    if (sensorValue > sensorMax) sensorMax = sensorValue;
  }
  return sensorMax;
}

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.