Remote Automatic Meter Reading System

— This paper designed a remote wireless automatic meter reading device to achieve the actual needs of users such as transform data as the set time, history report, monitoring status of the meters and so on. STM32 (32-BitSTMicroelectronics Microcontroller) series single chips work well as the core control devices to satisfy the requirements, combined with surveillance cameras and a 3G wireless module to complete the hardware circuit design, which includes an STM32 control circuit, sensor data acquisition part, a 3G wireless module interface section, the analog video signal processing section and the analog video signal processing section. The software was designed according to the users’ needs, support multi-network system as well as upload pictures and parameters in time, the test results show that the device satisfied the requirements and could be used in the resource monitoring directly. This paper describes the overall design, the design of the hardware and software, calibrating device and testing device.


Introduction
The development of automatic meter reading technology is closely connected with the development of electric power, electronics, computer and wireless communication technology, which is used to remote reading the consumption of gas, water, oil, electricity and so on. This technology first appeared in the European and American countries [1]. United States in 1986 founded the association for the study of automatic meter reading AMRA (Automation Meter Reading Association) [2] after nearly 30 years of developments, automatic meter reading scale gradually expanded. European countries are also unwilling to lag behind in this field, with the EUROAMRA (Europe Automation Meter Reading Association) and UKAMRA (United Kingdom Automation Meter Reading Association). Automatic meter reading technology has been applied more and more widely in the power enterprise [3].
The ever-expanding demand for electricity in the world has promoted the development of the electricity market. Automatic meter reading has become an industry sector [4][5][6]. In China, the automatic meter reading technology has been used widely in the electric power industry. The industry is currently using the meter reading method is divided into the following: artificial meter reading way, the way of power line

Overall Design of RWAMR Module
In order to satisfy the requirements of the project, the hardware specifications of the device are as follows. The wireless network should support 2G (GSM, CDMA) and 3G (W-CDMA) and the function of system supports video capture with multiplexed 4-channel camera input interfaces, picture taken and uploaded regularly, 4channel 4-20mA current input measurement, accuracy 0.1mA, to detect the current and 12V supply voltage measurement, accuracy 0.1V. The device needs a RS232 interface, two RS485 interfaces and an 8G Micro SD card interface. Besides, it should be able to configure the parameters through the server or the serial port and its maximum working power consumption is 2W, standby power consumption is 20 mW.
According to the above indicators, this paper completed the overall design of the block diagram in Figure 1. RWAMR device is comprised of two parts that are the substrate and carrier boards. MCU (Micro Control Unit) as the core control device controls the work of the external circuit and data acquisition. MCU is connected with 3G wireless module through the serial port, and control 3G module in accordance with the AT (attention) instruction. The 4-channel cameras are attached to the input channel of the 4-to-1 analog switch. The MCU controls the working channel and analog signals collected by video processing circuit. The wireless module controls the video decoding chip to decode the video or image data, and the data are stored in the SD card. 3G wireless module establishes a FTP (File Transfer Protocol) connection and uploads the image data to the FTP server. Using of the STM32 internal ADC (Analog-to-Digital Converter) can monitor the supply voltage of 12V, turn 4-20mA current into voltage through the precision sampling resistor, and then through the lowpass filter and the voltage follower, input voltage to the MCU ADC channel. So the current can be indirectly measured. On the carrier board, there are a wireless module interface and a video processing circuit. The SD card used is still mounted on the base board under the wireless module SD card. In order for the SD card to be installed under the wireless module on the carrier board, use a 2 of 1 analog switch on the SD card interface circuit and all of these are controlled by MCU.
In software design, the software overall design flowchart is shown in Figure 2. After the device is initialized, detect device whether needs to modify the serial port parameter. Then judge the optimal signal, the device will read the signal strength of the SIM card in each slot in order, and chooses the network with the largest signal strength value as the working network. After determining the current working network, the wireless module will update the time and configuration parameters from the server. And then, the core chip will detect whether there is a switch, if the switch is detected, the system would take pictures, connect with FTP and upload pictures. When uploaded successfully establish a TCP connection to the server and upload the data again.

