I think that trying to use RMS values of voltage and current for this is not going to work. Imagine shifting the current waveform 4ms later; neither the RMS voltage nor the RMS current would change at all, but the power drawn would change by an order of magnitude.
The instantaneous power drawn by your circuit is V * I. In any small time dt, the energy consumed will be V * I * dt. The energy consumed in 1s, the power drawn, will be the integral of V * I * dt from T=0 to T=1s. You could compute this directly from the sample values in your excel spreadsheet. At each time sample, multiply the instantaneous voltage by the instantaneous current, and that gives the instantaneous power drawn. Multiply that by the sample interval, and that is the energy consumed in that sample interval. Add all those up over an AC cycle, and multiply by the number of cycles per second and that is the energy drawn per second, otherwise known as the power.
Looking at the scope traces, the current drawn by the circuit is usually 0. Once per AC half-cycle, the current increases to about 90mA very quickly, then drops linearly to 0 over about 820us. It's a 60Hz circuit so it does this every 8.3ms. When the circuit is drawing current, the voltage is more-or-less constant at 170V. That's an average current of 45mA over the 820us at 170V = 7.65 W, but it only takes this power 1/10 of the total time, so the final power consumption is 0.76 W.
In my experience, the probability of wiring up a current probe backwards is exactly 0.5!
If someone asked for the average power dissipated in a device, what
would that mean?
The average power is the time average of the instantaneous power. In the case you describe, the instantaneous power is a 1W peak square wave and, as you point out, the average over a period is zero.
But, consider the case of (in phase) sinusoidal voltage and current:
$$v(t) = V \cos \omega t $$
$$i(t) = I \cos \omega t $$
The instantaneous and average power are:
$$p(t) = v(t) \cdot i(t) = V_m \cos\omega t \cdot I_m \cos\omega t = \dfrac{V_m \cdot I_m}{2}(1 + \cos2\omega t) $$
$$p_{avg} = \dfrac{V_m \cdot I_m}{2}$$
(since the time average of sinusoid over a period is zero.)
In the above, we evaluated the time average of the instantaneous power. This will always give the correct result.
You link to the Wiki article on AC power which is analyzed in the phasor domain. Phasor analysis assumes sinusoidal excitation so it would be a mistake to apply the AC power results to your square wave example.
The product of the rms phasor voltage \$\vec V \$ and current \$\vec I \$ gives the complex power S:
$$S = \vec V \cdot \vec I = P + jQ$$
where P, the real part of S, is the average power.
The rms phasor voltage and current for the time domain voltage and current above are:
$$\vec V = \dfrac{V_m}{\sqrt{2}} $$
$$\vec I = \dfrac{I_m}{\sqrt{2}} $$
The complex power is then:
$$S = \dfrac{V_m}{\sqrt{2}}\dfrac{I_m}{\sqrt{2}} = \dfrac{V_m \cdot I_m}{2}$$
Since, in this case, S is purely real, the average power is:
$$P = \dfrac{V_m \cdot I_m}{2}$$
which agrees with the time domain calculation.
Best Answer
The source of the confusion here is from the second equation you list:
$$P_\mathrm{avg2} = V_\mathrm{rms}\times I_\mathrm{rms} = \sqrt{\frac{1}{T} \int_{0}^{T} V^2(t) \, \mathrm{d}t} \times \sqrt{\frac{1}{T} \int_{0}^{T} I^2(t) \, \mathrm{d}t}$$
This equation is true under the assumption that both the voltage and currents are sinusoidal and in phase. The derivation works out that way, so it is a simple way to calculate average power under that specific circumstance. The instantaneous method you used is the general case, and should work under all circumstances.