Introduction

Water is an essential resource of living on the planet, whether it is for drinking purposes, industrial purpose, irrigation, or any other application. Globally, we utilize 70% of our water assets for agriculture and irrigation purpose and 10% for residential use [1]. It is consumed carelessly by the human being day by day. The rapid population growth has increased the consumption of water, but the resources (either natural or humanmade) are limited. The level of available water is regularly decreasing and may create a worse situation in the future. In developing countries, as much as 80% of sicknesses are connected to poor water quality and sanitation conditions [2]. India is one of the most water-challenged developing countries in the world. In India, 5% of death in an individual is due to diarrhea, which is among the top ten death causes in India. Death statistics in India are shown in Fig. 1. These are a few of the reasons behind drinking water quality assessment before consumption.

Fig. 1
figure 1

Source: World Health Organization-India: WHO statistical profile

Top ten cause of death in India.

Earlier people were using traditional water quality monitoring techniques involving sample collection on-site and laboratory-based chemical experimentation. This conventional method was time-consuming as well as labor and cost-intensive [3]. So, there was a need to have chemical-free testing and on-site measurement, which could avoid the use of high-cost toxic chemicals. To overcome this, many researchers make efforts that result in real-time and online water quality monitoring.

In this paper, a Raspberry Pi-based real-time water quality parameter measurement is proposed in which different water quality sensors are interfaced with the developed hardware platform to acquire data from various water samples. The results obtained from the developed setup are compared with the benchmark equipment Exo-1 from Sonde [4] for performance validation. The water quality parameters used are pH, Electrical Conductivity (EC), Oxidation Reduction Potential (ORP), Dissolved Oxygen (DO) and temperature.

Related Work

There are numerous papers in the literature claiming the development of water quality monitoring systems. Some of the papers are discussed in this section. Real-time water quality monitoring in the IoT environment has been attempted by many researchers. Vijaykumar and Ramya [5] and Arvind et al. [6] proposed a water quality monitoring system for real-time assessment based on the IoT platform. Vijaykumar used the “ioBridge” as an IoT platform, whereas Arvind used the “ThingSpeak” IoT platform. Das and Jain [7] developed a system using Zigbee and a GSM module for water quality monitoring. The proposed work can also track if someone is polluting the water and intimate the authorities. Chowdury et al. [8] developed a sensor-based system for water quality assessment in wireless sensor networks (WSN). Chowdury also implemented the SMS alert for the agents. Geetha and Gouthami [9] proposed a multi-sensor system for water quality monitoring in the IoT environment using the “Ubidots” server platform. Geetha also discussed a detailed literature survey about the work done in the same field by the researchers. Priya et al. [10] implemented IoT based real-time monitoring for contamination detection. Meyer et al. [11] attempted real-time monitoring for river pollution detection. Gopavanitha et al. implemented real-time monitoring and controlling of water [12].

The application of the Raspberry Pi board has also been increased in recent years. It has been used in increasing efficient usage of real-time traffic transportation [13], design of wireless vision sensor network for smart home [14], communication network for Multi-unmanned aerial vehicle networks [15]. The Raspberry Pi has also been used in the implementation of 3D wavelet transform [16], screening of skin cancer [17], and air quality monitoring [18]. More applications of Raspberry Pi are real-time video surveillance systems [19], video stenography allocation [20], biometrics implementation [21], and automatic logging of telephone calls in the reading room [22]. It can be observed from the above-mentioned paper that the Raspberry Pi has been used in numerous applications.

Based on the discussed literature survey, it can be stated that there is a need for a system, which can assess the water quality parameters in a real-time environment. In addition, which can reduce the labor cost as well as time consumption and the chemical used in the testing should be minimized or removed. And the processor should be capable of acquisition, analysis, and decision-making. So, we are exploring the hardware platform based on Raspberry pi for the assessment of water quality parameters.

Organization of the Paper

The organization of the entire paper is as follows. First, the introduction and literature review are presented. Second, the materials and methods detailing the selection of water quality parameters and embedded board and hardware platform design are described. Third, the experimental results are presented, and finally, discussions are described, followed by a conclusion.

