Real-Time Water Quality Assessment via IoT: Monitoring pH, TDS, Temperature, and Turbidity

ABSTRACT


INTRODUCTION
The alteration in surface and groundwater quality has been observed as a consequence of industrialization and urbanization.Despite its paramount importance, water remains an elusive primary drinking source for an estimated 844 million individuals worldwide [1].Defined by its degradation from various human activities, such as agriculture and industry, 'wastewater' often presents significant challenges [2].Even though surface water is invaluable globally, its quality and composition are significantly influenced by diverse wastewater sources.Toxic substances, heavy metals, and both organic and inorganic particles are commonly found, accompanied by physical, chemical, and biological contaminants like bacteria and viruses [3].Disturbingly, such pollutants are believed to account for nearly 1.5 million annual deaths in children below five, primarily from ailments such as diarrhea [4].This revelation is further exacerbated when considering that a mere 3% of Earth's water resources are freshwater, and these resources are being contaminated at an accelerating pace [5].
Traditional methodologies, like atomic absorption spectrophotometry, gas chromatography, and flame photometry, have been employed for water quality assessment.Nevertheless, these techniques are often marked by substantial costs and extended analysis times [6,7].Moreover, the need to transport samples to laboratories for in-depth evaluation has been identified as a major limitation, resulting in concerns like heightened expenses and inefficiencies [8].
With technological progression, integration of WQI into novel assessment techniques has been observed.Such advancements have led to the creation of user-centric portable kits for on-the-spot analysis.However, occasional discrepancies between user needs and kit capabilities have been reported [18].Modern water quality probes introduced to the market have been associated with integrated data collection and internet transmission, making them increasingly accurate and straightforward [19].Furthermore, the fusion of Cloud Computing with the IoT has been noted, offering transformative monitoring capabilities [20][21][22][23].IoT, described by its network of interlinked devices boasting sensing and communication features [24], provides a continuous influx of data.Wireless Sensor Networks (WSNs), pivotal to IoT, function both at data and edge levels.Raw data is aggregated at a local level and subsequently dispatched to the Cloud for further refinement [25], streamlining and enhancing the overall monitoring process [26].
A notable gap in real-time water quality evaluation is acknowledged, stemming primarily from sensor limitations.
By capitalizing on open-source software and commercial hardware, the present study seeks to deliver real-time monitoring capabilities, despite sensor constraints, with an initial focus on parameters like pH, TDS, turbidity, and temperature.This method aims to bridge the discrepancy between sensor availability and effective water quality evaluation.

Developmental stages of the online monitoring system
The methodology underlying the creation of a real-time water quality monitoring system was segmented into three pivotal stages: a) Hardware and Software Design: In this foundational stage, the hardware and software components of the system were meticulously designed.Node stations were developed and sensors were integrated.During this phase, software tools suitable for data acquisition, storage, and transmission were chosen.
b) Calibration and Validation: Subsequent to the design phase, calibration of the integrated sensors was undertaken to ascertain their accuracy and reliability.Validation was concurrently conducted, where sensor outputs were juxtaposed with established standards to determine their precision across diverse environmental conditions.c) Software Design and Data Transmission Protocols: Upon validating the hardware and sensors, emphasis was placed on formulating software designs and data transmission strategies.This entailed the identification or development of appropriate data analysis algorithms, as well as the establishment of protocols to facilitate real-time data transmission from node stations to the central processing mechanism.
Together, these stages laid the groundwork for the eventual deployment of the real-time water quality monitoring system.The synergetic alignment of hardware, software, and data transmission strategies was deemed essential for ensuring the consistency and trustworthiness of the resultant water quality data.

