Design of On-line Water Quality Monitoring System

Water is the source of human life. However, a large amount of domestic sewage, industrial wastewater and agricultural wastewater produced in human production and life pollute the surface water, threatening normal production and life of people.In order to grasp the water quality fully, the temperature, PH. turbidity and conductivity sensors are adopted to collect various water quality parameters, and necessary software and hardware design of the on-line water quality' monitoring system is completed to provide a basis for subsequent water quality monitoring in various industries.


Introduction
Water is the natural resource for the survival of mankind and is of great significance to human production and life. In recent years, with the vigorous development of mankind, domestic sewage, production wastewater and various wastes discharged from agricultural production are directly discharged into water bodies without treatment, which causes serious pollution of rivers, lakes and groundwater, further leads to serious deterioration of the water quality in the area, affects the normal life of residents and causes ecological unbalance. Therefore, mastering the quality of current groundwater or discharged wastewater is of great significance to maintai ecological balance and meet daily needs of people.
Further, it's particularly important to strengthen the monitoring and management of the water quality under the situation of relatively prominent water pollution. The on-line water quality monitoring system provides an important basis for the follow-up environmental governance. This paper will provide the design of the on-line water quality monitoring system. The details are described as follows:

Selection of sensors
Water quality monitoring is a huge project. The water quality is not only related to organic matters, inorganic matters, bacteria and other pollutants contained in water, but also related to water temperature, PH value, conductivity, sludge concentration, etc. Therefore, in addition to determination of microorganism and pollutant content, it's necessary to determine temperature, PH value, conductivity, turbidity and dissolved oxygen content to achieve the water quality monitoring. The above sensors should be provided for the on-line water quality monitoring system.

Selection of temperature sensor
Theoretically, the physical and chemical properties of water are closely related to its temperature. Furthermore, the temperature of water is generally related to its source. Under normal conditions, the temperature of groundwater in China is generally maintained at about 10℃, and the temperature of the groundwater varies widely with the season and the climate. The industrial wastewater has high temperature, often leads to the decrease in the content of the dissolved oxygen. At the same time, the increase in the water temperature will promote the oxygen loss rate, leading to the decrease in the oxygen content of the water bodies and ultimately the deterioration of the water quality. Therefore, the water temperature is also a key factor affecting the water quality [1] .
So the WQ101 temperature sensor is selected to monitor the water temperature in the scheme. The monitoring range of the sensor is -50℃-50℃, and the monitoring accuracy of the sensor is ±0.1℃.

Selection of PH value sensor
PH value is an indicator of acid and alkali, and the PH value of the water quality is related to the amount of substances contained in it. Therefore, the PH value can show the water quality more intuitively. Under normal conditions, the pH value of sewage is generally between 6.5 and 7. At present, the colorimetric method and the potentiometric method are often used in the industry to determine the PH value of water. Among them, there is a large error in the colorimetric method where automatic measurement cannot be achieved; the PH value can be determined accurately and rapidly in the potentiometric method, and the measurement result is less affected by water chromaticity, turbidity and reducing agents. Therefore, the WQ201 PH value sensor is selected in the scheme, the measuring range of the sensor is 0-14, and the measuring accuracy is ±0.1.

Selection of conductivity sensor
The conductivity reflects the current conducting capability of the measured water body. Under normal conditions, when the water body does not contain any substance, its corresponding conductivity is very low; when it contains a certain amount of alkaline substances or inorganic acids, its corresponding conductivity will increase significantly. The total concentration of ionic components in the measured water body can be obtained by conversion through determination of the conductivity parameter of the water body. Theoretically, the conductivity of the water body is related to factors such as the type, concentration, temperature and viscosity of ions contained [3] .
Under normal conditions, the conductivity sensor often adopted in the industry is composed of a conductivity cell system and a measuring instrument. The specific model of the conductivity sensor selected in the scheme is WQ301. It is a current measuring conductivity sensor with the measuring range of 0-5000μs and the measuring accuracy of ±1%.

