Disclaimer: Some components in this circuit are connected to dangerous mains voltage. Exercise caution when conducting experiments. If you’re a beginner, please seek guidance from experienced users.
Handling 220V AC mains voltage and accurately measuring the true power, voltage, and current parameters of AC loads is a significant challenge for electronics designers. This complexity increases when working with inductive loads, as they distort the sine wave of the AC signal (unlike resistive loads which do not affect the wave shape).
In this article/video, I present a circuit that measures the AC voltage, RMS current, active power, apparent power, power factor, and energy consumption (KWh) of electrical loads. I used an Arduino Nano board as the central processor, making the design more accessible and engaging for beginners. The device measures the aforementioned parameters independently and displays the results on a 4×20 LCD screen. The measurement error is around 0.5% or lower.
For the schematic and PCB design, I used Altium Designer 22, incorporating missing component libraries via Altium’s manufacturer part search. The Octopart website was instrumental in quickly gathering component data and creating the BOM for the project. I sent the Gerber files to Wellcircuits for high-quality PCB fabrication and used a Siglent SDM3045X benchtop multimeter to calibrate the board.
This device is highly practical for everyday electronics, so let’s dive in 🙂
• To order a fully assembled PCB (FREE shipping), please contact: info@wellcircuits.com
A. Circuit Analysis
Figure 1 shows the schematic diagram of the AC energy measurement circuit. As shown, the two main components of the design are the Arduino Nano board [1] and the HLW8032 [2] chip.
Figure 1
Schematic diagram of the digital AC energy meter circuit
A-1. Mains Input
Let’s begin with the schematic from top to bottom. P1 and P2 are power connectors providing secure screw connections for the 220V mains and the load. C1 is a 100nF X2-rated capacitor used to filter input noise. F1, R1, and R2 provide mains input protection, while T1 is a common-mode choke used to reduce common-mode noise.
R3, R4, R5, and R6 are four 4-milliohm resistors in parallel, creating a 4W, 1-milliohm shunt resistor. These resistors should be selected from 1% tolerance, 2512 package resistors. If you cannot access these resistors, you can use two 2-milliohm resistors in parallel. However, the original combination provides the best accuracy and rated shunt power.
A-2. Non-Isolated Supply
The power supply for the HLW8032 chip must be non-isolated and mains-referenced. This is necessary because the chip needs to directly measure the shunt resistor and mains voltage. C2 is a 470nF, 630V capacitor that reduces the mains voltage, and R8 limits the current. R7 shortens the discharge time of C2. D1 and D2 are rectifier diodes, while D3 is a 15V Zener diode that regulates the voltage to around 15V. C4, C5, and R9 form a low-pass RC filter to minimize noise.
REG-1 is the TS2937CW50 [3] 5V linear regulator, which stabilizes the voltage at 5V. C3 is the output capacitor that reduces noise from the regulator.
A-3. Isolated Supply
This section includes U1, the HLK-PM01 AC to DC conversion module, which provides an isolated supply for the Arduino board. C6, C7, and L1 form a low-pass Pi filter that further reduces the output noise from U1.
A-4. Energy Meter
The main component here is IC1, the HLW8032 chip. According to the datasheet: “The HLW8032 is a high-precision electric energy metering IC, built using CMOS technology, primarily designed for single-phase applications. It can measure line voltage and current, and calculate active power, apparent power, and power factor. It integrates two Σ-Δ ADCs and a high-precision energy metering core, and it communicates via UART. The device operates with a 5V power supply and a built-in 3.579M crystal oscillator in an 8-pin SOP package. Features include high precision, low power consumption, and strong environmental adaptability, making it ideal for electric energy metering in single-phase, two-wire systems.”
C8 and C9 are decoupling capacitors. C10, C11, R12, and R15 are part of the shunt resistor reading network (see the datasheet). R16-R20 and C12 are used in the voltage measurement network (see the datasheet). IC2 and IC3 are digital isolators (optocouplers) that transmit serial signals to the Arduino board. R10 and R13 are pull-up resistors.
A-5. Arduino Nano
AR1 is the Arduino Nano board, and IDC1 is a 2×8 IDC connector for linking to a 4×20 Green-Backlight Character LCD. R23-R26 are pull-down resistors, and R22 adjusts the LCD contrast. C13 and C14 are decoupling capacitors.
B. PCB Layout
Figure 2 shows the PCB layout for the design. It is a double-layer PCB board that uses both SMD and through-hole components. Figure 3 presents a 3D view of the PCB and assembly drawings.
Figure 2
PCB layout of the digital energy meter circuit
Figure 3
3D view of the PCB and assembly drawings
C. Calibration
To calibrate the device, you only need a resistive load (such as a classic incandescent light bulb, not an LED bulb) and an accurate RMS multimeter. I used the Siglent SDM3045X multimeter (Figure 4). Please refer to the YouTube video for detailed instructions.
Figure 4
RMS current measurement during calibration
Once the procedure is complete, you need to adjust the shunt resistor value in the “HLW8032.h” header file (Arduino library). Go to line 62 and modify the “float CurrentRF” value. In my case, the optimal value was 0.0012.
D. Code
The Arduino code is provided in the box below. You can also download the Arduino library from my GitHub repository [4]. I assume you know how to manually install an