WSN
A WSN is defined as a communication system that wirelessly interconnects a vast array of sensors, forging a robust framework for monitoring environmental parameters crucial to water quality assessment.At the heart of WSN functionality lie the Node Stations, which, being strategically positioned within the monitoring region, serve as vital conduits for data collection and transmission [34,35].By virtue of this integrated network, remote access to the systems and their accumulated data is made feasible.
Spanning a spectrum of applications, the relevance of WSNs is acknowledged in realms such as smart homes [36], healthcare [36], industrial sectors [36], energy management [37], transportation [38], agriculture [39], and prominently, environmental surveillance [40].Specifically in water quality monitoring, WSNs are employed to harness data from an assortment of sensors tasked with gauging parameters such as pH, TDS, turbidity, and temperature.These sensors are dispersed with precision across the monitoring expanse, ensuring data acquisition is exhaustive.The amassed data is then channeled to a centralized processing system via Node Stations, where it undergoes subsequent analysis and interpretation.
Elucidated in Figure 1 is the bifurcation of WSN architecture into two predominant models: centralized and distributed.Delving deeper, the taxonomical classification of WSNs encompasses variations rooted in sensor management during monitoring, culminating in configurations like single node-single sensor, single node-multi-sensor, multi-nodesingle sensor, and multi-node-multi-sensor assemblies [41][42][43][44].
Subject to the design and overarching objectives of the system, data visualization can be instantiated either in realtime [43] or archived for deferred offline scrutiny [44].It is imperative to acknowledge that the need for database facilities in some WSN implementations is obviated [45]; there exist systems where instantaneous data portrayal can be effectuated sans the mandate for expansive database reservoirs [46].

