Spectrophotometric-Based Sensor for the Detection of Multiple Fertilizer Solutions

: The online detection of fertilizer solution information is a crucial link in the implementation of intelligent and precise variable fertilization techniques. However, achieving simultaneous rapid online detection of multiple fertilizer components is still challenging. Therefore, a rapid detection method based on spectrophotometry for qualitative and quantitative identification of four fertilizers (typical N, P, and K fertilizers: KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 ) was proposed in this work. Full-scan absorption spectra of fertilizer solutions at varying concentrations were obtained using a UV–visible/near-infrared spectrophotometer. By assessing the linear fit between fertilizer concentration and absorbance at each wavelength within the characteristic band, the characteristic wavelengths for KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 were identified as 214 nm, 410 nm, 712 nm, and 1708 nm, respectively. The identification method of fertilizer type and the prediction model of concentration were constructed based on characteristic wavelength and the Lambert–Beer law. Based on the above analysis, a four-channel photoelectric sensor was designed with four LEDs emitting wavelengths closely matched to characteristic wavelengths for fertilizer detection. A detection strategy of “quali-tative analysis followed by quantitative detection” was proposed to realize the online detection of four fertilizer types and their concentrations. Evaluation of the sensor’s performance showed its high stability, with an accuracy of 81.5% in recognizing fertilizer types. Furthermore, the relative error of the sensor detection was substantially less than ± 15% for the fertilizer concentrations not exceeding 80 mg/L. These results confirm the capability of the sensor to meet the practical requirements for online detection of four fertilizer types and concentrations in the field of agricultural engineering.


Introduction
Precision irrigation is essential in modern agriculture to increase crop yields and reduce management costs [1].An intelligent water-fertilizer integration system can deliver a precise and quantitative water/fertilizer regulation online by combining water-fertilize prediction models with intelligent technology based on the actual crop water-fertilizer requirements [2][3][4][5].The system requires accurate information by monitoring nutrient components of fertilizer solution in real time to realize effective field regulation.However, online fertilizer detection is often influenced by natural environments and sensor stability, resulting in poor detection performance, such as incomplete nutrient component information, high cross-sensitivity, low detection accuracy, etc. [6,7].Therefore, fertilizer online detection remains a challenge for intelligent, controlled technology in agriculture management.
Currently, the main techniques for online acquisition of fertilizer solution information (including nutrient elements and concentrations) are the EC/pH detection [8], the ionselective electrode method [9], and the dielectric property method [10].The EC/pH sensors can continuously monitor the electronic conductivity (EC) and pH of the fertilizer solution and provide an indirect reflection of the concentration of nutrient components Agriculture 2024, 14, 1291 2 of 16 in the fertilizer solution by establishing a functional relationship between fertilizer ion concentration and solution conductivity and pH [8].However, this method can only characterize the total ion concentration and total pH of the fertilizer solution.Therefore, it is difficult to achieve precise regulation of multi-component fertilizer solutions.The ion-selective electrode (ISE) detection can selectively and sensitively determine the ion concentration of a fertilizer solution by detecting the potential difference resulting from the reaction of a particular electrode with ions in an electrolyte solution [9].The method is effective in quantifying the ions, such as K + , NO 3 − , PO 4 3− , and P 2 O 5 content, in fertilizer solutions [11,12].However, this method requires the fabrication of selective electrodes for each ion, and its precision is constrained by the cross-sensitivity between ions [13].Furthermore, the method exhibits some degree of hysteresis and temperature drift [14,15].Miras et al. [16] employed ISEs based on plasticized polyvinyl membranes containing an ion exchanger to quantify KNO 3 concentrations in hydroponic crop nutrient solutions, yielding satisfactory outcomes.However, this ISE sensor required the addition of ion exchangers and may exhibit cross-sensitivity in the presence of other components, potentially resulting in inaccurate measurements.The dielectric property detection method can rapidly determine the components and concentration in fertilizer solution by analyzing the dielectric frequency response features of the fertilizer solution (as a dielectric material) [17,18].Nevertheless, this method has encountered challenges in the detection sensors and dielectric frequency testing techniques, and further exploration is required to address these issues.Wu et al. [17] applied the dielectric eigenfrequency method to qualitatively identify fertilizer solutions such as K 2 SO 4 , KNO 3 , KH 2 PO 4 , etc.The identification accuracy was 98.3%, with an average identification time of 14.3 s.However, the method could only determine the types of fertilizer solutions, not their concentrations.The identification process was timeconsuming, and there remained a noticeable gap in real-time detection.Li et al. [18] designed a cylindrical capacitance sensor based on the dielectric properties of the fertilizer solution and proposed an online rapid detection method of fertilizer type and concentration based on the characteristic frequency response mode.The results showed that the maximum error of concentration detection was 7.26%.However, the sensor can only detect a singlecomponent fertilizer solution, which is less suitable for practical engineering applications.
Spectrophotometry is an important, powerful, and versatile analytical technique that has been widely applied to quantify, identify, and characterize ions and compounds in solution [19,20].For example, a UV-visible (UV-vis) spectrometry combining the extended Kalman filter and derivative methods is proposed by Zhou et al. to realize simultaneous determination of trace Cu 2+ , Co 2+ , and Ni 2+ in zinc hydrometallurgy [21].Some investigations have been conducted to explore the potential of UV-vis/near-infrared (UV-vis/NIR) technology for the detection of nutrient composition and content in soils and fertilizers.Zhang et al. determined the concentrations of the nutrients nitrogen (N), phosphorus (P), and potassium (K) in soil solution using UV-vis spectrophotometry, providing technical support for precision irrigation in agriculture [22].Shen et al. verified the feasibility of using vis/NIR spectrometers to quickly analyze the content of nitrogen, phosphorus, and potassium nutrients (N, P 2 O 5 , and K 2 O) in fertilizers [23].In conclusion, UV-vis/NIR spectrophotometry has the advantages of fast speed and wide detection range in solution composition detection.Therefore, the spectrophotometric technique can provide a new perspective for the development of sensors for online detection of fertilizer solutions.
This study proposed a novel method for online detection of four fertilizer components (NO 3 − , NH 4 + , H 2 PO 4 − , and K + ) based on the spectrophotometric techniques.Firstly, the full-scan absorption spectra curves of the four fertilizer solutions at different concentrations were obtained using a UV-vis/NIR spectrophotometer.Subsequently, the characteristic wavelengths (detection wavelengths) of the four fertilizers were determined by comparing the linear fit between the absorbance at the bands near the absorption peak and the fertilizer concentration.Then, the prediction models for fertilizer concentration were established based on the linear relationships between absorbance at the characteristic wavelengths and fertilizer concentrations.Building on this, four LED light sources were selected with center wavelengths close to the characteristic wavelengths of four fertilizer solutions.A low-cost photoelectric sensor with four channels was developed for online qualitative and quantitative detection of four fertilizer solutions.The developed sensor serves to enhance the intelligence of irrigation and fertilizer application systems.

