Design of multi-parameter water quality monitoring system based on Internet of Things
[Copy link]
This post was last edited by Maoqiu Dada on 2022-1-28 17:28
Abstract: In order to solve the problems of time-consuming and labor-intensive traditional water quality monitoring, low sampling accuracy, and difficulty in data statistics, a multi-parameter water quality monitoring system based on the Internet of Things was designed. The system uses the STM32 microprocessor as the control core, and collects data on water temperature, turbidity, pH value, and TDS value by controlling the internal ADC acquisition channel. It communicates with the Internet of Things platform server through the esp8266 module , and transmits data with the LabVIEW host computer through the serial port. At the same time, users can monitor and warn water quality parameters through three methods: OLED screen, mobile phone App, and LabVIEW host computer. Experiments have shown that the system is stable and reliable, the human-computer interaction interface is simple and convenient, and the measurement accuracy is high.
With the progress and development of society, people are paying more and more attention to the quality of water for drinking, domestic and aquaculture. However, in recent years, water pollution has frequently occurred, which has posed a great threat to industrial and agricultural production and people's health[1]. Therefore, it is very necessary to grasp the specific conditions of water bodies in a timely manner[2].
In the past, water parameters were usually measured and recorded manually, which was time-consuming and laborious, and the collected data was accidental, which was not conducive to comprehensive analysis of water quality. Therefore, a water quality monitoring system based on the Internet of Things was designed. The system can monitor the temperature, turbidity, total dissolved solids (TDS) and pH of the water in real time, and upload them to the Lab VIEW host computer to generate a change curve [3-5].
At the same time, the water quality information is transmitted to the Gizwits IoT platform server through the WiFi module [6]. Users can view the specific values of water quality parameters through three methods: OLED display, mobile phone app, and Lab VIEW host computer. This system uses IoT technology to solve the limitations of time and space, making it easy to view water quality at any time and place, and has high research value.
1 System overall structure design
The lower computer of the water quality monitoring system based on the Internet of Things works around the STM32 microcontroller; the four sensor modules of temperature, turbidity, TDS, and pH are used to collect water parameter information; the OLED display module is used to display the specific values of water parameters on site; the USB to serial port module is responsible for data transmission between the serial port and the upper computer; the cloud server is responsible for receiving and sending data transmitted by the WiFi module; the mobile phone App is responsible for remote monitoring of water quality parameters; the Lab VIEW upper computer is responsible for computer-side water quality data monitoring and providing alarm services. The overall structure of the system is shown in Figure 1.
Figure 1 Schematic diagram of the overall system structure
First, the ADC inside the STM32F103C8T6 microcontroller converts the analog signals collected by the pH, turbidity and TDS sensors into digital signals. Since the output of the temperature sensor is a digital signal, no A/D conversion is required. The MCU sends the converted digital signal to the internal data buffer, uses the serial data bus to transmit the data to the OLED display for real-time display, and transmits the data to the Lab VIEW host computer through the USB to serial port module. At the same time, the MCU sends the data to the WiFi module through USART3, and the WiFi module sends the data to the Gizwits IoT platform server through the TCP/IP protocol for storage. At this time, the mobile phone App can receive data information from the server by registering and logging in to bind the device, so as to view the water quality parameters.
2 System Hardware Design
2.1 STM32 MCU
The main control module uses the STM32F103C8T6 microprocessor, which has low power consumption, low cost and rich functions [7]. Its core is the 32-bit Cortex-M3 CPU based on the ARM architecture, with a maximum main frequency of 72MHz. It has 64 kB Flash, 20 kB SRAM, 2 12-bit ADCs, 16 ADC acquisition channels, 9 on-chip communication interfaces, and 37 fast I/O ports, so it is widely used in various low-cost embedded products.
2.2 Turbidity sensor module
The turbidity sensor uses the TSW-30 turbidity module. The module has a power supply voltage of 5V, a maximum operating current of 40 mA, and an operating temperature of -20 to 90°C. Because the module collects analog signals, it needs to be converted into digital signals by the built-in ADC of the STM32 microcontroller before it can be read and used by the MCU. Here, channel 1 of ADC1 of the STM32F103C8T6 is selected to collect turbidity parameters, and its corresponding microcontroller pin is PA1. The wiring of the turbidity sensor and the main control module STM32 microcontroller is shown in Figure 2.
Figure 2 Turbidity sensor wiring diagram
2.3 pH sensor and temperature sensor module
The pH electrode model for measuring the pH value of water is E-201-C. The module is powered by 5 V, has a pH value range of 0-14, an operating temperature range of 0-60°C, a measurement accuracy of ±0.1 (20°C), and a response time of less than 1 min. Since the pH value is greatly affected by temperature, temperature compensation is usually required, so the module comes with a temperature sensor connected to pin T0. The wiring of the pH value sensor and the main control module STM32 microcontroller is shown in Figure 3, where pin PA0 is the acquisition channel 0 of the STM32 microcontroller ADC1.
Figure 3 PH sensor wiring diagram
Under normal circumstances, the water temperature will not change much. If the water temperature changes dramatically, it is usually due to water pollution, so the water temperature is also an important indicator for evaluating water quality. The temperature sensor uses a DS18B20 module, which is powered by 3.3V and can detect temperatures up to 125℃ and as low as -55℃, with a measurement accuracy of ±0.5℃. The connection between the temperature sensor and the pH sensor is shown in Figure 4.
Figure 4 Temperature sensor wiring diagram
2.4 TDS sensor module
The TDS value of water body is measured by SEN0244 analog TDS sensor module. The power supply voltage of this module is 5 V, the working current range is 3-6 mA, the analog signal output voltage range is 0-2.3 V, the TDS measurement range is (0-1000)×10-6, and the measurement accuracy is ±5%. The wiring of TDS sensor and main control module STM32 microcontroller is shown in Figure 5. The PA2 pin corresponds to the acquisition channel 2 of ADC1 of STM32 microcontroller.
Figure 5 TDS sensor wiring diagram
2.5 OLED Display Module
Since the system needs to display numbers, English and Chinese characters, a 2.4384cm OLED display is selected. This display uses IIC communication and only needs to connect 4 pins to use, which is very convenient. Its connection with the STN32 microcontroller is shown in Figure 6.
Figure 6 OLED display module connection diagram
2.6 Wi Fi and serial communication module
The Wi Fi module uses the ESP8266-12F module of Essence. The module is compatible with 3.3 V and 5 V voltage inputs. Here, VCC is connected to 3.3 V power supply, GND is grounded, GPIO0 is connected to a 1 kΩ pull-up resistor and is set to the working mode by default. The TXD serial port sending pin is connected to the receiving pin PB10 of the microcontroller USART3, the RXD serial port sending pin is connected to the sending pin PB11 of the microcontroller USART3, and the RST reset pin is connected to a 1 kΩ pull-up resistor by default, which is valid when the level is low. The Wi Fi module circuit is shown in Figure 7.
Figure 7 WiFi module circuit
Since the communication methods between the host computer and the STM32 microcontroller are different, a USB to serial port module is required to realize the communication function between the two. The TXD and RXD pins of the module are connected to the RXD and TXD pins of the STM32 microcontroller US-ART1, so as to transmit the data in the internal data buffer of the MCU to the host computer. The USB to serial port module circuit is shown in Figure 8.
Figure 8 USB to serial port module circuit
3 System Software Design
3.1 Main control module software design
The development tool for the system main control module software is Keil μVision5, and the programming language is C language. The main control module software mainly includes system initialization program, timer interrupt program, sensor signal acquisition program, OLED display program, and Wi Fi transmission program. When the system is powered on, it will first perform initialization operations on each module of the system, that is, perform hardware driver initialization. After the initialization is completed, the sensor module will be called to collect water body data. The collected data will be displayed on the OLED display and LabVIEW host computer after being processed by the MCU. At the same time, if the current Wi Fi connection is normal, the Wi Fi module will send the data point protocol message processed and encapsulated by the MCU to the Gizwits cloud platform server. At this time, you can log in to the Gizwits mobile phone App to view various water quality information in real time. The overall process of the system software is shown in Figure 9.
Figure 9 System software overall process
3.2 Host computer software design
The system host computer software is developed based on Lab VIEW. The host computer display interface uses a graphical method to display the measured water data. The operation interface is also very friendly and simple. Serial communication is used to realize data transmission between the STM32 microcontroller. The system host computer can be divided into two parts: parameter value display and parameter warning setting. The former is used to display the specific values and curves of the current pH, TDS, turbidity, and temperature, so that users can understand the specific situation of the water quality as a whole; the latter is used to set the upper limit of water quality parameters and the storage location of water quality data, and provide water pollution alarm services to remind users to take measures to suppress water pollution. The program flowchart of the host computer is shown in Figure 10.
3.3 Design and implementation of cloud platform and App
Since it is costly and difficult to build a server independently, the Gizwits A iot development platform was selected as the server of the system. Gizwits is a development platform dedicated to the Internet of Things, software and hardware cloud services. The development tool of the water quality monitoring system App is Android Studi. In order to make it easier for users to develop mobile apps and connect with cloud servers, Gizwits provides a set of open source frameworks for Apps. The communication function between Apps and cloud servers has been completed within the framework. Users only need to perform secondary development on this framework according to their own functional requirements.
Figure 10 Partial flowchart
After the user opens the mobile app, the user will be prompted to register. After completing the registration operation, the ESP8266 Wi Fi module will enter the Air鄄Link mode, and then the mobile app will search and bind with the current device. At this time, the system will access the wireless local area network and communicate with the server. The App display interface is shown in Figure 11.
Figure 11 APP display interface
4 System Test Results and Analysis
In order to ensure the accuracy of data collected by the water quality monitoring system, the system needs to be actually tested. The operation of the lower computer is shown in Figure 12.
In the test, the PH-100 high-precision pH test pen was selected as the standard detection instrument for pH value; the SGZ-1000BS portable turbidity meter was selected as the standard detection instrument for turbidity; the Gree TDS test pen was selected as the standard detection instrument for TDS and temperature; the laboratory was selected as the test site, 3 cups of tap water were collected, and then buffer solution with a pH value of 4.0, phosphorus-containing fertilizer, dry soil and 90°C boiling water were added to the 3 cups of tap water from small to large amounts as the test solution, the test solution was fully stirred and allowed to stand for 10 s, and then tested using the standard detection instrument and the system in this paper respectively. The test data obtained are shown in Table 1.
Figure 12 Lower computer operation
Table 1 Water quality parameter test data
Note: NTU (nephelometric turbidity unit) is nephelometric turbidity unit.
In the table, the data detected by the standard testing instrument are standard values, and the data measured by this system are measured values; the three data of each parameter correspond to the tested solutions with increasing degrees of contamination from top to bottom.
After experimental verification, the error between the water quality parameters measured by the designed system and the standard value is within 3%, and the upper computer operation display results are the same as those of the lower computer, which shows that the system can stably detect various water quality parameters. The upper computer operation interface is shown in Figure 13.
Figure 13 Host computer operation interface
5 Conclusion
Through experimental verification, the designed multi-parameter water quality monitoring system based on the Internet of Things can operate stably and can realize real-time monitoring of water quality parameters in various ways. The system cost is low and the measurement accuracy is high. In addition, the Lab VIEW host computer human-computer interaction interface is simple to operate and has rich functions. The mobile phone App display interface is relatively intuitive. The system can meet most of the user's needs. The system can also be applied to fields such as aquaculture that require water quality monitoring, and has a strong application prospect [8].
|