Integration of IoT and cloud computing in uninterrupted data acquisition and preservation
Defined as a network of uniquely identifiable entities encompassing sensors, actuators, data storage mechanisms, and Central Processing Units (CPUs) [47], the IoT has been identified for its proficiency in autonomous data interchange.Through this capability, CPUs are enabled to process sensor data, subsequently leading to informed decisions, with the subsequent actions being executed by actuators.
Within the purview of the present study, a pivotal role is played by IoT technology in facilitating real-time water quality surveillance.Through the integration of sensors into the IoT architecture, continuous data acquisition is ensured.
Parameters such as pH, TDS, turbidity, and temperature are securely channeled to cloud-based repositories [48], underscoring the preservation of the all-encompassing raw data.The amalgamation of IoT and cloud computing has been recognized as a potent solution for safeguarding raw data.By capitalizing on cloud capabilities, the sanctity of the amassed data remains uncompromised, while still being immediately accessible for ensuing assessment.
Illustrating its adaptability, the utility of IoT spans varied domains like agribusiness, healthcare, environmental stewardship, and disaster mitigation [17,[49][50][51].The inherent flexibility of its architecture permits limitless global object connectivity to the internet.Data collected is processed in cloud-based servers, culminating in insights congruent with the specific IoT service deployed [52].Given the intrinsic sensitivity of the information, it is noted that an exhaustive multi-tier security structure encapsulating data, edge, fog, and cloud security strata has been integrated, bestowing comprehensive fortification upon the entire apparatus [53].

Hardware and software design
During the phase of hardware and software design, meticulous configuration of individual node stations for the water monitoring system was undertaken.For each node station, a specialized role was envisioned: the aggregation and transmission of water-related data.The node stations were equipped with sensor probes designed to measure key water parameters, such as pH, TDS, temperature, and turbidity.
Data generated by these sensors underwent processing through dedicated signal converters.In this crucial conversion process, initial sensor readings were transformed into precise parameter values, a step commonly termed as data acquisition.Subsequent to this acquisition, data from various sensors were received by the microcontroller, and subsequently stored within the local database of the node station.This repository thus becomes an integral foundation for later stages of the study.

Calibration and validation
During the calibration tests, a verification procedure was employed to ascertain the level of error.The percentage error was formulated using Eq. ( 1), while the accuracy of sensor acquisition was determined by Eq. ( 2), wherein X represents the observed variable, and Xi denotes the predicted variable.
Calibration for the temperature sensors utilized in this study was deemed unnecessary due to the inherent calibration of the controlling library, Dallas Temperature.The validity of this parameter was further corroborated by comparing readings from the DS18B20 probe sensor and a conventional mercury thermometer.As illustrated in Table 1, a comparative analysis between the temperature sensor and the probe sensor using mercury as a reference yielded an error rate of 1.46% over ten iterations.Utilizing Eq. ( 2), an accuracy of 98.54% was deduced for the temperature sensor.The pH sensor underwent calibration with three distinct buffer solutions, having pH values of 4.02, 6.84, and 9.10.Post operation over the Arduino Leonardo housed within the Lattepanda board, the potentiometer on the accompanying circuit board was adjusted to align the serial monitor reading with the pH value of the buffer solution.A tri-phase calibration procedure was executed to fine-tune the settings.Furthermore, the efficacy of the pH sensor was validated across three pH categories: normal, alkaline, and acidic.The outcomes of this comprehensive validation are tabulated in Table 2. Throughout 15 test iterations, the pH sensor was evaluated under varying temperatures (ranging from 15 to 35°C) and distinct water pH levels.The derived average error rate was 3.15%, resulting in a pH sensor accuracy of 96.85%.Components of the turbidity sensor encompassed nearinfrared LEDs and photodiodes.An inverse relationship was observed wherein an increase in solution turbidity led to a decrease in the amount of light perceived by the photodiode, correspondingly reducing the photodiode voltage relative to unimpeded light transmission.Employing pure water as the 0 NTU reference, calibration of the turbidity sensor was conducted between 0 NTU and 100 NTU standards.The potentiometer was adjusted based on the resultant solution water value to derive the calibration equation from a linear fit of NTU values against voltage readings.
For the validation of TDS, a reference buffered TDS solution from a probe sensor was employed.The results of this comprehensive validation are presented in Table 3.Over ten iterations, the TDS sensor was assessed across a temperature range of 0-30°C.An error rate of 1.90% was identified, leading to a derived accuracy of 95.0% for the TDS sensor.

Software and data transmission design
Data procured from the sensor probes at each station node is stored and subsequently analyzed to assess water quality acceptability.Figures 2 and 3 delineate the data transmission design and the synchronization of data phases, respectively.
Such a design has been observed to provide advantages in the face of network challenges.In the event of a network disruption, data is preserved within the node station and dispatched to the cloud computing server once network continuity is re-established.This mechanism guarantees the integrity of the data, irrespective of network anomalies.Moreover, a filtration system is implemented, circumventing the transmission of duplicated or previously dispatched data.Figure 3

Component details
For the development of a node-station design, an amalgamation of components spanning hardware, software, and communication networks is necessitated.Within the hardware construct, all components were integrated onto a Lattepanda v1 board, a singular computer board with an embedded Arduino Leonardo (SKU: DFR0419, sourced from Dfrobot.com).The turbidity sensor (SKU: SEN0189 from Dfrobot.com) functions as both a light transmitter and receiver, complemented by an amplifier.Its signal pins were attached to the analog inputs of the Arduino boards.A distinct 64-bit ID was possessed by one of the DS18B20 temperature sensors (SKU: DFR0198 from dfrobot.com), allowing for the connection of multiple temperature sensors to a single pin, specifically designed for one-wire applications.
Constructed from a sensitive glass membrane with diminished impedance, the pH sensor (SKU: SEN0169-V2 from Dfrobot.com) ensures precise pH readings.This electrode is characterized by remarkable thermal stability, rapid responsiveness, and suitability for a diverse range of pH measurements.It displays consistent reproducibility, resistance to hydrolysis, and alkali error elimination.Notably, the output voltage of the electrode remains linear across the pH range of 0 to 14. Augmented by the Ag/AgCl gel electrolyte salt bridge, the reference system demonstrates resilience against contamination and a stable half-cell potential.
The ring PTFE membrane, resistant to easy clogging, is optimal for prolonged online detection.A BNC (Bayonet Neill-Concelman) cable served as the linkage between the pH sensor and a circuit board, subsequently connected to the Arduino board's analog input A1.
Among the sensors, the TDS sensor (SKU: SEN0244 from dfrobot.com) is noteworthy, connected to an analog input and featuring a waterproof probe for prolonged immersion in water.The analog turbidity sensor (SKU: SEN0189 from dfrobot.com) was also interfaced with the analog pin on the Lattepanda board, catering to water turbidity measurements.Figures 4 and 5 encapsulate the components utilized in the device, additionally showcasing the device in its elemental form.

Real-time data transmission
Referring to Figure 2, synchronization of raw data was achieved utilizing the HTTP response and HTTP request methods between each node station and the cloud server.Such methods ensure that newly stored data in a node station's database is subsequently dispatched to the cloud server.Four parameters were under investigation: pH, temperature, turbidity, and TDS.Data transmission was executed every 3 seconds, resulting in the delivery of 28,800 raw data points from each node station during a single day of observation.Notably, a swift data exchange was observed, with an average latency of less than 1 second, which was derived from the interval between data procurement at the node station and data reception at cloud computing server, as registered in the database.

Raw data of the water monitoring system
To corroborate the study's findings, data collection was undertaken from authentic scenarios.A node station was established in Troso Village, Jepara, Indonesia.As illustrated in Figure 8, the pollution levels in this area appeared elevated.Predominantly, the pollution emanated from residential sewage intermingled with waste from the home textile industry.Given that the river irrigates neighboring paddy fields, non-compliance with water quality standards may engender cascading pollution.Data procurement was conducted from 01:00 pm to 03:00 pm on November 22, 2022.Within this two-hour span, 4833 data points were amassed, with the average monitoring value presented in Table 4.

Discussion
Within the scope of this research, methodologies for enhancing water quality monitoring via a wireless sensor node network were scrutinized.The findings revealed the system's proficiency in real-time data acquisition, transmission, and subsequent storage in cloud-based repositories.Emphasis is laid on the pertinence of these findings to extant knowledge in this domain and potential real-world applications.
Efficiency in real-time data transmission was noted upon synchronizing raw data via HTTP response and request protocols between node stations and the cloud server.Such a mechanism enabled fluid data interchange, incurring a negligible average delay of under 1 second.These results underscore the system's capacity to provide accurate and timely insights into water quality, even amidst network perturbations.This synchronization approach was discerned to be imperative for maintaining data integrity amidst potential network disruptions.
The empirical deployment in Troso Village, Jepara, Indonesia, served as testament to the system's practical applicability.The continuous monitoring and transmission capabilities over a two-hour duration, culminating in the collection of 4833 data points, accentuate the system's robustness and reliability in dynamic environments.

CONCLUSIONS AND FUTURE DIRECTIONS
In this investigation, an integration of cloud computing and the IoT was effectively achieved, paving the way for a continuous real-time water quality monitoring system.Through this integration, seamless transmission of data streams, generated by sensors, to cloud platforms was facilitated.Notable accuracy rates were observed: 98.54% for temperature, 96.85% for pH, and 98.10% for TDS sensors.
The cardinal outcome of this research lies in the evidenced accuracy and reliability of the introduced real-time data acquisition methodology.Such results attest to the system's potential utility as an efficacious real-time monitoring solution.A solid foundation has thus been laid for subsequent research endeavors, especially focusing on the optimization of cloudbased computing to further enhance data acquisition speed and efficiency.
It is acknowledged that the present study is not devoid of limitations.Prospective studies might delve into enhancing the system's resilience to connectivity disruptions and gauging its adaptability under an array of environmental circumstances.Additionally, the potential integration of machine learning algorithms, aimed at refining data analysis and predictive capacities, merits exploration, as this could bolster the system's analytical prowess.
To encapsulate, the findings underscore the paramount importance of optimized data transmission techniques in the realm of real-time water quality monitoring.By addressing the intrinsic limitations of conventional systems and ushering in a rapid and dependable data conduit, the proposed methodology holds promise for elevating environmental monitoring protocols.It is envisaged that subsequent investigations will seek to refine this approach further and probe its synergistic integration with avant-garde technologies to furnish a holistic water quality assessment and management framework.

Figure 1 .
Figure 1.Synchronization data flowchart offers a visualization of the data transmission pathway from individual node stations to the cloud computing server, facilitating global accessibility.

Figure 2 .Figure 3 .
Figure 2. Design of node station data acquisition

Figure 4 .Figure 5 .
Figure 4. Front view of node station hardware implementation

Figure 6 .Figure 7 .
Figure 6.Data transmission from node station to cloud server

Figures 9 -
11 showcase the real-time online display of the acquired data.

Figure 8 .
Figure 8. Condition of the river in Troso village during a pollution event

Table 1 .
Results of temperature parameter verification

Table 2 .
Results of pH parameter verification

Table 3 .
Results of TDS parameter verification