Acquisition of UV-vis/NIR Absorption Spectra
The standard solutions of KNO 3 , (NH 4 ) 2 SO 4 , and KH 2 PO 4 were fully scanned using a UV-vis spectrophotometer (Model 754PC, Jinghua, Shanghai, China), with a band range of 200-1000 nm (spectral bandwidth of 4 nm).While the standard solutions of K 2 SO 4 were fully scanned using a NIR spectrophotometer (Model 7100CRT, Xinmao, Shanghai, China), with a band range of 1000-2500 nm (spectral bandwidth of 4 nm) (Figure 1a).Specifically, deionized water was first used as a blank sample scanning baseline to eliminate the effects of instrumental system errors and ensure the accuracy and reliability of the measurement results.Subsequently, 3 mL of the fertilizer solution to be tested was pipetted into a quartz cuvette with an optical path length of 10 mm.The cuvette was then placed into the spectrophotometer, and the full-scan mode was used to obtain absorbance curves of the samples in the ranges of 200-1000 nm or 1000-2500 nm.The average spectra of three replicate samples were used for subsequent qualitative and quantitative analyses.

Spectral Pre-Processing and Characteristic Wavelength-Based Modeling of Fertilizer Concentration
In the spectral testing and analysis, spectral data were affected by background and noise [25].To eliminate the interference of these factors, spectral data need to be preprocessed before generating the calibration model [26].The Savitzky-Golay filter fitting method effectively achieves a smoothing effect by applying an arbitrary order polynomial to the spectral data.This method is widely used for spectral smoothing as it preserves the essential features of the spectral data while effectively smoothing the noise [27,28].Therefore, the Savitzky-Golay method was adopted to preprocess the absorption spectral curves of the fertilizer solutions.The smoothed spectra were then analyzed.The bands near the absorption peaks were selected as the characteristic bands of the nutrient components in the fertilizer solution.According to the Lambert-Beer law, the absorbance is proportional to the concentration of the solution for a fixed optical path length.The optimal characteristic wavelength (detection wavelength) was determined by comparing the effect of the linear fit between fertilizer concentration and absorbance at each wavelength within the characteristic band (Figure 1b).Finally, prediction models were established for fertilizer concentrations based on the absorbance at characteristic wavelengths.

Spectral Pre-Processing and Characteristic Wavelength-Based Modeling of Fertilizer Concentration
In the spectral testing and analysis, spectral data were affected by background and noise [25].To eliminate the interference of these factors, spectral data need to be preprocessed before generating the calibration model [26].The Savitzky-Golay filter fitting method effectively achieves a smoothing effect by applying an arbitrary order polynomial to the spectral data.This method is widely used for spectral smoothing as it preserves the essential features of the spectral data while effectively smoothing the noise [27,28].Therefore, the Savitzky-Golay method was adopted to preprocess the absorption spectral curves of the fertilizer solutions.The smoothed spectra were then analyzed.The bands near the absorption peaks were selected as the characteristic bands of the nutrient components in the fertilizer solution.According to the Lambert-Beer law, the absorbance is proportional to the concentration of the solution for a fixed optical path length.The optimal characteristic wavelength (detection wavelength) was determined by comparing the effect of the linear fit between fertilizer concentration and absorbance at each wavelength within the characteristic band (Figure 1b).Finally, prediction models were established for fertilizer concentrations based on the absorbance at characteristic wavelengths.

