Modeling Biodegradable Free Chlorine Sensor Performance Using Artificial Neural Networks

Electrochemical sensors are used to measure target analytes in water, meat, fruits, or vegetables, to ensure their safety, security, and integrity for human use. In this paper, a solution‐based fabrication process is presented for a biodegradable electrochemical free chlorine sensor using asparagine that is functionalized onto graphene oxide (GO). An ink solution of the GO functionalized with asparagine is synthesized, and then deposited onto a screen‐printed carbon electrode (SPCE) using a spin coater. The sensor shows high a sensitivity of 0.30 µA ppm−1 over a linear range of 0–8 ppm with a hysteresis‐limited resolution of 0.2 ppm after achieving a steady state at 50 s. From the development and testing of the free chlorine sensor, over 9000 datapoints are collected and used for training an artificial neural network (ANN) model to quantify and characterize the factors affecting the free chlorine sensor's performance, and model its degradation characteristics. The model reports a low mean absolute error (MAE) of 0.1603 and a high model accuracy with a Pearson correlation coefficient (PCC) of 0.9950, demonstrating that these degradation characteristics can be modeled and be used to compensate the degraded performance characteristics of the free chlorine sensors.


Introduction
Recent publications have shown a growing trend in the use of electrochemical sensors to measure pH, temperature, types of gases, and organic or inorganic compounds present in water, [1][2][3][4][5][6][7] meats, [8,9] fruits, [10] or vegetables. [11]This is to ensure the safety and security of the people or animals who come into contact or consume water from these water sources, are exposed to different DOI: 10.1002/admt.202300990gases, or consume food that may come into contact with contaminants and must be treated accordingly.A common challenge in electrochemical sensors is their selectivity to avoid multiple analytes triggering identical or similar sensor responses.This has led to the development of highly selective sensors to measure pH [12,13] and free chlorine [2,14] concentrations which are useful for targeted applications such as determining water quality, or monitoring the water used to wash food to ensure food safety by removing fecal matter. [3]However, the sensing materials lose their intrinsic sensing properties with aging and environmental factors, showing degradation in their sensing response.As such, with the development of highly stable, sensitive, and novel materials, machine learning is increasingly being considered a desirable tool for developing devices to solve the challenge of sensor degradation. [15]o address the challenge of performance changes resulting from sensor degradation, researchers have explored the use of artificial neural networks (ANNs) to improve their performance, the use of which can also be applied to electrochemical free chlorine sensors.ANNs are a type of machine learning technique that use data or tailored experiences for which the computer can make predictions for future applications based on that data. [16,17]There are two types of applications for ANNs: classification and regression problems.[28][29][30] By training ANNs with data from electrochemical free chlorine sensors, researchers will be able to develop models that can accurately predict the levels of free chlorine and compensate for sensor degradation.
Several studies have investigated the use of ANNs for electrochemical-free chlorine sensors.However, they have been in industrial applications to manage free chlorine concentrations.[33] Among the by-products of the increased free chlorine concentrations are trihalomethanes, a family of carcinogenic and mutagenic compounds generated from the decomposition of free chlorine.[36] One such use of ANNs was in measuring trihalomethanes in the Han River drinking water treatment plant in Seoul City, South Korea, where researchers measured free chlorine concentrations before, during, and after chlorination to ensure free chlorine levels were within a safe range. [37]ANNs were also used to maintain free chlorine concentrations in another water plant in Sao Paulo, Brazil. [38]After creating simulations of the constant fluctuations in chlorine demand resulting from natural causes, the water treatment plant incorporated a system of devices to correctly dose the water supply with the required concentration of free chlorine.
][41][42] When not measuring free chlorine directly, the measurement systems use softcomputing to determine residual chlorine which determines the concentration using 27 parameters. [27]However, soft sensor systems which use many different sensors, are not feasible in portable applications as they require the use of many measurements and sensors.A major challenge when measuring these systems is that the data collection process is not simple due to the requirements of the expensive sensing equipment, their maintenance, calibration, and sensor replacement costs, which all add to the complexity of maintaining them. [26,39]Furthermore, due to the complexity of the water supply systems themselves, the water being supplied from these plants may meet the required standards at the plants, but may become re-contaminated in transit, which increases the need for portable sensing systems, especially in remote-locations. [4,6,29]ecently, researchers developed a portable free chlorine concentration system that also measures pH with an accuracy of 99.71%. [43]Due to its portability, it can be used to measure water quality in drinking water, pools, parks, and other remote locations by using high-accuracy digital image processing based on the colorimetric method.However, taking consistent and accurate pictures of the colorimetric response requires the use of a bulky apparatus and a multi-step operating procedure, adding to the complexity in using the system.Furthermore, colorimetric methods are known to suffer from limitations such as being consumable or non-reusable, and the compounds that are required to cause the chemical change are toxic. [44,45]The compound used for this system is o-Toluidine, a known carcinogen, which is known to cause urinary-bladder cancer in people. [46,47]Although the accuracy of the system is excellent, the toxic effect of the compound makes it undesirable to use near drinking water, food, and food products, which require the use of safer non-toxic alternatives.
In this paper, we present the fabrication and experimental results of a solution-based, biodegradable, low-cost, asparaginefunctionalized disposable graphene oxide electrode as reported previously, highlighting its advantages over other electrochemical sensors. [48]The biodegradable graphene oxide is chemically functionalized by the non-toxic amino acid, asparagine, in a basic solution, suspended in a deionized (DI) water and ethanol solution, then spin-coated onto a screen-printed carbon electrode (SPCE) to achieve a uniform film surface.By using a large amount of data during the fabrication, validation, and testing the sensor, we developed an ANN model for the sensor to supplement the sensor performance by comparing sensor performance changes that result from fabrication changes, compensate for sensor drift and degradation, and allow for simple and accurate measurements to be reported in real-time.The free chlorine sensor is operated using an applied voltage of +0.1 V, operating outside the reduction potential range of dissolved oxygen, demonstrating a linear range from 0 to 8 ppm with a resolution of 0.2 ppm that is limited by hysteresis.The feasibility of using ANNs to improve the sensing performance of electrochemicalfree chlorine sensors is an important step toward portable, highly accurate, and sensitive devices with lifetimes compensated by machine learning algorithms.

