Introduction

Location-based remote water quality monitoring and data collection have been always a great challenge for different water laboratories and public health engineering departments (PHED). Most of the water laboratories and public health engineering departments are highly dependent on manual data collection and storage process, which is time-consuming and highly prone toward human error. Recently, there is a grown interest in the area of remote water quality data collection using various approaches such as wireless sensing node-based water quality measurement Rasin and Abdullah (2009), GPRS-based remote water quality analysis Ionel et al. (2015) and many more. Real-time water quality monitoring is a key to understand the chemical, physical and biological parameters of water samples and also to take remedial action as and when the need arises. Water quality judgment depends on large numbers of parameters such as chemical, physical and biological parameters. Physiochemical parameters measurement and monitoring are the most concerned issues according to water quality status of various Indian states Singh et al. (2012). In early age, water quality measurement was totally dependent on various chemical methods which are time-consuming, less reliable and required skilled human intervention Bartram and Ballance (1996); CPCB, Guide Manual. Further, colorimetric-based water quality sensing kits Ellerbee et al. (2009); Daniel et al. (2009) are also introduced by several researchers and few of them also reached up to commercialization [APPLIED MEMBRANES INC., homepage; HANNA instruments, homepage]. Indian water laboratories and public health engineering departments (PHED) rely on chemical-based methods and stand-alone instruments for water quality evaluation and database generation. Various water quality assessment methods have been reported in different studies such as monitoring of: lakes or ponds Haider et al. (2016); Kafli et al. (2016); Wiranto et al. (2015); Siyang and Kerdcharoen (2016), swimming pool Marais et al. (2016), wastewaters Oscanoa et al. (2016) and potable waters GH (2015); Regan et al. (2009). Recently, there has been a growing interest to develop smart water quality sensor-based systems along with different advanced features such as wireless data communication, alarm indication and auto-calibration Putra and Harsono (2016); Lee and Deininger (1992); Cloete et al. (2016). Few efforts have been observed in the direction to develop a floating water quality monitoring systems to assess the water quality of ponds and lakes. Most of them are manually driven Ethier and Bedard (2007); Vaddadi et al. (2012); Kafli et al. 2016, while some are autonomous Dunbabin et al. (2009). Power usage is one of the crucial aspects in such kind of applications, and continuous efforts have been observed in the direction of low power technology development. Researchers tried to solve power usage problem by connecting water quality measurement system with a solar panel Konyha (2016). Water quality indexing is also one of the key challenges and needs to be addressed, especially in case of drinking water. Multiple sensing variables such as pH, TDS, ORP, salinity, conductivity and many more need to be processed using different modeling techniques and convert them into a single water quality index. A single parameter-based water quality index can be easily evaluated. Few efforts have been observed in the direction of converting multiple water quality parameters into a single water quality index using rule-based fuzzy model Roveda et al. (2010) and neural network Gorashi and Abdullah (2012). Non-contact-based sensing techniques also have been explored for water quality parameters measurement. Simple led and photodiode-based optical sensing setup for turbidity measurement Komiyama et al. (2015) and ultrasonic-based water quality measurement Khairi et al. (2015) have been discussed by several researchers, but most of them have not reached up to maturity level. Finally, water quality evaluation still implies various challenges such as low power readout interface design, automatic data transfer, storage, portability, water quality indexing, analytics and many more. Presented work introduces a handheld smartphone-based device to analyze the water quality along with location information of testing sites in different applications. This device requires low power and uses smartphone for data storage and analysis. Dedicated Android application stores water quality parameters on the smartphone, transfers to the cloud with location information, predicts water quality index in real-time and also provides facility to integrate water quality data with Google map for rapid judgment and analysis at district, state and country level. The rest of the manuscript is organized as follows. Section II provided a detailed description of the embedded system for water quality inspection. Section III consists of the description of the implementation procedure for the smartphone-based Android application, along with its feature and utility. Section IV discusses the algorithms used for water quality indexing. Section V presents testing of the proposed system for different water quality evaluation scenarios. Section VI includes the performance evaluation, while the conclusions have been shown in section VII.

Embedded system design and development

