Developing a Portable Spectrometer to Detect Chemical Contaminants in Irrigation Water

: Water pollution is a critical issue since it can severely affect health and the environment. The purpose of the study is to develop a portable spectrometer (ESP32-based spectrometer) to detect chemical contaminants in irrigation water by observing the light absorbance of contaminants. ESP32 and a light sensor (photodiode) were respectively, used as the main controller and detector of the portable spectrometer. It was developed based on optical dispersion and Beer–Lambert law theory. The light absorbance of different types of contaminants was displayed in a Blynk application for real-time monitoring. The samples were also tested using a lab-based spectroscopy method, ultraviolet-visible (UV-Vis) spectrometer. The spectral range of the measurement is from 350 nm to 700 nm and the standard error of the ESP32-based spectrometer is from 0.01 to 0.05. Five water samples were tested, consisting of ammonium nitrate, organic pesticide, zinc oxide and two different reservoirs used for irrigation. The absorption peaks of the ammonium nitrate and organic pesticide are 363 nm and 361 nm, respectively. Zinc oxide shows the absorbance peak at 405 nm, whereas both reservoirs show absorbance peaks lie in the region from 300 nm to 370 nm. Therefore, this study shows that different types of contaminants can absorb light only at speciﬁc wavelength regions by considering the concentration of samples. The developed ESP32-based spectrometer can be applied for on-site water quality monitoring as it is portable, light, simple and can be monitored in real time using multiple devices.


