In order to solve the problems of high maintenance cost and low convenience of reading traditional electric meters, a wireless smart electric meter system based on WiFi communication was developed. The system uses STM32 as the controller, adopts the built-in AC voltage/current module to collect the voltage and current signals of the power grid, and realizes the transmission of electric energy data through WiFi wireless transmission. Combined with OLED and APP, users can monitor and manage voltage, current, electricity bill and electric energy data in real time. Tests show that the system has a measurement accuracy of 0.002%, and users can query the power data at any time, which has good practicality and operability.
Keywords: WiFi; smart meter; STM32; OLED; APP
Content
2.1 System overall circuit design
2.2 STM32 controller circuit design
2.3 AC voltage/current detection circuit design
2.4 OLED display circuit design
2.5 Wireless transmission circuit design
4. System software and hardware debugging
4.3 System overall function demonstration
1. System overall design
With the transformation of energy structure and the rapid development of smart grid, smart meters, as key components in modern power systems, can not only realize accurate power measurement, but also integrate remote monitoring, data transmission, energy management and other functions. They are gradually replacing traditional mechanical or electronic meters, providing strong support for the intelligent management and optimization of power systems. At present, smart meters based on microcontrollers have become a research hotspot. Combining 32-bit DSP and ARM technology, voltage data acquisition, storage and real-time visualization are realized. EM773 is combined with wireless transmission chip NRF24L01, and data is efficiently transmitted to the host computer through CAN bus technology to realize real-time monitoring, data acquisition and long-term storage of voltage. In addition, optical fiber sensors, digital-to-analog conversion chips AD7606 and Voltcal modules are widely used in the collection of voltage data. For example, the real-time automatic collection of user electricity consumption information is realized by combining the collection terminal and GPRS transmission technology. A power information collection and monitoring system with self-diagnosis function is designed to realize rich online functions, but the high cost and overly centralized deployment method limit its promotion and application to a certain extent. Zhejiang Reallin Electron Co., Ltd. combines the ATT7022E energy metering chip with the LoRa gateway to improve the reliability of the meter data transmission and reception, but its measurement accuracy still needs to be further improved. The ARM-based energy acquisition system that combines LoRa and GPRS communication technology improves the detection accuracy, but the large number of measurement points leads to a decrease in data loading speed and the real-time performance of data acquisition is difficult to guarantee. Research has found that the current research field of energy acquisition systems still faces many challenges such as poor environmental adaptability, complex software and hardware design, and high cost. Therefore, this paper designs a wireless smart meter system based on WiFi communication, which mainly uses voltage and current modules to accurately collect voltage and current signals, realizes efficient data transmission through WiFi, and designs a mobile phone APP for users to remotely view and manage voltage, current, electricity bills and energy usage.
The system mainly consists of three parts: data acquisition, data transmission and data display. The overall design framework is shown in Figure 1. The data acquisition part uses the built-in A/D converter of STM32 to obtain real-time voltage and current data; the data communication part uses the Esp8266 module to realize wireless data transmission; the data display part combines OLED and APP to intuitively display and query real-time voltage, current, power and other information.

2 System hardware design
2.1 Overall system circuit design
In view of the advantages of STM32 such as small package size, fast operation and low power consumption, the system is composed of STM32 as the core controller, combined with AC voltage/current detection module, OLED display and WIFI module, etc. The overall hardware circuit is shown in Figure 2. The AC voltage/current detection module is used to collect voltage and current in real time. The STM32 controller converts the collected real-time voltage and current into real-time power P, accumulated electric energy Q and accumulated electricity price V. The ESP8266 module efficiently converts the acquired data into wireless network data signals through the serial port, and the real-time data of the meter can be remotely viewed and wirelessly controlled through the mobile phone APP.

Figure 2 Overall hardware circuit of the system
2.2 STM32 controller circuit design
The STM32 controller circuit mainly consists of a reset circuit, a crystal oscillator circuit, and STM32, as shown in Figure 3.

Figure 3 STM32 controller circuit
2.3 Design of AC voltage/current detection circuit
The AC voltage/current detection circuit is shown in Figure 4. After collecting the analog current/voltage signal of the mains, it can be converted into voltage and current digital signals through A/D. The circuit integrates two A/D digital-to-analog converters and an energy metering core. The energy metering core includes two parts: the AC voltage transformer circuit and the AC current transformer circuit. The design of the AC voltage transformer circuit is shown in Figure 5. The AC voltage in the measured circuit generates a small voltage AC signal through the voltage transformer. The STM32 controller can complete the analog-to-digital conversion of the DC signal. Therefore, the detected AC small signal is rectified and filtered before being sent to the STM32 controller to complete the voltage signal acquisition. The voltage transformer uses TV1005-1M, which is transmitted to the analog-to-digital input port of the STM32 after rectification and filtering for analog-to-digital conversion. The AC current transformer circuit is shown in Figure 6. The AC current transformer uses TA1005-1M to realize current signal acquisition. The winding T2 proportionally reduces the voltage of the electrical network port, and the diode D2 rectifies and filters the negative half-axis electrical signal. The analog value of the secondary current is calculated according to Ohm's law, and the secondary current value is multiplied by the proportional scaling factor to obtain the real-time current value to be measured. The rest of the process is the same as voltage acquisition.