Reagents and Materials
Graphene oxide (GO) (796034-1G), Sodium hydroxide pellets (S8045), asparagine (A0884), and sodium hypochlorite (NaOCl, 425044-250 ML) were purchased from Sigma Aldrich and used as received.Deionized (DI) water (>18 MΩ) was used to prepare all solutions used in the reaction.A single-electrode screen printed carbon electrode (SPCE) was purchased from CH Instruments and used as received.Hamilton (Ontario, Canada) municipal tap water was used to make all the free chlorine solutions used for testing the sensor.

Sensor Fabrication
The fabrication process was previously described, [48] and is summarized in Scheme 1.A 10 mL solution of 10 mg mL −1 of GO in DI water was sonicated until the GO was dispersed homogenously according to the fabrication process in functionalizing GO with amino acids. [49,50]Another 10 mL solution of 1 m Asparagine and 1.5 m NaOH which was prepared to dissolve the asparagine and prevent the formation of amides by neutralizing carboxylic acid groups on the GO. [50]The two solutions were mixed together, and then stirred for 24 h at 1500 RPM under ambient conditions using a magnetic stirrer.After that, the dispersion was centrifuged at 7600 RPM for 45 min, and washed a total of three times with a mixture of DI water and ethanol at approximately a 1:1 ratio.The remaining material was suspended in a 15 mL solution of the same DI water and ethanol ratio.From this final dispersion, 12 μL was drop-casted onto an SPCE and spin-coated at 600 RPM for 10 s, and then dried on a hotplate for 10 min at 60 °C.