An embedded processing unit has been designed and developed to acquire the data from off the shelf available sensors imported from Toshcon Corporation & Ltd. Measured pH and TDS dataset have been used to predict other water quality parameters such as salinity, conductivity and ORP using standard mathematical models. Measured and derived water quality parameters have been used to predict a water quality index by means of different statistical modeling techniques. Developed smartphone-based handheld embedded system for water quality measurement is a step toward the development of a lightweight, low cost and easy to use modular embedded water quality inspection system.

Hardware development

The embedded system (Fig. 1) consists of various submodules such as signal conditioning unit, microcontroller unit, classical Bluetooth module and a rechargeable battery. The signal conditioning unit represents resistance to frequency converter. It is used to measure the resistance variation of the TS sensor along with an analog front-end circuit (LMP91200) [Sensor AFE System] for pH sensor. Two different resistance to frequency conversion approaches have been explored and compared based on their performance. Filter-based noise removal and impedance matching conditioning have been integrated with the resistance to frequency conversion unit. Amplification scaling procedures are used to adjust the sensor response from 0 to 5 V. Overall readout circuit has been interfaced with 8-bit microcontroller unit for data acquisition and processing. A classical Bluetooth module (HC-05) imported from element 14 Corp. Pvt. Ltd along with E2PROM has been integrated with microcontroller unit for on host data storage and data transfer to the smartphone. Overall, the embedded system is portable, low cost and easy to operate via smartphone-based android application. The system works on 7.5 V battery for more than 8–10 h continuously without charging.

Fig. 1
figure 1

Functional block diagram of proposed water quality measurement system

The TDS sensor resistance varies (Fig. 2) from 1.5 to 0.350 MΩ for 0 to 2000 ppm water sample.

Fig. 2
figure 2

TDS sensor characteristics (TDS = f(R)) (Temperature = 20 °C)

First resistance to frequency conversion approach (Fig. 3) Bandyopadhyay et al. (2016) consists of a 555 timer-based astable multi-vibrator to convert sensor resistance information to frequency variation (Fig. 4).

$$f = \frac{1.44}{{\left( {R_{y} + 2R_{x} } \right)C}}$$
$$R_{x} = \frac{0.72}{fC} - R_{y}$$
$${\text{TDS}} \left( {\text{ppm}} \right) = - 2208.1R_{x} + 2825.1$$
$$R_{x} = \frac{{\left( {2825.1 - {\text{TDS}} \left( {\text{ppm}} \right)} \right)}}{2208.1}$$
$$f = \frac{1.44}{{\left( {R_{y} + \left( {2825.1 - {\text{TDS}}} \right)/1104.05} \right)C}}$$

where Rx is the resistance of TDS sensor, and Ry and C are the values of the corresponding circuit elements. Ry has been used for calibration.

Fig. 3
figure 3

Resistance to frequency conversion scheme (first TDS sensor readout approach)

Fig. 4
figure 4

