This section introduces a distributed drinking-water monitoring system called the water quality identification IoT system (Water-QI). The subsequent subsections detail the end-to-end high-level system architecture, the IoT device, implemented communication methods and application protocols, and the proposed deep learning models for localized water quality index predictions. These models are designed for extensibility and edge predictability. Additionally, the evaluation metrics, dataset, proposed models, and training hyperparameters are described.
3.1. Proposed System Architecture
The proposed Water-QI platform is a cost-effective Internet of Things (IoT) system developed for real-time monitoring, visualization, and prediction of water quality, with a focus on the water quality index (WQI). The system architecture integrates a field IoT telemetry device, cloud-based data transmission, a web-based data management and visualization environment, and a mobile application. This configuration enables continuous monitoring of water conditions, reducing dependence on periodic laboratory analysis. The platform automatically collects measurements from the IoT sensing node, transmits data to the cloud via existing Wi-Fi infrastructure, and displays both raw measurements and the calculated WQI through intuitive user interfaces. Beyond real-time monitoring, the system offers historical data inspection, statistical analysis, alert management, and configurable parameter weighting for WQI calculation.
At the cloud level, the platform utilizes the open-source ThingsBoard AS [
44] to manage device communication, data visualization, and remote supervision. Data storage is performed using the Cassandra NoSQL database provided by ThingsBoard [
45]. The communication workflow links the end node to the cloud through telemetry services, while the application server hosts the predictive component. Specifically, a deep learning algorithm based on a variable-depth gated recurrent unit–recurrent neural network (GRU–RNN) infrastructure model operates on a cloud virtual server that operates on top of a container similar to the thingsAI paradigm [
46] to estimate and forecast WQI trends from incoming sensor data streams. This edge-to-cloud architecture enables the system to monitor current water conditions as a weighted cumulative index, facilitating early warning and proactive decision-making in smart city and environmental monitoring contexts.
Figure 1 presents the proposed Water-QI system architecture.
The Water-QI system also includes a mobile monitoring application developed in Flutter/Dart, designed to provide real-time supervision of the Water-QI IoT device via a cross-platform Android and iOS interface. In the uploaded project description, the mobile application is presented as a companion to the open-source ThingsBoard application server, which is responsible for telemetry collection, device supervision, alert exchange, and parameter configuration [
47]. Within this Water-QI architecture, the mobile application allows users to inspect live sensor measurements, review water quality history, and monitor the operational state of the field device through a portable interface, while the ThingsBoard backend manages data storage, dashboards, and server-side services.
Different protocols are utilized for the collection of data per IoT end-node device of the Water-QI: (1) the MQTT beacon protocol, (2) the HTTP telemetry protocol, and (3) the HTTP request-back control protocol. The MQTT beacon protocol is a real-time protocol for sending beacons from an IoT device to the ThingsBoard AS broker. The beacon packet includes AES-128-encrypted information about the IoT device UUID, the device sensory measurement period
, the data transmission period to the AS
, the AS command update period for the device control protocol
, and the beacon location expressed in latitude and longitude coordinates. The HTTP over SSL telemetry protocol is using the method POST to submit a JSON-encoded string of measurements to the Water-QI AS. Finally, the control protocol is an HTTP over SSL request–response protocol initiated periodically from the end node with the purpose to receive any updated information of probing intervals (periods), WQI weight parameters, and latitude and longitude coordinates on the map if the device does not include a GPS receiver for automatic location updates. The following
Section 3.2 provides additional information regarding the IoT device’s sensors, measurements, and protocols, including functionality and interoperability.
3.2. End-Node IoT Device
A primary objective in the design of the Water-QI IoT end-node device with edge capabilities was to demonstrate that high-fidelity environmental monitoring can be achieved using budget-friendly off-the-shelf components. The sensor suite was carefully curated to balance extreme affordability with the data reliability required for deep learning applications. For water temperature monitoring, we selected the DS18B20 digital stainless probe (Analog Devices Inc./Maxim Integrated in Wilmington, MA, USA). This sensor provides a highly stable one-wire digital output at a fraction of the cost of industrial-grade thermocouples or thermometers, making it an ideal candidate for large-scale distributed urban deployments.
Figure 2, illustrates the Water-QI IoT prototype.
To maintain the Water-QI device IoT implementation with edge capabilities using a low-power ARM multi-core processor while ensuring multi-parametric low-cost analysis, we integrated a series of analog sensors attached to the RPi zero 2W board via an I2C ADC board (ADS1115-Texas Instruments Inc., Dallas, TX, USA), as illustrated in
Figure 2a. The actual implemented prototype includes the DFR0300 sensor for electrical conductivity (EC—DFRobot/Zhiwei Robotics Corp., Shanghai, China) (see
Figure 2b(3)), the SEN0244 sensor for total dissolved solids (TDS—DFRobot/Zhiwei Robotics Corp., Shanghai, China) (see
Figure 2b(4)), the Grove V1.0 sensor meter (Seeed Studio/Seeed Technology Co., Ltd., Shenzhen, China), for turbidity measurements (see
Figure 2b(6)), the SEN0161-V2 sensor (DFRobot/Zhiwei Robotics Corp., Shanghai, China), for pH measurements (see
Figure 2b(5)), and the DS18B20 temperature sensor (see
Figure 2b(2)). The device is powered using a 5V USB type-A connector (see
Figure 2b(7)), and uploads measurements to the cloud AS using Wi-Fi connectivity provided by the RPi Wi-Fi transponder. These probes were specifically chosen because they offer a cost-effective entry point into smart city infrastructure without sacrificing the precision needed to calculate an accurate water quality index (WQI), since we are mainly focusing on measurement deviations rather than absolute values. These low-cost analog sensors’ main drawback is the necessity for frequent monthly calibration to perform adequately.
The low-cost sensors of the Water-QI prototype are calibrated and validated individually and then jointly at the device level. The SEN0161-V2 pH sensor is calibrated using standard buffer solutions, preferably pH 4.00, 7.00, and 10.00, so that the electrode offset and response slope can be adjusted before measurements are used in the WQI calculation. The DFR0300 EC sensor is calibrated using known electrical-conductivity reference solutions, while the SEN0244 TDS sensor is calibrated using TDS reference solutions or conductivity-derived TDS standards. Since both EC and TDS are temperature-dependent, their readings are interpreted alongside the DS18B20 temperature measurements. The Grove V1.0 turbidity sensor is calibrated using reference turbidity solutions in the expected operating range, with particular attention to low turbidity values relevant to drinking-water monitoring. The DS18B20 temperature probe is only validated against a reference thermometer.
Even if monthly calibration is needed, by opting for these accessible analog modules over expensive laboratory-grade equipment and focusing on real-time acquisition of measurement changes, we ensure that the proposed system remains financially viable for municipalities with limited budgets, facilitating the transition toward pervasive and sustainable water management. Furthermore, the device’s capability to include a GPS receiver (NEO 6M GPS module) connected to the RPi’s serial port, if selected or statically assigned localization GPS coordinates, makes the Water-QI system’s distributed approach fundamental for monitoring water quality deviations at city-district levels.
Figure 2a shows the actual control device and its interface with the analog sensors via the analog to digital converter, while
Figure 2b(1) illustrates the packaging of the actual PoC implementation that was put to the test without the use of a GPS receiver, as shown in
Figure 2a.
The probing Water-QI IoT node is built around the Raspberry Pi Zero 2W microprocessor, a compact single-board computer featuring a quad-core 64-bit ARM Cortex-A53 CPU at 1 GHz, 512 MB LPDDR2 RAM, integrated 2.4 GHz 802.11 b/g/n Wi-Fi, Bluetooth 4.2, mini-HDMI, micro-USB OTG, CSI camera connector, and a 40-pin GPIO header. The RPi zero 2W interfaces with an ADS1115 analog-to-digital converter over the I2C bus to acquire the outputs of the analog water quality probes. The ADS1115 is connected to the Raspberry Pi through GPIO2 (SDA) and GPIO3 (SCL), while its four analog 16-bit input channels are assigned as follows: AIN0 to the DFRobot SEN0161-V2 pH sensor, AIN1 to the Grove Turbidity Sensor Meter V1.0, AIN2 to the DFRobot SEN0244 TDS sensor, and AIN3 to the DFRobot DFR0300 electrical conductivity sensor. The pH conditioning board operates at 3.3–5.5 V with an analog output of 0–3.0 V, the TDS board operates at 3.3–5.5 V with an analog output of 0–2.3 V, and the EC board operates at 3.0–5.0 V with an analog output of 0–3.4 V. The Grove turbidity sensor supports 3.3 V/5 V operation and provides both analog and digital output; in the proposed setup, it is configured in analog mode and connected directly to AIN1. In addition, water temperature is measured using a DS18B20 digital sensor connected to GPIO4 via the Raspberry Pi 1-wire interface, with a 4.7 kΩ pull-up resistor between the data line and 3.3 V. All sensors share a common ground, and the DS18B20 temperature reading can also be used for compensation in conductivity and TDS-related calculations. Finally, the GPS receiver with an IPX uFL antenna included is connected via the GPIO 13-14 UART serial port of the RPi Zero 2W MPU.
The National Sanitation Foundation Water Quality Index (NSF-WQI) was proposed by Brown et al. [
48] as a refinement of the earlier index-based water quality assessment concept introduced by Horton [
49]. Horton’s contribution is generally recognized as the first formal WQI framework, designed to compress multiple physicochemical observations into a single interpretable score for surface-water assessment. Brown and colleagues extended this idea into the NSF-WQI by adopting a multiplicative model of weighting parameters and rating procedure, which made the index easier to apply and helped to establish it as one of the most widely used WQI formulations for rivers and other surface waters. Like the Horton model, the NSF-WQI preserves the four basic components that characterize most classical water quality indices: (i) parameter selection, namely the choice of the physical, chemical, and biological variables to be included; (ii) transformation of raw measurements into sub-indices so that heterogeneous variables with different units can be mapped onto a common quality scale, (iii) parameter weighting, through which more influential variables receive greater importance in the final score, and (iv) aggregation of the weighted sub-indices into a single composite WQI value. These four elements remain the conceptual backbone of many later WQI variants [
50,
51].
The NSF-WQI has since been widely applied to evaluate surface-water quality across diverse environmental and management settings, including rivers affected by urban, agricultural, and industrial pressures. For example, Abrahao et al. [
52] applied index-based analysis to assess a stream receiving industrial effluents, illustrating the practical use of WQI methods in pollution-impact studies. More broadly, the popularity of the NSF-WQI stems from its ability to reduce complex monitoring datasets into a concise communicable measure of overall water status while retaining the essential logic of Horton’s original formulation. The historical development of water quality indices, from Horton’s original formulation to the NSF-WQI and later variants, has been extensively reviewed in [
53].
For the real-time edge-device implementation, the weighting strategy was derived by adapting nominal literature-based WQI coefficients to the reduced parameter set available in the proposed sensing platform. Specifically, NSF-WQI-type formulations assign expert-defined raw weights to several physicochemical variables, including pH (
), temperature (
), turbidity (
), and total solids (
) (see [
54], Table 2). These coefficients, however, do not constitute a complete weighting scheme for the present five-parameter system since they originate from a broader multi-parameter index and sum to only 0.38 across the overlapping variables. Moreover, electrical conductivity is not explicitly included in the original NSF-WQI formulation and is therefore introduced here as an application-specific extension with raw coefficient
. To obtain a valid edge-computable WQI, all raw coefficients are normalized based on Equation (
2),
where
denotes the normalized weight of the i-th measured parameter,
is the corresponding raw weight before normalization,
indexes the five sensory attribute variables of the proposed Water-QI platform, and j is the summation index used to accumulate the raw weights of all five parameters in the denominator. Thus, the final weights satisfy
, or, equivalently, 100%. In this way, the final percentages are not directly copied from the bibliography but are obtained through proportional renormalization of literature-inspired coefficients over the subset of parameters actually measured at the IoT-device level.
According to the Horton model, which is one of the earliest and most influential weighted-arithmetic WQI formulations, five WQI classes are commonly used: very good (91–100), good (71–90), poor (51–70), bad (31–50), and very bad (0–30) [
49,
50]. Furthermore, there is also the canonical NSF-WQI, which evolved from Horton-type formulations and does not explicitly include electrical conductivity (EC) and uses total solids rather than total dissolved solids (TDS) among its standard variables [
50,
54]. Therefore, while the final WQI interpretation in this study follows an established five-class Horton-type scale for practical comparison, the individual sub-index equations for turbidity, pH, temperature, TDS, and EC are min–max tailored in the proposed Water-QI platform and measure attributive weights expressed as a quality score, where minimal values are better.
In depth, using the raw literature-inspired coefficients
,
,
,
, and the application-specific extension
, and based on Equation (
2), the total raw weight becomes
. The final normalized weights are then obtained as
, which yields
,
,
,
, and
. The final weighting scheme for the Water-QI system becomes 26.09% for pH (set to 25%), 21.74% for temperature (set to 15% to denote the minimal significance of temperature over the other parameters since it is rather constant for underground water pipelines and city installations), and 17.39% for turbidity, TDS, and EC, respectively (set to 20% to denote the importance over temperature), summing exactly to 100%.
Table 3 summarizes the WQI classes as well as the mathematical formulation for the selected parameters for the WQI index calculation performed by the Water-QI IoT device.
Table 3 presents the Horton/NSF-WQI attribute classification with respect to the Horton classification and the Water-QI score based mainly on min–max normalization, the per-measure normalization process, and the final WQI index value acting as a classification index value that is inversely proportional to Horton classification values. Furthermore, the NSF-WQI is disregarded and the TDS metric for total solids is used, along with temperature and EC values, each with its min–max limitations, in accordance with the NSF-WQI classification.
Our weighting strategy is not merely a mathematical convenience but is deeply rooted in the established theoretical foundations of the Horton and NSF-WQI models. These frameworks suggest that certain parameters, such as pH and turbidity, carry a disproportionate impact on overall water stability and consumer health. By aligning our custom weights with WHO and EPA safety thresholds, we ensure that the Water-QI system operates within a validated public health context. This theoretical alignment ensures that our predictive models are not just fitting numerical noise but are tracking the most critical biological and chemical risk factors defined by decades of environmental science research.
To ensure the Water-QI system reliability, specific operational thresholds were defined in accordance with WHO and Environmental Protection Agency guidelines [
55,
56]. In the proposed Water-QI implementation, the five monitored variables are combined through an application-specific weighted score rather than a canonical Horton or NSF-WQI formulation. The selection of the water quality index as a weighted score in this study was intended to be consistent with the air quality index metric, as mentioned in [
57]. Nevertheless, the NSF-WQI can easily be implemented at the Water-QI nodes as an additional measure.
With respect to drinking-water suitability, turbidity should ideally remain below 1 NTU and, in practice, not exceed 5 NTU. The pH value is commonly considered acceptable in the range 6.5–8.5, and total dissolved solids (TDS) are typically limited to 500 mg/L. By contrast, neither electrical conductivity (EC) nor temperature has a single universal WHO/EPA health-based drinking-water limit in the same sense. In the present work, the assigned weights of
,
, and
should be interpreted as operational surrogate variables whose influence is set by the custom weighting scheme of this study. Since the weights sum to 10, they correspond to normalized contributions of 25% for pH, 15% for temperature, and 20% each for turbidity, TDS, and EC. Selecting a larger weight for pH is similar to the NSF-WQI selection for water pH values. The same applies to temperature and weight selection. For all other measurements, a value of equal weights has been selected. Consequently, the resulting WQI index score is best described as a custom 0–100 water quality score derived from min–max-normalized measurements. In terms of class interpretation, the adopted bands, as mentioned in
Table 3, are not closest in direction to the NSF-WQI classification limits, where higher values denote better quality.
A critical design choice in the Water-QI architecture is the deployment of two separate physical sensors for EC and TDS. Although these parameters are theoretically correlated, where TDS (mg/L) is estimated as
(μS/cm), with a typical conversion factor of
, a single-sensor approach would introduce a static dependency that fails in complex environments. By utilizing distinct sensing elements, we overcome the limitations of pre-determined linear estimation. This redundancy allows the system to capture specific ionic fluctuations that a simple mathematical conversion might miss. For instance, one sensor may detect a spike in a specific mineral salt that alters the water’s conductive profile differently than total dissolved solids do. This dual-sensing strategy prevents blind spots in the detection logic, ensuring that, if one sensor reaches its sensitivity limit or encounters a specific type of ionic interference, the other remains as a fail-safe to maintain the integrity of the water quality index (WQI) calculation. According to regulations, TDS values above 500.0 ppm are considered medium/fair and set as very high for drinking water. Moreover, TDS values above 1200 ppm are considered unacceptable. In accordance, electrical conductivity (EC) is considered unacceptable for drinking water if a value of 2000.0 μS/cm and above is detected (see
Table 3).
Temperature measurements for the Water-QI node are performed using a DS18B20 sensor. This is because thermal variations significantly affect ion mobility. Maintaining water temperature between 5 °C and 15 °C is considered ideal for palatability and the prevention of microbial regrowth, which becomes a significant risk at temperatures exceeding 25 °C or with temperature variations of 10 °C (penalty value of 100). The following
Section 3.3 describes the metrics used in the authors’ experimentation.
3.4. Proposed Deep Learning Models for WQI Prediction
Following the extensive comparative analysis of the existing literature, we designed a targeted experimental framework. While complex hybrid models are popular, they often require significant computational power, which contradicts the philosophy of low-cost IoT smart city deployments. Instead, our approach focuses exclusively on gated recurrent units (GRUs). GRUs offer a streamlined alternative to LSTMs, requiring fewer computational resources and memory while maintaining excellent retention of temporal dependencies in time-series data.
Heavier architectures, such as temporal convolutional networks (TCN) or transformer-based models, were excluded from this specific study to focus on GRU models that adequately run primarily on edge computing, apart from the cloud scope, with close LSTM model predictive performance. Although effective in high-performance cloud environments, their self-attention mechanisms and heavy parameter profiles often lead to memory overflows or unsustainable latency on resource-constrained hardware like the Raspberry Pi Zero 2W, which is the cornerstone of the Water-QI framework.
To thoroughly evaluate the trade-off between predictive accuracy, temporal granularity, and computational cost, we developed and trained three distinct GRU architectures:
The Standard Model:
Designed with practical low-cost IoT deployment in mind, it consists of a single GRU layer with 64 units. This model is engineered to be computationally inexpensive, capable of running on edge devices, while capturing the general daily trend of the water quality index (WQI).
The High-Capacity/Heavy Model:
Built to capture maximum detail, this model significantly increases the network’s capacity to 256 units or more. It serves as our benchmark for maximum achievable accuracy, albeit at a higher computational cost.
The Deep GRU Model:
To test the limits of network depth and investigate potential diminishing returns, we constructed unusually deep multi-layer (up to 10) GRU architectures. This experimental model acts as a stress test to determine if extremely deep GRU layer networks justify their massive training times in the context of environmental monitoring.
To ensure training stability and prevent the models from simply memorizing the training data (overfitting), we applied rigorous regularization techniques across all three architectures. Batch normalization was applied after each GRU layer to stabilize learning, followed immediately by a 20% dropout rate to promote generalization. The final features are passed through a fully connected (dense) layer and reshaped to output the exact forecasted sequence (either the next 24 h or the next 1440 min) for the five key water parameters (temperature, TDS, EC, pH, and turbidity).
Employing a 1440-step sequence substantially increases input dimensionality, memory requirements, training costs, and inference latency compared to the 24-step hourly configuration. Extended recurrent sequences can also intensify optimization challenges, such as vanishing gradients and slower convergence rates. Consequently, GRU models were chosen instead of simple RNNs because their gating mechanisms enhance the retention of long-term dependencies. Additionally, batch normalization, dropout, learning-rate reduction, and early stopping were implemented to enhance training stability.
The models in the minute-resolution temporal scale also follow the previously mentioned classification of the standard, heavy, and deep GRU models. However, they have been classified according to their GRU depth as follows:
Small models:
Models of a single layer and their corresponding multi-layer derivatives of 64 (standard model) to 128 GRUs per layer.
Medium models:
Models of at least 256–512 GRUs per layer and their corresponding stacked-layer counterparts. A single-layer entity is considered a heavy GRU model, while a multi-layered entity is considered a deep GRU model.
Large models:
Models of at least 512 GRUs per layer, with significant representatives being the 1024 and 2048 GRUs per layer. A single-layer entity is considered a heavy GRU model, while a multi-layered entity is considered a deep GRU model.