Setup
All chemical solutions were made using a standard magnetic stirrer and centrifuge (Benchmark MC-24 Touch Microcentrifuge) to remove the reacted GO from the precursor solution.A conventional three-electrode electrochemical cell (Scheme 1) was used to measure the free chlorine solutions with an EmStat potentiostat (PalmSense BV, Utrecht, The Netherlands), a reference electrode (CHI111) and a counter electrode (CHI115).

Free Chlorine Sensing
The free chlorine stock solution was used to prepare different concentrations of free chlorine (NaOCl) by diluting the as-received NaOCl using only tap water.The free chlorine solutions in tap water were calibrated using the LaMotte 2056 ColorQ PRO 7 Hand-Held Photometer which is a commercial DPD-based colorimetric test kit.The free chlorine sensors were characterized using an amperometric test set-up where the asparagine-GO on SPCE was the working electrode, Ag/AgCl was used for the reference electrode, and platinum for the counter electrode.Current was measured at a sampling rate of 0.1 Hz for 50 s with the electrodes dipped into the free chlorine solution.From each measurement, 1 data point was taken for each second for a total of 51 data points each measurement for training the ANNs.

Machine Learning Model Training
Keras, an open-source software, was used to build and test the ANNs.The dataset is scaled using Equations ( 1) and (2).The model has ten input nodes and 1 output node with two hidden layers (N 1 , N 2 ) where the number of nodes in the hidden layers varied from a minimum of 8 nodes per hidden layer to a maximum size of 32 nodes between the two hidden layers.At each hidden layer node, the activation function used was the ReLu (rectify linear unit) function.The nodes between the ANNs are made of layers that were all fully-connected layers.The output layer outputs a continuous value and does not have an activation function.The training and testing data sets were split 80% and 20% (Scheme 1), respectively, from a dataset of a total of 9385 datapoints, where the data points for each data set were selected randomly.
After a blank model is created with the specified architecture, it is trained and evaluated, the results of which are given by the mean absolute error (MAE): [51] where t i is the real value measured, y i is the predicted value from the ANN, and n is the number of data points.The MAE will measure the average accuracy of the outputs, or the difference between the predictions and targets (in ppm).The second metric used to evaluate the optimal model is the Pearson Correlation Coefficient (PCC) given by: where t and ȳ are the measured and predicted mean values, respectively.The PCC is determined between t i , the true label of a data point and y i , the predicted value using the inputs of the same data point, and n is the number of datapoints.The correlation is high if R = 1 and low if R = 0 where a higher PCC shows that the model can accurately predict the real values of a data point from a set of inputs.The optimal ANN is obtained using the lowest MAE value to determine which ANN would give the smallest error in predicting the free chlorine concentration in the test set.

K-Fold Cross Validation
K-Fold Cross Validation (KCV) was used to reliably evaluate the models with varying architectures by balancing the distribution of values across the input parameters, so once the optimal model architecture is chosen, the relevant sensor parameters can be analyzed.KCV operates by first splitting up the training data into K partitions or folds and then creating K identical blank ANNs with an identical number of nodes and network parameters (Scheme 1).Each ANN will be trained on one of the (K − 1) partitions and the model parameter (w) will be recorded.Then, on each model, the remaining partition is evaluated from which the error  i is recorded.The averages of all these errors are then calculated over all the folds using the following equation which gives the error for the model with a given architecture: where ε is the average error across each of the folds, and K is the number of folds.Both the MAE and PCC are calculated using this method where the MAE and PCC are averaged across each of the folds.

