A Portable Tool for Spectral Analysis of Plant Leaves That Incorporates a Multichannel Detector to Enable Faster Data Capture

: In this study, a novel system was designed to enhance the efficiency of data acquisition in a portable and compact instrument dedicated to the spectral analysis of various surfaces, including plant leaves, and materials requiring characterization within the 410 to 915 nm range. The proposed system incorporates two nine-band detectors positioned on the top and bottom of the target surface, each equipped with a digitally controllable LED. The detectors are capable of measuring both reflection and transmission properties, depending on the LED configuration. Specifically, when the upper LED is activated, the lower detector operates without its LED, enabling the precise measurement of light transmitted through the sample. The process is reversed in subsequent iterations, facilitating an accurate assessment of reflection and transmission for each side of the target surface. For reliability, the error estimation utilizes a color checker, followed by a multi-layer perceptron (MLP) implementation integrated into the microcontroller unit (MCU) using TinyML technology for real-time refined data acquisition. The system is constructed with 3D-printed components and cost-effective electronics. It also supports USB or Bluetooth communication for data transmission. This innovative detector marks a significant advancement in spectral analysis, particularly for plant research, offering the potential for disease detection and nutritional deficiency


Introduction
Optical spectrometers that operate in the visible and infrared regions have become indispensable tools in our daily lives, fundamentally transforming our comprehension and interaction with a wide range of materials and substances, regardless of their physical state.This technology is extensively employed in several areas, including agriculture, energy, chemistry, materials science, and food production [1][2][3][4][5][6][7][8][9].The operating principle of visible-short-wave near-infrared (VIS-NIR-SWIR) spectroscopy is the transfer of energy between light and matter.This fundamental principle allows for the identification and study of different compounds by examining their distinct spectral properties.In fact, the spectral characteristics within the VIS-NIR-SWIR range are intricately linked to the vibrational modes of the functional groups found in the target substance [2,10].Indeed, the vibrational modes serve as a distinctive mark, resembling a fingerprint, which enables scientists and researchers to obtain valuable information about the composition and characteristics of the substances being studied.Moreover, the non-invasive, high-resolution, and non-destructive aspects of Vis-SWNIR spectroscopy are very beneficial in plant studies [3,11,12].It enables quick assessments without causing damage to the samples, making it ideal for the real-time monitoring of plant health and nutrient levels.
Several studies used spectral analysis to investigate plants in the past [12][13][14][15][16][17][18][19][20].For example, Ge et al. explored the utility of VIS-NIR-SWIR as a high-throughput instrument for measuring six leaf parameters of maize plants: chlorophyll content (CHL), leaf water content (LWC), specific leaf area (SLA), nitrogen (N), phosphorus (P), and potassium (K) [12].To estimate leaf attributes from hyperspectral data, two multivariate modeling techniques, namely, partial least-squares regression (PLSR) and support vector regression (SVR), were used to calculate several vegetation indices.The results show that the proposed methodologies can be used to predict CHL levels but not the other leaf metrics.In 2020, Xiong et al. used Vis-SWNIR spectroscopy and chemometric techniques to investigate the potassium concentration in fresh lettuce [21].The authors demonstrated how PLS and SVR can be used to assess potassium concentrations in these plants.The results show that the PLS model outperformed the SVR model in terms of prediction.In 2021, Mahajan and collaborators characterized the foliar nutrient status of mango through the development of spectral indices, multivariate calculus, chemometrics, and machine learning (ML) models [15].Recently, Wang et al. created an inexpensive spectrometer for assessing the quality attributes of tea tree leaves [13].The device utilizes the random forest method to accurately predict the quantities of nitrogen, chlorophyll, and free amino acids.However, the predictions for moisture, polyphenol, and sugar exhibit some inconsistency, which impacts the overall accuracy.
Conventional high-performance spectrometers have historically depended on robust and costly setups that integrate bulky dispersive elements, long optical paths, and complex mechanical processes.Additionally, expert personnel are required to carry out the tests in some cases.However, the demand for versatile spectroscopy tools tailored to specific applications has driven innovation in the form of more compact, cost-effective designs and user-friendly systems.These modern spectrometers prioritize portability, affordability, durability, and energy efficiency, making them suitable for a diverse range of scenarios [4,9,[22][23][24][25][26]. The rising demand for mini-and micro-spectrometers across different industries has resulted in a projected market value of almost USD 900 million, showing a significant surge in interest in this technology [27].Coronel-Reyes et al. created an inexpensive NIR spectrometer to evaluate the duration of egg storage [7].Consequently, the eggs were subjected to spectral analysis by utilizing reflectance measurements ranging from 740 to 1070 nm.In addition, appropriate predictive models were constructed using PLS and artificial neural network (ANN) regression approaches, which aided in determining the freshness of eggs.In 2020, Laganovska and her colleagues presented a cost-effective, self-contained portable spectrophotometer [24].In addition, this device offers exceptional performance and achieves a resolution of 15 nm.In 2021, Botero-Valencia et al. introduced a cost-effective and wireless IoT multispectral acquisition device aimed at improving the availability of spectrum data for diverse applications [23].This device utilizes the functionalities of small-scale spectrometers and Internet of things (IoT) technologies, hence creating possibilities for more extensive spectrum investigations in various domains.Another low-cost spectrometer was developed for biochemical assays [28], measuring the milk quality [4], and the testing of citrus cultivars [1].These devices typically utilize artificial intelligence approaches to overcome the restrictions imposed by the detectors and other inexpensive components.Nevertheless, these algorithms necessitate substantial computational resources, resulting in increased energy consumption.Consequently, these devices are unsuitable for integration into Internet of things (IoT) networks.Due to this argument, there has been a significant inclination toward adopting a range of TinyML techniques, which is a specialized area within machine learning that aims to facilitate the integration of ML applications into small, energy-efficient, cost-effective devices [29][30][31].Likewise, TinyML allows for the analysis and interpretation of data directly on devices, enabling immediate decision-making and action.Furthermore, several of these systems do not account for the measurement of multispectral data on both sides of the leaf.This is crucial considering the varied manifestations of diseases and the need to assess their transmittance simultaneously.
In this work, we present a cutting-edge device that effortlessly integrates all of the aforementioned unique characteristics.The design features two AS7341 detectors strategically placed at the sample's upper and lower interfaces.Each detector has an independently programmable light-emitting diode (LED) system that allows for the fine control of the incident light spectrum.Importantly, depending on the precise LED activation sequence, these detectors can concurrently evaluate the reflectance and transmittance characteristics of the sample under test.In the proposed device, when the upper LED module is turned on, the lower detector goes into a passive state, allowing for the evaluation of light transmission properties across the sample.Likewise, the detecting mechanism's reliability was validated.An in-depth error approximation strategy was used for this purpose, employing the standard color checker technique.The system was then subjected to data alignment using a multilayer perceptron (MLP) algorithm, ensuring the best possible correlation of the acquired data with predetermined reference standards.
This calibration process in particular is fully integrated with the dedicated microcontroller unit (MCU) via cutting-edge TinyML technology, enabling accurate and reliable real-time acquiring of spectral data.Furthermore, the use of TinyML allows for the proposed spectrometer to consume less power than other previously presented options.Finally, all of these components are assembled in a 3D-printed chassis that is meticulously constructed, which reduces the cost of the proposed device.

Multispectral Sensor
The AS7341 sensor (Adafruit, New York, NY, USA) is a versatile and high-performance 11-channel multispectral sensor designed for accurate color detection and extensive spectral analysis applications [32].It effectively spans a broad spectral range from 350 nm to 1000 nm, encompassing the visible spectrum, near-infrared (NIR), and clear light.With eight optical channels dedicated to the visible spectrum, one for NIR light, and an additional one for clear light, it also includes a specialized channel for detecting 50 Hz or 60 Hz ambient light flicker.Employing nano-optic deposited interference filter technology, this sensor seamlessly integrates filters into standard CMOS silicon, enabling a streamlined and costeffective sensor design.Equipped with a built-in aperture, it efficiently regulates the influx of light into the sensor array, with control accessible through a serial I²C interface.It is available in an ultra-low-profile package, featuring dimensions of 3.1 mm × 2 mm × 1 mm, making it an optimal choice for space-constrained engineering applications.In the case described in this study, two AS7341 sensors were employed to evaluate the reflection of each side of the plant leaf while simultaneously assessing the transmission.Each sensor is paired with a digitally controllable LED, namely, the EAHC2835WD6, which further streamlines the acquisition process.Figure 1b shows the relative luminous intensity for the EAHC2835WD6 LED, which was taken with an OHSP-350C (Ocean Optics, Orlando, FL, USA).The spectrum depicted illustrates the LED's effectiveness across the wavelength range of 400 to 750 nm. Figure 1a illustrates an approximation of the spectral distribution of the bands (relative sensitivity) in the multispectral sensor.The bandwidths (BWs) of the channels range from approximately 26 to 90 nm.The datasheet does not specify the BW of the 910 nm channel.The AS7341 is a versatile sensor that allows both the gain and the integration time to be configured via software, which allows the sensitivity of the sensor to be adjusted within the program.In the case of the data used in this work, a gain of 32 was used.

Mechanical Design
The entire structure of the proposed spectrometer was 3D-printed using polylactic acid (PLA) material.The first components, namely, MCU_cover and MCU_support (parts 1 and 2), were specifically designed to encase the microcontroller and battery, with MCU_support featuring an aperture for the microcontroller display.An additional component, namely, MUX_support (part 3), is used to hold and cover the multiplexer and for toggling the activation between the two spectrometers.Inside the device, two AS734 multispectral sensors are employed and are positioned opposite each other to evaluate the transmittance and reflectance of the leaf specimen placed between them.The first sensor is shielded by components 4 and 5, denoted as top_base and top_cover, respectively, while the second sensor is protected by components 6 and 7, named bottom_cover and bottom_base.This design allows the system to be opened and closed, thereby enabling the adjustment of the separation between the spectrometers for non-invasive leaf measurements.Finally, components 8 and 9, identified as top_hinge and bottom_hinge, function as pivotal elements, facilitating the system's open-and-close movements.Figure 2 illustrates the configuration of the proposed spectrometer, together with a detailed inventory of the components comprising the proposed design.Additionally, the table includes a hyperlink to the online repository, where the files are accessible in STL format for printing and utilization by interested users.

Electronic Design
Figure 3 shows the electronic wiring diagram of the components used in the presented system.To accommodate the requirement of utilizing two AS7341 sensors, which only support I²C communication and cannot be modified, it became imperative to employ the DFR0576 digital 1-to-8 I²C multiplexer.We utilized two of its outputs for this purpose.This is connected to the I²C bus of the microcontroller, namely, the LILYGO-T-HMI-ESP32-S3.Furthermore, the system is equipped with a 450 mAh lithium battery, enabling it to function independently in the field.

Color Checker
Calibration is an essential stage in the development of a low-cost spectrometer.Currently, there are various approaches available for this purpose, depending on the specific application.In our particular scenario, a color checker, as stated in reference [33] was used.A color checker is a tool used in spectroscopy and photometry to standardize and assess the precision of a spectrum [33][34][35].The color checker seen in Figure 4 consists of a sequence of color patches that possess predetermined and standardized reflectance values.As a result, these patches exhibit distinct and consistent colors that are precisely determined in terms of their wavelength and reflectance intensity.To provide a visual representation, we overlapped each spectrum in the box with the corresponding color patch.This demon-strates how the spectrum was modified based on the studied color.Figure 4 depicts a color checker with 24 unique colors [33], which was referenced as a "patch" during the analysis.Within each patch, and simply as a representation, the x-axis indicates the wavelength between 400 and 980 nm, and the y-axis shows the normalized reflectivity.The suggested spectrometer operates in the visible and near-infrared (NIR) wavelength range.The color checker then indicates each color's reflectance across a wavelength range of 400 nm to 1000 nm.The color checker for black showed a reflectance value of 0.0125, as expected, whereas the color checker for white showed a reflectance value of 0.8812.[33].In the figure, the distribution of the rows and columns corresponds to the original Color checker, and within each patch the reflectance curve is shown as a reference.

Machine Learning Algorithm
The data provided by the AS7341 sensor is in a raw format expressed in counts.To calibrate these values to a standardized reflectivity measure, the color checker mentioned in Section 2.4 was employed to capture the values with each sensor.Subsequently, these values were adjusted using a supervised machine learning method, specifically, a multilayer perceptron (MLP) [36].The MLP method was selected due to its ability to describe intricate interactions between inputs and outputs, making it particularly advantageous in spectral analysis cases where the relationships may exhibit nonlinear behavior.Furthermore, the MLP approach possesses the capacity to extrapolate from a restricted amount of training data [37][38][39].In this particular instance, the MLP model comprises nine neurons in the input layer, two hidden layers, and nine neurons in the output layer, as can be seen in Figure 5. Every neuron in the input layer receives reflectance data that are measured at nine distinct wavelengths: 415, 445, 480, 515, 555, 590, 630, 680, and 910 nm.These same wavelengths correspond to the expected outputs of the model.The neurons in each layer are completely interconnected with the neurons in the subsequent layer, facilitating the unidirectional flow of information.The network architecture is specifically built to enable the mapping of input data, which represents the spectrum reflectance measurements, to the matching output data, which are the reflectance values at specified wavelengths.The MLP model, which is designed for feedforward operation, adeptly captures intricate connections between the input and output data, facilitating accurate spectrum analysis and predictions.On the other hand, the weights of these connections are modified during the training process.Each neuron's output is multiplied by the connection weight, then undergoes a rectified linear unit (ReLU) activation function and is summed with the outputs of other linked neurons.In this case, a ReLU function was selected because of its reduced training time and straightforward integration into embedded devices.
Tiny machine learning (TinyML) is a revolutionary branch of artificial intelligence that enables the execution of ML models on low-power devices, like MCUs.This breakthrough technology empowers the implementation of machine learning models for sensor data analysis directly on the device, resulting in lower power consumption and feasible deployment on battery-powered devices.The benefits of TinyML are manifold: local data processing minimizes the latency, enhancing the efficiency and expediting decision-making without the need for information transfer to a server.Moreover, reduced power consumption is critical for battery-constrained devices, while local data storage heightens the security by mitigating risks associated with information transfer.The implementation process typically commences with training the model on a higher-power computer using TensorFlow, fol-lowed by optimization with TensorFlow Lite to reduce the size and complexity.The model is then adapted to the MCU's capabilities, and necessary code is written to load and run the model on the device, undergoing tests and performance adjustments as needed.
In this work, the perceptron training process was carried out using the TensorFlow library.The main objective of this implementation was the subsequent integration of the model in an embedded system to have the data adjusted in real-time.This optimization process is achieved through the adaptation of the model to the tiny machine learning framework, which allows for its efficient implementation on an MCU with limited resources.

Measurement of Reflectance Using an Optical Spectrum Analyzer (OSA)
The experimental setup illustrated in Figure 6 was employed to obtain the reflectance spectrum of colored paper sheets with different colors.This setup employed a lasercontrolled plasma-type white light source (Energetiq EQ-99-FC, Wilmington, MA, USA) that emitted between 190 and 2500 nm, and an optical spectrum analyzer (OSA) (Yokogawa, AQ6373, Tokyo, Japan).Both instruments in this scenario were connected using a fiber optic probe (Ocean Optics, QR200-7-UV-VIS), which enabled the measurement of the reflectance of the sample being analyzed.As depicted in Figure 6, the probe was strategically positioned at a 45 • angle to mitigate the impact of undesirable reflections that might compromise the measurement accuracy.This orientation served the dual purpose of not only minimizing unwanted reflections but also preventing incident light from reflecting directly back toward the light source.To ensure that the measurement was always taken in the same position, i.e., at the same distance between the probe and the sample, a holder was employed.This holder was allowed for securing the position of the probe with a screw.
The OSA measurements were conducted using a linear scale with a precision of 5 nm, covering a wavelength range of 350 nm to 980 nm with increments of 0.31 nm.The initial phase of the experiment entailed capturing diffuse reflectance spectra spanning from 350 nm to 980 nm.This was achieved by utilizing a certified reflectance standard, specifically the USRS-99-010 model from Labsphere (Hewlett Packard, Palo Alto, CA, USA).This accessory helped to calibrate the white color, thereby guaranteeing the consistency and accuracy of measurements.Its function was to emulate an ideal target with nearly perfect reflectance, facilitating precise and reliable data collection throughout the experiment.Through spectral analysis of this reference sample, we established a standard against which the reflectance characteristics of other materials could be evaluated.This comparison was crucial to ensure precise and uniform measurements across all samples.By employing a reference sample, we could compensate for variations in the measurement configuration, such as fluctuations in the light intensity or sensor sensitivity, ensuring the successful normalization of the collected data.Subsequently, a series of colored paper sheet samples, with each one displaying a distinct color, were subjected to experimentation utilizing the aforementioned setup to acquire the reflectance spectrum for each colored paper sample.

Assembly and Manufacturing
First, each element of the suggested affordable spectrometer was constructed utilizing the 3D-printing technique, specifically employing the Creality Ender 5 printer.Although polylactic acid (PLA) is a suitable material for this purpose, acrylonitrile styrene acrylate (ASA) is advised due to its superior mechanical strength and ability to protect against UV radiation.Subsequently, the assembly of all components was executed following the instructions outlined in Section 2.2, following the assembly of the mechanical components.M3 screws and safety nuts were utilized to ensure secure assembly and prevent misalignment during operation.Additionally, two 30 mm watch glasses can be used to hide the sensors for added protection against dust ingress and facilitate cleaning.The mechanical design has space to accommodate them.The electronic system described in Section 2.3 was implemented in a manner that ensured optimal sensor placement to prevent any errors.An essential aspect was to ensure that each component was properly fixed to prevent any movement, as this could lead to measurement inaccuracies.Therefore, it was crucial to align the size of the mechanical components with the specific shape of each electronic element.Conversely, the software responsible for acquiring, storing, and processing data was installed in the MCU.As stated in Section 2.5, this software incorporates a TinyML model.
Figure 7a shows a picture of the entire view of the proposed spectrometer, and each component was sequentially labeled according to the diagram presented in Figure 2 to facilitate their identification.Figure 7b displays an image depicting the specific region of the device where the samples to be analyzed are positioned.The construction and integration of an affordable spectrometer was accomplished, demonstrating its user-friendly nature and suitability for use in external laboratory settings.

Model Selection and Training Error
As previously stated, the calibration dataset was drawn from the data acquired using the color checker [33], which consisted of 24 patches with known reflectance curves, and the raw data taken from each of the sensors, considering the potential variances that may exist between them.Table 1 presents a summary of the training for the upper sensor.A total of 16 different MLPs were trained, varying the number of layers and the number of neurons in each of the hidden layers.Given the limited amount of data, each neural network was trained five times, and the error was averaged to ensure stability.The metrics used were the mean absolute error (MAE) and total P.The total P refers to the total number of parameters in the model, in this case, the parameters were the weights and biases used to connect the neurons.The number of parameters is important as it affects the size and complexity of the model.A model with many parameters can be more accurate but may also be more challenging to train and might require more training data.In our case, it would also imply more complexity in deploying it on the embedded system.According to the findings presented in Table 1, the model that utilized two hidden layers with 64 neurons in each layer was chosen since the inclusion of a third layer did not result in a substantial enhancement in performance.Conversely, the inclusion of a third hidden layer resulted in an almost double increase in the value of the total P metric compared with the scenario when only two hidden layers were employed.Therefore, the model would become more complex and robust, thereby increasing the difficulty of its integration into the embedded system.Furthermore, it is evident that the inclusion of a fourth hidden layer negatively impacted the outcomes, which was a phenomenon that might be attributed to limited available data.All the conducted training sessions involved a rigorous execution process spanning 1000 epochs, each with a modest batch size of 3, while ensuring data diversity through the strategic utilization of the "shuffle" option.In the neural network architecture, only the bias was implemented in the initial layer, while the loss function was carefully designated as the mean absolute error (MAE), indicating a robust approach to error measurement.Notably, these intensive training operations were seamlessly orchestrated within the userfriendly Google Colab platform and were consistently completed within a highly efficient time frame, with no instance surpassing the 200 s mark.Both tools used have an opensource license that allows users to utilize, modify, and redistribute the software without any restrictions.
A comparison analysis was conducted to assess the performance of the suggested spectrometer and the implemented ML model.In the initial scenario, the measurements were compared by utilizing the color checker specified in [33] as the reference technique.There, the authors report the reflectance curves of 24 different patches.All these reference patches were then experimentally characterized using the proposed low-cost spectrometer.Figure 8 shows only six of them for clarity (patch 01, patch 04, patch 10, patch 14, patch 15, and patch 19).A comparison of the reference reflectance (MEA), raw reflectance (SEN), and adjusted reflectance (ADJ) is shown in each scenario.The ideal MLP configuration (64 neurons in each of the two hidden layers) was used to obtain the ADJ findings.Based on the obtained results, it is evident that there was a strong correlation between the MEA and SEN measurements, particularly at shorter wavelengths.Additionally, there were slight discrepancies observed at longer wavelengths.However, these disparities were rectified when employing the ideal machine learning model, hence significantly improving the accuracy of the obtained results.In fact, the methodology utilized successfully achieved a strong correlation between the ADJ results and the reference reflectance values across the whole research range (400 to 980 nm).
On the other hand, a quantitative study of the training error was conducted on the 24 instances.The findings are succinctly presented in Table 2.This table displays the training error analysis, where SEN represents the absolute error against the raw measurement and ADJ denotes the error with respect to the adjusted values.To conduct a thorough investigation, the MAE analysis was computed for each patch and each channel.The obtained results corroborate that the error was significantly reduced in all cases, even at a wavelength of 910 nm, which was the channel that first exhibited the highest level of inaccuracy.Finally, the overall MAE was calculated.The implemented MLP successfully reduced the obtained overall MAE from 0.2979 to 0.0398.In other words, the proposed model reduced the training error by a factor of at least three.

Validation Error
A second test was carried out to validate the proposed device.For this particular instance, a total of nine colored paper sheets, each of a distinct color, were examined.The reference method employed was the setup outlined in Section 2.6, wherein measurements were conducted with the Yokogawa AQ6373 optical spectrum analyzer, which is a sophisticated instrument known for its high resolution.
Figure 9 demonstrates the outcomes achieved by utilizing only six out of the nine colored paper sheets, specifically the red, yellow, light-blue, light-green, violet, and darkgreen sheets.As in the previous case study, MEA refers to the reference reflectance obtained with the OSA.The raw reflectance is denoted as SEN, and ADJ represents the adjusted reflectance obtained using the best MLP setup.
As in the prior case, the spectrometer provided the correct results, especially at shorter wavelengths.Furthermore, the proposed correction model greatly improved the findings by lowering the difference between the reference reflectance and the obtained reflectance.The results show that the MLP-based model was well-suited for these circumstances, as it allowed for adjustments even when dealing with highly nonlinear reflectance behavior, which is fundamentally complex.For example, while evaluating the red paper sheet (see Figure 9a), reflectance values of more than 0.8 were found for wavelengths greater than 630 nm.Similarly, when inspecting the violet paper sheet, there was a fall in reflectance between 445 nm and 630 nm (see Figure 9c), indicating substantial absorption within this range, which is consistent with prior studies.Table 3 shows the detailed error for each band and each color analyzed with the OSA.Once again, SEN refers to the raw sensor data, and ADJ refers to the data adjusted with the selected MLP.It can be observed that the MAE in this case decreased from 0.1137 to 0.03901 and that the error after adjustment remained close to that of validation, indicating that there was no significant overfitting during the training.Again, it can be observed that the error before adjustment (SEN) was higher in the 910 nm band, but afterward, the error significantly decreased, and the highest error in the adjusted values (ADJ) was observed in the 415 nm band.It can also be seen that the highest error of the adjusted data was found in C07, corresponding to light blue, with an MAE value of 0.0829.Finally, the proposed spectrometer was employed to analyze and evaluate the optical properties of a plant leaf.Through this practical application, we were able to verify the efficiency of the system in real-life situations, showcasing its value in the spectral analysis of plants, encompassing both reflectance and transmittance.Figure 10a displays the measured transmittance (TRA) and reflectance (REF) of the sun-exposed side of a leaf, while Figure 10b illustrates the same parameters for the shaded side of the leaf, as obtained using the suggested affordable spectrometer.As expected, the reflectance of the sunexposed side was reduced compared with the shaded side of the leaf.This reduction was attributable to the leaf's optimization for absorbing sunlight efficiently, thereby enhancing its photosynthetic activity.In addition, the drop in the reflectance spectrum curve at 555 nm of a leaf could be attributed to the absorption characteristics of chlorophyll.Chlorophyll, which is the pigment responsible for photosynthesis in plants, absorbs light most efficiently in the blue (427-476 nm) and red (618-780 nm) regions of the electromagnetic spectrum, with minimal absorption in the green region.This phenomenon is known as the "green gap" or "chlorophyll absorption dip".On the other hand, a considerable increase in reflectance in the infrared band was also expected since plant leaves absorb infrared radiation less efficiently.Infrared radiation is related to heat, and an increase in the reflectance in this region aids in preventing the leaf from overheating.

Conclusions
First, a cost-effective and user-friendly optical spectrometer was designed, fabricated, and experimentally validated.This spectrometer employs a training technique based on a comparison with a color checker, which greatly enhances its accuracy and applicability.
The training results demonstrated that the machine learning model utilizing a MLP model effectively decreased the training error, even when working with a limited amount of data.Furthermore, the efficacy of the suggested spectrometer in precisely assessing the spectrum of materials exhibiting different colors in the visible and NIR regions was verified by a comparative technique utilizing a high-resolution optical spectrum analyzer.The validation findings indicate that the proposed spectrometer accurately characterized the spectrum properties, and the MAE could be minimized using ML models.
In addition, the integration of a tiny machine learning model within the MCU allowed for real-time data processing and reduced power consumption, enhancing the efficiency and usability of the device.This innovation opens up possibilities for further developments in the field of portable spectroscopy.On the other hand, the proposed device's capabilities enabled its use in leaf characterization, showcasing its proficiency in analyzing the spectral attributes of leaves in both reflection and transmission.This is particularly advantageous, as certain plants have distinct characteristics or colors on each side of their leaves.
Finally, our research demonstrated the feasibility of creating an optical spectrometer that is not only cost-effective and precise but also user-friendly, with the flexibility to be tailored for diverse applications.The novel training and machine learning techniques we introduced, coupled with the incorporation of real-time learning models, present exciting opportunities for further exploration and advancement in this field.This innovation represents a valuable asset that can be seamlessly integrated into agricultural practices, particularly for the ongoing monitoring of plant health.Funding: This study was suported by the research project "Diseño, desarrollo y validación de un modelo de detección temprana de Tizón Tardío en cultivos de papa Diacol Capiro mediante análisis de imágenes espectrales adquiridas en los departamentos de Boyacá y Cundinamarca", with the code RC1013-2021 and belonging to the "890-2020 Convocatoria para el fortalecimiento de CTeI en instituciones de educación superior públicas-MINCIENCIAS".
Informed Consent Statement: Not applicable.

Data Availability Statement:
The data presented in this study are available upon request from the corresponding author.

Figure 1 .
Relative sensitivity and luminous in AS7341 integrated board.(a) Relative sensitivity of the AS7341.(b) Relative luminous intensity profile of the EAHC2835WD6 LED.

Figure 2 .
Figure 2. Assembly and list of mechanical parts.

Figure 4 .
Figure 4. Color checker and reflectivity curves[33].In the figure, the distribution of the rows and columns corresponds to the original Color checker, and within each patch the reflectance curve is shown as a reference.

Figure 5 .
Figure 5. Architecture of the proposed MLP.

Figure 6 .
Figure 6.Experimental setup used to measure the reflectance with different colors using an OSA.

Figure 7 .
Figure 7. Photograph of the constructed spectrometer.(a) View of the entire device.(b) Detailed view of the area where the samples were located.The numbers in the figure correspond to the identification in the Figure 2.

Figure 9 .
Figure 9.Validation with a reference method based on the use of a Yokogawa AQ6373 optical spectrum analyzer.MEA is the OSA reference reflectance.SEN is the raw reflectance, while ADJ is the best MLP setup-adjusted reflectance.

Figure 10 .
Figure 10.Measurements of transmittance and reflectance on a vegetable leaf.

Table 1 .
Training error analysis of the ML model used.The MAE and total P metrics were analyzed as functions of the hidden layers and the number of neurons per layer.The best results have been highlighted in the table to facilitate their identification.

Table 2 .
[33]arative training error while employing the proposed spectrometer for characterizing the patches reported in[33].
Figure 8.Comparison of the fits of multiple patches.MEA is the color checker reference reflectance.SEN is the raw reflectance, while ADJ is the best MLP setup-adjusted reflectance.

Table 3 .
Comparative validation error while employing the proposed spectrometer for characterizing colored paper sheets.The reference method employed in this instance was the Yokogawa AQ6373 optical spectrum analyzer.