SCT013 20A + ESP8266 - wrong results

Hi,

I want to use a SCT013 20A/1V with an ESP8266.
the wirering is illustrated here:

my problem is, if I attach the sensor to a powerline (of course only one of the three wires) which has a momentary load of 35W I got as an result 80W.
If I disconnect the wire to the sensor, it drops to 0. So the wirering itself should be ok.
If I raise the load the 80W increases too.

So, what could be wrong?


#include <SPI.h>

#include <EmonLib.h> 
 
#define ANALOG_INPUT_SENSOR A0  // The digital input you attached your SCT sensor.  (Only 2 and 3 generates interrupt!)
//#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)


EnergyMonitor emon1;

long wattsum = 0;
double kwh = 0;
double wh = 0;
long lastmillis = 0;
int minutes = 0;


void setup()  
{  
  
  Serial.begin(115200);
  emon1.current(ANALOG_INPUT_SENSOR, 25);             // Current: input pin, calibration.



}


void loop()     
{ 
  
  
  
  if (millis()-lastmillis > 5000) {
    double Irms = emon1.calcIrms(1480);  // Calculate Irms only
    if (Irms < 0.3) Irms = 0;
    long watt = Irms*240.0;
    wattsum = wattsum+watt;
    minutes = minutes + 1;
    lastmillis = millis();
    Serial.print(watt);         // Apparent power
    Serial.print(" ");
    Serial.println(Irms);          // Irms
  
  }
  if (minutes == 10) {
    wh = wh + wattsum/10;
    kwh = wh/1000;
    
    wattsum = 0;
    minutes = 0;
  }

}

I have not used this sensor yet, but isn't the output of the SCT013 AC?

Maybe, but is that a problem? Every sketch in the Internet looks like this. :thinking:

Hi,
What voltage is Vin?

What voltage does the Emon library expect at A0 with no AC current?
Measure the voltage at A0 and compare.

The code measures the AC current by measuring the DC biased AC at A0.
If the bias, the voltage when no AC is not as the library expects, that could be where your problem is.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

Vin is 5V. But I get the same values if I connect it to 3.3V. THat makes no difference.

Hi,

What is the load?
How momentarily?

Note Node MCU pinout;

NodeMCU ESP8266 Specifications & Features

  • Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106
  • Operating Voltage: 3.3V
  • Input Voltage: 7-12V <<<<---------
  • Digital I/O Pins (DIO): 16
  • Analog Input Pins (ADC): 1
  • UARTs: 1
  • SPIs: 1
  • I2Cs: 1
  • Flash Memory: 4 MB
  • SRAM: 64 KB
  • Clock Speed: 80 MHz
  • USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
  • PCB Antenna
  • Small Sized module to fit smartly inside your IoT projects

Vin == 7V to 12V

Some loads when turned on have a surge current that can be twice or more higher than running current.
How are you measuring the AC current to calibrate your project?

Tom... :smiley: :+1: :coffee: :australia:

1 Like

hey TomGeorge,

I am sorry, the project is dead :frowning:
the SCT 013 is not suitable for small loads. I got it working and I can do measurements with loads >500W. For example an electric heater with 1000-2000W can be monitored correctly. but even if I switch off the power, there is still be noise up to 100W which does not disappear.
So, all in all, it was a nice try but I can't use it like I want to.
I'm going to do it like my last project with a pulse counter.
And also it must be done by using an ESP32 because the library is designed for ESP32.
So my attend to do this was not correct :confused:

pulse counter with esp8266, SD-card and mqtt features

thanks a lot.

Hi,
Okay good to see you have what you wanted.
What power resolution does you smart power meter have, you will have to do some maths to get power as the pulse I believe represents Wh or kWh.

Tom... :smiley: :+1: :coffee: :australia:

yeah, it's 1600 pulses for 1 kWh.
So every pulse represents 0,625 Wh.
That's ok and these cheep puls counters are relativly precise. I compared it to an other power consumption meter and the results were the same.

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