Introduction

Due to rapid urbanization and industrial development, heavy metal pollution in groundwater has become a major issue throughout many countries all over the world, owing to their possible toxic effects in people’s life. Heavy metal ions are highly toxic species, which can cause long term damage to the biological systems. These species are also well known to disrupt biological events at the cellular level (Knecht and Sethi 2009). Aquatic environments including freshwater and coastal marine waters are often contaminated with numerous organic and inorganic compounds. Among these pollutants, heavy metals cannot be easily detoxified via degradation. Most of these heavy metals such as Fe (III), Cu (II), Hg (II), Cr (VI), and many more can act as ecological toxins in aquatic echo system and may pose a health risk to humans and also to the environment (Wang et al. 2014). Currently, heavy metals have been measured using highly sophisticated equipment’s developed by various researchers over the time period such as atomic absorption spectrometer (AAS), inductively coupled plasma/atomic emission spectrometer (ICP/AES), and inductively coupled plasma mass spectrometer (ICPMS). Though most of these methods are ultra-sensitive and relatively accurate, they are also time consuming and costly and require high-skilled manpower and best suited for laboratory-level applications (Ansari et al. 2004). Other than these methods, ion-selective electrode (Sauvé et al. 1995), voltammetry (Sonthalia, et al. 2004), e-tongue (Karkra, et al. 2017), etc., based methods also have been explored by various researchers to detect and quantify different heavy metals presence in water samples. Unfortunately, most of these methods have various flaws such as sensitivity and selectivity toward specific ion, cleaning of the electrode, and drift over the time period and many more (Lu, et al. 2018). Recently, aptamer-conjugated gold nanoparticle-based colorimetric sensor have been reported for mercury detection in drinking water samples. Reported colorimetric-based sensor has been integrated with the smartphone-based reader to correlate change in color with the concentration of mercury ion in the water sample (Sajed 2019). Another similar kind of application using aptamer-conjugated gold nanoparticle colorimetric sensor with smartphone-based readout has been reported to detect mercury ion contamination in drinking water samples. Reported range of mercury ion commination detection in water sample is around 3.5 ppb (Wei, et al. 2014). Another colorimetric sensing-based application has been reported to detect chromium contamination in water samples. Synthesized silver nanoparticles (Ag NPs) without surface functionalization have been used for colorimetric sensor fabrication. Further UV–VIS spectrometer has been used to analyze the change in color and also to correlate with the concentration of chromium in water sample (Ravindran, et al. 2012). Another very interesting effort has been observed to detect multiple heavy metal contamination in drinking water samples using a chemically functionalized microfluidic-based platform. Reported microfluidic-based platform has been tested to detect multiple heavy metal ions such as Cr (VI), Hg (II), and Ni (II) contamination presence in water samples (Devadhasan and Kim 2018). Another very simple colorimetric-based sensing method has been reported to detect lead ion contamination presence in water sample with the range from 0.5 to 500 ppm. Property of selective binding nature of sulfur ions with lead ion presence in water samples have been used to fabricate colorimetric sensor (Yan and Indra 2012). Another very interesting method has been proposed to realize the visual detection of mercury ions via anti aggregation of gold nanoparticles. Further UV–VIS spectrometer has been used to correlate change in color with mercury contamination in water sample (Ding, et al. 2012). Apart from single heavy metal contamination detection in water sample, various methods also have been reported to detect multiple heavy metal contamination presence in water samples. In one of the recently reported methods, fluorescent carbon nanodot-based microarray has been fabricated to detect multiple heavy metals contamination detection in water samples. Fabricated fluorescent carbon nanodots microarray-based sensing platform has been coupled with smartphone-based color detection application to correlate change in color with the concentration of heavy metal contamination presence in water samples. Reported application has been tested to multiple heavy metals contamination in water such as mercury, copper, and lead (Xiao, et al. 2020). Another similar kind of smartphone-based PDMS microfluidic kit has been reported to detect mercury and arsenic contamination presence in water samples (Motalebizadeh, et al. 2018). Further capability of smartphone to detect change in color has been exploited to measure mercury contamination in water by integrating smartphone-based application with fabricated paper-based colorimetric sensor (Firdaus, et al. 2019). Another colorimetric sensor array for discrimination of multiple heavy metal ions presence in aqueous solution based on three different kind of thiols as a receptors. Reported application has been tested to detect 11 different heavy metal contamination such as Ni (II), Zn (II), Mn (II), Ag (I), Cd (II), and Fe (III) (He, et al. 2018). Another novel method for simultaneous detection and identification of multiple heavy metal ions in water samples. Reported application has been tested to detect three different heavy metal contamination in water samples such as Fe (III), Fe (II), Co (II), and Hg (II) (He, et al. 2018). A simple colorimetric reagent-based method to detect chromium and iron contamination presence in water sample. Two different digital image processing methods have been reported and compared to measure the change in color (Firdaus, et al. 2014). In another application, laser-induced breakdown spectroscopy has been reported to detect multiple heavy metal contamination presence in water samples. Reported application has been tested for multiple heavy metals such as Cd, Cr, Cu, Ni, Pb, and Zn (Zhao et al. 2019). Further, a simple colorimetric sensor for detection of multiple heavy metal in aqueous solution has been reported. Rhodamine used as a base material for the fabrication of colorimetric sensor and further tested to detect Cu, Cr, and Ni contamination detection (Kadem et al. 2019). In another effort, candidate method identification has been used to identify colorimetric sensing reagents to detect arsenic contamination in water samples. Further UV–visible spectrometer has been used correlate the change in color with the concentration of arsenic contamination present in water sample (Lace, et al. xxxx). Various colorimetric methods coupled with electronic readers have been reported by so many researchers over the time period, but unfortunately, very few of the efforts have reached up to the commercialization level (Merck 2020; Feedwater, https:, , feedwater.co.uk, water-testing-for-metals-and-heavy-metals, , Assessed 05th June 2020). Various colorimetric chemical kits to detect different heavy metals contamination in water sample are available in the global market. Most of the chemical kits are very easy to use and cost-effective but has various problems such as exact quantification of heavy metal concentration, dependent on human visibility for matching the color change with color chart. Even most of the chemical kits gets isolated due to damage or loss of color chart. The presented invention integrates existing chemical kits knowledge with developed IoT-enabled handheld spectrometer to predict concentration of multiple heavy metals contamination in drinking water samples.