Structural Design of the Sensor
According to the detection principle of spectrophotometry [29] and Lambert-Beer's law [30], as well as the above characteristic wavelengths, a four-channel fertilizer solution detection sensor was designed.The sensor has a general pancake shape with a diameter of 120 mm and a height of 50 mm.It primarily consists of a light source chamber, a fertilizer chamber, four fertilizer inlets, four LED light sources, and four fertilizer detection  According to the detection principle of spectrophotometry [29] and Lambert-Beer's law [30], as well as the above characteristic wavelengths, a four-channel fertilizer solution detection sensor was designed.The sensor has a general pancake shape with a diameter of 120 mm and a height of 50 mm.It primarily consists of a light source chamber, a fertilizer chamber, four fertilizer inlets, four LED light sources, and four fertilizer detection channels (Figure 2).The light source chamber, fertilizer chamber, and fertilizer inlets are integrated housings made of 3D-printed resin.Four LED light sources (incident light sources) and four fertilizer detection channels (KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 ) are embedded within these integrated housings.Each detection channel consists of one filter and two identical photodetectors.A sealing cover over the light source and fertilizer chamber prevents fertilizer solution from entering the light source chamber and effectively reduces the impact of external light on fertilizer detection.The sensor was placed in the fertilizer solution to be measured, allowing the solution to enter the fertilizer chamber through its inlet.The fertilizer detection channels were then activated sequentially, enabling online detection of the fertilizer type and concentration.
To ensure the accuracy of the fertilizer sensor, the center wavelengths of the four LED light sources should theoretically coincide with the characteristic wavelengths of the four fertilizer solutions.However, unless specifically tailored, it is difficult to find commercially available LED light sources with center wavelengths that match the characteristic wavelengths of the four fertilizer solutions.Considering cost factors, four commercial LEDs with center wavelengths as close as possible to the four characteristic wavelengths were selected, and their main parameters are given in Table S1 (Supplementary Materials).
and two identical photodetectors.A sealing cover over the light source and fertilizer chamber prevents fertilizer solution from entering the light source chamber and effectively reduces the impact of external light on fertilizer detection.The sensor was placed in the fertilizer solution to be measured, allowing the solution to enter the fertilizer chamber through its inlet.The fertilizer detection channels were then activated sequentially, enabling online detection of the fertilizer type and concentration.To ensure the accuracy of the fertilizer sensor, the center wavelengths of the four LED light sources should theoretically coincide with the characteristic wavelengths of the four fertilizer solutions.However, unless specifically tailored, it is difficult to find commercially available LED light sources with center wavelengths that match the characteristic wavelengths of the four fertilizer solutions.Considering cost factors, four commercial LEDs with center wavelengths as close as possible to the four characteristic wavelengths were selected, and their main parameters are given in Table S1 (Supplementary Material).The four filter bands were positioned close to the center wavelengths of the LED light sources, aiming to concentrate the incident light around the center wavelengths.Two photodetectors per channel were employed to detect the intensity of light before and after it passed through the fertilizer solution and convert it into an electrical signal.According to the central wavelengths of the LED light sources, six UV-enhanced silicon photodiodes (LSSPD-U1.2,Beijing Lightsensing, Beijing, China) were selected as the photodetectors for KNO 3 , (NH 4 ) 2 SO 4 , and KH 2 PO 4 detection channels.Two indium-gallium-arsenic photodiodes (LSIPD-H2, Beijing Lightsensing, Beijing, China) were chosen for the K 2 SO 4 detection channel.The specific parameters of these two types of photodetectors are shown in Table S2 (Supplementary Materials).

Detection Principle of the Sensor
The sensor performed qualitative and quantitative analyses based on the difference in absorbance of four fertilizer solutions at different wavelengths.The absorbance can be calculated according to the Lambert-Beer law [31], as follows: where A is the absorbance, and I 0 and I t are the intensities of the incident and transmitted light, respectively.During the measurement process, the LED light passed through a filter to Photodetector 1 and then through the fertilizer solution to Photodetector 2. Photodetector 1 and Photodetector 2 recorded the intensities of the incident and transmitted light, respectively.The corresponding light intensities were expressed by the output voltages V i and V t .Prior to the activation of each LED light source, the photodetector measured the voltage (V a ) corresponding to the ambient light.In order to account for the impact of ambient light on sensor detection, the absorbance (A s ) was calculated by subtracting V a from both the incident light intensity (V i ) and transmitted light intensity (V t ) as described in Equation (2).

Signal Conditioning Circuit
The output signal from the photodetector was a weak current signal; it could not be used directly in the subsequent circuit.Therefore, a signal conditioning circuit was required to convert the raw output signal into a voltage signal of a suitable amplitude (Figure 1c).The signal conditioning circuit primarily consists of the following two parts: the I-V (current-to-voltage) conversion circuit and the gain amplification circuit.The I-V conversion circuit, mainly composed of the operational amplifier AD825 and a Ttype feedback resistor network (composed of R1, R2, and R3), converts the weak current signal from the photodetector into a voltage signal.The gain amplification circuit, mainly composed of the operational amplifier LF353N and its peripheral resistive-capacitive components, amplifies the amplitude of the voltage signal, with its gain adjustable up to 100 times by RP1.

Evaluation of the Sensor Stability
The detection stability of the sensor depends on the stability of the LED light source and the photodetector during the detection process.To evaluate the stability of the selfdesigned sensor in practical detection, (NH 4 ) 2 SO 4 solutions with concentrations of 30, 60, and 90 mg/L were used as test fertilizer solutions.The sensor was immersed in these solutions to assess the stability of the LED light source and the transmitted light, as well as the effect of ambient light.Each test was conducted for 2 h, with the output voltage of the photodetector recorded every 15 min.