Hardware Design of RWAMR
In order to satisfy all the requirements from the Section II, the available MCU has to be chose first to support the module. From the subject of demand, power consumption, the richness of peripheral resources point of view, we elect to consider what type of core control device MCU. The resources required for the design: ADC, 5 serial ports (wireless module requires two serial ports. RS485 channel requires two serial ports. Serial port to modify the parameters part need 1 serial port), RTC, external interrupt input interface, IO (Input/Output) control interface. So STM32F103RC whose core is Cortex-M3 is used as the core control device. Its frequency can be up to 72MHz.
The kind of camera decides the resolution of the picture. Compared to USB (Universal Serial Bus) camera and serial camera, the surveillance camera used in this design has such advantages: • The using of analog video signal transmission has strong anti-jamming ability in the signal transmission process. • Video capture can be simple to achieve with the control of 3G module by using camera and video processing chip AK8856 program. • Analog camera technology is stable. The huge number of the manufacturer market, low cost, mass production will not cause the supply problems of microcomputer production.
Due to poor industrial environment and the need of the power, the camera needs a long lead and anti-interference ability. USB camera can't guarantee the requirement of the situation. In view of the above analysis, the design selected the surveillance camera.
The choice of 3G wireless module also has to adapt to the need of multi-network. This design requires 3G wireless module to support China Mobile and China Unicom, the two kinds of mobile communication network. The design of the program is the camera's output directly connected with the 3G wireless module. STM32 sends commands to control the work of the camera through the serial port. SIM5215E, developed by SIM Group, is fully compliant with the above requirements.
This device has a minimum system based on MCU chosen which includes JTAG (Joint Test Action Group) debug interface circuit, reset circuit, crystal oscillator circuit, chip Flash W25X16 circuit.
The five serial ports of STM32 are used for parameter modification, controlling 3G wireless module, RS485 data reception. The reset circuit adopts "RC (Resistance and Capacitor) power-on reset" structure [18].
3G module used SIM5215E version, which is fully compatible with the interface, which can support different network formats if only need to replace the 3G module and SIM card.
The peripherals that are mounted below the 3G wireless module are shown below: Micro SD card, Camera interface, SIM (Subscriber Identification Module) card and Serial port communicated with STM32.
In all of devices discussed above, putting Micro SD card mounts under 3G wireless module illustrates that Micro SD card worked under 3G wireless module's controlling. At this time, the wireless module has the support of the file system in order to be able to read Micro SD card data correctly. What STM32 needs to do is needs to send the corresponding control commands to the wireless module according to the standard instruction set.
One of the required function is the video processing before sending to the server. We have to choose one chip to pretreatment. SIM5215E has a digital image input interface, supporting 4:2:2 8bit YUV model [19], which can directly input image data generated from video processing chip.
AK8856's work is decoding NTSC (National Television Systems Committee) or PAL (Phase-Alternative Line) mixed video signal to digital video data, and outputs a digital signal compatible with Y, Cb and Cr signal. The 3G module uses IIC (Inter-Integrated Circuit) bus to control the work of AK8856.
STM32 will send a series of commands when need pictures or videos, and the wireless module transformed these orders into other formats that can be identified by AK8856, specific controlling process is completely transparent to the user.

4
Software Design of RWAMR

Remote Synchronization Time and Parameter Configuration
Parameter configuration via serial interface is mainly used to write information such as device number, FTP related parameters, and current measurement calibration parameters when a new board needs to be configured. First, initialize the STM32 serial port 1and send data to the host computer to receive data request. Determine the validity of the data after the data obtained from the host computer. The chip will determine the validity of the data, when the data from the host computer to obtain. The host computer will send the data again after the data is sent to the host computer again. Then the data will be sent to the host computer again and the host computer will send the data again. If the device considers that the host computer update parameter operation has been completed, send "INI Parameter Finished" to the upper computer to indicate that the modification parameter is successful. Otherwise, send the error message to indicate that the modification parameter operation has failed. After the parameter information is successfully obtained from the host computer, it is also necessary to write the parameters to Flash.
The device obtains the time through the TCP (Transmission Control Protocol) connection to control the central server. The real-time clock time for all devices should be based on the server time, after the synchronization time and the parameters of the configuration parameters are combined. The operation of the synchronization parameters can be performed from the FTP. Each time the device obtains configuration parameters TXT file from the FTP. If the file can't be read, it means that not need to modify the parameters. The remote parameter configuration operation is combined with the time synchronization operation to acquire the configuration data of the device while obtaining the time data. According to the format agreed in advance, it is possible to judge whether the synchronization operation needs to update the configuration parameters. According to the device technical index analyzed in Section 2, the flowchart of the software design of remote synchronization time and configuration parameters is shown in Figure 3.

Parameter Operation Updating and Picture Upload
The required parameters value must be update first to the server to record the information and data, the device number, upload interval, camera channel, and so on are the default values, when the device leaves the factory. For different devices, the user need to modify the parameters ether using the serial port or the setting button on FTP to obtain the parameters. This sub-function will update the parameters and put them into the device, turn on the power to run in accordance with the new parameter configuration. In a working cycle, after access to such parameters, the parameters will be stored in the off-chip Flash W25X16. STM32 can also save the parameters when the power off. The flowchart of the work is shown in Figure 4.
Picture shooting and video are sharing a four-channel camera. The configuration parameters determine the camera to take pictures or take pictures. FTP (File Transfer Protocol) is an abbreviation of the text transfer protocol. FTP can be used to easily share files between hosts. FTP client is used to issue commands to the server to download files, upload files and delete files on the server. Figure 5 shows the operation flowchart of the FTP connection before the device performs data exchange with FTP.

