2.1. Electrochemical Probes and Mobile Sensors
A system to monitor environmental and water quality parameters becomes more efficient if it does not require chemical reagents for the measurements [
9]. Therefore, the advantages of a monitoring system with electrochemical probes are notorious compared to other more traditional methods (sample collection and transportation to a laboratory, pretreatment processes and use of reagents) to obtain the final measurements [
14]. In general, to monitor the environmental contamination requires portable sensors with rapid response, robust with sufficient sensitivity, and long service life. Among some aspects that should be taken into consideration when choosing electrochemical sensors are: selectivity, concentration range, calibration precision, measurement response time, and technological availability disposable, reusable, or renewable sensors [
24].
The electrochemical devices that are used for environmental monitoring are: amperometric or voltammetric, potentiometric, and conductometric. The first group is based on the application of a potential through two electrodes in order to oxidate or reduce electroactive species. In this case, the resultant current is measured. This measurement method is used for the dissolved oxygen probes. For the potentiometric sensors, an electrode or membrane potential is measured when a local equilibrium is reached at the sensor interface. In this second case, the potential difference informs us about the composition of a sample. Typical examples of such as devices are in situ pH or pCO
meters. Finally, conductometric sensors are related to the measurement of conductivity at different established frequencies [
25].
In the study area, we located three unique zones through which the San Pedro River flows: agricultural, industrial and residential (see
Table 1). The factories were the first to reach the river banks a few decades ago and began to discharge their waste directly into the river. After the arrival of the factories to the San Pedro river basin, the population also began to grow, contributing with its waste to a greater contamination of the river. Both sources of wasterwater have common water quality characteristics such as dissolved oxygen (DO), electrical conductivity, and water temperature, dissolved oxygen being the the key parameter. If the DO concentration were in between 5 and 8 mg/L, water could be considered acceptable for most fish and other aquatic organisms while if the concentration were less than 5 mg/L, there would be a great risk of disappearance of organisms and sensitive species [
26].
In this work, an electrochemical probe to measure the dissolved oxygen, an electrical conductivity probe for the estimation of total water salts, and an air temperature and percent of relative humidity sensor based on integrated circuits were used (see
Figure 2). The dissolved oxygen probe includes a polyethylene membrane, a cathode, and an anode immersed in an electrolyte. The oxygen molecules that diffuse through the membrane at a constant rate [
27] are reduced at the cathode and a voltage is produced. If there are no oxygen molecules, the probe will measure 0 mV. As the dissolved oxygen increases, the output measurement of the probe will also increase. The measurement of water temperature in the river was performed by using the integrated circuit device of the LM35 series. The LM35 device does not require any calibration or trimming to provide an accuracy around
C at room temperature and
C on the temperature range from
C to 150
C. Humidity measurements were obtained with a DHT11 integrated circuit device, which includes a resistive type humidity sensor, and a negative temperature coefficient for temperature measurement. This sensor was connected to a high performance 8-bit micro-controller, hence offering good quality measurements with a quick response, interference reduction, and low cost. Each DHT11 measuring device was carefully calibrated in the manufacturer laboratories to obtain accurate measurements of humidity. The calibration coefficients were stored in the OTP (One-Time-Programmable) memory, which was used by the sensor for each measurement [
28]. The technical specifications of the probe and sensors can be seen in
Table 2.
The monitoring campaigns were carried out following the order of geographical positions of the stations, starting from ST1 to ST9 (see
Table 3). The sampling dates were chosen according to the climatic conditions that allowed access to the monitoring stations, and to the administrative permissions to access the sites by the landowners of factories or housing complexes. At each monitoring site, the following activities were performed: (1) calibration of the dissolved oxygen probes and the conductivity meter for the actual environmental conditions, considering particularly the ambient temperature, as this affects the second calibration point of the dissolved oxygen probe; (2) setting up the prototype, probes and sensors in a safe place, in such a way that the probes can be extended up to a distance of 1 m between the river border and the water; (3) starting the measurement program at least 10 s after having inserted the probes into the water, so that the transient measurements at the starting time periods can be released; (4) stopping the information recording program at least 10 s before removing the probes from the water; and (5) verification of the data collection, cleaning up probes and sensors with distilled water, and cleaning up with towel paper the solid part of the measurement system.
Mobile Sensor
Generally, in a water quality monitoring program, the monitoring objectives are established, indicating the variables that are to be investigated, the monitoring sites and when these measurements will be made. It is also necessary to know how the collection of samples will be carried out, what tools will be necessary for the analysis, and then the interpretation of the results [
29]. The provision of a mobile prototype that allows online samples to be collected at any point in the study area and stored for later analysis is beneficial since it facilitates monitoring tasks. Although the monitoring sessions could be of short duration, the sum of all the sets of samples will allow forming databases with which studies of spatio-temporal trends of the variables of interest can be carried out. In the present work, micro-controlled devices were used, such as Arduino-Mega 2560 for the acquisition of data from the probes, GPS NEO 6M (Global Positioning System) for capture latitude, longitude, date and time during each monitoring session, and ESP8266-12E for the wireless transmission of information. This data set constitutes important information that could be stored for every campaign where it could be sent to the cloud for remote analysis or be stored in local form through a laptop and make a database of pollution water data. The portability of this prototype is due to some features as its battery durability, low weight, low cost, an easy software to manipulate, and simple calibration process.
In the market, there are multiparameter probes that allow for measuring water quality variables and datalogger to capture the information locally or remotely. These devices are very expensive for multiparameter measurements even without the availability of procedures for data analysis. In contrast, current-microcontrolled devices are cheap, easy to program, providing great versatility of applications to users and can also be adjusted to specific needs once they are coupled with medium-cost electrochemical probes. Thus, the great advantage of having electronic devices with their own software to perform the tasks of water quality monitoring is evident, which is moreover sensitive to the needs of researchers.
2.2. Electrochemical Probes and Mobile Networks
The prototype developed in this work is depicted in
Figure 3. The measurements of the five variables are made at each monitoring site through a microcontroller electronic system (Arduino Mega 2560, GPS NEO 6M, ESP8266-12E, 12 V battery, control software created by ourselves to capture data and frame formation periodically) and the electrochemical probes. These five variables then adhere to the location information of the GPS, the date and the time duration of the measurements for each monitoring site. Therefore, the final data set (Frame) consists of the following variables:
Sample number,
Latitude,
Longitude,
Year, month, day, hour, minute, second,
Water temperature,
Dissolved oxygen,
Air temperature,
Percentage of relative humidity,
Water electrical conductivity.
The sampling period was approximately 35 s and the average sampling time at each site was 12 min. This sampling time per session was not constant due to the difficulties of the place access, the vegetation that impeded the reception of the GPS signals and the limitations of the dissolved oxygen sensor whose membrane was saturated after an exposure time greater than 12 min for the waters of the San Pedro River. The final data set can be sent wirelessly to a mobile phone and then to the cloud for backup storage. You can also send the information through the Arduino serial port to a laptop and thus form a local database.
We have developed a software (for Arduino) to capture data and shape the frame to transmit it through the serial port, either to send it to the cloud through the wireless system (ESP8266-12E) thus forming a remote monitoring network of water quality and environment variables, or to transmit it directly via serial cable to a laptop that is a few meters from the monitoring site. It should be noted that one of the advantages of this prototype is its portability that allows several measurements in a single day, taking care of the corresponding calibrations in each monitoring site.
Table 3 shows the summary of the monitoring campaigns carried out and the measured variables. It is important to point out that from 15 to 19 of November 2017, measurements of the river temperature (
), concentration of dissolved oxygen in the river water (DO), ambient temperature (
) and percentage of relative humidity were performed. The conductivity were not measured in this time period because the probe was not available yet. It is also relevant to remark that weather conditions in the study are unique. For example, in a single day, we could have a pleasant climate of 15
C without wind and rain, in the morning. In the afternoon, at about 2:00 p.m., the temperature could rise to 27
C with dry air, and approximately at 4:00 p.m. the temperature could drop to about 10
C and experiencing heavy rain. Therefore, it was necessary to carry out the measurements in that time span since the weather was more stable; however, on 15 and 22 of November 2017, it was raining. Additionally, from 22 November 2017 to 4 December 2017, measurements of five variables were carried out, including the water electrical conductivity. A field campaign description is provided in
Figure 4.
Because the field campaigns were carried out at separate monitoring stations with non-uniform distances and non-uniform times, the measurements of the five variables were different for each campaign and for the final sample sets.
Figure 5 shows measurement values of the five variables in a time period of less than 100 sampling hours. Panel (a) represents the behavior of the river temperature, in which the measurement variability is noticeably larger than in the other variables. Panel (b) represents the trend of dissolved oxygen, likewise, its variability is lower than the river temperature, but still larger than the last three variables included in
Figure 5. Panels (c)–(e) show the dynamics of air temperature, percentage of relative humidity, and electrical conductivity. It is seen that less spatial variability and highly regular behavior seems to be present. As expected, there could be a direct relationship between the measurement variability and the sensor quality for each. For example, the temperature in the water body of the river does not usually change abruptly. Thus, the variations observed in the measurements could be partially attributed to the quality of the semiconductor device used in this investigation.
2.3. Algorithms for Spatio-Temporal Dynamic Analysis
The proposed system allows us to measure an environmental variable in each location in a short time period and likely moving in space. In previous works [
14,
15], the dynamics of the variables resulting from the monitoring campaigns were represented using machine learning and advanced interpolation techniques. In this work, the availability of measurements sets for each location allowed us to calculate the mean and the standard deviation, hence yielding a map representation of the first and second order statistics of the spatio-temporal dynamics. This better exploits the information of the resulting data and gives a more complete description of the environmental variables.
According to purpose of the described system, we needed to analyze the data of our campaigns to monitor measurements on each variable sampled at different times and spatial locations. If we denote by
a given environmental variable to be measured, its spatio-temporal distribution can be denoted as:
where
d is the distance along the river path in a downward direction, usually starting from a zero reference point, and
t is the time elapsed in a given area of consecutive sampling. We call this subset of consecutive samples at a geographically region with moderate displacements a session, and, in each session, we take a number of separate samples in time and space, that is:
where
is the number of samples acquired during that session. The set of measures of
in a session is obtained as:
where
is the Dirac’s delta function in our two-dimensional domain. A measurement campaign is the set of measurement sessions for the same variable and is denoted as:
and the sessions are numbered by
, where
is the total number of sessions for variable
.
We can characterize each session by using a statistic p applied to that set of samples, for example, if and ), with , represent the sample average operator and the sample variance operator when applied to the samples of session , we have that and represent the estimated spatio-temporal dynamics for the first and second order statistics of that variable.
At this point, we need to introduce methods to provide us with this estimation from the available samples. Following previous works, we scrutinize here three of the algorithms that showed better performance in the analysis of Machángara River. First, the
k Nearest Neighbors (
k-NN) algorithm is a simple procedure that has been successfully used to interpolate multidimensional data with low computational burden. Second, the Support Vector Machine (SVM) algorithm has been previously used to estimate the spatio-temporal dynamics of contamination measurement in rivers, and it was shown that Mahalanobis and autocorrelation kernels often outperformed
k-NN. Here, we scrutinize these three algorithms, which are next summarized [
14,
15]. We will denote by
the spatio-temporal coordinate vector, and by
f the measured variable or its estimated statistic, i.e.,
f is here a generalized notation for
,
M, and
S, according to the analysis context.
One of the advantages of
k-NN algorithm is that it is easy to implement it in software, providing robust estimates when a cross-validation technique is used [
30]. The estimation of new values for targets
is computed from the set of
k closest neighbors. In addition, each selected neighbor
, with
, uses a weighted function according to its corresponding distance. The most common used distances are the Euclidean, Minkowski, Mahalanobis, and Cosine distances. The Mahalanobis distance between two points
and
is defined by
where
is the covariance matrix of the available dataset. With relation to the Euclidean distance, the Mahalanobis distance has important properties; for instance, the Mahalanobis distance is invariant to scale changes and variable units, and it does not require any previous normalization. In addition, the matrix
accounts for the covariance among variables and possibly some redundancy effect. The estimation function
is computed by the Distance Weighted Nearest Neighbor algorithm [
31] as follows:
where
represents the value of
f at that neighbor sample, and
are the weights defined in terms of the Mahalanobis distance as
Consequently, the interpolation algorithm is polished by weighing the contribution of each neighbor according to their distance to target point . When matches exactly a neighbor, the denominator becomes zero; in that case, we just assign to .
In this work, we additionally use kernel methods to interpolate and construct visualizations of the spatio-temporal dynamics of the measured water quality variables. Under this approach, kernel methods can be very useful when the statistical structure of the variables has been taken into account [
32,
33]. Probably the most well-known algorithm of the SVM is the classification one, but also good results have been obtained when addressing the solution of nonlinear regression applications.
Vapnik proposed to use the
-insensitive loss function to obtain scattered solutions in the SVR algorithm [
34,
35]. Being
, then we can define
This loss function sets to zero any error smaller than
providing also robustness against outliers. The regression function construct a tube around the true function in order to estimate it, defining a margin around the function and treating the deviation as noise. In fact, the SVR model used in this study applies the following nonlinear regression model:
where
is a nonlinear transformation to a higher dimensional space, and
b is a bias term. Then, considering a dataset
, where
N is the number of observed samples, the
-SVR algorithm states that the function to minimize is [
36]
where the first term is an
regularization and the second one is the
-insensitive loss function. Note that
is the insensitivity parameter,
C is a parameter that allows for tuning the compensation between the error tolerance and the softness of the regression. Additionally,
and
are the slack variables representing error excesses for each sample
, and
is the operative parameter that controls
in terms of the maximum deviation from the measured value. Taking into account the following constraints:
and, by using the Lagrangian functional, the solution to the nonlinear SVR is
where
, with
are scalars, and samples
for which
are the support vectors. Thus,
which is equivalent to
where
denotes a Mercer’s kernel, standing for the dot product independently from the nonlinear transformation or the dimensional space. In this work,
-SVR is used to provide the estimation of the support vectors. Thus, the solution can be linearly expressed in terms of the kernel function and the available support samples.
Among the most usual Mercer’s kernels, we have the linear and Gaussian ones. In order to provide an improved performance, we have increased the statistical knowledge about the data structure within the algorithm through the following procedure. First, a conventional Gaussian radial basis function kernel (
RBF-SVR) is used. In this case, the kernel is a bivariate function given by
where the parameter
allows for controlling the neighborhood of the samples influencing the solution. These structures can approximate the underlying function of a wide variety of data as long as
is adequately tuned. Note that, in our study, we assume that changes in time and space dimensions follow similar dynamics because of radial symmetry. However, temporal and spatial variations will probably differ. Although normalization of inputs can alleviate this problem, other advanced kernels can be used without needing normalization.
Second, we propose to use a non-radially symmetric kernel, by using the covariance matrix of data (i.e.,
). Then, an SVR with a Mahalanobis distance kernel (
Ma-SVR) is created. This kernel equation is given by
where the covariance-weighted distance between samples
and
is considered. Note that different spatial and temporal scales do not influence the basic distance.
Third, we use a SVR with an Autocorrelation kernel (
Au-SVR), defined as
where
is the estimated two-dimensional autocorrelation function of the spatio-temporal dynamics. This kernel is a new type of SVR kernel that takes advantage of the autocorrelation value among samples. The autocorrelation is highly relevant function in digital signal processing, and a basic feature of stochastic processes. A main characteristic of the autocorrelation function is the symmetry with relation to the kernel matrix elements,
. Note that the autocorrelation function is a robust measurement of the dependence among samples [
37], depending only on the relative difference between elements rather than on their absolute values in the case of stationary processes.
This study looks for an optimum relationship between the amount of data, the quality of data approximation, and the parameters that characterize the approximation functions [
38]. The problem is to find the best SVR structure that allows us to generalize the measurement samples in the presence of noise.
2.4. Motivation and Considerations for ICT on Sustainability
Several aspects can be considered for the use of ICT in the water monitoring environments, in terms of their technical and applied sustainability. On the one hand, the use of interpolation algorithms allows us to process the data to more efficiently extract the information. Specifically, the advantage of the interpolation algorithm in working with the closest neighbor criterion weighted by distance is that the measurements closest to the point to interpolate will be more important than those that are farther away. This is achieved by using the inverse of the square of the distance as the weighting criterion. This decreases the risk that all samples are taken into account for training and decrease the response time of the process. Another advantage is the increased robustness against data noise, especially against large data sets. As previously described, many estimation methods could be applied; however, the kernel methods are very popular and obtain very good benefits and generalization in non-uniform interpolation problems. Mercer kernels can be seen as bivariate functions and this type of kernel has the advantage of being able to do nonlinear learning in quadratic cost functions with a single minimum.
On the other hand, a -SVR is adopted in this study; however, other alternatives could be used, such as -SVR. Although performance of both algorithms would be similar when their free parameters are optimally selected, the free-parameter of -SVR is bounded above and below, , and thus its adjustment is easier and optimal selection can be easier obtained. This is the reason why we have used -SVR. In addition, each dimension can present a different variation since non-radially symmetric kernels can assign different variation to each dimension, in this case these kernels have an advantage over symmetric kernels. One way of assigning that variation to each distance would be, for example, by applying the Mahalanobis distance with a Gaussian distribution to calculate the kernel, like the Mahalanobis nucleus we apply. Another option is to calculate the autocorrelation of the data in each dimension, as is done in the autocorrelation kernel.
From the acquisition of information perspective, there are two more water quality parameters that provide useful data when evaluating water of rivers, namely, COD and BOD5. However, there are few COD sensors for online measurements that can be hooked up to the designed mobile device. In regard to BOD5, it is usually measured in the laboratory after 5 days of sample collection, thus this parameter cannot be measured every 20 or 30 seg, during time periods of 12 min that lasted every measurement campaign. For the given reasons, we selected dissolved oxygen as the main river’s water quality parameter, which is directly related to both COD and BOD5 and can be measured at the same time as the other variables in situ.
San Pedro River was chosen because domestic discharges from Quito are collected through four rivers, Machángara, Monjas, San Pedro and Guayllabamba. The Machángara River receives approximately 75% of the total discharges of the city and passes through the urban area of Quito and studies of the spatio-temporal trends of some water quality variables have been carried out. However, the San Pedro River crosses a peripheral zone of Quito and receives approximately 5% of the total discharges of wastewater and is less polluted according to studies by EPMAPS (Metropolitan Public Company of Drinking Water and Sanitation) but requires urgent actions such as monitoring and control the water quality before it becomes contaminated as the Machángara River, although the San Pedro River encompasses three type of discharges: agriculture, industrial and residential wastewater, which may end up as an ugly mixture of liquid waste to be treated.