Electronic – How to measure ac Power using a micro-controller

armmicrocontrolleropto-isolatorpower electronicssensor

I want to measure AC power of any general device such as TV, laptop etc using a microcontroller. My MCU is ARM Cortex-M TM4C1233H6PM.

I am using ACS712 current sensor to measure the AC current and then using an optocoupler to isolate it from my MCU. After which, it is fed to the ADC of my MCU and it's value measured.

My problem is with voltage measurement. I do not have access to many transducers and voltage measuring IC's in my area. Here is what I have though so far along with my questions related to it:

Use a transformer to convert from 0-220V AC to 0-5V DC and then feed it to my MCU's ADC using another optocoupler.But my questions are these:

1)Won't my voltage measured, be in a smaller range (0-5V DC) then my current measured in AC and the power will come out wrong?
Also, since my voltage is now measured in DC, how can I calculate the AC power?

2)How can I find the zero crossings and phase difference (theta) to measure P=VIcos(Theta) in both current and voltage?

I know my questions may seem rather lengthy but I really do need your help.
Thanks for any help!

Best Answer

If you want to measure appliance power you need to digitise signals that represent alternating voltage and current waveforms. You should strongly consider simultaneous digital sampling of both quantities at a sampling rate of at least 1000 times per second in order to achieve some measure of accuracy. Multiply each simultaneous pair together and average the resulting waveform to give you power.

Using a dc quantity to represent voltage should not be regarded as having any merit. Trying to calculate RMS values for voltage and current then trying to measure phase difference by zero crossing is naive given the harmonic nature of current waveforms in a lot of appliances. This is not how pros measure power.

Power = voltage x current whether it's dc or ac, analogue or digitally sampled.