I live in Greece where 220Volts/50 Hz is in every house's socket.
I need to measure the watts being consumed by a device (a single lamp) which I hook up in the socket.
The problem is that I can only measure the instantaneous current i(t). I don't know the resistance of the lamp or the instantaneous voltage. The current is being measured from an Arduino, using ACS712-5A, which makes my first question:
Is this safe, for me, my Arduino and all my peripherals to measure the curent with ACS712-5A?
Secondly, this is the "analysis" I did to determine a way to measure the Power. I need you to tell me, if it's valid.
$$ P_R(t) = V(t)i(t)\\ => P_R(t) = \sqrt(2)V_{rms}cos(ωt)*\sqrt(2)I_{rms}cos(ωt+φ) $$
φ=0 since I just have a lamp (an ohmic load,) so
$$ P_R(t) = 2V_{rms}I_{rms}cos^2(ωt)\\ => P_R(t) = V_{rms}I_{rms}(1 + cos(2ωt))\\ $$
Instantaneous power is not so useful, so I go for the average power:
$$ P_M = \int_0^T V_{rms}I_{rms}(1 + cos(2ωt))dt\\ => P_M = V_{rms}I_{rms} (t\Big|_0^T + \frac{sin(2ωt)}{2}\Big|_0^T)dt\\ $$
The second term is 0, so
$$ P_M = V_{rms}I_{rms}T \\ => P_M = \frac{V_{rms}I_{rms}}{f} \\ => P_M = \frac{220I_{rms}}{50} $$
All I need is to calculate \$I_{rms} : I_{rms} = \frac{I_{max}}{\sqrt2}\$ which means that I must determine the maximum current. In order to do this, I need to have a sample rate faster than 50Ηz (ideally faster than 2*50Hz based on Nyquist theorem).
This question, says that:
For a 16 MHz Arduino the ADC clock is set to 16 MHz/128 = 125 KHz. Each conversion in AVR takes 13 ADC clocks so 125 KHz /13 = 9615 Hz.
I assume my Arduino is capable of that measure. The pseudocode will be something like this:
max = 0; t = millis(); while (1) { instantCurrent = readAnalog(); if (instantCurrent > max) max = instantCurrent; if (millis() - t > 1/50) //period is over. { // prepare for the next maximum in the next period Irms = max/sqrt(2); AveragePower = 220 * Irms<s>/50</s>; // --> THAT'S WHAT I WANT t = millis(); max = 0; } } What's your opinion?
Edit : Missed the division by T in calculating the average power:
$$ P_M = \frac{1}{T}\int_0^T V_{rms}I_{rms}(1 + cos(2ωt))dt\\ $$
That makes a more reasonable result, independent of frequency as Anderson mentions:
$$ P_M = V_{rms}I_{rms} $$
The general problem, though, remains the same.


