Design of a GPRS-based automatic water quality monitoring system
2026-04-06 06:20:12··#1
Abstract: Addressing the problems of weak water quality sampling capacity, untimely data processing, and lack of early warning mechanisms for water quality changes in China's main water quality monitoring systems, this paper proposes a design scheme for an automatic water quality monitoring system based on GPRS technology. The system composition is described, with a focus on the working process of the GPRS module and the key components of the monitoring center subsystem. The software design of the water quality acquisition subsystem is also elaborated, proposing a multi-state, multi-task, and multi-threaded software design approach. The GPRS module flow is analyzed in detail, and the system functions are implemented. Tests show that the system has stable performance, good timeliness, and low operating costs, making it suitable for the water quality monitoring needs under the new circumstances. Keywords: GPRS; water quality monitoring; scheduler; operating system Abstract: In response to the problems in Chinese major monitoring system of water quality such as weak sampling capability of water quality, untimely data processing, and lack of early warning mechanism of water quality change, based on GPRS technology, the design scheme of an automatic water quality monitoring system was proposed. The system composition was described, and the working process of GPRS module, together with the key part of the sub-system of monitoring center was introduced in detail. Meanwhile, the software design of the sub-system of water quality collection was explained, advancing the multi-state, multi-task, multithreading software designing idea. The GPRS module flow was analyzed and the systematic function was achieved. Tests showed that the system had stable performance, good timeliness and low operation cost, which can meet the need of water quality monitoring under the new situation. Key words: GPRS; monitoring water quality; scheduler; operation system 0 Introduction Water is a natural resource that humans depend on for survival. However, with the rapid development of the economy and the rapid increase in population, the amount of pollutant emissions has continued to increase, and water pollution has become increasingly serious, affecting people's lives and production order, and causing irreversible impacts on the ecological environment [1]. Therefore, strengthening water resource management has become an urgent and practical issue. Among them, strengthening water quality monitoring is particularly important, as it is the foundation of water resource management and provides an effective basis for water resource management. At present, the main water quality monitoring system in my country adopts the on-site collection-laboratory analysis method. This method has problems such as insufficient water quality sampling, lack of automatic monitoring and reporting capabilities, poor timeliness of water quality monitoring information processing, and lack of early warning capabilities for sudden pollution accidents [2]. At present, there are also automatic monitoring systems that adopt wired telephone dialing communication and wireless MODEM and SMS short message communication to address the above problems. However, they also have problems: the wired telephone dialing system is limited by natural conditions, the wireless MODEM system has limited network coverage and slow data transmission, and the SMS short message system has high operating costs and cannot achieve real-time transmission of monitoring data due to the limitations of communication principles. Therefore, how to effectively and reliably monitor water quality in real time has become a problem that must be solved. To address the aforementioned issues, this paper proposes a design scheme for an automatic water quality monitoring system based on GPRS. This system utilizes GPRS technology and leverages existing mobile communication networks to achieve real-time remote monitoring of water quality in dispersed water areas. It boasts advantages such as being unrestricted by geographical environment, climate, or other factors, having a wide monitoring range, low operating costs, and good real-time performance, making it a promising system for application. 1 System Composition The automatic water quality monitoring system consists of two parts: a water quality acquisition subsystem and a monitoring center subsystem, as shown in Figure 1. [align=center] Figure 1 Framework of automated monitoring system of water quality based on GPRS[/align] The water quality acquisition subsystem mainly consists of a collection of water quality sensors, an A/D converter, a microcontroller, and a GPRS module. The subsystem converts real-time water quality information into analog signals through water quality sensors, then converts them into digital signals through A/D converters and reads them by a microcontroller. The water quality monitoring data is then sent to the primary monitoring center subsystem via the GPRS module for analysis and processing. Emergency plans are activated in a timely manner according to changes in water quality, and early warning information is issued to achieve the purpose of real-time sampling of water quality, timely processing of data, and early warning of water quality changes. The analysis and processing data is stored in the monitoring center database for long-term water quality change analysis, and the water quality information is uploaded to the advanced monitoring center, thus forming a comprehensive and integrated water quality monitoring mode. The key modules and subsystems of the system are described in detail below. 1.1 GPRS Communication Module GPRS is a new bearer service developed on the basis of GSM (Global System for Mobile communication), which can provide high-speed wireless IP for mobile users [3]. GPRS makes full use of the existing GSM network of China Mobile, and has the advantages of high coverage, good real-time performance, high transmission rate, low operating cost, security and reliability and support for IP protocol. It uses packet switching technology, and each user can occupy multiple wireless channels at the same time. The same wireless channel can be shared by multiple users, so it can effectively utilize resources and the data transmission rate is up to 160Kbps. In addition, GPRS adopts full-duplex operation, intermittent transmission and reception, and always-on working mode. It only occupies system resources when transmitting and receiving data, and the billing method is based on the amount of data transmitted[4]. Compared with the SMS short message transmission mode under the GMS network, it has better real-time performance and lower system operating cost. The GPRS module is a key device for wireless communication and is the foundation of the automatic water quality monitoring system. This system selects PIML-900/1800 as the GPRS communication module. This module is a GSM/DCS dual-band module launched by TechFaith Wireless. It has a standard AT command interface, embedded TCP/IP protocol, and can provide GSM voice, SMS short message and GPRS Internet access services. It has a good cost performance and a wide range of applications. The GPRS module and the microcontroller communicate using the standard RS-232 serial interface for data transmission. The monitoring center computer with a fixed IP address accesses the private network provided by the mobile company and logs into the Internet. The GPRS module logs into the GPRS network through the SGSN node, enters the Internet network through the GGSN gateway, finds the monitoring center computer IP for data exchange, and thus realizes the function of remote data transmission. In this system, the water quality acquisition subsystem transmits real-time monitoring data to the monitoring center host computer system through the GPRS network according to specific protocols, and waits for system analysis and processing. 1.2 Monitoring Center Subsystem The monitoring center subsystem is responsible for the analysis and processing of monitoring data from each water quality acquisition subsystem, requiring the server to be connected to the dedicated network provided by the mobile company. On the one hand, it can ensure that the server's IP address remains fixed. Since the IP address connected to the GPRS terminal is unique, when the server's IP address is not fixed, the GPRS module will not be able to connect to the server, thus causing the GPRS module to be unable to transmit monitoring data to the monitoring center subsystem. Currently, public IP can also be used to ensure that the IP address is fixed, but compared with the mobile company's dedicated network, the rental cost of public IP is high, which increases the operating cost of the entire system [5]. On the other hand, using the mobile company's dedicated network can ensure that the server is not interfered with by other terminals with GPRS function. Because only GPRS terminals using dedicated SIM cards provided by mobile companies can log in to the private network, the interference of GPRS terminals using ordinary SIM cards with the monitoring center subsystem is avoided intentionally or unintentionally [6], thus ensuring the safe operation of the system. 2 System Software Design The system software is divided into two parts: the water quality acquisition subsystem software and the monitoring center subsystem software. The water quality acquisition subsystem software is written in C language; the monitoring center subsystem software is written in Visual Basic language. The two parts of the software are described in this paper as follows, with the water quality acquisition subsystem software being the focus of the discussion. 2.1 Water Quality Acquisition Subsystem Software This subsystem does not use the currently common multi-processor hardware design, but instead uses a single microcontroller to handle all tasks independently. When faced with a multi-state, multi-task, and multi-threaded processing problem, the system, without using an operating system, uses the concept of a scheduler to simulate a simple operating system and breaks down the subsystem software into multiple task modules. Each task is further divided into multiple simple steps, which are scheduled and executed according to the needs of the task and the requirements of the designer. The main functional modules of the water quality acquisition subsystem include a keyboard scanning and LCD display module, a GPRS communication module, a signal acquisition module, a data preprocessing module, a real-time clock, and a memory module. This paper details the overall design concept of the subsystem and the design of the GPRS module as follows. 2.1.1 Overall Subsystem Software Design Concept This subsystem is designed based on modular programming principles, using a super loop as the framework and a scheduler as a simplified operating system. It consistently incorporates the design concepts of multi-level tasks and multi-state tasks, constituting the entire subsystem software design. The program flow charts for the super loop and scheduler are shown in Figures 2 and 3. [align=center] Figure 2 Flow chart of super loop[/align] Each functional module is identified by its own identifier, which is set by the system's scheduler. The scheduler is actually a function called within the main loop program. This function uses a timer as the basic time unit and sets different counters with different identifiers based on the different task execution intervals, allowing tasks to be scheduled and run at specific times. To ensure real-time monitoring, time-critical tasks are set as preemptive tasks and executed with priority. Time-consuming tasks with lower time requirements are broken down into multi-level tasks and completed sequentially, thereby reducing latency and keeping the main loop time within a few milliseconds, ensuring the system runs quickly and smoothly. [align=center] Fig 3 Flow chart of scheduler[/align] 2.1.2 GPRS Module Design Since the system uses a PIML-900/1800 dual-band GPRS module with SMS and GPRS internet access capabilities, GPRS communication can operate in two modes: timed transmission mode and central call sign mode. Based on the requirements for real-time water quality monitoring, this system selects the timed transmission mode. In this mode, after the GPRS module is powered on, it initializes, logs into the GPRS network, and successfully connects to the data center, transmitting real-time monitoring data at regular intervals (minutes). Because the GPRS terminal automatically disconnects when connected to the network without data transmission (the disconnection time is determined by the mobile network), the concept of a GPRS heartbeat packet is proposed to ensure the GPRS terminal remains online. The GPRS heartbeat packet is sent to the monitoring center by the GPRS terminal every 4 minutes. Upon receiving the heartbeat, the monitoring center responds, ensuring the GPRS terminal remains online. If the GPRS terminal disconnects, the water quality acquisition subsystem automatically re-logs into the monitoring center system, resuming its online status and enabling real-time data transmission for water quality monitoring. The GPRS module requires a certain waiting time between establishing a connection, sending data, and receiving data. If an operation is completed during this waiting period, the system will be idle. Therefore, this subsystem adopts a multi-tasking approach, breaking down the module's task into seven short steps. Each module operation only needs to complete one step, releasing CPU resources for other tasks. The next step is completed during the next module access, until all steps are completed. This satisfies the waiting requirements of the GPRS chip while reducing the time consumed in a single loop, allowing access to other modules and improving system efficiency. The GPRS module communication flow is shown in Figure 4. A simulated timer is set between two steps; the system does not allow the next step to be performed before the timer expires. This simulated timer is nested within the scheduler. 2.2 Monitoring Center Subsystem Software The monitoring center subsystem software mainly includes functions such as GPRS data reception/transmission, database, reports, graphs, and data export. The monitoring center computer maintains a connection to the dedicated network, receives data sent back from each water quality acquisition subsystem, and parses the data packets according to specific protocols. The parsed data guides the monitoring system in performing heartbeat responses, analyzing and processing water quality data, and activating emergency plans and issuing early warning information in a timely manner based on water quality changes. The database function is used to store and manage water quality monitoring data from each monitoring point and each river basin. Furthermore, databases at all levels share data resources, which not only facilitates centralized and unified management of water quality monitoring but also ensures comprehensive and integrated water quality monitoring. The report and graph functions vividly reflect the water quality changes at each monitoring point, in each water area, and in each river basin, facilitating accurate judgment of water quality changes and providing decision-makers with real-time and accurate water quality change information. The data export function is used to output paper data to a designated printer for easy archiving and management. [align=center]Fig. 4 Flow chart of communication of GPRS module[/align] 3 System Performance Testing and Analysis To test the overall performance of the system, a trial run was conducted on a section of a canal. The system sampled, transmitted, and analyzed the water quality every 5 kilometers along the section. During system testing, considering various factors that might affect the system's transmission performance, data transmission recording experiments and performance analyses were conducted for different time periods, data lengths, and the number of monitoring points. The system monitoring performance indicators are shown in Table 1. The test results show that the data transmission performance is good in a primary monitoring center at the city level, the system operates stably, data processing is timely, and monitoring accuracy is high; from the perspective of wireless transmission, the GPRS transmission rate is 3 times faster than a wireless MODEM and the operating cost is 47% lower than that of SMS. The overall performance of the GPRS wireless transmission system is superior to that of the wireless MODEM and SMS systems. Table 1. System Monitoring Performance Indicators [/align] 4. Conclusion This study designed a GPRS-based automatic water quality monitoring system, which has the advantages of wide water quality monitoring sampling range, data transmission without geographical or climatic limitations, timely data processing, and timely early warning of water quality changes. Utilizing GPRS communication technology, it monitors water quality changes in real time, providing comprehensive and real-time water quality monitoring information to environmental monitoring departments. Furthermore, the system has low operating and maintenance costs, saving significant manpower, material resources, and financial resources. The system has been piloted in a section of a canal, demonstrating stable and reliable operation, high economic and social benefits, and promising application prospects. References: [1] Wu Hongyan. The role of water quality monitoring in water resource protection [J]. Journal of Electric Power Engineering, 2007, 22(4): 509-511. [2] Huang Yi, Li Jie. Real-time remote monitoring system for water plants based on GPRS [J]. Journal of Hefei University of Technology (Natural Science Edition), 2008, 31(5): 705-707. [3] Zheng Wanxi, Huang Yuanqing, Zhang Xin et al. Remote detection system based on GPRS communication technology [J]. Sensors and Microsystems, 2008, 27(2): 83-85. [4] Tang Huiqiang, Xu Fang. Automatic water condition monitoring instrument based on GPRS [J]. Instrumentation Technology and Sensors, 2008(1): 74-76. [5] Ding Hui. Research on the application of GPRS technology in power SCADA system [J]. Electrical Measurement and Instrumentation, 2007(8): 25-28. [6] RJ (Bud) Bates. General Packet Radio Service (GPRS) Technology and Applications [M]. Beijing: Posts & Telecom Press, 2004, pp. 35-47.