When should we introduce the engineered bacteria and activate the light-on killing system are questions keeping bothering us. Also, traditional water detection method has the defects such as long cycle time and inaccuracy, making it hard to maximize the function of our engineered bacteria. Therefore, software compatible with the iTube is needed to solve these problems. With Python and Matlab, we build a software integrating data acquisition and modeling to control the iTube and the behavior of the bacteria.

GUI Design

Figure1 GUI

Figure 1 shows the software interface which is based on pyQT, an open-source library for GUI coding. The data including temperature, pH, ORP and electrical conductivity is collected by the analog sensors on iTube which streams those values through serial port. Finally, real-time plotting will be displayed on the right widget. On the left widget, we implemented LED only for the purpose of demonstration. But actually, in the real scenario, LED control will be replaced by water-quality prediction model and we will discuss this later.

Prediction Model

Data Sample

Corrosion is a process caused by multiple factors. To better predict the corrosion rate of a pipeline, temperature, pH, electrical conductivity and alkalinity are chosen as the input of the neural network based on the analysis of their importance to the corrosion process, while the corrosion rate is the output. All the sample data ranging from 2016 to 2018 are collected from a petrochemical company and a steel company.

Neural Network Configuration

Network Architecture

The water quality related data is actually a time series sequence, and NARX neural network is applied in this study considering it is a suitable predictor for dynamic nonlinear system. And also given the availability of past water quality data, series-parallel architecture is ideal for the model.

Figure2 NARX Architecture
Figure3 Cost Function

Network Sturcture

After several modification and testing, 1 hidden layer and 15 neurons in the hidden layer has the best performance and minimal MSE.

Prediction Performance and Discussion

Figure 3 shows the cost function. Though the model is useful in certain circumstances, it varies from factory to factory. Before the implementation of the model, data from certain factory should be obtained and retrained for the best performance of the prediction.


Q. Gao et al., "The Research of the Water Quality Prediction Model for the Circulating Cooling Water System", Applied Mechanics and Materials, Vols. 385-386, pp. 408-411, 2013