1. Blog>
  2. Digital AC Energy Measurement Circuit V2 RMS Voltage, RMS Current, Real Power, Power Factor, Energy KWh

Digital AC Energy Measurement Circuit V2 RMS Voltage, RMS Current, Real Power, Power Factor, Energy KWh

by: Oct 05,2023 6295 Views 0 Comments Posted in Technology

Power Factor Energy KWh

By Hesam Moshiri, Anson Bao

Copyright: Attribution-NonCommercial-NoDerivs (CC-BY-NC-ND)

Disclaimer: Some parts of this circuit carry dangerous Mains voltage. If you are a beginner, seek guidance from experienced users. 

Dealing with the 110V/220V AC mains voltage and measuring the AC load parameters are regarded as a challenge for electronic designers, both in circuit design and calculations. The situation becomes more complex when dealing with inductive loads because they cause a phase shift between voltage and current and alter the sine-wave shape of the AC signal (resistive loads do not). The power factor of resistive loads is theoretically equal to 1.

In this article/video, I introduce a circuit that can measure AC RMS voltage, RMS current, active power, power factor, and energy consumption (KWh) of the loads. I used a low-cost STM32 Microcontroller and provided four push buttons for initial calibration. The device can independently measure the parameters and display the results on a bright 1.3-inch OLED display. The measurement error rate is around 0.5% or lower.

For the schematic and PCB design, I use Altium Designer 23. I shared the PCB project with my colleague for feedback and edits through Altium 365's secure cloud space. The Octopart component search engine proves invaluable for obtaining component information and generating the Bill-of-Materials (BOM). To ensure the production of high-quality fabricated boards, I forwarded the Gerber files to PCBWay. I used the Siglent SDM3045X benchtop multimeter to calibrate the circuit. That’s a quick and easy process.

It's a cool device for everyday electronics, so let’s get started! :-)

Download the Gerber or order 10-Pcs high-quality PCB boards for just 5 USD

If you would like to order a fully assembled PCB board (including Free Shipping), Just click here

Circuit Analysis

Figure 1 shows the schematic diagram of the AC-Mains input and shunt resistor. P1 and P2 are input/output terminals for the AC input and load connection.

Figure 1

Schematic diagram of the AC input, Load terminal, shunt resistor, and input protection

F1 is a 500mA fuse [1] and R1 is the 7D471 varistor [2] to protect the device against high-voltage transients. T1 is a 10mH common mode choke [3] and C1 is a 100nF-X2 capacitor [4] to reduce the noise. The circuit shunt resistor should be a 1-milliohm resistor; however, the power rating of the shunt also matters. Therefore, you can use R2 … R5 resistors in parallel to increase the power rating of the shunt to up to 12W, by using four 4-milliohm 3W resistors in parallel. In my case, I used two 2-milliohm resistors in parallel.

Figure 2 shows the power supply section of the circuit, isolated output and non-isolated. The power supply of the measurement part should be non-isolated and referenced to one of the AC-Mains terminals. 

Figure 2

The power supply section of the circuit

C2 is a 470nF-630V capacitor [5] to reduce the AC voltage. R6 discharges the capacitor at power OFF. D1 and D3 are 1N4007 [6] diodes to rectify the AC voltage and D2 reduces to voltage to be applied to the 78L05 [7] regulator. U1 is the HLK-PM01 [8] AC to DC conversion module that converts 220V-AC to 5V-DC. C5, L1, and C6 create a Pi network to reduce the noise REG2 is the SPX3819M5 regulator [9] to prepare a 3.3V supply rail. C7 stabilizes the output of the regulator.

Figure 3 shows the measurement part that consists of the HLW8032 chip, PC817 optocoupler [10], and some passive components. 

Figure 3

The measurement section of the circuit

C8 and C9 are decoupling capacitors to reduce the noise of the IC1 supply. R10 limits the current of the optocoupler diode and R11 is a pull-up resistor for the collector of the transistor. R13 … R17 resistors reduce the input voltage to be applied to the IC1 and C12 reduces the high-frequency noise. 

Figure 4 shows the microcontroller section of the board which mainly consists of the STM32G030F6 microcontroller [11]. R18 … R21 are pull-up resistors and C13 … C16 are debouncing capacitors for SW1 … SW4. OCS is the 16MHz oscillator XO [12] to prepare the clock for the MCU. T2, T3 [13], R22, and R23 are used for level conversion between the MCU and the OLED display module.

Figure 4

The microcontroller section of the circuit 

PCB Layout

Figure 5 shows the PCB layout of the design. It’s a two-layer PCB board with a mixture of SMD and through-hole components. Figure 6 shows the wiring diagram of the board. Figure 7 shows the assembled board. If you are a beginner or have no time to purchase and solder the components yourself, you can order the board assembled.

Figure 5

PCB layout of the AC energy meter circuit

Figure 6

Wiring diagram of the AC energy meter circuit

Figure 7

Assembled PCB board of the AC energy meter circuit

Calibration & Code

To calibrate the board, you need to have an accurate True RMS multimeter. Please watch the YouTube video completely for more information. You can download the compiled HEX file from here [14].

Bill of Material

Figure 8 shows the bill of materials. Octopart website provides free tools to build any kind of BOM.

Figure 8

Bill of materials of the AC energy meter circuit


[1]: Littelfuse 500mA: https://octopart.com/37005000410-littelfuse-39623899?r=sp

[2]: MOV-07D471K: https://octopart.com/mov-07d471ktr-bourns-19184728?r=sp

[3]: Bourns 7355-H-RC: https://octopart.com/7355-h-rc-bourns-12614152?r=sp

[4]: 100nF-X2: https://octopart.com/r46kf310000p1m-kemet-20074740?r=sp

[5]: 470nF-630V: https://octopart.com/ecw-fa2j474j-panasonic-22311695?r=sp

[6]: 1N4007: https://octopart.com/ecw-fa2j474j-panasonic-22311695?r=sp

[7]: 78L05 SOT89: https://octopart.com/ua78l05acpk-texas+instruments-525167?r=sp

[8]: HLK-PM01: https://octopart.com/hlk-pm01-hi-link-122345845?r=sp

[9]: SPX3819M5: https://octopart.com/spx3819m5-l-3-3%2Ftr-maxlinear-94414540?r=sp

[10]: PC817: https://octopart.com/pc817x1nip1b-sharp-80968503?r=sp

[11]: STM32G030F6: https://octopart.com/stm32g030f6p6-stmicroelectronics-103773023?r=sp

[12]: 16MHz XO: https://octopart.com/ecs-3225mv-120-cn-tr-ecs+international-95544585?r=sp

[13]: 2N7002: https://octopart.com/2n7002-diotec-109206764?r=sp

[14]: HEX File: https://drive.google.com/file/d/1YjMJoeoZTZRZ4UXn3D2VWpdxdK30F0ar/view?usp=sharing

Join us
Wanna be a dedicated PCBWay writer? We definately look forward to having you with us.
  • Comments(0)
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000
    Back to top