Material and methods

Two different versions of handheld chemo-electronic systems have been developed to measure the heavy metal (copper and iron) concentration in water sample with the help of imported chemical kits. One of the version has capability to operate standalone and does not have capability to transfer data to cloud while as other version works with the developed smartphone-based android app and also has capability to transfer data to cloud. Developed handheld system works based on the principle of visible spectroscopy for detection of the change in color produced by imported chemical kits. Various chemical kits available in global market have been explored, and detailed experimentation has been carried out and best results shown chemical kit has been selected for final water quality analysis. Further, known heavy metal concentrations from 0.001 to 5 ppm have been used to design calibration curve. Calibration curve has been used to train developed handheld spectrometer and further tested for unknown samples collected from nearby villages. Results obtained with the developed system have been validated using commercially available system for heavy metal contamination measurement imported form HANNA instruments. Details of various experiments, system development, calibration, training, testing, and development have been shared as follows.

Experiments with chemical kits

Standard buffer solutions of 1000 ppm copper and iron samples have been procured from Sigma Aldrich, India. Procured standard buffer solutions have been further diluted using DI water and buffer solutions of different standard concentration have been prepared. Eight standard copper and iron buffer solution with different concentrations such as 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, and 5 ppm have been prepared and accessed using commercially imported chemical kits from Merck for copper and iron contamination detection in drinking water (Fig. 1).

Fig. 1
figure 1

Color produced after experimentation with chemical kits a Iron b Copper

Further color formed of all standard buffer samples after experimentation with standard copper and iron chemical kits have been accessed with developed handheld IoT-enabled spectrometer for calibration model development.

Data acquisition process has been carried out with all prepared standard iron and copper buffer samples and visible spectrum with the range from 400 to 700 nm has been acquired (Fig. 2). Acquired spectrum has been used to develop calibration model for developed handheld spectrometer.

Fig. 2
figure 2

Acquired visible spectrum for prepared standard concentrations sample tested with chemical kits a Iron b Copper

Design and construction of sensing module of handheld spectrometer

A visible spectroscopy-based sensing module has been designed and developed to acquire the visible spectrum of processed sample prepared using chemical kit. Developed sensing module uses off-the-shelf available light-emitting diodes and spectral sensors (AS7262) (AMS 2020) imported from Adafruit Industries. Sensing module uses a source and detector module (Fig. 3) in transmittance mode to record the visible radiation propagated through the processed water sample. White light-emitting diode with broader visible band (Table 1) has been used as source and a six-channel visible spectral device with the electronic shutter and smart interface has been used as a detector. Imported spectral sensor acquires visible spectrum from 400 to 700 nm with the resolution of 30 nm.