Introduction
Water contamination increases in parallel with technological advances. Pesticides and metal contribute the most to water contamination in agriculture [1,2]. The concentration of metal in soil and water has continuously increased due to industrialization and electronics wastes, which affect human, animals and plants [3]. Heavy metals are chemical elements that have a relatively high density and are poisonous even at low concentrations. Therefore, they are commonly associated with contamination, potential toxicity or ecotoxicity. Metal contaminants that are consumed by plants may cause various health risks when they enter the human body. Phytotoxicity by lead (Pb) causes disorders in normal plant physiological activities, killing cells when organisms are exposed to high concentrations [4]. Untreated wastewater carries a substantial amount of heavy metals and causes potential ecological risks to the environment, food quality, soil health and sustainable agriculture [5]. Metals are toxic at concentrations above ambient conditions, non-biodegradable in the environment and accumulate in animal and plant tissue [6]. The absorption spectrum range of heavy metal ion is from 400 to 500 nm and the absorbance peak for copper ions is around 498 nm [7].
Meanwhile, organic contaminants refer to any chemicals based on carbon such as pesticides, organic solvents and petroleum-based waste. The contaminant is usually produced by the organic nature that has a covalent bond with another compound. These types of contaminants are toxic or carcinogenic not only to humans but also to animals and plants [8]. The organic toxic may affect roots and leaves. Organic pollutants may have toxic effects on plant and root cell structure, biosynthesis, membrane stability and DNA [9]. The absorbance spectrum range for organic matter lies between 280 nm and 380 nm [7]. The intensive use of inorganic fertilizers and pesticides can cause the loss of biodiversity in soils and health problems in plants. Thus, the fertilization leads to water, soil and air pollution [10].
Good water quality monitoring and treatment can produce high quality crops as crop stress can hinder photosynthesis, thereby reducing the growth, fruit weight and yield. Recent studies on water quality include the assessment of water quality using a cyber physical system [11], a filtration system [12] and the estimation of groundwater quality using the integration of a water quality index [13]. Optical sensing is a recent technique that has potential use in water irrigation systems since the method is non-invasive and has a high reliability. Optical techniques can consist of laser application [14], optical sensors [15] and spectroscopy [7,[16][17][18][19]. Spectroscopy is a reliable physical study used in physics, materials science, chemistry, biochemistry and biomolecular studies since it is suitable for environmental protection and has high detection efficiency [7].
Most spectroscopy studies [17][18][19] had been conducted using lab-based methods in which a spectrometer or detector was used to measure the optical properties of the samples, and data were displayed in a computer in the lab. These methods are accurate and reliable, but they are complicated and time consuming because samples need to be transported to the lab. It becomes an issue for any consumers who require fast results for quick action. The development of miniaturized analytical devices is important since the devices not only can give fast and reliable outcomes but also can bypass logistic issues via on-site testing or remote confirmation of detection [16,20].
Here, we developed a portable ESP32-based spectrometer to detect the light absorbance of chemical contaminants in irrigation water. The testing was also conducted using a lab-based method (Ocean Optics Spectrometer) to observe the reliability of the developed spectrometer. Optical dispersion and the Beer-Lambert law theory were referred to in this study, and we focus on contamination in irrigation water. We use samples from organic and metal contaminants as they are common issues faced in water irrigation systems in Malaysia. The system was developed using an ESP32 microcontroller to control the spectrometer and a light sensor to sense and measure the light. The output was displayed in a Blynk online application for real-time monitoring using a mobile phone and a laptop. We tested ammonium nitrate, organic pesticides, zinc oxide and water sources from the irrigation system. The sample solutions were prepared by dissolving the chemical compound in the deionized water solution. The presence of contaminants can be detected by their optical properties because they have molecules that can absorb the light. Thus, this study can further assist farmers to monitor irrigation systems that need high quality water for plants. This is because excessive organic contaminants and heavy metals in water can lead to the abnormal growth of plants.

Theoretical Study
The spectrometer was developed based on optical dispersion and the Beer-Lambert Law.

Optical Dispersion
Optical dispersion occurs when light is separated into different individual colors of the spectrum and exposed to diffraction grating [21]. The rainbow color spectrum is produced when the white light is separated into components of different wavelengths or colors. When a light ray passes through one transparent substance and into another, its path bends or refracts. Different wavelengths are separated by modest angles because the refraction index of optical glasses varies by only a few percent across the visible spectrum [21].

Light Absorbance and Transmittance Based on Beer-Lambert Law
Light absorbance and transmittance in the sample can be found using the Beer-Lambert law. The Beer-Lambert law is a linear relationship between the light absorbance and the concentration of solution. The Beer-Lambert law states that the concentration of a solution is directly proportional to the light absorbance, as shown in Equation (1) [22,23], where A refers to the light absorbance at a given wavelength of light, ε is the molar absorptivity, b is the path length referring to the distance of light passing through the solution and c is the concentration of the compound in the solution.
The light absorbance (A) has an algorithmic relationship to the light transmittance (T) [9]. The light transmittance (T) of the solution is defined as the ratio of the transmitted intensity (I t ) over the incident intensity (I 0 ). The light transmittance can be defined as in Equation (2) [22][23][24], where T refers to the light transmittance of a sample, I t is the transmitted light intensity and I 0 is the incident light intensity.
The incident and transmitted light intensities can be calculated according to Equation (3) [24].

Sample Preparation
Zinc, ammonium nitrate and organic pesticides were tested because they were among the top environmental toxicants endangering the relevant environment [25]. Water from two reservoirs, used for irrigation was also tested.

Ammonium Nitrate (NH 4 NO 3 )
Ammonium nitrate can contaminate water when there is a spill from fertilizer. Ammonium nitrate results in small root and small leaf area, which may contribute to a low carbon gain and inhibit crop growth. Ammonium nitrate was prepared by mixing 8.2 g NH 4 NO 3 that had around a 0.052-10 µm particle size with 60 mL of deionized water, which produced 0.14 g/mL of sample concentration.

Organic Pesticides
Organic pesticides are chemical compounds or mixtures of chemical compounds that are used to prevent or reduce insect populations. Organic pesticides are made from natural ingredients such as minerals, plants and microorganisms. The elements in pesticides that inhibit plant growth are usually coming from organochlorine DDT, endosulfan, endrin and heptachlor [25]. The larger the organic matter content, the greater the absorption of pesticides.

Zinc Oxide
Zinc oxide is a metal oxide material that has bandgap tailoring, doping with various types of materials and is able to form many structures [26]. Metal contaminations can lead to the decline and deterioration of soil fertility and environment quality [27]. Zinc exists in irrigation water due to chemical spills, which can affect plants. Zinc is a heavy metal compound that has a strong metallic bond. A high concentration of zinc can cause toxicity in plants, which itself can cause the stunting of shoots, the curling and rolling of young leaves and the death of leaf tips and chlorosis. The particle size of zinc oxide used in the system and dissolved in the water was less than 100 nm. A 0.125 g/mL solution was prepared by dissolving 7.5 g of zinc oxide powder in 60 mL of deionized water. The solution was stirred frequently during the testing process to ensure the solution was well mixed.

Water Sources from Irrigation System
The irrigation water sample was taken from different water sources in Nilai. The sample was tested, and types of contaminants could be investigated by observing the spectrum of light absorption. Reservoir I is located near the Faculty of Science and Technology, Universiti Sains Islam Malaysia (USIM). It is used to irrigate the Nursery Landscape, Department of Development and Facilities Management (JPPF), USIM. According to the caretaker of the area, the water may have organic material since it is near the area's sewage. The water source is used twice a day to irrigate the agriculture area. Reservoir II is also located in USIM, but it is rarely used for the irrigation system. The water source may indicate the presence of organic material based on its color. We observe that Reservoir II contains many living things, such as fish, which also can contribute to organic contaminants in the water sample.

Spectroscopy Techniques
Spectroscopy is a non-destructive approach that uses the interaction effect of electromagnetic radiation to identify the energy level and structure of an atomic or molecular substance [28]. Ultraviolet-visible (UV-Vis) spectroscopy methods are used to quantify the transition of ions and highly conjugated electronic compounds by measuring an electron transition corresponding to the excitation of the outer electrons [29]. When light is absorbed by a material, valence (outer) electrons are excited from their normal (ground) states to higher energy (excited) states. Broad absorption peak can be seen instead of sharp absorption peak. Vibrational energy levels are available at each electronic energy level, and transitions can occur to and from the different vibrational levels and, thus, result in peak broadening [29].
We developed a ESP32-based spectrometer and set up the experiment using a labbased spectrometer, ultraviolet-visible (UV) Ocean Optics spectrometer (Ocean Insight). Ocean Optics spectrometer is commercially used for finding light transmittance, absorbance and fluorescence of any material. The measurements from both spectroscopy techniques were averaged from 10 measurements.

Measuring Light Absorbance Using a Portable Spectroscopy Technique (ESP32-Based Spectrometer)
ESP32 microcontroller was used to read the data waveform generated from the system. Servo motor was used in the system to move a compact-disk (CD) player to provide different light spectrum ranges. Light source (XM-L2 LED Light source, spectrum ranging from~300 nm to 780 nm) shined the CD player that showed the characteristics of an optical grating. The system was placed in a closed black box to prevent outside light from affecting the samples and to reduce the reflectivity of the internal surfaces. A light sensor (silicon photodiode) was located near the sample to measure the amount of transmitted light. The sensor has high photo sensitivity and radiant sensitivity to measure light from 300 nm to 1200 nm and transform it into electricity. Figure 1 shows the spectrometer that has been developed. Figure 1a,b show the front view and side view of the design to justify the portability of the spectrometer, whereas Figure 1c depicts the position of light source, ESP32 microcontroller and light sensor inside the box. When the light source shined on the CD player, light spectrum was diffracted and the light passed through the sample via the small slit. The enclosure was closed during measurement to reduce effects from surrounding light.
Flow chart of the testing method using ESP32-based spectrometer is depicted in Figure 2. When ESP32 microcontroller was connected to a power source, the servo started to rotate, and various colors of light were exposed to the sample. Light sensor measured the light transmission in the system. After obtaining the light transmission, the light absorbance can be calculated using Beer-Lambert law. If the light absorbance had the maximum peak in the UV-Vis range, the data were analyzed to determine whether the contaminants were organic or heavy metals. Otherwise, if the maximum light absorbance was not in the range of UV-Vis, the system was terminated and another sample was tested. The sample was tested ten times to ensure accuracy of the data.
Agriculture 2023, 13, x FOR PEER REVIEW 5 of 15 grating. The system was placed in a closed black box to prevent outside light from affecting the samples and to reduce the reflectivity of the internal surfaces. A light sensor (silicon photodiode) was located near the sample to measure the amount of transmitted light. The sensor has high photo sensitivity and radiant sensitivity to measure light from 300 nm to 1200 nm and transform it into electricity. Figure 1 shows the spectrometer that has been developed. Figure 1a,b show the front view and side view of the design to justify the portability of the spectrometer, whereas Figure 1c depicts the position of light source, ESP32 microcontroller and light sensor inside the box. When the light source shined on the CD player, light spectrum was diffracted and the light passed through the sample via the small slit. The enclosure was closed during measurement to reduce effects from surrounding light. Flow chart of the testing method using ESP32-based spectrometer is depicted in Figure 2. When ESP32 microcontroller was connected to a power source, the servo started to rotate, and various colors of light were exposed to the sample. Light sensor measured the light transmission in the system. After obtaining the light transmission, the light absorbance can be calculated using Beer-Lambert law. If the light absorbance had the maximum peak in the UV-Vis range, the data were analyzed to determine whether the contaminants were organic or heavy metals. Otherwise, if the maximum light absorbance was not in the range of UV-Vis, the system was terminated and another sample was tested. The sample was tested ten times to ensure accuracy of the data. The measurement of light absorbance using the Ocean Optics Spectrometer was conducted according to a flow chart in Figure 3. Sample was placed in the cuvette and absorbance measurement in OceanView software was applied. The measurement of light absorbance using the Ocean Optics Spectrometer was conducted according to a flow chart in Figure 3. Sample was placed in the cuvette and absorbance measurement in OceanView software was applied.  Figure 4 shows the experimental setup using the Ocean Optics spectrometer. A light source produced light in a range from 350 to 1000 nm that passed through the plastic cuvette that had samples. The transmitted light was measured by the Ocean Optics spectrometer, which was connected to a computer. The OceanView software was installed in the computer to record the data that were measured by the spectrometer and to display the spectral response. The amount of light transmitted through the sample decreased because some light may have been absorbed by the molecules or particles in the samples, based on the Beer-Lambert law [22,23]. To calibrate the spectrometer, an empty cuvette was shined by the light source, and the light absorbance was stored as a reference spectrum.  Figure 4 shows the experimental setup using the Ocean Optics spectrometer. A light source produced light in a range from 350 to 1000 nm that passed through the plastic cuvette that had samples. The transmitted light was measured by the Ocean Optics spectrometer, which was connected to a computer. The OceanView software was installed in the computer to record the data that were measured by the spectrometer and to display the spectral response. The amount of light transmitted through the sample decreased because some light may have been absorbed by the molecules or particles in the samples, based on the Beer-Lambert law [22,23]. To calibrate the spectrometer, an empty cuvette was shined by the light source, and the light absorbance was stored as a reference spectrum. Agriculture 2023, 13, x FOR PEER REVIEW 8 of 15

Real-Time Monitoring Using Blynk Application
The sample was tested, and the output was displayed using a Blynk application for real-time monitoring. The data slightly fluctuated due to the sensitivity of the light sensor. Thus, the measurement was repeated ten times. The output was averaged, and the data were plotted using Origin software to observe the absorbance peak. Figure 5 shows the real-time monitoring and sensing method using a mobile phone. The light transmittance, It, and the light absorbance, A, can be observed with the Blynk application. In Figure 5, the top display shows four buttons (ON and OFF) to control the movement of the servo motor to vary the spectrum wavelength. The value of the transmitted light, It, from the sample is shown on the Blynk display. The light sensor detects light and

Real-Time Monitoring Using Blynk Application
The sample was tested, and the output was displayed using a Blynk application for real-time monitoring. The data slightly fluctuated due to the sensitivity of the light sensor. Thus, the measurement was repeated ten times. The output was averaged, and the data were plotted using Origin software to observe the absorbance peak. Figure 5 shows the real-time monitoring and sensing method using a mobile phone. The light transmittance, I t , and the light absorbance, A, can be observed with the Blynk application.

Real-Time Monitoring Using Blynk Application
The sample was tested, and the output was displayed using a Blynk application for real-time monitoring. The data slightly fluctuated due to the sensitivity of the light sensor. Thus, the measurement was repeated ten times. The output was averaged, and the data were plotted using Origin software to observe the absorbance peak. Figure 5 shows the real-time monitoring and sensing method using a mobile phone. The light transmittance, It, and the light absorbance, A, can be observed with the Blynk application. In Figure 5, the top display shows four buttons (ON and OFF) to control the movement of the servo motor to vary the spectrum wavelength. The value of the transmitted light, It, from the sample is shown on the Blynk display. The light sensor detects light and from the sample is shown on the Blynk display. The light sensor detects light and converts it to an electrical signal output. The transmitted light is then converted to the absorbed light using the Beer-Lambert law. The value of the light sensor is displayed together with the value of the light absorbance at the specific range of the spectrum. Figure 6 depicts the real-time monitoring and sensing by a computer. The servo motor can be turned on or off to change the region of the spectrum wavelength. The output of the absorbance value versus time is displayed by the graph. converts it to an electrical signal output. The transmitted light is then converted to the absorbed light using the Beer-Lambert law. The value of the light sensor is displayed together with the value of the light absorbance at the specific range of the spectrum. Figure  6 depicts the real-time monitoring and sensing by a computer. The servo motor can be turned on or off to change the region of the spectrum wavelength. The output of the absorbance value versus time is displayed by the graph.

Light Absorbance from ESP32-Based Spectrometer
The light absorbance using the ESP32-based spectrometer and the Ocean Optics spectrometer was plotted in Origin. Figure 7a-e show the output of the light absorbance (wavelength ranging from 300 nm to 700 nm) from the ESP32-based spectrometer. Figure 7a shows the light absorbance from the pesticide sample with the highest absorbance peak lying in the wavelength ranging from 300 nm to 400 nm. The absorbance peak of ammonium nitrate is also within the wavelength range between 300 nm and 400 nm (Figure 7b), and the absorbance peak of zinc oxide using ESP32-based spectrometer lies between 400 nm and 500 nm with the absorbance peak at 400 nm, as shown in Figure 7c. Meanwhile, Figure 7d shows the light absorption spectrum of Reservoir I and the absorbance peak lies in the region between 300 nm and 400 nm, which indicates that the water may consist of organic contaminants. Reservoir II shows the wavelength range of the absorbance spectrum to be between 300 nm and 400 nm, which also shows that the water sample may consist of organic contaminants (Figure 7e).

Light Absorbance from ESP32-Based Spectrometer
The light absorbance using the ESP32-based spectrometer and the Ocean Optics spectrometer was plotted in Origin. Figure 7a-e show the output of the light absorbance (wavelength ranging from 300 nm to 700 nm) from the ESP32-based spectrometer. Figure 7a shows the light absorbance from the pesticide sample with the highest absorbance peak lying in the wavelength ranging from 300 nm to 400 nm. The absorbance peak of ammonium nitrate is also within the wavelength range between 300 nm and 400 nm (Figure 7b), and the absorbance peak of zinc oxide using ESP32-based spectrometer lies between 400 nm and 500 nm with the absorbance peak at 400 nm, as shown in Figure 7c. Meanwhile, Figure 7d shows the light absorption spectrum of Reservoir I and the absorbance peak lies in the region between 300 nm and 400 nm, which indicates that the water may consist of organic contaminants. Reservoir II shows the wavelength range of the absorbance spectrum to be between 300 nm and 400 nm, which also shows that the water sample may consist of organic contaminants (Figure 7e).

Light Absorbance from Ocean Optics Spectrometer
The sample was also tested with a lab-based spectroscopy method. The light absorbance output from the Ocean Optics spectrometer for each water sample is depicted in Figure 8a-e. Figure 8a shows the absorption spectrum of the pesticide sample (from 300 nm to 400 nm) with the absorbance peak at~361 nm [16]. Meanwhile, Figure 8b shows the absorbance spectrum of ammonium nitrate and the absorption peak lies at 363. Furthermore, the absorbance peak of zinc oxide (Figure 8c) is~405 nm and the absorption peaks of Reservoir I (Figure 8d   ure 8a-e. Figure 8a shows the absorption spectrum of the pesticide sample (from 300 nm to 400 nm) with the absorbance peak at ~361 nm [16]. Meanwhile, Figure 8b shows the absorbance spectrum of ammonium nitrate and the absorption peak lies at ~363. Furthermore, the absorbance peak of zinc oxide (Figure 8c) is ~405 nm and the absorption peaks of Reservoir I (Figure 8d) and Reservoir II (Figure 8e) are ~346 nm and ~361 nm, respectively.

Discussion
Detecting heavy metal and organic contaminants in water is crucial in agriculture. In this research, three contaminants (zinc oxide, ammonium nitrate and organic pesticide), commonly found in irrigation water, and two irrigation water sources (Reservoir I and Reservoir II) were tested. Other chemical elements can also be tested as long as they can absorb light in the ultraviolet and visible spectral ranges. The light source needs to be changed to infrared to detect elements with wavelengths over 800 nm.
The developed spectrometer can display outputs on multiple devices such as mobile phones ( Figure 5) and computers ( Figure 6). Figure 7a depicts that the highest absorbance of the pesticide sample is in the range from 300 nm to 400 nm. We attribute that to the organic compounds in pesticides, which may comprise of rotenone, neem, pyrethrum and minerals, such as cryolite, boric acid and diatomaceous earth. The chemical compounds also can contribute to the color of the pesticide solution. A previous study conducted by Rohit et al. [30] also showed a quite similar absorbance range of pesticides, from 360 nm to 400 nm.
Meanwhile, the absorption peak of the nitrate sample also lies from 300 nm to 400 nm (Figure 7b). The nitrate ions can be classified as ions that have a strong absorption range in ultraviolet spectrum region, from 280 nm to 320 nm [31]. Most types of UV sources emit in the spectrum region and can interact with nitrate in water to generate hydroxyl radicals [31,32]. When the electromagnetic energy, such as UV light, propagates in aqueous samples, a fraction of energy can be transferred to the ions via the transition of electrons between different energy levels [23,33]. Thus, it shows that nitrate ion achieves the excitation in the region of 300 nm to 400 nm.
Then, the absorption spectrum of zinc oxide lies from 400-500 nm (Figure 7c). The result is similar to the previous studies from Kolli et al. [34] and Darroudi et al. [35], in which the absorbance spectrum of zinc ranged from 350 nm to 500 nm with absorption peaks~383 nm and at~357 nm, respectively. This is because the metal bond has strong electron excitation in the respective wavelength region. The electron transition in zinc oxide occurs due to the transition from the valence band to the conduction band. Metal sources in the environment are both anthropogenic and natural. The sources include effluents from wastewater treatment plants, industrial and agricultural wastes, power stations, mining, boating activities, transportation vehicles, urban runoff and geological processes [6].
Reservoir I (Figure 7d) and Reservoir II (Figure 7e) show that the absorbance peaks lie within the wavelength range of 300 nm to 400 nm. This is because the organic material consists of carbon and a hydrogen bond and is matched with the absorption energy from the molecules in the sample solution. The light absorbance of Reservoir II is slightly low compared to Reservoir I since the water is not as turbid as Reservoir I. Reservoir II is not near any sewage area, but the reservoir has many fish, which may also contribute to organic compounds.
In comparison to the ESP32-based spectroscopy method, the lab-based spectrometer ( Figure 8) can give higher accuracy due to the continuous reading or light scanning of each sample. The absorption peak of zinc oxide (Figure 8c) is at~405 nm due to electron transition in the spectrum region. It can be assigned to the intrinsic band-gap absorption of ZnO due to the electron transitions from the valence band to the conduction band (O→Zn) [35]. Then, Ocean Optics spectrometer depicts the absorbance peak at~346 nm for Reservoir I (Figure 8d) because the organic particles achieve the excitation energy within this region [36]. The Ocean Optics spectrometer also depicts the absorbance peak at 361 nm for Reservoir II (Figure 8e), which lies from 300 nm to 400 nm. This shows that Reservoirs I and II contain organic contaminants.
Both types of spectrometers have proved the ability to measure the light absorbance to further detect organic and heavy contaminants in water samples. The comparison of system performance between lab-based spectrometer and portable ESP32-based spectrometer is shown in Table 1. These two techniques have advantages and disadvantages, respectively. ESP32-based spectrometer is portable, low-cost and can be monitored in real-time via multiple devices, whereas Ocean Optic spectrometer is non-portable (must be set up with a light source and a computer), requires lab-based monitoring and is high-cost. However, the Ocean Optic spectrometer can give higher accuracy. Thus, it depends on farmers or consumers to choose their preferred method.

Conclusions
In conclusion, we have developed a portable spectrometer that can measure light absorbance to detect contaminants in water. The spectrometer was developed based on optical dispersion and the Beer-Lambert law. Different types of chemical compounds can produce different absorbance peaks based on their chemical structure. The study investigates the relationship between the types of compounds and absorption spectrum to obtain the light transmittance and absorbance of the sample. The study can be used further to sense any presence of organic and metal contaminants in irrigation water. The spectrometer consists of the ESP32 microcontroller, a servo motor to control spectra movement, a light sensor to measure light transmittance and Blynk software to display the output of the spectrometer. An experiment to measure light absorbance using a lab-based spectrometer, Ocean Optics spectrometer, was also set up. The organic contaminants have an absorbance peak that lies between 300 nm and 400 nm, whereas the heavy metal contaminants show a peak that lies between 400 nm and 500 nm. The irrigation water from two different water sources (Reservoir I and Reservoir II) was tested using the ESP32 and Ocean Optics spectrometers and both sources show the presence of organic contaminants. Thus, we believe that the ESP32-based spectrometer can reliably be used in irrigation systems since the device is portable and can be monitored in real-time. The other advantages of the ESP32-based spectrometer are that it is low-cost, non-invasive and can differentiate types of contaminants based on optical properties. It is also a simple and fast method for quantitative estimation.
In the future, a larger battery capacity will be used to ensure the spectrometer can last longer. We will perform simultaneous detection of elements by combining a few contaminants into one sample. We will test more heavy metal elements such as copper and iron. Rivers and lakes, especially polluted rivers will be tested as well. The ESP32-based spectrometer can be further upgraded to find concentrations or the molar absorptivity of biological macromolecules and organic molecules.