# Power consumption measurement

#### Davidoff

Joined Oct 27, 2019
9
Hello,

Im a complete beginner and i want to develop a circuit for my DIY smart plug based on the Rasberry Pi Zero W,

I developed a circuit which can measure current ( I ) but to measure Power I also need the voltage ( V ) (P = I * V)
Can someone help me how should i expand my circuit to achieve this?

PS: C.T stands for Current Transducer (CKSR 6-NP )

Best regards,

David

#### MrChips

Joined Oct 2, 2009
20,856
If the supply voltage is known and constant, then all you need is to measure the current.
Simply multiply the current times voltage to give the power.
Or you can display the current on an analog meter and change the scale to show power.

#### Davidoff

Joined Oct 27, 2019
9
Thank you but my mentor told me that I should also get the voltage.

#### MrChips

Joined Oct 2, 2009
20,856
Thank you but my mentor told me that I should also get the voltage.
If you must, measure the voltage and calculate power = current x voltage.

#### DickCappels

Joined Aug 21, 2008
6,300

#### AlbertHall

Joined Jun 4, 2014
9,613
If the ADC and/or Pi is being fed with power from a standard mains transformer then you could measure the transformer secondary voltage and scale that to get the mains voltage.
https://openenergymonitor.org/

#### Davidoff

Joined Oct 27, 2019
9
If the ADC and/or Pi is being fed with power from a standard mains transformer then you could measure the transformer secondary voltage and scale that to get the mains voltage.
https://openenergymonitor.org/
The Pi is fed with power from the wall power outlet (Europe).

#### Davidoff

Joined Oct 27, 2019
9
If you must, measure the voltage and calculate power = current x voltage.
That's exactly what I do not know how to do, how to measure voltage with my Pi?

#### MrChips

Joined Oct 2, 2009
20,856
That's exactly what I do not know how to do, how to measure voltage with my Pi?
Your initial post shows a CT feeding a voltage into an ADC which is read by the rPi.
Can you not do the same to measure voltage?

#### AlbertHall

Joined Jun 4, 2014
9,613
Can you not do the same to measure voltage?
But with a standard mains transformer, not a current transformer, yes.

Joined Jan 15, 2015
5,335
Your initial circuit reflects using a CT (Current Transducer) to measure a current. The current transducer measures a current and sends out likely a voltage which is proportional to the current and you do the ADC output in code. What you want is a Voltage Transducer which will convert your AC mains voltage to a low level DC voltage which you would feed to your ADC and process the same way. Then in your code you multiply the current * the voltage to get the power. This assumes a purely resistive load as was mentioned. If the load is not purely resistive or if it is inductive then there is more to things. There are also Power Transducers for measuring reactive and active power which will provide an output voltage which is proportional to the power being consumed. A Google of AC Current Transducer, AC Voltage Transducer and AC Power Transducer will bring up examples of all three.

The AC current transducer you have chosen is in this family. You may want to note that the base DC out is 2.5 VDC which allows an AC current to swing above and below that DC level. Page 8 of your data sheet reads:
"The output voltage range is limited to between 0.375 V for the negative current range and 4.625 V for the positive current range centered around 2.5 V when external reference voltage is not used. The positive and negative voltage variation spans are each of 2.125 V and fluctuate around the internal voltage reference fixed at 2.5 V. To define the measuring range, just divide the possible max voltage variation span (positive or negative) by the gain defined by the concerned model". Consider that the current signal will be changing constantly so write your code accordingly.

Ron

#### AlbertHall

Joined Jun 4, 2014
9,613
For the voltage transducer you can use a simple mains transformer to reduce the mains voltage to a lower value. Incidentally you can also use this for getting power for everything else.

Then you can read the voltage and current, multiple samples during a cycle, and calculate the instantaneous power at each sample point and calculate the rms value over a complete cycle. This automatically takes care of reactive loads.

Simples.

Joined Jan 15, 2015
5,335
For the voltage transducer you can use a simple mains transformer to reduce the mains voltage to a lower value. Incidentally you can also use this for getting power for everything else.

Then you can read the voltage and current, multiple samples during a cycle, and calculate the instantaneous power at each sample point and calculate the rms value over a complete cycle. This automatically takes care of reactive loads.

Simples.
Albert, if we do that and just use a transformer what happens when the AC signal goes below zero volts if the ADC is not capable of a differential input. Don't we want to offset the zero level?

Ron

#### KeepItSimpleStupid

Joined Mar 4, 2014
3,992
Take a look here: https://www.picotech.com/library/application-note/analysing-mains-power-with-picoscope

You would have to understand the math behind the functions mentioned.

You do have to find the frequency to get the period. You do have to measure v(t) and i(t) and multiply to get vi(t)

You have to use calculus to get the RMS value and the average value.

It's not as simple as you thought it would be. The RMS value of voltage * the RMS value of current won;t cut it unless the load is reistive.