Frequency characteristics using first approach (F(Hz) = f(R(MΩ)) (Temperature = 20 °C)

One of the other resistance to time conversation approaches (Fig. 5) De Marcellis(2008) also has been explored to convert the resistance variation to time information. This approach works based on the integration of current flowing through the sensor exited by a D.C. pulse signal provided through closed-loop feedback. This scheme consists of three different stages such as integrator along with amplifier in primary stage to integrate the current flowing through the sensor, comparator unit in the second stage for threshold detection and ex-or gate in the last stage to eliminate the common feature in both signals. The timing of output signal depends on the current flowing through the sensor. Second resistance to frequency approach results has been compared with the first one in the context of power consumption, portability and range. It has been concluded that, for our application, the first approach requires very less power, covers the target concentration range and occupies less physical space.

Fig. 5
figure 5

Resistance to time conversion scheme for TDS sensor readout (second TDS sensor readout approach)

Commercially available low power analog front-end (LMP91200) [Sensor AFE System] imported from Texas Instruments has been used for pH sensor interface followed by impedance matching and amplification circuit. The output of the analog front-end (LMP91200) has been fed into the noise removal unit, amplification unit along with post-scaling unit to scale signal from 0 to 5 V for 0 to 14 pH buffer solutions (Fig. 6).

Fig. 6
figure 6

pH versus scaled output voltage curve recorded using pH sensor readout circuit (Temperature = 20 °C) (R2 = 0.99)

K type thermocouple has been used for temperature measurement of the water samples, and further data have been used to compensate the effect of temperature variation over pH and TDS sensor. Other parameters such as salinity, ORP and conductivity have been derived from pH and TDS data using standard mathematical relationships. Embedded system schematic and functionality flow diagram have been presented as follows (Fig. 7).

Fig. 7
figure 7

a Schematic of various components of smart water meter prototype and b integration scheme of smart water meter (SWM-1.0)

Software package development

Various modular programs are written in cross C and C++ compiler for the functioning of ATMEGA 328-based handheld water quality measurement system. The main software module initializes the water quality sensors, analog to digital converter, E2PROM, Bluetooth module, serial port and also checks all sensors connections along with battery level. A menu-driven program has been developed to operate smartphone-based water quality measurement system. Menu-driven program consists of testing and calibration submodules for testing of water samples and calibration of sensors, respectively. Calibration mode provides facility to calibrate device with standard buffer samples using 2, 3 and 5 point calibration algorithm.

The smartphone-based application provides facility to select the sensor type and calibration method and further uploads the calculated calibration coefficients (offset and gain value) of linear models to the device. Device saves calibration coefficients in E2PROM as a backup and also updates its prediction models with new calibration coefficients.

Measurement mode consists of various submodules for data acquisition, storage, water quality parameters prediction and data transfer to the smartphone. Predicted parameters converted in to a single data chunk along with start, stop and a parity bit for transferring data to the smartphone without any error. It also includes I2C-based E2PROM read and write module to recall the stored calibration coefficients. All modular programs have been linked to the main menu program to operate smartphone-based water quality measurement system.

Android-based smartphone app interface development

A smartphone-based android application (Fig. 8) has been developed to communicate with the device using Bluetooth protocol. A classical Bluetooth module (HC-05) has been used to establish communication between handheld device and smartphone. The android application provides a front-end view to display water quality parameters along with temperature and battery level. It also provides facility to collect location information of water sites and store them on the smartphone in excel file format. Android app provides facility to connect the smartphone with Google firebase cloud and save per minute water quality data along with location information. As global positioning system coordinates changes only after moving a certain distance, but there could be a possibility that two water sites are so near that even global positioning system cannot discriminate them. Android application tackles the above-mentioned problem by providing facility to share testing site details, description and picture along with water quality information. Android application provides an on-site auto-calibration feature to calibrate sensors using different calibration methods such as 2, 3 and 5 point calibration and saves calibration history in the smartphone itself for record purpose. Android application provides multiple options to share location-based water quality data and warnings using multiple options such as SMS, WhatsApp and e-mail.

Fig. 8
figure 8

Smartphone-based water quality measurement system operation with different features of developed android app

Performance evaluation and applications

Smartphone-based water quality measurement system has been tested with standard water quality measurement system PCD 650 imported from Eutech Instruments. Water samples collected from nearby villages and institute colony have been accessed using smartphone-based water quality measurement system. The similar set of samples have been accessed with standard water quality measurement system imported from Eutech instruments.

It has been observed that smartphone-based water quality measurement has an excellent accuracy (Fig. 9) to predict water quality parameters. The developed system shows excellent results to predict pH, TDS, conductivity, salinity and ORP with the accuracy acceptable to Indian water quality standards. Presented work has been compared with past literature (Table 2), and it has been found that smartphone-based water quality measurement system could be a low-cost tool for location-based water quality measurement as well as it could be used in each Indian water quality measurement laboratory.

Fig. 9
figure 9

a Experimental setup for developed system validation, b accuracy plot of various water quality parameters and c measured water quality parameters vs actual water quality parameters

System has been tested for different water quality measurement applications such as handy water quality meter for instant water quality judgment, integrated with reverse osmosis plant for real-time water quality monitoring and also converted into a floating water quality monitoring node to assess the water quality of small lakes and ponds.

A real-time water quality monitoring

System has been integrated with reverse osmosis water purification plant installed in institute campus for input and product water quality monitoring (Fig. 10). A cylindrical shape sampling chamber made of plastic along with three D.C. solenoid valves has been used to maintain the constant water flow. Sensors have been installed inside the sampling chamber for water quality measurement. Valves have been controlled by reverse osmosis controller unit. Product and raw water have been passed alternatively through the sampling chamber. Installed water quality measurement system transfers water quality information to the smartphone-based android application and also to cloud for record and analysis purpose.

Fig. 10
figure 10

Integration of smart water meter with RO plant for real-time water quality monitoring

Floating water quality monitoring system

System has been integrated with a plastic cubic hollow platform having dimensions of 12 cm × 10.0 cm × 6.0 cm to monitor the water quality of small ponds and lakes (Fig. 11). The direction of the floating system has been managed by a string tied to the platform as well as wind flow. System acquires water quality data per minute. System has been tested in institute small fountain pond, and acquired data have been transferred to the cloud using smartphone app interface. Overall idea is to demonstrate the utility of smartphone-based water quality monitoring system for water quality monitoring of small ponds and lakes. Floating system has been tested for ten days. Average readings of each day for every water quality parameter have been calculated and presented as follows (Fig. 11).

Fig. 11
figure 11

Floating water quality monitoring system along with acquired water quality parameters of pond water

Instant water quality judgement

System also has a potential to use for instant water quality judgment at different rural and urban places. System has been tested at different villages, and location-based water quality data (Fig. 12) have been transferred to the cloud. Collected location-based water quality data have been integrated with Google map for analysis at the village level. Acquired water quality data have been used to predict water quality index using different statistical and ANN-based techniques. Water quality can be easily and instantly judged based on the predicted water quality index with different thresholds. Smartphone-based app also shows warning in the form of color indication based on the quality of the tested water sample. Red color indicates for totally contaminated and non-drinkable, yellow for mordantly contaminated and needs treatment before drinking and green for safe drinkable water. System has been tested at seven nearby villages of Rajasthan. The overall idea is to demonstrate the concept of automatic water quality data collection along with location information. The presented method is less prone toward human error and highly useful for Indian water laboratories and public health engineering departments for water quality data collection of different rural and urban locations.

Fig. 12
figure 12

Collected location-based water quality data of nearby villages of Rajasthan

Water quality indexing

Water quality depends on several physiochemical parameters and complex to understand for a common person. It is difficult to judge the water quality based on the variation of multiple water quality parameters. Water quality index (WQI) is an important and unique rating to depict the overall quality of water in a single term, and also it is easy to understand for everyone to select the right quality of water or to select appropriate treatment technique to improve the quality of water Tyagi et al. (2013). Water quality measurements are often processed using various mathematical models to find the score for water quality status. Several models for water quality indexing have been explored using different methods such as weighted average method, weighted geometric mean method, minimum operator and hybrid methods. Most of these methods process different water quality parameters using basic mathematical operations with standard weights and calculated sub-index Krishan et al. (2016).

Few of the algorithmic approaches such as partial least mean square regression based Sim et al. (2015) and fuzzy based Bai et al. (2009) have been tried to make water quality prediction process more intelligent and less time-consuming. As it is difficult to correlate single water quality parameter with water quality index, researchers have used several water quality parameters to predict water quality index such as pH, TDS, TSS, DO, BOD, COD and many more. Selection of water quality parameters to predict water quality index is a very important step and should be selected on the location and application basis. Selection of a large number of input parameters makes WQI prediction model complex and time-consuming. Five different water quality parameters such as pH, TDS, salinity, conductivity and ORP have been selected according to Rajasthan water quality scenario and further used for water quality indexing. Target water quality index values have been calculated using weighted arithmetic index method Sengupta and Dalwani (2007) for collected water quality samples data from various villages of Rajasthan. Standard and ideal values have been taken from Bureau of Indian Standards (BIS) for drinking water. Various statistical methods have been implemented to predict water quality index and further compared based on their accuracy and complexity.

Further, artificial neural network-based learning scheme with three different training techniques also have been explored to predict water quality index and results have been compared with results obtained with statistical modeling methods.

Statistical modeling

Various statistical methods have been implemented to predict water quality index, and results have been compared based on their prediction accuracy. Principle component regression (PCR) Jolliffe (1982), partial least square regression (PLSR) Sim et al. (2015) and multiple linear regression (MLR) Grégoire (2014) have been implemented on acquired water quality parameters data to predict water quality index. Selection of latent input variables to generate reliable prediction models is a crucial step. As less number of input latent variables can loss the information, while a large number of input variables can lead toward complexity. Variance analysis (Fig. 13) has been performed to select the optimal number of PLS components. Overall five input latent variables have been selected for the water quality index prediction model based on the variance analysis.

Fig. 13
figure 13

Water quality indexing prediction using partial least mean square regression (PLSR)

MLR, PCR and PLSR statistical modeling techniques have been used for water quality index prediction model, and it has been observed that PLSR method predicts water quality index less accurate (Fig. 13) (R2 = 95.81%) compared to other two methods. PCR and MLR predict better results (R2 = 99.99%) (Fig. 14) compared to PLSR.

Fig. 14
figure 14

Predicted water quality index using multiple linear regression (MLR) method

The reason behind the higher accuracy could be the method used for target water quality index prediction. As weighted arithmetic index uses the linear combination of water quality parameters and further calculates water quality index.

Artificial neural network (ANN)-based modeling

ANN-based modeling technique also has been explored to predict water quality index. Multi-input and single output-based neural network architecture has been used to predict water quality index. Five water quality parameters have been used as inputs in the input layer and single output water quality index in the output layer. The optimal number of neurons in the hidden layer has been achieved using trial and error method (4 trials (neuron count = 2, 4, 6 and 8) for each training algorithm). Three different training techniques such as Levenberg Marquardt, Bayesian regulation and conjugate gradient have been explored and implemented in MATLAB 2015a to achieve best results. Further, results have been compared on the basis of mean square error, number of neurons and accuracy. Hidden layer neurons have been varied from 2 to 8, and obtained results have been compared in the context of complexity, computation time and accuracy. Total water samples dataset (50 samples) have been divided into three different datasets such as training, testing and validation. Training dataset consists of 70% of the dataset, while testing and validation consist of 15% each. Out of all three training techniques, conjugate gradient performs worst and predict results with highest mean square error (749–0.5439 for 2–8 neurons in hidden layer) and least accuracy (R2= 86.38–99.98 for 2–8 neurons in hidden layer), while Bayesian regulation performed best with least mean square error (0.005 × 10−5) and with highest accuracy (R2= 100%) at very less number of neurons in the hidden layer (4 neurons). Performance of all three training techniques has been compared based on the variation of mean square error with the variation of the number of neurons in the hidden layer (Table 1).

Table 1 Performance comparison of three different training techniques used of water quality index prediction

MLR and PCR also have shown the similar level of accuracy as ANN-based approach has shown. MLR and PCR are just linear models and take less computation time (less additions and multiplications) compared to neural network approach. MLR-based prediction model for water quality index prediction has used to train smartphone-based water quality monitoring system. Further, water quality index has been predicted for water samples collected from nearby villages of Rajasthan (Fig. 15).

Fig. 15
figure 15

Water quality indexing of nearby villages of Rajasthan

Discussion and conclusion

This paper reported a handy smartphone-based battery operated water quality measurement system to measure water quality for different applications. A smartphone-based application interface with various advanced features such as location-based data collection, storage on the cloud, integration with Google map for quick judgment, sensor calibration and many more has been introduced. System has been tested for various water quality measurement applications. Different statistical and ANN-based algorithms have been explored to predict water quality index. Presented work consists of various innovations such as location-based water quality measurement and storage, water quality indexing prediction, hassle-free operation, on-site calibration and many more. Presented work has been compared with past literature (Table 2), and it has been found that system could be a low-cost tool for water quality measurement at various rural and urban places. The overall system is cost-effective, portable and easy to use for villagers or any unskilled person.

Table 2 Comparison of presented work with previous literature