Calibration and Testing of the Device
The device voltage measurement and current measurement are used within the STM32 ADC. The input of each channel was calibrated.

Calibration of the Device
As shown in Figure 6, the board is composed of the base board and the carrier board. The source of error comes from the following aspects. The impact of the reference source: 3.3V output voltage accuracy of PT1102 is connected with the resistance value accuracy of the power circuit. Due to the discreteness of the resistance value, output voltage values of the same batch of different board are in different. The impact of ADC noise itself: the noise inside the ADC will affect the quantization accuracy, which may come from the environment, but also from the impact of temperature changes. The output noise of the operational amplifier: it introduces noise using the operational amplifier as the voltage follower in the measurement of 4-20mA input. Figure 7 shows the current calibration circuit. The calibration uses the least squares method to calibrate the voltage measurement channel and the current measurement channel. As shown in Figure 7, the current measurement calibration circuit is established by the current source, power supply, desktop multi-meters, to be calibrated board and computer. We can see the measured voltage error range is 0.07V to 0.1V before the calibration, which is not suit to the requirement of 0.1V voltage measurement accuracy in Figure 8.After the least squares correction, there is only 0.01V voltage measurement error range. After comparing with the required voltage measurement accuracy increased by an order of magnitude, so that the calibration has a good effect. Figure 9 shows the current values entered on Channel 1 for one of the boards and the measured current values before and after calibration.
As can be seen from the Figure9 above, the actual measured current value before calibration is smaller than the input current value, the maximum difference of 0.26mA, after the least squares calibration, only a maximum of 0.01mA voltage measurement error. This shows that the results of current measurement channel calibration meet the accuracy requirements of 0.1mA.
In summary, it can be seen that the deviation is large compared the measured precalibration value and the theoretical value, the error beyond the specified range. After calibrate the vale measured is approximately the same as the theoretical measured value, and the error is less than the specified range. It indicates that this method has achieved good results.

Function Test of the Device
The Test of Serial Port Parameters!First of all the device sends the request of configuration parameters "Please input parameters:". And then enter the parameters to be configured in the string input box. The type of parameter is based on the beginning of the first two bit.
"01" means that only modify the common configuration parameters, "02" means that modify the calibration coefficient, 03 means that modify the common configura-tion parameters and calibration coefficients. After receiving the data, the device will judge the validity of the data. If valid, it will prompt "Set PAR Finished".
The above operation can show that the data with different beginning of the first two bit can be updated to the system. Before the test, original parameters is 1000025_04_010_2211481982500,1000025 is device number,04 is enabled camera number,010 means upload parameters every 10 seconds, 22114819825 is related parameters on FTP server. Enter 011000025_01_010_22114819825 after "Please input parameters:" appeared. The return parameter is 1000025_01_010_22114819825 after "Set PAR Finished". It is a successful operation through the serial port to modify the parameters.
The Test of Synchronization Time and Modifying Parameters Remotely!After the device powered on, it will establish a TCP connection with the server and sends the device number of the device to the server. The server returns the current system time, all the parameter data corresponding to this number device and the MD5 [20] value calculated from these characters. The device receives the current time 2016061321551601000023, which means the time is year: 2016, date: June, 13 th ; time: 21:55:16. And the last '01000023' is the reserved data bits. The followed flag means whether the parameters have to be modified. "0" means no modification is needed, and the configuration parameters of the device are behind it. The Test of Uploading Pictures!Uploaded data can be queried on the server side. The network uses China Unicom company, signal strength is 14.The supply voltage of the equipment is 14.94V. Figure 10 shows the total amount and the flow of water passing through the water pipe, the temperature and humidity of the current environment. Figure 11 shows the pressure inside the current pipe. The sizes of these two pictures are 36725B and 22845B.All the data obtained are normal. After all the functional and performance tests, the results show that the design of the device to meet the technical requirements.

Conclusions
The design of the remote wireless automatic meter reading module according to the technical requirements, completed the hardware circuit design and related program design. First, STM32 was used in the controller selection, because the STM32 series MCU not only has ADC, rich serial resources and IO pins, but also has good low power consumption and low cost. In this device, its performance plays to the extreme. Next, communication part selected 3G wireless module of "SIMCom" company. It supports different network standards and its pin is fully compatible to facilitate the design of the device board. SIM5215E supports the camera data acquisition and decoding control, reduces the cost of video signal acquisition and improves the reliability of the device.
The design of the device satisfies the requirements by the water factory. After a lot of production testing, the device runs in a good condition, and all the functions satisfy the function requirements. The result indicates the design of the expected objectives is completed.