Detection Strategy
A detection strategy of "qualitative analysis followed by quantitative detection" was adopted to achieve the rapid determination of the component information of four fertilizer solutions (Figure 2d).In each test, the following three steps were performed: (1) The four detection channels were activated sequentially for signal acquisition and absorbance calculation; (2) the type of fertilizer solution to be measured was determined by the detection channel (KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 ) corresponding to the absorbance maximum (A max ); and (3) the concentration of fertilizer solution was computed by substituting the A max into the corresponding concentration prediction model.

Evaluation Method of the Sensor Detection Accuracy
In order to evaluate the accuracy of the self-designed sensor for the detection of four fertilizer solutions, each type of fertilizer was configured with 10 concentrations, spanning a range of 10 to 100 mg/L with a 10 mg/L gradient.Five replicate tests were conducted for each concentration of fertilizer solution, with the mean value taken as the result of the fertilizer solution test.The sensor was placed into the sample solution to be tested, and the four detection channels were activated sequentially for detection.The voltages corresponding to ambient, incident, and transmitted light were recorded for each detection channel.The absorbances associated with the four detection channels (A 1 , A 2 , A 3 , and A 4 ) were then calculated according to Equation (2).
Identification of fertilizer solution type: The recognition accuracy of each type of fertilizer solution was assessed by sensitivity and specificity, which are calculated as the following Equations ( 3) and ( 4).The total recognition accuracy of the sensor for the four fertilizer solutions was calculated using Equation (5).
where TP (true positive) represents the number of samples correctly classified as 'Class 1'; FN (false negative) represents the number of 'Class 1' samples misclassified as 'Class 0'; TN (true negative) stands for the number of 'Class 0' samples correctly classified as 'Class 0'; and FP (false positive) refers to the number of 'Class 0' samples misclassified as 'Class 1'.Moreover, n is the number of classes, and N is the total number of samples.In the case of multi-classification, sensitivity reflects the recognition accuracy of a certain category, while specificity indicates the probability that other categories will not be recognized as this category.Detection accuracy of fertilizer concentration: After identifying fertilizer solution type, the absorbance was identified in the corresponding detection channel.Then, the solution concentration was calculated by substituting the absorbance into the fertilizer concentration detection model.The accuracy of the detection model was verified with the relative error.