Mechanisms
The free chlorine concentration was monitored by an amperometric sensor with an asparagine-functionalized GO as the working electrode, Ag/AgCl reference electrode, and a platinum counter electrode at an applied potential of 0.1 V.This is much lower than the theoretical reduction voltage range for dissolved oxygen which begins at 0.4 V [1,4] and is to avoid the reduction potentials of interfering ions. [52,53]At the working electrode, OCl − undergoes electrochemical reduction according to the chemical equation: The output current stabilizes after the initial potential step, characteristic of chronoamperometric curves as given by the Cottrel equation, to a level that is linearly dependent on the concentration of free chlorine. [54]As shown in Figure 1a, the total response time was measured up to 50 s.This allows the system to reach less than 5% of its initial value and is sufficient time to allow the system to reach a steady state.The output current at the 50th second was used for the calibration measurements.The reproducibility of the sensors was measured using three different free chlorine sensors that were fabricated in the same batch and their response characteristics are shown in Figure 1b.The average sensitivity was ≈0.30 μA ppm −1 (0.43 μA cm −2 ppm −1 for the sensors with an electrode area of 0.7 cm 2 ).The maximum recorded variation in the sensor's sensitivity is 15 nA ppm −1 (21 nA cm −2 ppm −1 ; ≈5% of the sensitivity) which corresponds to an accuracy of ± 0.05 ppm.Therefore, the sensors show high reproducibility with a low variation of output current among the sensors for the same free chlorine concentration. [6,14]

Hysteresis
The resolution of the free chlorine can be determined from its hysteresis.Figure 1c shows three cycles of chronoamperometry responses recorded at 50 s where free chlorine concentrations were cycled from 0.9 to 8 ppm (solid blue circles) then back to 0.9 ppm (hollow black circles).This resulted in an average hysteresis of 51 μA which corresponded to a worst-case resolution of 0.2 ppm.This resolution is high enough for the safe monitoring of drinking and pool water given that the smallest amount of free chlorine currently present in drinking water is 0.2 ppm. [33]igure 1.a) Varying free chlorine measurements measured using chronoamperometry, from low to high concentrations of free chlorine; b) The current response of three different free chlorine sensors measured at 50 s to show the reproducibility of the sensors; c) current response at 50 s versus free chlorine concentration to show the hysteresis behavior of the sensor from 3 increasing and decreasing concentrations.

Training
Using the training data, 153 different unique models were created, with one model for each of the four folds, making a total of 612 models trained using the training data and evaluated using the validation data.For each model, the validation dataset was used to calculate the MAE and PCC, and the model with the lowest MAE was chosen as the optimal model.Figure 2a shows the evolution of the MAE averaged from the K folds across 400 epochs, and Figure 2b shows a close-up of the evolution of the MAE between 100 epochs and 400 epochs.The peaks and the valleys shown are at 30% of their original amplitude, where Figure S1a,b (Supporting Information) show the original amplitudes.After ≈300 epochs, the model's rate of improvement diminishes and there is an increased amount of noise generated during training.The final obtained MAE and PCC, as shown in Table 1, are   0.1603 and 0.9950, respectively.The models were evaluated on the training data set, the test data set, then the entire data set, each containing 7508, 1877, and 9385 datapoints, respectively, all of which were randomly selected from the data set where the transient relationship of the sensor output is governed by the Cottrell equation.

Spin Coating
Before being spin-coated and as part of the sensor development process, the sensors were originally fabricated by simply dropcasting the sensitive material onto the SPCE, and then dried on the hotplate.After transitioning to spin-coating the sensors, a parameter was introduced to distinguish the performance between the two modes of fabrication.This allowed the ability to quantitatively determine the reliability and consistent performance of the sensors fabricated using spin coating, and how its performance compares over drop-casted sensors.Figure 3a shows the correlation plot of the non-spin coated and Figure 3b shows the correlation plot of the spin-coated sensors, demonstrating the impact of spin coating, and Figures S2 and S3a,b (Supporting Information) show the same correlation plots for the training and test dataset, respectively.The MAE for the spin-coated sensors and drop-casted sensors is 0.1039 and 0.2301, respectively, showing a significant difference in the accuracy and consistency of the sensors' performance between the two fabrication methods.Furthermore, when calculating the average sensitivity across the measurements for drop-casted sensors, the average sensitivity was ≈0.22 μA ppm −1 (0.31 μA cm −2 ppm −1 for the sensors with an electrode area of 0.7 cm 2 ) with an R 2 of 0.906.This low repeatability can be attributed to inconsistencies across sensors when drop-casting the sensitive material, and when comparing the results between the fabrication parameters, it is clear that spin coating significantly improves the performance characteristics of the sensors.
A factor to consider is the discrepancy in the number of data points between the two cases.The number of data points for drop-casted sensor data and spin-coated sensor data are 5814 and 3570, respectively.Since the results measured from spin-coated sensors were found to be more consistent and provided competitive results across a smaller range of sensors, fewer sensors were needed to be fabricated and tested.More trial, error, and variations in the performance of the non-spin-coated sensors are reflected in the larger spread in Figure 3a.Overall, the correlation plots show that the sensor data from the spin-coated sensors is more repeatable and can be modeled with higher accuracy than the sensor data from drop-casted sensors.As a result, only data points where the sensors were spin-coated will be investigated for the remaining parameters.