Fig. 3
figure 3

Schematic of selected spectral sensor for handheld heavy metal detection system (AMS 2020)

Table 1 Specifications of used white light-emitting diode as a source

Both light-emitting diode and spectral sensor along with lens arrangement have been packaged into the custom designed sensing chamber using solid works. Designed sensing chamber has been fabricated using institute 3D printer. The major challenge was in the design of sensing chamber to avoid the any kind of external light interference during measurements. Design of the sensing chamber (Fig. 4) has been optimized after multiple iterations to achieve the repeatability and reproducibility in measurement.

Fig. 4
figure 4

Designed sensing chamber for handheld heavy metal detection system

Embedded system design and development

An embedded processing and control unit has been developed and integrated with the sensing module to acquire the visible spectrum dataset of processed water samples. Embedded system consists of various submodules (Fig. 5) to perform various operations in real-time such as data acquisition, storage, processing and prediction of heavy metal concentration. The developed embedded system uses an 8-bit microcontroller-based module interfaced with traditional Bluetooth communication to perform the various operations using the smartphone-based android app. A Darlington-based led driver module has been designed to provide required biasing current for led-based source. The designed led driver module has been interfaced with the GPIO port of the microcontroller module to generate the led switching sequence based on the requirement. A visible spectral device with an electronic shutter and smart interface (AS7262) has been directly interfaced with the I2C port of the microcontroller module and further a software module has been created to acquire the data of visible spectrum. Continuous mode on trigger has been selected in the implemented software module for AS7262 to acquire the visible spectrum continuously based on the received trigger signal from the I2C port of the microcontroller module. Received signal has been amplified by the gain of 16 to read small radiation variations using in-built gain selection feature of the spectral sensor. Bluetooth module (HC-05) has been interfaced with developed microcontroller module using USART protocol (serial) to communicate with a smartphone-based android app. Developed handheld chemo-electronic-based system communicates with smartphone-based android app and acquires visible spectral data after receiving trigger command from the android app. Acquired spectral data by the handheld chemo-electronic-based system has been transferred to the smartphone-based app and saved in to.csv file format along with sample ID information.

Fig. 5
figure 5

Functional block diagram of developed handheld spectrometer system for heavy metal detection

The system also provides the facility to save data along with sample ID in on-chip EEPROM. A 3.7 V, 1000 mAh Li-ion battery has been integrated with a developed power management module to power up the developed system. The power management module provides the facility to monitor the battery status and automatically connects to the charging source after the battery level reaches to discharge threshold voltage. The power management module also communicates battery status to the microcontroller module using I2C communication to display the battery level for the user. It also avoids over and undercharging situations. The overall developed embedded system (Fig. 6) has been interfaced with the sensing module to trigger source for visible radiation transmission and to sense transmitted radiation from the processed water sample.

Fig. 6
figure 6

Developed handheld IoT-enabled and standalone spectrometer system for offline heavy metal measurement

Software package development

Various software modules have been written on C language-based cross compiler to provide the functionality of various operations such as data acquisition, data storage, calibration, data transfer to the cloud, and many more. The developed software package provides the facility to operate a handheld chemo-electronic-based system in two different modes such as measurement and calibration. Measurement mode further provides two different submodes to test processed water samples such as manual and automatic. Automatic measurement mode initializes and performs a diagnosis over the different hardware submodules of the overall system such as GPIO ports, ADC ports, EEPROM, led driver, spectral sensors, signal conditioning, etc. Further, the system runs a predefined software sequence to acquire visible spectrum data and stores it to the smartphone with sample ID and date, time information. The system triggers designed Darlington -based led driver to switch light-emitting diode for the predefined time interval. After the activation of each light-emitting diode, the system acquires the data of spectral sensor for pre-defined time intervals and saves in EEPROM and transfers overall spectrum data to the smartphone-based app after completion of a full source trigger sequence. Transferred visible spectrum has been undergone through different statistical and ANN-based models followed through various pre-processing and feature extraction techniques implemented offline to predict heavy metal concentration in water samples. Predicted parameters along with sample ID information have been transferred to third party cloud using developed smartphone-based android app. Similar software flow of data acquisition, storage, transfer, etc., have been followed in manual measurement mode, but this mode facilitates user to select and define the data acquisition process parameters manually such as sampling time, wavelength selection, led switching sequence generation, etc. Various software submodules have been written in manual and automatic measurement mode to access different ports (GPIO, ADC,

SPI, I2C, etc.) of the microcontroller module to perform various operations of the handheld system. Calibration mode provides the facility to update the bias and weight values of the training model simulated offline on MATLAB 12.0. Updated bias and weight values along with date-time have been saved in EEPROM and overwrites the old values to predict heavy metal concentration in water sample. Various implemented submodules have been linked together and integrated with the main modular program implemented on the android app to perform various data acquisition, storage, and prediction process. The developed android app communicates with system software package with different commands to run various measurement and calibration modes (Fig. 7).

