First we get the question and analyze it
The title reminds us that we need to analyze and monitor the power parameters of single-phase electrical appliances, and we can learn to identify various electrical appliances.
At the same time, observe the picture. We need to leave two monitoring points to monitor whether the parameters of our analyzer are correct. We should pay attention to this. The previous stage is AC input, the latter stage is AC output, and the power strip is connected at the same time.
From the question, we can learn: Monitoring load types: USB charger (with load), wireless router, electric fan, kettle, switching power adapter, soldering iron.
In learning mode, each single electrical appliance is used in various states. Identify electrical appliances and their working conditions and store the characteristic parameters of their operating status;
In the analysis and monitoring mode, the category and working status of electrical appliances are indicated in real time.
The operating current of the device in monitoring mode is not greater than 15mA
The performance part reminds us that the processing time when learning should not exceed 1 minute, which requires us to sample quickly and accurately.
After knowing the requirements of these questions, our ideas for solving problems will become clearer. Make alternating current samples, process them with a microcontroller, and display them on the screen.
There are also requirements for the power consumption of the entire instrument. 15mA is 220*0.015A=3.3W, and the entire instrument must be below 3.3W.
I plan to use PM01 as the power supply for the entire system. This module is very suitable for small-sized products, AC-DC modules, and the price is acceptable.
Looking at its data sheet, the overall power of the entire module is 3W, which meets the requirements of our question.
In the AC power sampling part, I plan to use HLW8032 or BL6523, which can not only sample voltage and current, but more importantly, can monitor the phase angle between current and voltage. Why is this important? Because different loads have different power factors, so we can easily determine the type of electrical appliances.
The picture above shows the characteristics of HLW8032 . The price is not very expensive, only a few yuan per piece.
The picture above shows the application circuit of non-isolated HLW0832. I use isolated sampling.
The picture above shows the characteristics and internal functions of BL6523. Taking the two chips into consideration, the peripheral circuit of BL6523 is more complicated and is not suitable for our students with weak foundation, so I used HLW8032
I use STC15W4K56S4 as the microcontroller. Why do I use this microcontroller? The first is because the price of STM32 has skyrocketed. The second is because we don’t need to involve too many functions, and I have a source program based on 51, so I chose it.
I will introduce the main components here, and I will introduce the schematic diagram and PCB later.
1. Main power circuit
2. MCU circuit
3. Sampling circuit
1. Main power circuit
The above picture is the main power circuit. U3 is the AC-DC step-down HLK-PM01, U2 is the sampling chip HLW8032 chip, J1 and J2 are the interfaces for the series current transformer, and P1 and P2 are the 220V power output and input.
I connected a large-capacity capacitor in parallel to the PM01 output, and it is a solid capacitor. The latter stage uses a 100nF capacitor to filter high frequencies. At the same time, an LED is used as a power indicator.
Some students may ask why ADC sampling is not used. Let me answer it here: Our circuit needs to sample an AC circuit, and it involves 220V high voltage. We must consider the safety of our subsequent microcontroller, so using an integrated AC sampling chip is The most convenient and safe.
In other words: “You don’t need to raise a cow to drink milk.”
2. MCU circuit

The picture above shows the MCU circuit. The circuit is designed with four buttons and an OLED screen interface. It also retains the serial port download circuit, but does not integrate the USB-TTL circuit on the board because it can save space and reduce costs.
This circuit does not need to be introduced too much. It is the most basic microcontroller and the smallest system. The power supply current of OLED is also very small, which basically meets the requirements.
3. Sampling circuit
The picture above shows the sampling circuit, which uses a ZMPT107 voltage transformer and a ZMCT103 current transformer. The accuracy of these two transformers is relatively high.
The picture above shows the ZMCT103 current transformer, the ratio is 1000:1
The picture above is the official design drawing
1. HLW8032 sampling method: isolated sampling;
2. The output signal of the current transformer in this figure is a current signal, and R2 converts the current signal into a voltage signal;
3. The maximum input range of the current signal acquisition terminal is 30.9mV, and the current transformer output The voltage difference after the current passes through R2R3 is 30.9mV;
4. Current-type voltage transformer, maximum output 2mA, transformation ratio 1000:1000, R8 takes the current limiting function, and the power value of R8 is P=u*u/R;
5 , current transformer, transformation ratio 1000:1;
Our peripheral circuits can just follow the official design
For wiring we can refer to the design guide of HLW0832
The picture above shows the official design guidance, which tells us to ground at a single point.
The picture above shows the PCB board I designed. It has a simple structure. The upper part is the high-voltage part and the lower part is the microcontroller processing part . What we should note here is that the 220V AC power must be provided with slots to prevent electricity creepage.
The way to set the slot is to draw a top line of about 20mil, then right-click and set it to slot
Before designing the PCB of the power supply, we need to understand two things first. The first is that the power supply circuit generally has a large current. Generally, the copper coating on the PCB is 1OZ.
When we design the connection line, it is best to wire it according to the 100mil 5A standard. My power supply is 2-3A.
So I chose 80mil power supply wiring, and the current must first pass through the capacitor and then enter the component, which can greatly improve the efficiency of our circuit. This time I chose semi-circular arc wiring, which is more beautiful!
It is best to leave a little space between each module, which is not only more beautiful but also anti-interference.
Add via holes and large areas of copper to increase current and increase heat dissipation
The picture above shows the 3D model of the circuit board
In programming, we need to clarify the program ideas and program framework
The figure below is the program flow chart
First, let’s analyze the registers of HLW0832
The following is part of the HLW0832 register source program
#define u8 unsigned char
#define u16 unsigned int
#define u32 unsigned long
u8 Receive_Data[24]; //Receive data cache, HLW8032 sends 24-byte data every 100ms
u16 Data=0; //Currently received data
u8 Receive_Flag=0; //The status of received data
u8 SumCheck=0; / /Checksum
u32 VParam=0; //Voltage register
u32 VReg=0; //Voltage parameter register
float Cur_Voltage=0; //Current voltage value
u32 IParam=0; //Current register
u32 IReg=0; //Current Parameter register
float Cur_Current=0; //Current current value
u32 PParam=0; //Power register
u32 PReg=0; //Power parameter register
float Cur_WATT=0; //Current power value
float Cur_VA=0; //Current view In power
float Cur_PF=0; //Current PF
u8 DUR7=0; //The seventh bit of the data update register, when the PF register overflows, bit7 is inverted once
float Acc_electricity=0; //The accumulated electric power
u8 Vol_Flag=0;
u8 CUR_Flag =0;
u8 POW_Flag=0;
u8 Err_Flag=0;
u32 PF_Num=0;
u8 StateREGData=0;
static unsigned char Test1[10],Test2[10];
After sampling the voltage and current, it is displayed and output to the OLED screen using analog IIC.
After pressing the learning button, the current information is automatically saved to the microcontroller.
When you press the start monitoring button again, the program will automatically search for electrical appliances with matching parameters.
Since the program is too long, I will put the source program in the attachment below.

The picture above shows the working power. Only 0.856W meets the requirements of our question.