Time
Time was isolated to evaluate the evolution of the performance of the model over time and the effect that the changing time has on the MAE, and then to use this to evaluate the performance of the sensor.This would also identify a more optimal range in which the sensor reaches a steady current flow when measuring free chlorine, allowing for faster and possibly real-time responses.Figure 4a shows the evolution of the MAE and the PCC for the entire dataset, and Figures S4 and S5 (Supporting Information) shows the evolution for the training and test dataset, respectively.Omitted from the curve are the first two seconds of data which show artifacts generated from a potential step.The plot shows the lowest MAE at 4 s, the highest at 50 s, and a plateau between 12 s and 20 s.The PCC is the lowest at 7 s, increases until it reaches a peak of 41 s, then soon begins to decrease, indicating the model accuracy loses accuracy after 41 s.However, because the MAE range is within 0.005 ppm, and the model accuracy remains within a range of 0.0002, the fluctuations may be a result of a change in the diffusion of the free chlorine from the bulk to the sensor surface or the transition from a kinetics-based reaction to a diffusion-controlled process as the free chlorine diffuses across the diffusive layer toward the electrode surface. [54]Furthermore, this range of error is much smaller than the accuracy of the reference colorimetric sensor and what is reported of the electrochemical asparagine-GO free chlorine sensor themselves, making the   4a and the small in the MAE, the most consistent reliable sensor performance is approximately between 10 and 20 s. also that the sensor's performance is very consistent throughout the duration of the measurements.

Increasing and Decreasing Cycles
There are two phases measuring the free chlorine sensors: the first is when the sensor is measuring the concentration as the free chlorine concentrations increase, and the second is when the concentrations are decreasing.As reported in Section 3.2, the sensor reports an average hysteresis of 0.2 ppm.Shown in Figure 5a are the correlation plots when the free chlorine concentration is increasing from low to high, and Figure 5b shows the correlation plot of data points when the concentration is decreasing from high to low.Figures S6 and S7a,b (Supporting Information) shows the same correlation plots for the training and test set, respectively.Figure 5a shows a small cluster of outliers near 7.8 ppm where the cluster is due to 50 separate data points obtained from 1 measurement from t = 0 s to t = 50 s.Given the nature of this outlier, it is likely the result of an inaccuracy in the performance of the colorimetric sensor, or the degradation of the sensor which will be further discussed in Section 4.5.The difference between the two MAEs is ≈0.01 ppm and with a difference between the models of 0.08%, it is seen that the ANNs can accurately model the sensor performance in both phases of the measurements such that the impact of the hysteresis can be reduced.In both cases, the ANN model results are comparable, showing that it can accurately model hysteresis and degradation in sensor performance.

