How to get watt hour consumption from current reading of AC current

Is there any way to get a watt hour reading from AC current reading? I have a SCT-13 current transformer that lets me read the current consumption of appliances. But since its AC the reading is not stable and it changes along with the frequency?

what fomula do i use to get my watt hour reading ? assuming 220vAC.

is it just simply read the voltage and current at certain time and thats it? Is it possible to remove the reading of the voltage part?

Strictly speaking you need to sample the current several times over each AC cycle and from that calculate the RMS value of the current.

You could probably get a fairly good approximation just by measuring the peak current in a cycle.

Then you need to save the RMS values at suitable intervals (which will depend on how quickly the RMS current changes) so that you can calculate the RMS current multiplied by the number of hours (or minutes or seconds) that it existed at that level.

Assume, for example that you measure the RMS current at 2 amps for 3 minutes and assuming the RMS voltage is a constant 220v then the energy consumption would be 220 * 2 * 3 = 1320 watt-minutes or 22 watt-hours

...R

The RMS for a sine wave is 0.707 x Peak. (That goes for current and/or voltage.)

A "real" power meter measures the voltage & current and the phase difference caused by inductive loads. But, if your load is non inductive or only slightly inductive you can ignore that and still get a reasonably close measurement, and you can also assume the voltage is constant.

See [u]OpenEnergyMonitor.org[/u].

Robin2:
Strictly speaking you need to sample the current several times over each AC cycle and from that calculate the RMS value of the current.

yes i understand that i have to sample it several times, my concern though is how do you know the peak value. sampling the waveform serveral times does not assure me that i have sampled the peaks it could be a little bit before or after.

DVDdoug:
A "real" power meter measures the voltage & current and the phase difference caused by inductive loads. But, if your load is non inductive or only slightly inductive you can ignore that and still get a reasonably close measurement, and you can also assume the voltage is constant.

now that you mention it i have one inductive load appliance an inverter Air conditioner. How can i isolate this appliance to the rest of my appliance so that my readingg on the appliances so that the reading on the others will not be so out of phased

Maybe I see it wrong but you can take roughly 10,000 samples per second with the Arduino. So chances of missing the (relevant part of the) the peaks in a 50Hz signal are quite slim.

sterretje:
Maybe I see it wrong but you can take roughly 10,000 samples per second with the Arduino. So chances of missing the (relevant part of the) the peaks in a 50Hz signal are quite slim.

Im planning to use an external adc, the arduino doesnt have enough resolution to read the steps from my current transformer. Im using the ads1115, which is 16bit resolution opposed to arduinos 10 or 12. And can read only 860 max samples per second.

How about, is it possible to rebuild a sine wave from a set number of points?

860 points per second corresponds to 14 samples/cycle of a 60 Hz waveform or 17 at 50 Hz, which is fine for reconstructing the sine wave.

It would be somewhat inaccurate to calculate the RMS value of the waveform directly from the data points, as demonstrated by the program below, so you may want to fit a sine curve to the sampled data.

void setup() {
  Serial.begin(9600);
  int i;
  float sample_rate = 860.0, freq = 60.0;  //ADC samples/second, AC waveform freq.
  int npts = sample_rate / freq + 1.0;
  float sum2 = 0.0;

  for (i = 0; i < npts; i++) {
    float A = 11.0 * sin(2 * PI * freq * (i / sample_rate)); //calculate and sample sine wave, arbitrary amplitude
    Serial.print(" i, A ");
    Serial.print(i);
    Serial.print(", ");
    Serial.println(A);
    sum2 += A * A;  //sum squared values
  }
  Serial.print("RMS value ");
  Serial.println(sqrt(sum2 / npts));  //experimental RMS value
  Serial.print("expected RMS ");
  Serial.println(11.0 / sqrt(2.0));
}

void loop() {}

jremington:
860 points per second corresponds to 14 samples/cycle of a 60 Hz waveform or 17 at 50 Hz, which is fine for reconstructing the sine wave.

It would be somewhat inaccurate to calculate the RMS value of the waveform directly from the data points, as demonstrated by the program below, so you may want to fit a sine curve to the sampled data.

Are there other way of doing it that has a better accuracy?

Yes, as already stated, fit a sine curve to the points. Or use a faster ADC and collect more points.

the arduino doesnt have enough resolution to read the steps from my current transformer

Even using the 1.1V ADC reference?

You may find this report on the SCT-13 interesting.

Why would you want to fit a sine curve if the current is not a sinewave, as it is not for any electronic device such as computers, TVs, printers, LED or fluorescent light bulbs, microwaves, modern washing machines and dishwashers, appliances with power packs and such? :roll_eyes:

John41234:
yes i understand that i have to sample it several times, my concern though is how do you know the peak value. sampling the waveform serveral times does not assure me that i have sampled the peaks it could be a little bit before or after.

Have a look at a pure sine wave. For a significant part of the time it is very close to the peak - within a few %. That's similar to the error you can also expect from your current sensor.

If you sample 1,000 times a second, so 10 times for each half wave at 50 Hz, the peak you measure will be very close to the actual peak of the wave. The Arduino can do up to ~9800 sps in default settings.

Then there's indeed the problem of phase shift by inductive loads, fluorescent tubes do this as well I think, there's the chopped of switching power supplies, maybe also phase cutting light dimmers... All in all a lot of noise is to be expected on the wire.

jremington:
Yes, as already stated, fit a sine curve to the points. Or use a faster ADC and collect more points.
Even using the 1.1V ADC reference?

you can use a 1.1V ADC as reference? This is new to me, are there external components needed for this??

jremington:
You may find this report on the SCT-13 interesting.

Wow there seems to be a community that is specialized to this task

wvmarle:
Then there's indeed the problem of phase shift by inductive loads, fluorescent tubes do this as well I think, there's the chopped of switching power supplies, maybe also phase cutting light dimmers... All in all a lot of noise is to be expected on the wire.

So how do you recomend i calculate for power consmed? Am i really going to need a voltage at the time of sampling?

John41234:
So how do you recomend i calculate for power consmed? Am i really going to need a voltage at the time of sampling?

If you're expecting 16 bit accuracy at the output of your measurement process, definitely yes.

you can use a 1.1V ADC as reference? This is new to me, are there external components needed for this??

This excellent ADC tutorial shows you how to measure the voltage range from 0 to 1.1V with 10 bits of accuracy (for AVR based Arduinos).

John41234:
So how do you recomend i calculate for power consmed? Am i really going to need a voltage at the time of sampling?

Yes - unless you can be absolutely sure there is no phase shift due to inductive or capacitive loads or phase cutting taking place anywhere down the line.

jremington:
This excellent ADC tutorial shows you how to measure the voltage range from 0 to 1.1V with 10 bits of accuracy (for AVR based Arduinos).

I have looked into and wow this is a cool AVR feature, and it would seems this is an AVR specific feature too.

wvmarle:
Yes - unless you can be absolutely sure there is no phase shift due to inductive or capacitive loads or phase cutting taking place anywhere down the line.

I think its better to be safe than sorry, Can you recommend an IC or module that can read 220VAC. I think i prefer the another IC handling it because it will be for sure be built have the protection of the nuances of the mains voltage. I might go as well as having a different power supply for that thing and the signal back to my arduino be opto-isolated.

The usual and safe way to read AC supply voltages is with another small transformer, as described here.

There is no need to reinvent the wheel.

John41234:
I have looked into and wow this is a cool AVR feature, and it would seems this is an AVR specific feature too.

It's not. On the contrary. In the ESP8266 a fixed voltage reference is in fact all you get!

Opto-isolating analog signals is VERY hard and not commonly done.