Characteristic Wavelength Selection of Nutrient Ions in Fertilizer Solution
The spectral curves of four standard fertilizer solutions were smoothed by using the Savitzky-Golay filter fitting method (Figure 3).The absorbance of four fertilizer ions(NO 3 − , NH 4 + , H 2 PO 4 − , and K + ) generally increased with increasing concentration in the test bands.However, the maximum absorption wavelengths (absorption peaks, marked in Figure 3 with rectangular boxes of different colors) of the four ions showed significant differences (214 nm for NO 3 − ; 398 nm for NH 4 + ; 708 nm for H 2 PO 4 − ; and 1588 and 1804 nm for K + ).Theoretically, the maximum absorption wavelengths can be used as the characteristic wavelengths (detection wavelengths) to quantify different ions.Since the rate of change in absorbance at the peak point is minimal, the absorbance at nearby wavelengths is very close to the peak absorbance.This proximity reduces detection errors caused by wavelength drift when using the maximum absorption wavelength for detection.However, the absorbance curves for (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 , as measured in this study, showed some fluctuations near the peaks and were not smooth.Therefore, selecting the absorption peak directly as the detection wavelength for fertilizer concentration is not always the most effective approach.To address this issue, we sought the optimal detection wavelength (characteristic wavelength) within the band near the peak/trough by comparing the results of the linear fit between the concentration and absorbance of the fertilizer solution.This method aims to improve the accuracy and reliability of fertilizer concentration measurements.It is important to note that the characteristic wavelength is also to provide a basis for the selection of the LED light source of the fertilizer sensor.The majority of commercially available LED light sources exhibit a center wavelength of less than 1800 nm.Accordingly, the characteristic bands of NO 3 − , NH 4 + , H 2 PO 4 − , and K + can be set as 200-250 nm, 350-450 nm, 650-750 nm, and 1580-1800 nm, respectively.By analyzing the aforementioned bands, the characteristic wavelengths of the fo ions (NO3 − , NH4 + , H2PO4 − , and K + ) were determined to be 214, 410, 712, and 1708 n respectively (Figure 4).It can be observed that the distribution of absorban corresponding to different concentrations at the characteristic wavelength is mo uniform, and the linear correlation between absorbance and ion concentration was fou to be highly significant, with R 2 and RMSE values varying from 0.951 to 0.999 and 0.001 0.026, respectively (as illustrated in Figure 4e-h).It can be demonstrated that 214, 410, 71 and 1708 nm are the optimal wavelengths for the detection of NO3 − , NH4 + , H2PO4 − , and K respectively.Shen et al. [23] found that the signal of P2O5 was stable in the 550-950 n spectral band.The characteristic wavelength (712 nm) chosen to determine H₂PO4 − in th study is within the above range.Wang et al. [32] carried out a rapid detection of nit nitrogen (NO3 − ) in water using a UV-vis spectrophotometer and found that the secon order derivative absorbance of nitric nitrogen at 223.5 nm showed a linear relationsh with the concentration.Chen et al. [33] used first-order derivative spectroscopy in the 22 230 nm band to determine nitrate content (NO3 − ) in water, which could reduce t interference from water turbidity.These results are close to the characteristic waveleng (214 nm) chosen for the determination of NO3 − in the present work.By analyzing the aforementioned bands, the characteristic wavelengths of the four ions (NO 3 − , NH 4 + , H 2 PO 4 − , and K + ) were determined to be 214, 410, 712, and 1708 nm, respectively (Figure 4).It can be observed that the distribution of absorbance corresponding to different concentrations at the characteristic wavelength is more uniform, and the linear correlation between absorbance and ion concentration was found to be highly significant, with R 2 and RMSE values varying from 0.951 to 0.999 and 0.001 to 0.026, respectively (as illustrated in Figure 4e-h).It can be demonstrated that 214, 410, 712, and 1708 nm are the optimal wavelengths for the detection of NO 3 − , NH 4 + , H 2 PO 4 − , and K + , respectively.Shen et al. [23] found that the signal of P 2 O 5 was stable in the 550-950 nm spectral band.The characteristic wavelength (712 nm) chosen to determine H 2 PO 4 − in this study is within the above range.Wang et al. [32] carried out a rapid detection of nitric nitrogen (NO 3 − ) in water using a UV-vis spectrophotometer and found that the second-order derivative absorbance of nitric nitrogen at 223.5 nm showed a linear relationship with the concentration.Chen et al. [33] used first-order derivative spectroscopy in the 220-230 nm band to determine nitrate content (NO 3 − ) in water, which could reduce the interference from water turbidity.These results are close to the characteristic wavelength (214 nm) chosen for the determination of NO 3 − in the present work.

Identification of Fertilizer Solution Based on Characteristic Wavelengths
Figure 5 illustrates the absorbance profiles of the four fertilizer solutions (NO 3 − , NH 4 + , H 2 PO 4 − , and K + ) at the four selected characteristic wavelengths (214, 410, 712, and 1708 nm).The trends in absorbance versus characteristic wavelengths were obviously different for the four fertilizer solutions.With increasing wavelength, the absorbance exhibited a trend of "sharp decrease→zero" for NO 3 − ; "rise→fall→zero" for NH 4 + ; "no obvious increase→rise→down to zero" for H 2 PO 4 − ; and "zero→rise" for K + (Figure 5).The absorbance curve of K + in the range of 200-1000 nm is shown in Figure S1 (Supplementary Materials).It can be observed that the absorbance of K + at 214, 410, and 712 nm is close to zero.In brief, all four fertilizer solutions exhibited the greatest absorbance at their respective characteristic wavelengths.Therefore, light sources with different wavelengths (214, 410, 712, and 1708 nm) can be employed sequentially to detect the tested fertilizer solution, and the type of fertilizer solution can be determined by the wavelength exhibiting the maximum absorbance.

Identification of Fertilizer Solution Based on Characteristic Wavelengths
Figure 5 illustrates the absorbance profiles of the four fertilizer solutions (NO3 − , NH4 + H2PO4 − , and K + ) at the four selected characteristic wavelengths (214, 410, 712, and 1708 nm).The trends in absorbance versus characteristic wavelengths were obviously differen for the four fertilizer solutions.With increasing wavelength, the absorbance exhibited a trend of "sharp decrease→zero" for NO3 − ; "rise→fall→zero" for NH4 + ; "no obvious in crease→rise→down to zero" for H2PO4 − ; and "zero→rise" for K + (Figure 5).The absorb ance curve of K + in the range of 200-1000 nm is shown in Figure S1 (Supplementary Ma terial).It can be observed that the absorbance of K + at 214, 410, and 712 nm is close to zero In brief, all four fertilizer solutions exhibited the greatest absorbance at their respective characteristic wavelengths.Therefore, light sources with different wavelengths (214, 410 712, and 1708 nm) can be employed sequentially to detect the tested fertilizer solution and the type of fertilizer solution can be determined by the wavelength exhibiting the maximum absorbance.

Detection of Fertilizer Solution Concentration
Four models were established for the detection of fertilizer solution concentration based on the positive linear relationships between absorbance at characteristic wave lengths and fertilizer solution concentrations (Figure 4e-h and Table 1).The R 2 values o the four models were all greater than 0.91, indicating a strong linear relationship between the concentration and the absorbance.

Detection of Fertilizer Solution Concentration
Four models were established for the detection of fertilizer solution concentration based on the positive linear relationships between absorbance at characteristic wavelengths and fertilizer solution concentrations (Figure 4e-h and Table 1).The R 2 values of the four models were all greater than 0.91, indicating a strong linear relationship between the concentration and the absorbance.

Stability Analysis of the Fertilizer Solution Sensor
The stability of the LED light source is a determining factor in the stability of the incident light in each detection channel.This can be characterized by the stability of the output voltage of the Photodetector 1 (Figure 2).As shown in Figure 6a, the voltage value of Photodetector 1 remained within the range of 133.0 to 137.0 mV, exhibiting a fluctuation of −1.38% to +1.33% under the illumination of the LED light.This indicates that the LED light source is stable enough to provide a stable incident light to the fertilizer sensor.The stability of the transmitted light can be quantified by the output voltage stability of Photodetector 2 (Figure 2), and the test results are presented in Figure 6b.The output voltage of Photodetector 2 varied with the concentration of fertilizer solution.However, for the same fertilizer concentration, the voltage values fluctuated within ±0.5 mV, with a variation of −2.58% to +3.04%.This demonstrates that the stability of the transmitted light is good enough to meet the requirements of practical applications.To assess the effect of ambient light on the sensor, the LED light source was switched off during the test, and only the output voltage values of Photodetector 2 under ambient light were recorded.As shown in Figure 6c, the voltage values had been maintained between 10.0 and 10.5 mV with a fluctuation range of −1.82%-2.07%,implying that the sensor has been subjected to little or even negligible influence from ambient light.Note: C1-C4 present the concentrations of NO3 − , NH4 + , H₂PO4 − , and K + fertilizer solution, respectively.A1-A4 present the absorbance at the characteristic wavelengths of 214, 410, 712, and 1708 nm, respectively.

Stability Analysis of the Fertilizer Solution Sensor
The stability of the LED light source is a determining factor in the stability of the incident light in each detection channel.This can be characterized by the stability of the output voltage of the Photodetector 1 (Figure 2).As shown in Figure 6a, the voltage value of Photodetector 1 remained within the range of 133.0 to 137.0 mV, exhibiting a fluctuation of −1.38% to +1.33% under the illumination of the LED light.This indicates that the LED light source is stable enough to provide a stable incident light to the fertilizer sensor.The stability of the transmitted light can be quantified by the output voltage stability of Photodetector 2 (Figure 2), and the test results are presented in Figure 6b.The output voltage of Photodetector 2 varied with the concentration of fertilizer solution.However, for the same fertilizer concentration, the voltage values fluctuated within ±0.5 mV, with a variation of −2.58% to +3.04%.This demonstrates that the stability of the transmitted light is good enough to meet the requirements of practical applications.To assess the effect of ambient light on the sensor, the LED light source was switched off during the test, and only the output voltage values of Photodetector 2 under ambient light were recorded.As shown in Figure 6c, the voltage values had been maintained between 10.0 and 10.5 mV with a fluctuation range of −1.82%-2.07%,implying that the sensor has been subjected to little or even negligible influence from ambient light.

Identification of Fertilizer Solution Types
The developed sensor was used to detect ten different concentrations of (NH4)2SO4 solution with five replicates.Four detection channels were activated sequentially for each sample, and the voltages corresponding to ambient, incident, and transmitted light were recorded for each detection channel.The absorbances of four detection channels (A1, A2, A3, and A4) were calculated according to Equation (2), and the results are shown in Table 2.The trend in absorbance variation at four detection wavelengths for 10 concentrations of (NH4)2SO4 solution was plotted, as illustrated in Figure 7b.It is evident that the  The developed sensor was used to detect ten different concentrations of (NH 4 ) 2 SO 4 solution with five replicates.Four detection channels were activated sequentially for each sample, and the voltages corresponding to ambient, incident, and transmitted light were recorded for each detection channel.The absorbances of four detection channels (A 1 , A 2 , A 3 , and A 4 ) were calculated according to Equation (2), and the results are shown in Table 2.The trend in absorbance variation at four detection wavelengths for 10 concentrations of (NH 4 ) 2 SO 4 solution was plotted, as illustrated in Figure 7b.It is evident that the (NH 4 ) 2 SO 4 solution exhibits the greatest absorbance at 405 nm, with the absorbance varying from 0.9965 to 1.3656.To assess the detection accuracy of the sensor, the remaining three fertilizer solutions (KNO 3 , KH 2 PO 4 , and K 2 SO 4 ) were also tested at different concentrations.The trends in the absorbance of KNO 3 , KH 2 PO 4 , and K 2 SO 4 are presented in Figure 7a,c,d, respectively.KNO 3 , KH 2 PO 4 , and K 2 SO 4 solutions show the highest absorbance at 256, 700, and 1650 nm, respectively.The variations in absorbance observed for the four fertilizer solutions using the developed sensor (Figure 7) are consistent with the results obtained from the spectrophotometer (Figure 5).Table 2. Detailed data recorded for the detection of different concentrations of (NH 4 ) 2 SO 4 solution.

Concentration
(mg/L) ing from 0.9965 to 1.3656.To assess the detection accuracy of the sensor, the remaining three fertilizer solutions (KNO3, KH2PO4, and K2SO4) were also tested at different concentrations.The trends in the absorbance of KNO3, KH2PO4, and K2SO4 are presented in Figure 7a,c,d, respectively.KNO3, KH2PO4, and K2SO4 solutions show the highest absorbance at 256, 700, and 1650 nm, respectively.The variations in absorbance observed for the four fertilizer solutions using the developed sensor (Figure 7) are consistent with the results obtained from the spectrophotometer (Figure 5).Following 200 tests, the developed sensor demonstrated the ability to correctly recognize KNO3, (NH4)2SO4, KH2PO4, and K2SO4 with a sensitivity (accuracy) of 84%, 84%, 82%, and 76%, respectively (Figure 8).A total of 12 K2SO4 samples were incorrectly Following 200 tests, the developed sensor demonstrated the ability to correctly recognize KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 with a sensitivity (accuracy) of 84%, 84%, 82%, and 76%, respectively (Figure 8).A total of 12 K 2 SO 4 samples were incorrectly identified as (NH 4 ) 2 SO 4 , resulting in a low identification accuracy.High specificities are observed for KNO 3 (95.33%),KH 2 PO 4 (94.00), and K 2 SO 4 (98.00%),indicating good rejection to other fertilizer solutions.In summary, the sensor has good detection performance with a total detection accuracy of 81.5%.identified as (NH4)2SO4, resulting in a low identification accuracy.High specificities are observed for KNO3 (95.33%),KH2PO4 (94.00), and K2SO4 (98.00%), indicating good rejection to other fertilizer solutions.In summary, the sensor has good detection performance with a total detection accuracy of 81.5%.Wu et al. [17] designed a sensor based on the dielectric properties of fertilizer solution, which achieved 100%, 100%, 97.43%, and 94.8% recognition accuracy for KNO3, (NH4)2HPO4, K2SO4, and KH2PO4, respectively.However, they did not investigate the quantitative performance of the sensor in measuring fertilizer concentration.The sensor developed in this work can be placed in the buffer tank of fertilizer solution for detection, effectively preventing detection errors caused by uneven mixing of water and fertilizer, as well as fluctuations in the flow rate of fertilizer solution in the pipeline.

Fertilizer Solution Concentration Detection Model Verification
The relative errors between the actual and the predicted concentrations of the four fertilizer solutions determined by the developed sensor are illustrated in Figure 9.The detection errors of KNO3, (NH4)2SO4, KH2PO4, and K2SO4 concentrations were found to range from −16.31% to 12.65%, −9.75% to 9.86%, −12% to 13.3%, and −14% to 15%, respectively, when the concentration of fertilizer solution was lower than 80 mg/L.The LED light sources utilized in the four detection channels of the sensor were not entirely monochromatic, and their central wavelengths deviated from the characteristic wavelengths of the four fertilizer solutions.These deviations resulted in a reduction in the sensor's detection accuracy.Given the limitations of selecting characteristic light sources in this study, a monochromatic LED light source with the same wavelength as the characteristic wavelength of fertilizer solution can be customized to improve detection accuracy without taking cost into consideration.Dong et al. [34] employed UV-vis spectrophotometry to measure nitrate content (NO3 − ) in water, and the relative error of nitrate detection was reduced from 94.44% to 3.36% by correcting the offsets induced by dissolved organic carbon.Cho et al. [35] developed an on-site ion monitoring system based on ion-selective electrodes.The detection of NO3 − and K + concentrations in the hydroponic solutions was highly consistent with the results determined by a standard instrument (ion chromatography), and the average root mean square errors (RMSE) were 11.9 and 19.3 mg/L, respectively.The RMSEs for NO3 − and K + in the present study were 5.26 and 9.29 mg/L, respectively.The precise and quantitative regulation of crop water and fertilizer through intelligent waterfertilizer integration systems rely on real-time monitoring and feedback regulation of fertilizer component information.Therefore, the development of low-cost, fast, and accurate Wu et al. [17] designed a sensor based on the dielectric properties of fertilizer solution, which achieved 100%, 100%, 97.43%, and 94.8% recognition accuracy for KNO 3 , (NH 4 ) 2 HPO 4 , K 2 SO 4 , and KH 2 PO 4 , respectively.However, they did not investigate the quantitative performance of the sensor in measuring fertilizer concentration.The sensor developed in this work can be placed in the buffer tank of fertilizer solution for detection, effectively preventing detection errors caused by uneven mixing of water and fertilizer, as well as fluctuations in the flow rate of fertilizer solution in the pipeline.

Fertilizer Solution Concentration Detection Model Verification
The relative errors between the actual and the predicted concentrations of the four fertilizer solutions determined by the developed sensor are illustrated in Figure 9.The detection errors of KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 concentrations were found to range from −16.31% to 12.65%, −9.75% to 9.86%, −12% to 13.3%, and −14% to 15%, respectively, when the concentration of fertilizer solution was lower than 80 mg/L.The LED light sources utilized in the four detection channels of the sensor were not entirely monochromatic, and their central wavelengths deviated from the characteristic wavelengths of the four fertilizer solutions.These deviations resulted in a reduction in the sensor's detection accuracy.Given the limitations of selecting characteristic light sources in this study, a monochromatic LED light source with the same wavelength as the characteristic wavelength of fertilizer solution can be customized to improve detection accuracy without taking cost into consideration.Dong et al. [34] employed UV-vis spectrophotometry to measure nitrate content (NO 3 − ) in water, and the relative error of nitrate detection was reduced from 94.44% to 3.36% by correcting the offsets induced by dissolved organic carbon.Cho et al. [35] developed an on-site ion monitoring system based on ion-selective electrodes.The detection of NO 3 − and K + concentrations in the hydroponic solutions was highly consistent with the results determined by a standard instrument (ion chromatography), and the average root mean square errors (RMSE) were 11.9 and 19.3 mg/L, respectively.The RMSEs for NO 3 − and K + in the present study were 5.26 and 9.29 mg/L, respectively.The precise and quantitative regulation of crop water and fertilizer through intelligent water-fertilizer integration systems rely on real-time monitoring and feedback regulation of fertilizer component information.Therefore, the development of low-cost, fast, and accurate online fertilizer detection sensors is crucial for advancing agricultural engineering technology.Overall, the detection accuracy of the fertilizer sensor developed in this study can be enhanced by improving the LED light sources and modifying the prediction models.Despite this, its low-cost development strategy offers great potential for promoting agricultural applications.
online fertilizer detection sensors is crucial for advancing agricultural engineering technology.Overall, the detection accuracy of the fertilizer sensor developed in this study can be enhanced by improving the LED light sources and modifying the prediction models.Despite this, its low-cost development strategy offers great potential for promoting agricultural applications.

Conclusions
In this paper, a rapid detection method based on spectrophotometry was proposed for the information of four fertilizer solutions (KNO3, (NH4)2SO4, KH2PO4, and K2SO4).By analyzing the spectral curves, the characteristic wavelengths of the four ions, NO3 − , NH4 + , H₂PO4 − , and K + , were determined to be 214, 410, 712, and 1708 nm, respectively.The absorbance at the characteristic wavelength showed a good linear fit to the ion concentration (R 2 : 0.952~0.999;RMSE: 0.001~0.026).Based on the above analysis, a four-channel sensor was designed for the online detection of four fertilizer solutions according to the Lambert-Beer law, and a detection strategy of "qualitative analysis followed by quantitative detection" was adopted to achieve the rapid identification of four fertilizer types and the prediction of their concentrations.The assessment of the sensor's performance showed that it was highly reliable, achieving an accuracy of 81.5% in identifying four types of fertilizers.In addition, the sensor's detection error was substantially less than ±15% for four fertilizer concentrations not exceeding 80 mg/L.These results confirm the capability of the sensor to satisfy the practical requirements for online detection of four fertilizer types and concentrations in the field of agricultural engineering.However, under certain constraints, this study only explored N, P, and K nutrient fertilizers represented by KNO3, (NH4)2SO4, KH2PO4, and K2SO4.To further enhance the applicability and generalization of the sensor, further research could explore expanding the variety of fertilizer solutions (KCl, CO(NH2)2, Ca(H2PO4)2•H2O, compound fertilizer, etc.) and developing online sensors based on Raman spectroscopy to detect higher concentrations of fertilizer solutions.In addition, the influence of fertilizer temperature and water quality variations on the sensor detection accuracy and the corresponding compensation methods also warrant investigation.Overall, this study presents a promising technique for developing sensors that can efficiently, quickly, and inexpensively detect fertilizer solution information.

Figure 1 .
Figure 1.Development strategy for fertilizer detection sensors: (a) The acquisition of UV-vis/NIR absorption spectra of four fertilizer solutions: (i) KNO3, (ii) (NH4)2SO4, (iii) KH2PO4, and (iv) K2SO4.(b) Determination of characteristic wavelengths and construction of quantitative models.(c) Sensor structure and amplifier circuit design.(d) The detection strategy of qualitative analysis followed by quantitative assessment.

Figure 1 .
Figure 1.Development strategy for fertilizer detection sensors: (a) The acquisition of UV-vis/NIR absorption spectra of four fertilizer solutions: (i) KNO 3 , (ii) (NH 4 ) 2 SO 4 , (iii) KH 2 PO 4 , and (iv) K 2 SO 4 .(b) Determination of characteristic wavelengths and construction of quantitative models.(c) Sensor structure and amplifier circuit design.(d) The detection strategy of qualitative analysis followed by quantitative assessment.

2. 4 .
Development of a Four-Channel Fertilizer Solution Detection Sensor 2.4.1.Structural Design of the Sensor

Figure 2 .
Figure 2. Fertilizer solution detection sensor.(a) Internal structure of the sensor; (b) external structure of the sensor; (c) physical drawing of the sensor; and (d) fertilizer solution identification and concentration detection strategy.

Figure 2 .
Figure 2. Fertilizer solution detection sensor.(a) Internal structure of the sensor; (b) external structure of the sensor; (c) physical drawing of the sensor; and (d) fertilizer solution identification and concentration detection strategy.

Figure 6 .
Figure 6.Stability test results of the fertilizer solution sensor: (a) the stability of the LED light source characterized by the output voltage of the Photodetector 1; (b) transmission voltage value; and (c) ambient light voltage value.

Figure 6 .
Figure 6.Stability test results of the fertilizer solution sensor: (a) the stability of the LED light source characterized by the output voltage of the Photodetector 1; (b) transmission voltage value; and (c) ambient light voltage value.

Figure 8 .
Figure 8. Confusion matrix charts of the classification results for four fertilizer solutions (KNO 3 , (NH 4 ) 2 SO 4 , KH 2 PO 4 , and K 2 SO 4 ) obtained by the developed sensor.

Figure 9 .
Figure 9. Detection errors of the sensor on the concentration of four fertilizer solutions.

(
Jianian Li) and C.W.; visualization, J.L. (Jiawen Liang); supervision, C.W.; project administration, J.L. (Jianian Li); funding acquisition, J.L. (Jianian Li).All authors have read and agreed to the published version of the manuscript.Funding: This research was funded by the National Natural Science Foundation of China, grant number 52069008; the Yunnan Major Science and Technology Special Plan, grant number 202302AE090024; the Yunnan Fundamental Research Projects, grant number 202101AT070113; and the Yunnan Revitalization Talent Support Program.Institutional Review Board Statement: Not applicable.

Table 1 .
Detection models for the concentrations of four fertilizer solutions.

Table 1 .
Detection models for the concentrations of four fertilizer solutions.

Table 2 .
Detailed data recorded for the detection of different concentrations of (NH4)2SO4 solution.