Sensor Cycle
A cycle consists of a series of measurements of increasing free chlorine concentration, then after reaching 9 ppm, decreasing the concentration.Isolating the model's performance on the sensor data for different cycles was carried out to evaluate the degradation of the sensor over time.On the fourth cycle, the sensor displayed noticeable signs of degradation, hence it is limited to three cycles.Figure 6a-c shows the correlation plots for one, two, and three cycles, respectively, for the entire dataset.Figures S8 and S9a-c (Supporting Information) shows the same correlation plots for the training and test set, respectively.The MAE in the second cycle increases by 0.065 ppm which demonstrates some possible degradation of the sensor, but because the total error is within 0.2 ppm, the ANN model can display a result more accurately than the measurements reported by the sensor.As for the third cycle, with comparative PCCs for the first two cycles, the performance of the model on the third cycle shows a noticeable de-crease of 0.0043 compared to the previous cycles while the MAE increases by more than 0.1 ppm.This is likely due to the cluster of outliers in the red circle and are 0.79 ppm away from the x = y line (Figure 6c).Two possible causes for the outliers are an inaccuracy in the hand-held colorimetric detector and the sensor performance degrading during the third cycle.The error in the colorimetric detector is more likely because the outlier appears during the increasing phase in the cycle, as shown in Figure 6a, but the ANN performance remains accurate in the decreasing phase of the cycle where the sensor continues to measure free chlorine.Figure S10 (Supporting Information) shows that the model's performance degrades after two measurements, but remains consistent after the appearance of the outlier.Although it appears that there is a significant performance degradation during the third cycle, this degradation is likely not to the degree shown by the increase in the MAE since the ANN remains an accurate predictive tool for all three cycles and as a result, can be used to compensate for sensor degradation.

Conclusion
Biodegradable free chlorine sensors were fabricated using graphene oxide functionalized with asparagine in a solutionbased process and were used to measure free chlorine in real water samples.The sensor showed a high sensitivity with an acceptable resolution and good reproducibility.Using chronoamperometry, the sensitivity of the sensor to free chlorine is 0.30 μA ppm −1 at 50 s, with a hysteresis of 0.2 ppm in the range between 0 -8 ppm.The sensors performance using the ANN was corroborated by what was observed from the experiments.After training, testing, then comparing 153 ANNs, the optimal ANN architecture had 15 and 17 nodes in the first and second hidden layers, respectively, with a MAE of 0.1603 and a Pearson correlation coefficient of 0.9950.Several parameters were isolated and used to measure and analyze the sensor's performance characteristics, degradation, and hysteresis.The sensor was found to have an optimal measurement between 12 s and 20 s.Although the hysteresis characteristics of the sensor affect its performance, it was found that degradation behavior and hysteresis is repeatable and can therefore be modeled.Machine learning models working tandem with free chlorine sensors have great potential to fabrication parameters, improve sensor performances, and response times.The challenges, however, continue to be the number of data points required, and thus the parameters be carefully selected which would also minimize both fabrication costs and computation costs.

Scheme 1 .
Scheme 1. Free chlorine sensor fabrication, testing, and machine learning processing workflow.

Figure 2 .
Figure 2. a) MAE of validation curve of the optimal model and b) a zoomed-in image showing its evolution after 100 epochs, reduced to 30% of its original amplitude.

Figure 3 .
Figure 3. Correlation plot comparing the model performance on predicting the free chlorine concentration of sensors fabricated a) without and b) with spin coating over the entire data set.

Figure 4 .
Figure 4. a) Evolution of MAE and PCC on full dataset over duration of free chlorine measurement; Correlation plots of the model's performance on all the sensors at b) t = 1 s, c) t = 10 s, d) t = 25 s, e) t = 50 s to show the evolution of spread and the accuracy of the at different points in time.
Figure 4b-e show correlation plots of the model at = 1, 10, 25, and 50 s, respectively.Figures S4 and S5b-e (Supporting Information) shows same correlation plots for the training and test respectively.Throughout the duration of the measurecorrelation are accurate to the x = y relationship, as shown by the trendline equations, where the predicted value matches the real value.However, based on Figure

Figure 5 .
Figure 5. Correlation plot comparing the model performance on predicted free chlorine concentration of sensors fabricated a) with decreasing and b) increasing free chlorine concentrations during the measuring cycles on the entire dataset.

Figure 6 .
Figure 6.a-c) shows the correlation plots for one, two, and three cycles, respectively, for the entire dataset.

Table 1 .
Validation MAE and PCC of ANNs (PCC on top; MAE below); N 1 and N 2 are the first and second hidden layers of the ANN architecture, respectively.