Figure 4 AC voltage and current detection circuit

Figure 5 AC voltage transformer circuit

Figure 6 AC current transformer circuit
2.4 OLED display circuit design
The system uses a four-pin OLED display as the display device, which has the characteristics of low driving voltage and low energy consumption. STM32 sends instructions and data to the OLED display through the SPI bus to control the display content. The circuit design is shown in Figure 7.

2.5 Wireless transmission circuit design
The system uses the WiFi_ESP8266 module to realize wireless communication of data. As a complete and self-contained Wi-Fi network solution, ESP8266 can work in softAP, station and softAP/station modes [18-19]. The circuit design is shown in Figure 8. Pin P4 (TXD) of the ESP8266 module is connected to the microcontroller pin P, pin P8 (RXD) is connected to the microcontroller pin P9, pin P is grounded, pins P5 and P7 are connected to the power supply, and pins P2, P3 and P6 are unloaded.

3.System software design
After the system overall software is powered on and initialized, the AC voltage/current acquisition module reads the real-time average voltage and average current values; the STM32 control module parses and processes the received data, calculates the real-time power P and the accumulated power Q, and makes an overload judgment on the accumulated power. If the overload system is powered off, the buzzer alarm is activated at the same time. Otherwise, the data is synchronously transmitted to the OLED display module and the mobile phone APP.
4. System software and hardware debugging
4.1 System software debugging
The system uses Keil4 for software debugging to check for errors in program logic, function, and compilation. Write the program according to the requirements, establish a project to compile and run the program, and the program automatically generates a HEX file with a correct suffix. Use the serial port debugging tool SSCOM to connect the software and hardware and download it.
4.2 System hardware debugging
Perform dynamic debugging of the system to detect and solve problems such as cold soldering, leaking soldering, short circuit, open circuit, and signal abnormality in the hardware circuit. The debugging results are shown in Figure 11.

4.3 Demonstration of overall system functions
In order to verify the design, software and hardware joint debugging was carried out, and the load test results are shown in Figure 12. When the system is connected to the load and the test begins, the OLED shows that the real-time power P is 52W, the accumulated power Q is 0.24389kW/h, the real-time electricity fee V is 0.12 yuan, and Running means that the relay is connected and the meter is in normal working condition. The results show that the system measurement accuracy reaches 0.002%.

The corresponding mobile phone APP is developed to realize the real-time transmission and visualization of data, and improve the user experience. It can display key information such as voltage, current, power, electricity and electricity bill data, so that users can fully understand the electricity consumption. At the same time, two virtual buttons for connecting Wi-Fi and starting the system are configured on the interface to realize the remote control function of the smart meter.
The smart meter designed with STM32, HLE8012 and WiFi module has the characteristics of high accuracy, low power consumption and wireless meter reading. The smart meter designed with RS485 module and ZigBee wireless communication technology realizes real-time two-way communication while effectively reducing communication costs. The smart meter designed with STM32, SI4463 wireless transceiver and GSM module can automatically record electricity bills and support users' remote inquiries. In contrast, the smart meter designed in this design has high measurement accuracy, up to 0.002%, and realizes low cost, wireless meter reading, electricity bill recording and user inquiry functions. At the same time, it has a simple circuit structure, comprehensive functions, and strong practicality and operability.
5 Conclusion
In order to solve the problem of high maintenance cost of traditional electric meter design, Zhejiang Reallin Electron Co., Ltd. designed a wireless smart electric meter system based on WiFi communication. Based on the STM32 control module, the system uses AC voltage/current module to realize real-time collection, processing and transmission of electric energy data, and can also display the system's voltage, current, power and electricity fee data in real time. Combined with the wireless meter reading function of the system WiFi communication module, users can remotely view power data and control through the mobile phone APP, realize real-time tracking and accurate display of power, significantly improve the user experience, and enhance the intelligence level and convenience of operation of the system. The system has a simple circuit structure, comprehensive functions, strong practicality and operability, and broad application market prospects.