Materials and Methods

Water Quality Parameter Selection

The parameters used in this study are decided by Central Pollution and Control Board (CPCB), New Delhi, India, as shown in Table 1 [23]. There are different categories of water that CPCB has defined for various purposes. In this paper, Type ‘C’ water is used for water quality parameter measurement.

Table 1 Central pollution and control board criteria for water quality [23]

Methodology

In this section, we will discuss the block diagram of the proposed system, hardware setup, and software framework.

Block Diagram of the Proposed System

The block diagram of the overall proposed system is shown in Fig. 2. The different water quality sensors to be interfaced, are purchased from Atlas Scientific, USA [24]. The sensors are pH sensor, electrical conductivity (EC) sensor, dissolved oxygen (DO) sensor, oxidation reduction potential (ORP) sensor, and temperature sensor, as shown in Fig. 3. Raspberry Pi board is used as a core controller, and the sensors are interfaced with it through serial port expander followed by python framework. There is only one hardware I2C for serial communication, and hence to extend the port, a multiplexer (serial port expander) is used so that all the sensors can be communicated simultaneously.

Fig. 2
figure 2

Block diagram of developed setup

Fig. 3
figure 3

Water quality sensors

Hardware and Software Framework Design

After the selection of the water quality sensors, there is a need to acquire the parameters from the water sample. A Raspberry Pi-based hardware platform is developed. Raspberry Pi is a single board credit card-sized micro-computer with ARM cortex A-53 processor with many onboard peripherals such as USB port, video card, HDMI port, audio jack, and GPIO [25]. All the sensors are connected to Raspberry Pi through the signal conditioning circuit. The advantage of Raspberry PI is its inbuilt Wi-Fi module, which enables it for IoT implementation, cloud storage, and remote access as well. The sensors and signal conditioning circuit require a 5 V DC supply, which is available on the Raspberry Pi board. Only the Pi board is required to power using a 5 V adapter.

In continuation of the hardware development, a software framework has been designed based on Python. A program for the acquisition of water quality parameters is written in Python v3.7. Python is a high-level, general-purpose programming software with a wide variety of open-source libraries such as sklearn, NumPy, Panda, Matplotlib, and SciPy for data preprocessing, analysis, and visualization as well. Python is also adopted for various platforms ranging from environmental to complex applications, such as database access, GUI development, network programming, web development, scientific applications, software, and game development. The flow diagram for water quality parameter acquisition is shown in Fig. 4. Initially, the sensors have to be awakened from sleep mode. After that, I2C communication needs to be established. Once the communication is established, water quality parameters can be acquired. Finally, the sensors can be set in sleep mode again. For live plotting of water quality parameters, the Matplotlib library is used.

Fig. 4
figure 4

Flow diagram for water quality parameter acquisition

Experimental Results

A Raspberry Pi-based hardware platform for quality parameter measurement has been proposed in this paper. The developed setup consists of different water quality sensors, a serial port expander, and a Raspberry Pi development board, followed by Python software. All sensors have been calibrated before testing with the reference solution given for each sensor to avoid uncertainty in measurement. The reference solutions used for calibration were of analytical grade and non-toxic. The developed hardware setup has been tested for various water samples. The obtained parameters have been compared with the results obtained from the sonde sensor and are shown in Table 2. The procedure of data acquisition is implemented on the Raspberry Pi development board using Python programming. Along with the acquisition of water quality parameters, plotting of the same parameters has been done in real-time. One of the parameters (conductivity) plot is shown in Fig. 5. The x-axis corresponds to the time in seconds, and the y-axis corresponds to the water quality parameter.

Table 2 Results Comparison of Parameters Obtained from Developed Setup and Benchmark, and their calculated PRE
Fig. 5
figure 5

Live electrical conductivity plot

Performance Validation

To ensure the accuracy of the used water quality sensors, the obtained results were compared with the benchmark. The performance analysis of water quality sensors was done by calculating the Absolute Percentage Relative Error (APRE) [26]. APRE expresses the error in percentage to determine the accuracy and is given by Eq. (1):