Fig. 7
figure 7

Overall flow of developed IoT-enabled handheld spectrometer system for heavy metal (Fe and Cu) contamination prediction

Android application development

An android application has been developed to communicate with the developed handheld spectrometer system using Bluetooth low energy protocol. Developed spectrometer has an on-board Bluetooth low-energy facility to communicate with developed smartphone-based application. Developed application provides facility to visualize predicted copper and iron contamination prediction. Further it also provides information whether predicted copper and iron contamination is safe, tolerable or dangerous based on the define threshold levels in the application. Further developed android application also facilitates user to transfer predicted heavy metal contamination information along location and date time stamp to the third party cloud for further analysis and processing. Developed application also provides facility to store predicted heavy metal contamination data along with location and date, time information in the form of.csv file format.

Data modeling and calibration curve development

Standard buffer samples with eight different concentration processed with chemical kits have been undergone though visible spectrum data acquisition process using developed smartphone.

based handheld spectrometer. Acquired spectrum has been analyzed and wavelength with maximum variation have been selected for iron and copper contamination prediction. Average transmittance (uW/cm2) on selected wavelength has been calculated from acquired visible spectrums. Further, piecewise modelling has been used to correlate the copper and iron concentration with the calculated average transmittance on selected wavelength. A custom model (Fig. 8) has been designed by combining different linear and non-linear pricewise models to predict iron and copper concentration presence in water sample. It has been observed that calculated average transmittance (uW/cm2) at 550 nm shown the best results for both copper and iron concentration prediction.

Fig. 8
figure 8

Designed model for copper and iron concentration prediction in heavy metal concentration prediction

Developed models has been used to train developed handheld spectrometer, and further standard prepared known copper and iron concentrations have been tested with trained developed handheld spectrometer. It has been observed that developed spectrometer has shown excellent level of accuracy to predict iron and copper concentration prediction for known samples (Fig. 9).

Fig. 9
figure 9

Testing of developed spectrometer system with known concentrations of copper and iron samples

Testing and field validation

Different water samples have been collected from institute colony and pre-processed using imported chemical kits for copper and iron contamination measurement. Processed samples have been tested with developed handheld spectrometer to predict copper and iron contamination presence in water samples. Collected samples have been majorly classified in three different kind of classes such as tap water, RO water (TDS = 260 ppm) and DI water. Further obtained results using developed handheld spectrometer have been validated with the standard system for copper and iron measurement imported from HANNA instruments (Fig. 10). It has been observed that developed system predict iron and copper contamination in drinking water with excellent level of accuracy (R2 for iron prediction = 0.99, R2 for copper prediction = 0. 9912).

Fig. 10
figure 10

Validation of developed spectrometer system with commercially imported system for unknown concentrations of copper and iron samples

Discussion and conclusion

Developed handheld spectrometer along with commercially imported chemical kits provides an innovative chemo-electronic system to measure heavy metal contamination presence in water samples in real-time. System opens up the possibilities of on-site water quality analysis along with automatic data logging to third party cloud without any data manipulation and tempering. System also provides facility to store measured data with location and date time stamp for location-based water quality mapping and analysis. Overall system is cost-effective, user-friendly, and loaded with state-of-the-art features. Developed system works with very easy sample injection and cleaning cycle using normal de-ionized water sample. System can be useful at various village level for water quality database management of various villages. System is IoT-enabled and has ability to work in standalone model and also with smartphone-based android app. System also can be train with other chemical kits for other heavy metal contamination measurement. Overall system can be a great tool and can facilitate common people for easy, rapid and cost-effective water quality analysis and monitoring.