1. Introduction
The smart electricity meter digital electricity metering module can measure the current voltage, current, active power, reactive power and other data in real time by connecting this module to the home power grid. The html server is built using Raspberry Pi to push the electricity consumption to the web page for display, and the cumulative electricity consumption is recorded under Raspberry Pi.
2. Principle Introduction
2.1 Digital Electricity Metering Module
The measurement module uses a professional metering chip to accurately measure voltage, current, active power, and accumulated power information. It has been calibrated at the factory and does not require user calibration.
The output result of the module is output through the serial port with TTL level.
2.2 GD32E231
This project uses the serial port function of GD32E231 to read the power meter module and convert the data. The communication format is as follows
Serial number
|
Function
|
Head
|
Data 1-Data 5
|
Sum
|
1
|
Voltage
|
B0
|
C0 A8 01 01 00 ( computer sends a request to read voltage value )
|
1A
|
|
|
A0
|
0 0 E6 02 00 00 ( the meter reply voltage value is 230.2V)
|
88
|
2
|
Current
|
B1
|
C0 A8 01 01 00 ( computer sends a request to read the current value )
|
1B
|
|
|
A1
|
00 11 20 00 00 ( The meter returns a current value of 17.32A)
|
D2
|
3
|
Active Power
|
B2
|
C0 A8 01 01 00 (computer sends a request to read active power)
|
1C
|
|
|
A2
|
08 98 00 00 00 (The meter replies that the active power value is 2200w )
|
42
|
4
|
Reading power
|
B 3
|
C0 A8 01 01 00 (computer sends a request to read the power value)
|
1D
|
|
|
A 3
|
01 86 9f 00 00 ( The meter returns the power value to 99999wh)
|
C9
|
5
|
Set the module address
|
B4
|
C0 A8 01 01 00 (the computer sends a request to set the address, the address is 192.168.1.1)
|
1E
|
|
|
A4
|
00 00 00 00 00 (indicates that the address setting is successful)
|
A4
|
6
|
Set the power alarm value
|
B5
|
C0 A8 01 01 14 (The computer sends a command to set the power alarm value)
|
33
|
|
|
A5
|
00 00 00 00 00 (Indicates that the power alarm value is set successfully)
|
A5
|
Table 1 Communication protocol
Communication protocol example
③Read the current voltage
Send command: B0 C0 A8 01 01 00 1A
Reply data: A0 00 E6 02 00 00 88
Note: The reply voltage data is D1D2D3=00 E6 02 , 00 E6 represents the integer of the voltage, 02 represents the decimal of the voltage, the decimal of the voltage is 1 , 00 E6 is converted to decimal as 230 ; 02 is converted to decimal as 2 , so the current voltage value is 230.2V .
GD32 sends instructions to the metering module to read voltage, current, power and electricity in turn. After receiving the instructions, the metering module sends the results in hex format to GD32, and gd32 converts the received information.
2.3 Raspberry Pi
The Raspberry Pi stores the information sent by gd32 in the sqlite database
Raspberry Pi runs flask and websocket.
The front-end code will periodically request data from the back-end program through ws. After receiving the request, the back-end will remove the latest results from the database and send them to the front-end.
The front-end code uses the echarts framework to draw a straight line graph
3. Source code
4. Demonstration
5. Documentation
smartpower.docx
(511.91 KB, downloads: 11)
See the attached video
|