$${\text{Absolute}}\;{\text{PRE}} = \left| {100 \times \left( {\frac{{{\text{actual}} - {\text{observed}}}}{{{\text{actual}}}}} \right)} \right|.$$
(1)

Here the actual reading is the one obtained from the benchmark, and the observed reading is derived from the developed setup. The absolute PRE is calculated for various water samples and is shown in Table 2. The maximum absolute error obtained is 2.56, and the minimum is 0.11 for DO and pH sensor, respectively. The entire APRE ranges from 0 to 3% for all the water quality sensors. The lower PRE shows better accuracy of the water quality sensor and vice versa. The APRE is also displayed in graphical form in Fig. 6. The x-axis represents the sampling locations, and the y-axis represents the APRE in percentage.

Fig. 6
figure 6

APRE plot for water quality parameters

Discussion

The suitability of the Raspberry Pi development board based developed hardware for water quality parameter measurement has been investigated in this paper. Five water quality parameters have been monitored in this work, namely temperature, pH, ORP, DO, and EC. More parameters can be derived from these parameters for, e.g., Total dissolved solids (TDS), and salinity can be derived from the conductivity [27]. While observing the results acquired from the developed setup, it can be stated that Raspberry Pi could be the future of water quality monitoring. Many more features can be further implemented in the Raspberry Pi, such as IoT and cloud-based monitoring, data analysis, wireless sensor network, and machine learning. An interactive user interface can be designed for live plotting and parameter measurement.

Currently, we have not added the E. Coli. and turbidity in measurement. No literature found citing the presence of E. Coli. in the Rajasthan Province of India as the study area has dry weather conditions, where the chance of growth of E. Coli. is very less. E. Coli is presented only, where the storage container is not appropriately cleaned or old distribution pipeline or the pipeline leakage or bad sanitation condition [28, 29]. The turbidity can be added in the future as low-cost sensors are available easily.

Cost-Effectiveness of the Developed Setup

The cost of any water quality monitoring system is the combined cost of hardware and software. Many companies charge a considerable amount for the device as well as software. The benchmark used in this paper costs us 800 K INR, which includes the cost of both the instrument and the software as well. In comparison, the developed setup cost was less than 60 K INR, including water quality sensors and Raspberry Pi development board. There is no cost for software as the Python is open-source software, which reduces the overall system cost and makes the system cost-effective.

Comparison with Other Work

Various papers are discussed in the “Related work” section. Some of the authors have used the Arduino development board; some have used the older versions of Raspberry Pi. In the case of IoT implementation, these development boards need additional Wi-Fi modules to be interfaced. Whereas in the proposed work, the latest version of Raspberry Pi is used, which does not require any additional module as it has inbuilt Wi-Fi and Ethernet module as well. The only requirement is either wired or wireless internet connection. An additional advantage of the Raspberry Pi is that it could operate on 12 V DC supply, which enables it for field and remote area deployment. A comparison of the proposed method with the existing state of the art technologies has been performed in Table 3. The comparison is made based on sensor accuracy, communication technology of the system, and the software used. It can be observed from the table that the water quality sensors have higher accuracy in the proposed method except for pH. In addition, there is no need for external module integration for communication, and open-source software is used for the cost-effectiveness of the system, as discussed earlier.

Table 3 Comparison of the proposed method with existing methods

Conclusion

Traditional water quality measurement methods are now obsoleting due to the development of real-time in-situ water quality monitoring systems. This paper demonstrates the Raspberry Pi-based real-time water quality parameter measurement using different water quality sensors. This approach can be an efficient way for water quality monitoring in smart cities as compared to a manual approach. The developed setup consists of a multi-sensor array, Raspberry Pi as a hardware platform, and Python as a software framework. The results obtained from the setup were compared with the benchmark for validation. The developed setup can be used for logging, processing, and analyzing the data in a real-time environment. Real-time monitoring is essential for several applications such as environmental monitoring, lake, and river water quality monitoring, distribution networks monitoring, and contamination detection in drinking water. The proposed work can be modified according to the required application such as urban, rural, and environment. In the future, the focus will be on the implementation of water quality monitoring using fuzzy logic in the IoT environment and distribution networks.