Selection of turbidity sensor
Turbidity is an indicator reflecting the sensory and physical properties of the measured water body. The indicator mainly reflects the obstruction degree of the suspended solids to the light going through the measured water body. Under normal conditions, the turbidity of the water body is mainly related to the content of the suspended solids in the water; in addition, the indicator is further related to the components, size and shape of the suspended solids in the measured water body. At present, the most widely used method for determining the turbidity of the water body in the industry is nephelometry where the turbidity of the measured water body is converted by determining the intensity of scattered light.
The WQ700 turbidity sensor is selected to measure the turbidity of the water body in the scheme, with the measuring range of 0-200NTU and the measuring accuracy of ±1%.

Selection of dissolved oxygen sensor
Dissolved oxygen is the content of the oxygen in the measured water body and is one of the necessary conditions for the survival of aquatic lives. Under normal conditions, the dissolved oxygen of the measured water body is related to the atmospheric pressure in the area, the temperature of the measured water body and the salt content of the water body. At present, the automated colorimetric microassay and chemical analysis methods, paramagnetic methods and electrochemical methods can be adopted to measure the content of the dissolved oxygen in the water body [2] .
Considering the stability of the sensors, the maintenance convenience and the measurement accuracy, the scheme selects the WQ401 dissolved oxygen sensor with the measuring range of 0-100% and the measuring accuracy of ±0.5%.
In summary, the performances of various types of the sensors selected in the scheme are shown in Table 1:

Hardware design of on-line water quality monitoring system
The section will mainly provide the design of the hardware of the on-line water quality monitoring system. To ensure that the designed on-line water quality monitoring system has high reliability and the equipment has good performance, the following principles should be followed during design of the hardware of the on-line water quality monitoring system [4] .
(1) The designed on-line water quality monitoring system has the energy-saving mode, i.e. the system hibernates in the non-action state; (2) The designed on-line water quality monitoring system has abundant extension modules to facilitate following extension of the system functions; (3) The power performance of the designed on-line water quality monitoring system meets the actual use requirements, and the system further has enough analog acquisition channel.
Based on the hardware requirements of the on-line water quality monitoring system and comparison of extension modules, analog acquisition channels and power performances of the microcontrollers, the MSP430F149 microcontroller is finally adopted as the core control hardware of the on-line water quality monitoring system.
The hardware design of the on-line water quality monitoring system is completed based on MSP430F149 microcontroller, including design of the single chip microcomputer circuit and design of the power circuit

Design of the single chip microcomputer processing circuit
The main task of the single chip microcomputer processing circuit of the on-line water quality monitoring system is to transmit the analog quantity collected by the system to the GPRS module through the serial port [7] . The single chip microcomputer processing circuit shown is designed according to the task requirements of the on-line water quality monitoring system.
The MSP430F149 module package has three clock sources of high-speed crystal, low-speed crystal and digital control oscillator DCO. Therefore, three sets of button switches and three light-emitting diodes are designed in the single chip microcomputer processing circuit to match the above three clock sources of the MSP430F149 module. The functions of the three button switches in the single chip microcomputer processing circuit are to reset the single chip microcomputer, reset the GPRS module and complete the redial operation in time when the GPRS module has the disconnection fault [5] .
In addition, in order to ensure that the on-line water quality monitoring system can still work normally and stably after the software has the problem of run-out or dead circulation, the watchdog timer is added to the single chip microcomputer processing circuit, so that the crash fault of the on-line water quality monitoring system can be avoided.

Design of the power circuit
According to the power requirement of the MSP430F149 module adopted by the on-line water quality monitoring system, the control module and the GPRS module should be powered, and the supplied voltage classes are 3.3V, 4V and 5V. Wherein, 3.3V is the typical working voltage of the MSP430F149 module. Therefore, based on the above power requirement analysis, the LD1117 chip selected by the scheme is the power chip, and finally the power chip in SOT-223 package type is selected [6] .
Besides, SIM300C has high requirements for the power current characteristics due to the fact that the instantaneous current cannot be less than 2A during normal work. Therefore, the power chip in TO-220-5 package type is specially selected for SIM300C. The maximum current that can be supplied by the chip is 3A and can be applicable to normal stable work of SIM300C and meet its power requirement.
The power circuit principle of the on-line water quality monitoring system is shown as Figure 1:

Design of A/D interface circuit
The on-line water quality monitoring system measures the continuously variable analog of the measured water body through the sensor and converts the measured analog signals into the digital quantity through A/D conversion. The obtained digital quantity can be processed and controlled by the MSP430F149 module. The MSP430F149 module is provided with six-way analog input channels according to the type of the sensors provided in the earlier stage.
Therefore, the A/D interface conversion circuit should be designed according to the analog to digital conversion requirement of the on-line water quality monitoring system, the designed interface conversion circuit includes three lines and six ground terminals, and its schematic diagram is shown as Figure 2:

Software design of on-line water quality monitoring system
The core controller of the on-line water quality monitoring system designed in the paper is the MSP430F149 microcontroller which is a 16-bit single chip microcomputer. Considering the program compatibility, the C programming language is selected for its programming design.

Functional requirements of the on-line water quality monitoring system
In combination with the expected effect of the on-line water quality monitoring system designed in the paper, it's required to monitor the water quality of the surface water or sewage and display the monitored data on the computer. Therefore, the on-line water quality monitoring system is required to meet the following functions: (1) The system can collect the temperature, PH value, turbidity, dissolved oxygen, conductivity and other parameters of the surface water or the sewage in real time; (2) After the collected water quality information is uploaded to the upper computer, the upper computer encodes and registers the data for later use of the collected data; (3) The on-line water quality monitoring system is required to achieve remote computer control and management based on the GPRS module. That is, the operator can control the on-line water quality monitoring system on the upper computer of the remote computer to achieve the purpose of remote control; (4) The IP address of the upper computer of the remote computer can be managed and modified according to the actual demand through the on-line water quality monitoring system [8] .

Overall design of the software of the on-line water quality monitoring system
The overall design of the software of the on-line water quality monitoring system is the design of its main program. According to the task requirements of the system, the main program is required to perform coordination processing and data interaction on the modules in the system. When the system is powered on, it should be initialized first, including clock setting, ADC initialization, timer initialization, initialization of UART0 and UART1, etc. After the above initialization work, SIM300C can be started. The main program flow of the software of the on-line water quality monitoring system is shown in Figure 3: As shown in Figure 3, after end of the system program initialization, judge whether P2.1 is at low level, modify the system parameters when P2.1 is at low level; otherwise establish connection with the management computer of the system. When the system is successfully connected with the management computer, continue operation according to the flow chart till system hibernate [9] .

Design of upper computer management software
Based on the principle of friendliness and clear expression, it's required that users can use the on-line water quality monitoring system more conveniently, and all the functions of the system can be called on the main interface of the upper computer management software, including five modules of system management, administrator, enterprise object management, database management and query and help.
The system management module includes server settings, IP address modification, data accepting and user login and logout; The management module includes three functions of adding an administrator account, editing an administrator account and deleting an administrator account; The enterprise object management includes adding, editing and deleting of the cutting objects; The database management and query include importing, exporting and querying of the enterprise object data [10] .
The main interface adopts MDI window in the form of drop-down menu and tool bar, so that the users can call various modules conveniently. In addition, CommomDialog software is adopted on the main interface window to facilitate the import and export of the enterprise data. The main interface of the on-line water quality monitoring system is shown in Figure 4:

Summary
In recent years, China has paid more and more attention to environment protection, especially the protection of water resources. However, the vigorous construction of factories and exploitation of mineral resources like coal mines have caused serious damage to the water resources and even serious ecological imbalances in today's era of rapid global development, resulting in worse and worse water quality. Therefore, strengthening monitoring and management of the water quality is of great significance to ensuring daily production and life. The on-line water quality monitoring system is designed based on the MSP430F149 controller, the temperature sensor, the PH sensor, the turbidity sensor and other sensors are utilized to collect water quality parameters, and the on-line water quality monitoring system is controlled through the single chip microcomputer processing circuit, the power circuit and the A/D control circuit and subjected to commissioning and control through the upper computer interface. Meanwhile, the design of the main program and upper computer management software of the corresponding monitoring system is completed in combination with the functional requirements of the on-line water quality monitoring system, and the system is commissioned and controlled through the upper computer interface. This paper aims at providing the on-line water quality monitoring system for monitoring the quality of surface water and sewage to provide a basis for subsequent water quality management.