Development and Testing of an IoT Spectroscopic Nutrient Monitoring System for Use in Micro Indoor Smart Hydroponics

: Nutrient monitoring in Micro Indoor Smart Hydroponics (MISH) relies on measuring electrical conductivity or total dissolved solids to determine the amount of nutrients in a hydroponic solution. Neither method can distinguish concentrations of individual nutrients. This study presents the development and testing of a novel spectroscopic sensor system to monitor nitrogen changes in nutrient solutions for MISH systems. The design phase determined that using an inexpensive AS7265x Internet of Thing (IoT) sensor in a transﬂective spectroscopic application could effectively detect small ﬂuctuations in nitrogen concentraation. Next, a novel transﬂective sensor apparatus was designed and constructed for use in a MISH system experiment, growing lettuce over 30 days. Two solution tanks of different sizes, 80 L and 40 L, were used in the deployment of the system. Samples from each tank were analyzed for nitrogen concentration in a laboratory, and multilinear regression was used to predict the nitrogen concentrations using the AS7265x 18 spectral channels recorded in the sensor system. Signiﬁcant results were found for both tanks with an R 2 of 0.904 and 0.911 for the 80 and 40 L tanks, respectively. However, while the use of all wavelengths produced an accurate model, none of the individual wavelengths were indicative on their own. These ﬁndings indicate that the novel system presented in this study successfully and accurately monitors changes in nitrogen concentrations for MISH systems, using low cost IoT sensors.


Introduction
The adoption of hydroponics in urban applications has been proposed to assist in alleviating pressure on global food security, enabling urban residents to grow food at home [1][2][3][4].The COVID-19 pandemic and extreme weather caused by climate change have exposed the vulnerability of the global food supply chain, emphasizing the need for alternative solutions, such as hydroponics [5][6][7][8][9][10].The system complexity and expertise required for the adoption of hydroponics are a barrier to its wider adoption and use in an appliancelike manner [1][2][3][4].To simplify the management of the system complexities, micro indoor smart hydroponics (MISH) systems use Internet of Things (IoT) technologies [4,11,12].IoT technologies enable sensors and actuators to connect to a networked computing system, allowing software systems to monitor and assist with hydroponic management.
One of the most complex aspects of hydroponics is managing the nutrient content in the hydroponic solution.Thirteen common elements are needed in hydroponic solutions; the macronutrients nitrogen, potassium, phosphate, calcium, magnesium, and sulfur are added in larger amounts than the other elements, with nitrogen being applied in the greatest quantity.Balancing and managing the quantity of the nutrients in the solution is a difficult task requiring expertise.The complexity and need for expertise have slowed the adoption of hydroponics [13].
In addition to the difficulty of managing the nutrients, there is also the wastewater that hydroponics generate [14].Because there is no simple inexpensive method for home gardeners to determine the individual nutrients in the solution, after or during the growing process, the water is often discarded and a new solution is mixed.This has the potential to negatively impact the environment, wasting resources and causing problems for water treatment [15] and possibly creating a major hurdle for the wider adoption of MISH systems, especially in urban settings where disposal options are limited [16].Accurate nutrient solution management is important for resource conservation and efficient use [14].Currently MISH systems are managed using electrical conductivity (EC) meters [17,18].EC meters use the potentiometric effect of an electrical current between electrical probes to measure the amount of mineral salt in the water.These meters are inexpensive and a have been shown to be useful for monitoring the overall amount of fertilizer in the water [19,20].However, EC meters cannot determine the amount of individual minerals, only the total combined amount.
Ion-selective electrodes (ISEs) have emerged recently as a solution preferred to the opaque EC meter [14,15,17,[20][21][22][23].ISEs work like EC meters but use an ion-selective membrane to only measure individual nutrients.Although ISEs are accurate, they are not feasible for use in MISH systems.Each nutrient needs a separate ISE probe [13,23,24], making the approach cost-prohibitive in the context of home hydroponics.Additionally, at the time of writing, consumer-grade ISE probes or commodity-grade IoT ISE sensors are not widely available.ISE sensors have durability issues, the probes are delicate, and the membrane has a limited lifespan while submerged in water [13,23].They are also prone to electrical, chemical, and biological interference in water, causing issues with accuracy and calibration; this limits their application in certain environments [25].
Spectroscopy techniques, a form of optical sensors, are currently the most promising alternative to ISEs in MISH systems for several reasons.Firstly, optical sensors are less prone to chemical, electrical, and biofouling interference [26][27][28][29].Secondly, only one sensor is needed to measure multiple nutrients [27,30].Thirdly, ISE sensors are more delicate and have a limited lifespan compared to optical sensors [31].Finally, the developments in commodity IoT optical sensors are advancing the application of optical sensor systems for simple, practical, and easy-to-deploy spectroscopy [27].
The purpose of this study was to demonstrate a proof of concept of an inline optical nutrient monitoring system that can be applied in a MISH system for home use.The proposed system, hereby referred to as NutriSpec, was built with a commodity IoT spectroscopic sensor and hardware.The NutriSpec system uses IoT hardware and software architectures that are well-established for MISH systems [4,12,32,33].The system was demonstrated in a real-world setting via a 28-day lettuce-growing experiment.The lettuce acted as a nutrient sink, creating dynamics in the nutrient solution that were monitored by the NutriSpec system.This paper first presents the literature that was used to identify the gap in the research and served as the basis for the system design.Next, in the Materials and Methods section, the system design, materials selection, and experimental methodology are presented.Finally, the results of the experiment, the system performance, and a discussion of their implications are presented.

Literature Review
Hydroponics has a well-established history of using spectroscopic techniques to quantify the individual nutrients of a solution [28,34,35].This is traditionally conducted offline in a laboratory using lab-grade equipment.Samples are individually prepared and processed, with considerable delay between the sampling and the result.While the results are accurate and useful, the lab approach makes it difficult to monitor the solution in real time.Four survey papers that covered 544 studies on automated aquaponics [17], smart hydroponics [36], smart farming with IoT [18], and IoT smart irrigation systems [37] found no inline spectroscopic application of nutrient monitoring for hydroponics.The studies shown in Table 1 and discussed below cover the body of literature on the applied spectral measurement of hydroponic nutrient solutions.D. Jung et al. [25] combined the use of an array of cobalt ion sensors and penetrative spectroscopy equipment to estimate phosphate quantities in hydroponic solutions.By adding spectroscopy to their model, they were able to achieve a 20% improvement in accuracy.However, the spectroscopy was not applied inline [25].Critical work for the advancement of spectroscopy in hydroponics by Bamsey et al. [38,39] presented two transflectance spectroscopy optodes for measuring calcium and potassium.Optodes use a transflective spectroscopic technique, a form of reflective spectroscopy that relies on a mirror to reflect light; this was combined with an ion-filtering membrane on the mirror, to measure specific nutrients in a solution.The probe design allowed them to be submerged in a solution and take readings.Like ISEs, the mirror was coated with an ion-selective membrane and also suffered from a short lifespan [38,39].Additionally, Bamsey et al. [38,39] only tested the optode sensors in a lab setting.
Recent studies in spectrophotometry have demonstrated the progress toward developing a simple homemade spectrophotometer [40][41][42][43][44].These sensor systems use a 3D printed or cardboard housing with a place to put a sample and pass light through a cuvette to measure the spectral readings.Han et al. [44] provided an example of the application of these sensor systems in hydroponics.Their study developed a homemade spectrophotometer to measure phosphorus in a hydroponic solution.While Han et al.'s [44] approach produced accurate phosphorous concentration predictions, the application technique made it difficult to translate to inline nutrient monitoring.Monteiro-Silva, Jorge, and Martins [31] presented an inline spectroscopic system sensor design for measuring nitrogen, phosphorus, and potassium (NPK) in nutrient solutions.A rectangular flow chamber was placed between a lab-grade deuterium light source and an ultraviolet-visible (UV-Vis) wavelength spectrometer; hydroponic solution circulated through the chamber, and spectral transmission readings were taken [31].Their sensor system was able to accurately predict NPK concentrations in a lab setting with samples taken from local commercial hydroponic farms, with an error rate of <3%. A. F. Silva et al. [31] extended this work by testing the same sensor application using a different spectrometer and light source and were able to obtain accurate predictions of nitrogen content with an error rate of <6% and potassium content with an error rate of <3%.These results show the real potential of measuring nutrient solutions using optical approaches in place of EC for MISH systems.
MISH systems aim to increase the of spread urban agriculture [4].This area of research can be accelerated with citizen science contributions to the advancement of MISH.Lowcost technology and robust practical design are crucial for facilitating citizen science [45].Five of the proposed systems in Table 1 utilize expensive spectrometers, costing hundreds or thousands of USD [25,30,31,39,40].The only system with inexpensive commodity electronics uses a fragile paper housing in a plywood box and requires impractical sample preparation for analysis [38].Additionally, all the studies in Table 1 examine the sensor systems in a lab setting.None of the systems examined were built with low-cost IoT sensors and applied in situ for inline monitoring in a real-world setting.There is a clear need for a sensor system that uses inexpensive commodity IoT optical sensors in a housing that can be applied inline and tested in a real-world application.This study presents a proof of concept and feasibility study of a low-cost, novel submergible spectroscopic sensor system for monitoring hydroponic nutrients in a real-world application for MISH systems.

Materials and Methods
Three subsections are presented below: first, the NutriSpec sensor housing design and the spectrophotometry technique determination; next, the NutriSpec system hardware and software architecture configurations; and finally, the experimental methodology used to test the NutriSpec system.

NutriSpec Sensor System Design
The sensor selected was the SparkFun Triad Spectroscopy Sensor-AS7265x costing USD 70.The sensor uses three AMS pre-calibrated photodiodes that cover 18 spectral channels, 30 nm wide, ranging from 410 nm to 940 nm.The sensor has three onboard LED lights next to the photodiodes, an ultraviolet light (UV), a 3300 k white LED for the visible spectrum (VIS), and an infrared (IR) light.These lights are used in reflective spectrophotometry applications.The light photons reflect off the test material upon flashing, and the photodiode measures their intensity.The suitability of the sensor for the NutriSpec system was determined based on similar applications.A smart buoy prototype successfully used a submerged AS7265x to measure the quality of seawater [46].Another study used the AS7265x in a 3D printed spectrophotometer with accurate results for measuring soft drink concentrations [47].Finally, two studies used the AS7265x to measure the quantity of photosynthetic active radiation (PAR) [4,48].Both studies demonstrated the sensor's high accuracy, surpassing that of a lab-grade Li-Cor 190R quantum sensor [48] and thus supporting the selection of the sensor for accuracy and applicability.
Prior to the sensor housing design, the sensor was evaluated for consistency.Consistency rather than accuracy was used to evaluate the quality of the sensor to align with the citizen science approach.A typical home user would generally need access to a lab or commercial-grade equipment to calibrate for accuracy.The sensor's ability to produce consistent results enables the establishment of a baseline from which changes can be observed.To test for consistency, the sensor was placed in a dark chamber face up with an empty glass beaker placed atop.The onboard LED lights flashed every 10 s for five minutes.Next, a glass beaker filled with 500 mL tap water was placed atop the sensor, and the process was repeated.Finally, a glass beaker filled with 500 mL distilled water was set atop the sensor, repeating the same process.The results are shown for stable consistent readings.
Table 2 presents the data from the consistency tests.The spectral channels are labeled by color: blue, which includes the UV channels; green; red; and IR.The results demonstrated the sensor's ability to produce consistent readings across all channels and all treatments.The standard deviation (SD) for all treatments was less than 1.5 raw spectral intensity units.Additionally, the largest difference in the max and min was just under five units.These results demonstrated the AS7265x's consistent stability and strongly supported the choice of the sensor for the NutriSpec system.After sensor selection the waterproof housing was designed.First, the AS7265x with no box was connected to an Arduino Uno and placed facing up at the bottom of a black lightproof chamber.The onboard LED lights flashed every 10 s, and readings were taken.The sensor readings were collected for six minutes.Next, the AS7265x was placed in each of the boxes, and the process was repeated.The results were analyzed using MANOVA (Pillai's trace = 2.402, F (12, 714) = 238.979,p = 0.000), showing that there was a difference between no box and all thicknesses of boxes for all spectral channels.The thickness was chosen based on the mean closest to the sensor reading with no box.As shown in Table 3 and Figure 1, the 2 mm acrylic was the closest to the sensor with no box.Based on this analysis, the 2 mm acrylic was used to waterproof the AS7265x for the experiment.Next, the sensor was sealed in the 2 mm acrylic box and waterproofed with epoxy resin, as shown in Figure 2. A series of tests were conducted to determine if the sensor could detect any changes in the water contents using reflective spectrophotometry, as per Bruzzese et al. [46].The sensor was fixed to the bottom of a 1200 mL beaker facing up in a lightproof chamber, as shown in Figure 3.One liter of distilled water was added to the beaker, and readings were taken every 10 s for six minutes.Next, 1 mL of a locally produced consumer-grade hydroponic nutrient A solution was added every six minutes, up to 3 ml, and EC readings were taken.An analysis was performed on the four series of readings using MANOVA (Pillai's trace = 2.823, F(13, 132) = 32.82,p < 0.001), showing that there were significant differences in the concentration changes.However, 5 of the 18 spectral variables (940 nm, 860 nm, 810 nm, 705 nm, and 760 nm) showed no significant changes between the concentrations.
AS7265x was placed in each of the boxes, and the process was repeated.The results were analyzed using MANOVA (Pillai's trace = 2.402, F (12, 714) = 238.979,p = 0.000), showing that there was a difference between no box and all thicknesses of boxes for all spectral channels.The thickness was chosen based on the mean closest to the sensor reading with no box.As shown in Table 3 and Figure 1, the 2 mm acrylic was the closest to the sensor with no box.Based on this analysis, the 2 mm acrylic was used to waterproof the AS7265x for the experiment.Next, the sensor was sealed in the 2 mm acrylic box and waterproofed with epoxy resin, as shown in Figure 2. A series of tests were conducted to determine if the sensor could detect any changes in the water contents using reflective spectrophotometry, as per Bruzzese et al. [46].The sensor was fixed to the bottom of a 1200 mL beaker facing up in a lightproof chamber, as shown in Figure 3.One liter of distilled water was added to the beaker, and readings were taken every 10 s for six minutes.Next, 1 mL of a locally produced consumer-grade hydroponic nutrient A solution was added every six minutes, up to 3 ml, and EC readings were taken.An analysis was performed on the four series of readings using MANOVA (Pillai's trace = 2.823, F(13, 132) = 32.82,p < 0.001), showing that there were significant differences in the concentration changes.However, 5 of the 18 spectral variables (940 nm, 860 nm, 810 nm, 705 nm, and 760 nm) showed no significant changes between the concentrations.Next, the sensor was sealed in the 2 mm acrylic box and waterproofed with epoxy resin, as shown in Figure 2. A series of tests were conducted to determine if the sensor could detect any changes in the water contents using reflective spectrophotometry, as per Bruzzese et al. [46].The sensor was fixed to the bottom of a 1200 mL beaker facing up in a lightproof chamber, as shown in Figure 3.One liter of distilled water was added to the beaker, and readings were taken every 10 s for six minutes.Next, 1 mL of a locally produced consumer-grade hydroponic nutrient A solution was added every six minutes, up to 3 ml, and EC readings were taken.An analysis was performed on the four series of readings using MANOVA (Pillai's trace = 2.823, F(13, 132) = 32.82,p < 0.001), showing that there were significant differences in the concentration changes.However, 5 of the 18 spectral variables (940 nm, 860 nm, 810 nm, 705 nm, and 760 nm) showed no significant changes between the concentrations.A multiple linear regression (MLR) model was used to examine the sensor's ability to predict the concentration of nutrients based on the EC.A significant model was created (F(13, 134) = 521.92),p < 0.001) with an R 2 of 0.981.While this model was promising, five channels in the red and IR range were not responsive; thus, transflection was also examined.Transflection can be considered when low concentrations cause only slight light attenuation [47,48].
A mirror was placed 5 mm [47] opposite the sensor, as shown in Figure 3.A low-cost aluminum-backed mirror was used, as it performed sufficiently across all the wavelengths being examined (410 nm to 940 nm) [49].The light was reflected off the mirror into the photodiode.This method has been proven to work well for agricultural applications, specifically for measuring fertilizer content in water [47,48].The same methods and data collection techniques were used, and the same tests were performed for the reflective application.MANOVA (Pillai's trace = 2.827, F(54, 396) = 119.85,p < 0.001) found that all 18 spectral channels had an observable significant difference in the concentrations of the solutions, producing a significant MLR model (F(18, 1009) = 858.807,p < 0.001) with an R 2 of 0.992.
Based on this analysis of spectrophotometry using the AS7265x, it was clear that transflection produced a better model than reflection to measure nutrient concentrations in hydroponic solutions.The next step was to apply these findings by deploying the sensor in an IoT sensor system using the submerged AS7265x for inline nutrient monitoring in an MISH system.
The housing was designed and 3D printed for the transflective application of the waterproofed AS7265x.It was printed with an Ender 2 fused deposition modeling (FDM) printer, using eSUN polylactic acid (PLA) filament.This printer and filament type are commonly used in hydroponics and spectroscopy prototyping.For example, Takeuchi [50] created an innovative hydroponic NFT system using a 3D FDM printer with PLA filament.Cecil, Guijt, Henderson, Macka, and Breadmore [51] created a flow chamber for liquid spectroscopy using the same.The housing shown in Figure 4 was 73 mm × 40 mm × 71 mm.It was designed to minimize interference from outside light while still allowing space for circulation through the sensing zone.The front and back walls featured 1 mm × 8 mm slots, 2 mm apart.A solid lid fit over the top of the housing, as seen in Figure 4.A 12 mm base was created with a slot for the mirror and sensor.The mirror was 5 mm from the sensor; while Feng et al. [48] showed that 1 mm was the optimal distance, they found that 5 mm was also effective.Based on the constraints of the acrylic box being 2 mm thick, 5 mm was used.Perforations of 1 mm, 2 mm apart, ran through the entire base section of the housing.

MISH IoT System Design and Architecture for Field Testing
A full MISH system was constructed to test the capability of the NutriSpec sensor.The IoT system used common commodity hardware components, arranged in a simple architecture, as shown in Figure 5.The AS7265x was connected to the inter-integrated circuit (I2C) bus of the Arduino Uno, then by USB to the Raspberry Pi 4 B (RPi 4B).The

MISH IoT System Design and Architecture for Field Testing
A full MISH system was constructed to test the capability of the NutriSpec sensor.The IoT system used common commodity hardware components, arranged in a simple architecture, as shown in Figure 5.The AS7265x was connected to the inter-integrated circuit (I2C) bus of the Arduino Uno, then by USB to the Raspberry Pi 4 B (RPi 4B).The RPi 4B acted as a gateway for the sensors and was connected via general-purpose input-output (GPIO) pins to solid-state relays to actuate the grow lights and water pump.A DFRobot analog EC sensor DFR0300, DFRobot pH analog sensor V2 SEN0161-V2, analog water-level sensor, and DS1820 digital temperature sensor were added for additional water monitoring.All of these were connected to an Arduino Uno and to the RPi 4B, as shown in Figure 5.The RPi 4B, running Raspbian 10 Buster, in addition to acting as a gateway for the IoT sensors, provided the processing, storage, and user interface services for the system.As shown in Figure 5, all the sensor data were received and processed by Node-RED 1.3.4.The data from the sensors were combined in Node-RED to form a single JavaScript objection notation (JSON) string and stored in Influx DB 1.8.5, a time-series database.Grafana 8.1.5,a user interface dashboard, was connected to Influx DB to visualize the data for easy monitoring.In addition, Node-RED was also used to schedule the timing for the lights and the water pumps.

Experiemental Materials and Methods
This section presents the experiment used to determine if the NutriSpec system could measure changes in hydroponic nutrients in a real-world application.The experiment focused on observing changes in nitrogen concentrations during a standard 28-day growing period of lettuce in a MISH system.Nitrogen was selected because it is the most important mineral for plant growth and is easily measured in the lab using spectrophotometry.However, a smaller-scale analysis was conducted to explore whether potassium and phosphorus were also impacted.As the focus of this study was nitrogen, potassium and phosphorus were not analyzed in depth.Lettuce was selected for the experiment to act as a nutrient sink for the hydroponic solution.Lettuce is a well-established tool for research in The RPi 4B, running Raspbian 10 Buster, in addition to acting as a gateway for the IoT sensors, provided the processing, storage, and user interface services for the system.As shown in Figure 5, all the sensor data were received and processed by Node-RED 1.3.4.The data from the sensors were combined in Node-RED to form a single JavaScript objection notation (JSON) string and stored in Influx DB 1.8.5, a time-series database.Grafana 8.1.5,a user interface dashboard, was connected to Influx DB to visualize the data for easy monitoring.In addition, Node-RED was also used to schedule the timing for the lights and the water pumps.

Experiemental Materials and Methods
This section presents the experiment used to determine if the NutriSpec system could measure changes in hydroponic nutrients in a real-world application.The experiment focused on observing changes in nitrogen concentrations during a standard 28-day growing period of lettuce in a MISH system.Nitrogen was selected because it is the most important mineral for plant growth and is easily measured in the lab using spectrophotometry.How-ever, a smaller-scale analysis was conducted to explore whether potassium and phosphorus were also impacted.As the focus of this study was nitrogen, potassium and phosphorus were not analyzed in depth.Lettuce was selected for the experiment to act as a nutrient sink for the hydroponic solution.Lettuce is a well-established tool for research in hydroponic systems, due to its ability to produce a large mass in a short amount of time; other green crops would also work, but lettuce was optimal for this study [4,12,[52][53][54][55].The changes in the solution were monitored, as well as the weight of the plants.Two sets of plants were grown simultaneously using different volume sizes of nutrient tanks.An 80 L tank and a 40 L tank were used, as shown in Figure 6, to observe and verify changes at different scales and protect internal validity.The sensor housing design, construction, and data collection were carried out in a real-world setting for microscale home hydroponics.The experiment was carried out in a residential apartment in Dubai, UAE, during the month of May 2022.The hydroponic system used a flood and drain design [4].Two flood trays containing two 70 cm × 19 cm grow beds Figure 6 were filled with perlite and a thin top layer of coco coir.The media were sterilized with boiling distilled water.Ten-day-old lettuce seedlings (Lollo bionda) and hydroponic nutrient solutions A and B were sourced from Greenoponics Agricultural Services, Dubai UAE.Two 300 mm × 240 mm full-spectrum LED grow lights were hung over each tray and adjusted to average 330 µmol/s/m 2 and operated for 12 h a day to provide a total of 14 DLI [56,57].At day 14, beds A and B were swapped in both flood trays.
Two nutrient tanks were used for the experiment, an 80 L tank and a 40 L tank.To block ambient light, black-colored tanks were used with tight-fitting lids.Each tank used a 25 watt Dynamax water pump that flooded the trays every 12 h for 20 min.The AS7265x sensor housing was mounted to the bottom of each tank in the front left corner, 20 cm from the front and left wall, as shown in Figure 6.A temperature sensor, pH sensor, EC meter, and water-level sensor were deployed in each tank and connected to the NutriSpec sensor system.The tanks, pumps, pipes, and fittings were rinsed with distilled water prior to commencing the experiment.After setting up, the tanks were filled with distilled water, and the system ran for 24 h prior to adding the nutrients.The nutrient solutions were locally produced, with a breakdown of their contents shown in Table 4.The sensor housing design, construction, and data collection were carried out in a real-world setting for microscale home hydroponics.The experiment was carried out in a residential apartment in Dubai, UAE, during the month of May 2022.The hydroponic system used a flood and drain design [4].Two flood trays containing two 70 cm × 19 cm grow beds Figure 6 were filled with perlite and a thin top layer of coco coir.The media were sterilized with boiling distilled water.Ten-day-old lettuce seedlings (Lollo bionda) and hydroponic nutrient solutions A and B were sourced from Greenoponics Agricultural Services, Dubai UAE.Two 300 mm × 240 mm full-spectrum LED grow lights were hung over each tray and adjusted to average 330 µmol/s/m 2 and operated for 12 h a day to provide a total of 14 DLI [56,57].At day 14, beds A and B were swapped in both flood trays.
Two nutrient tanks were used for the experiment, an 80 L tank and a 40 L tank.To block ambient light, black-colored tanks were used with tight-fitting lids.Each tank used a 25 watt Dynamax water pump that flooded the trays every 12 h for 20 min.The AS7265x sensor housing was mounted to the bottom of each tank in the front left corner, 20 cm from the front and left wall, as shown in Figure 6.A temperature sensor, pH sensor, EC meter, and water-level sensor were deployed in each tank and connected to the NutriSpec sensor system.The tanks, pumps, pipes, and fittings were rinsed with distilled water prior to commencing the experiment.After setting up, the tanks were filled with distilled water, and the system ran for 24 h prior to adding the nutrients.The nutrient solutions were locally produced, with a breakdown of their contents shown in Table 4. Solutions A and B were added to each of the tanks according to the prescribed proportion on the bottles (125 to 100 mL).To keep the solution in the optimum nitrogen absorption band without effecting the other nutrient absorption rates, the pH was adjusted and maintained throughout the experiment between pH 5.5 and pH 6.4.After the initial adjustment of the pH, the EC of Tank S was 1322, and that of Tank L was 1366.The water level was monitored daily, and when the level reached 5 L below the desired level, distilled water was added.This process was performed for both tanks to maintain the level at 40 L and 80 L, respectively.The system was then allowed to run for another 24 h prior to transplanting the seedlings.The seedlings were transplanted then given 12 h rest from the light before commencing the lighting cycle.
Sensor readings were recorded every 10 s and averaged hourly, excluding the two hours when the trays were flooded daily.We took 50 mL samples from each tank after the completion of both flooding cycles at the end of the day for nitrogen analysis.Additionally, six 50 mL samples were taken from each tank at the beginning and end of each week and at the end of the experiment to conduct an analysis of potassium and phosphorus.The EC and pH of these samples were also recorded.Samples were analyzed at the Middle East Testing Services, Ajman, UAE, using a UV-Vis spectrophotometer.At the end of day 28, the lettuce was harvested, weighed, and then dried in an oven at 80 • C for 72 h.

Results
This section presents the results of the field experiment designed to determine if the NutriSpec sensor system could detect changes in the nitrogen levels in hydroponic nutrient solutions in a real-life MISH system application.Nitrogen was selected because it is the most important mineral for plant growth and is easily measured in a lab using spectrophotometry.The nutrient solution, shown in Table 4, contained calcium nitrate Ca(NO3)2; therefore, the nitrate nitrogen changes were monitored as the primary nitrogen changes for the experiment.This section first covers the analysis of the nutrient solution tanks and plant growth to demonstrate the validity of the context for testing the NutriSpec sensor system.Next, an analysis was performed of the NutriSpec sensor system's ability to detect the changes demonstrated by the nitrogen and plant analysis.
Two NutriSpec sensor systems were constructed and deployed, one in each tank, as shown in Table 5.Once the tanks were set up and the nutrients added, issues emerged regarding the EC and pH sensor readings.The pH readings showed a negative number, and the EC readings were lower than expected.Upon investigation, the sensors were suffering interference from the analogue water-level meter.The water-level meter was a potentiometer, which conducted a small charge of electricity through the water and then estimated the water levels based on the resistance readings.This caused interference with the EC and pH sensors.Even after removing the water-level sensor, the EC and pH sensors no longer held a calibration.For the duration of the experiment, EC and pH readings were taken by hand at the end of the pump cycle.In addition, water-level marks were used to manually identify when five liters of water should be added.The water temperatures (t(58) = 0.347, p = 0.558) and pH levels (t(58) = 2.45, p = 0.123) in both tanks were stable and showed no significant difference, as demonstrated in Table 5.The thermostat of the room in the flat was set to 25 • C for the duration of the experiment.The collected samples were analyzed in the lab with a spectrophotometer for nitrate nitrogen levels.Figure 7 shows the daily levels recorded in mg/L over 28 days.A two-sample t-test was used to compare the mean nitrogen levels between the tanks.Tank L (M = 91.5,SD = 14.15) and Tank S (M = 92.72,SD = 16.25)showed no significant difference in mg/L (t(53) = 2.00, p = 0.85).Additionally, a Pearson's correlation was used to assess the nitrogen depletion rates between Tank S and Tank L (r(53) = 0.82, p < 0.0001).Strong similarities were established between the tanks regarding nitrogen levels over time, showing that a stable, consistent, and measurable dynamic was created in the nutrient solution, with which to compare the AS7265x spectral readings.similarities were established between the tanks regarding nitrogen levels over time, showing that a stable, consistent, and measurable dynamic was created in the nutrient solution, with which to compare the AS7265x spectral readings.To further demonstrate the integrity of the test environment, the weight of the plant growth, shown in Figure 8, was analyzed.Table 6 shows the total fresh and dry weight of the plant growth for both tanks over the four weeks.The total harvested fresh mass from Tank S was 383.1 g, and that from Tank L was 683.5 g.The mean fresh weight of Tank S (M = 29.46,SD = 9.27) and Tank L (M = 52.57.SD = 9.22) showed a significant difference (t(24) = −6.36,p < 0.001).After the plants were dried for 72 h in an oven, they were weighed again.The total dry weight of Tank L (29.8 g) was almost double that of Tank S (15.2 g).The disparity remained, with Tank S (M = 1.17,SD = 0.00) and Tank L (M = 2.30, SD = 0.00) showing a significant difference in dry weight (t(24) = 1.27 × 10 18 , p < 0.001).Both the fresh weight and dry weight differences were in line with the expectations for stable growth and proportionate results.Tank L, which contained twice the amount of freely available nitrogen for the plants, was close to double the size of Tank S. After establishing that the environment performed as expected, the spectral results for both tanks were analyzed to evaluate the sensor system.Table 6.Total fresh and dry weight from the 28-day experiment.

Tray
Bed Fresh Weight Dry Weight To further demonstrate the integrity of the test environment, the weight of the plant growth, shown in Figure 8, was analyzed.Table 6 shows the total fresh and dry weight of the plant growth for both tanks over the four weeks.The total harvested fresh mass from Tank S was 383.1 g, and that from Tank L was 683.5 g.The mean fresh weight of Tank S (M = 29.46,SD = 9.27) and Tank L (M = 52.57.SD = 9.22) showed a significant difference (t(24) = −6.36,p < 0.001).After the plants were dried for 72 h in an oven, they were weighed again.The total dry weight of Tank L (29.8 g) was almost double that of Tank S (15.2 g).The disparity remained, with Tank S (M = 1.17,SD = 0.00) and Tank L (M = 2.30, SD = 0.00) showing a significant difference in dry weight (t(24) = 1.27 × 10 18 , p < 0.001).Both the fresh weight and dry weight differences were in line with the expectations for stable growth and proportionate results.Tank L, which contained twice the amount of freely available nitrogen for the plants, was close to double the size of Tank S. After establishing that the environment performed as expected, the spectral results for both tanks were analyzed to evaluate the sensor system.To assess the sensor's ability to detect the established nitrogen depletion, the means of each day, for 28 days, were calculated for all 18 wavelength channels, excluding the two hours when the beds were being flooded.These raw spectral readings were analyzed using MLR to assess their ability to predict the nitrogen levels.The analysis was carried out on each tank separately; then, the datasets were combined and analyzed.Additionally, absorption rates were calculated for each channel; this was carried out by applying the Beer-Lambert law, i.e., log10(I0/I).The blank reading in distilled water was used as I0, and the mean intensity was used as I [48].
Tank L absorbance rates were plotted for each wavelength over 30 days, as shown in Figure 9. Tank L produced a significant model (F(15, 14) = 8.76, p < 0.001) with an R 2 of 0.904.Figure 10 shows the model's predicted nitrogen levels plotted against the actual nitrogen levels.A linear regression model using the daily EC readings to predict nitrogen was also created.The model was significant (F(1, 28) = 60.64,p < 0.001), but the fit had an R 2 of 0.673, much lower than that of the NutriSpec sensor system.To assess the sensor's ability to detect the established nitrogen depletion, the means of each day, for 28 days, were calculated for all 18 wavelength channels, excluding the two hours when the beds were being flooded.These raw spectral readings were analyzed using MLR to assess their ability to predict the nitrogen levels.The analysis was carried out on each tank separately; then, the datasets were combined and analyzed.Additionally, absorption rates were calculated for each channel; this was carried out by applying the Beer-Lambert law, i.e., log10(I0/I).The blank reading in distilled water was used as I0, and the mean intensity was used as I [48].
Tank L absorbance rates were plotted for each wavelength over 30 days, as shown in Figure 9. Tank L produced a significant model (F(15, 14) = 8.76, p < 0.001) with an R 2 of 0.904.Figure 10 shows the model's predicted nitrogen levels plotted against the actual nitrogen levels.A linear regression model using the daily EC readings to predict nitrogen was also created.The model was significant (F(1, 28) = 60.64,p < 0.001), but the fit had an R 2 of 0.673, much lower than that of the NutriSpec sensor system.While the model was significant and clearly able to predict nitrogen with a high accuracy, none of the individual coefficients, shown in Table 7, were significant.The Tank L absorbance rates, presented in Figure 10, showed variation and inconsistencies, contributing to a lack of significance.The highest standardized coefficients were 410 nm, 460 nm, 760 nm, and 585 nm, while the coefficients with the greatest influence were 435 nm, 460 Predicted Nitrogen mg/L Actual Nitrogen mg/L  While the model was significant and clearly able to predict nitrogen with a high accuracy, none of the individual coefficients, shown in Table 7, were significant.The Tank L absorbance rates, presented in Figure 10, showed variation and inconsistencies, contributing to a lack of significance.The highest standardized coefficients were 410 nm, 460 nm, Predicted Nitrogen mg/L Actual Nitrogen mg/L While the model was significant and clearly able to predict nitrogen with a high accuracy, none of the individual coefficients, shown in Table 7, were significant.The Tank L absorbance rates, presented in Figure 10, showed variation and inconsistencies, contributing to a lack of significance.The highest standardized coefficients were 410 nm, 460 nm, 760 nm, and 585 nm, while the coefficients with the greatest influence were 435 nm, 460 nm, 705 nm, and 730 nm.For both coefficient rankings, 410 nm and 460 nm were the least significant but still had a p value greater than 0.05.The Tank S absorbance rates were plotted for each wavelength over 30 days, as shown in Figure 11.Tank S also produced a significant model (F(18, 11) = 62.51, p = 0.002) with an R 2 of 0.911.Figure 11 shows the model's predicted nitrogen plotted against the actual levels.This model was also able to predict the nitrogen levels with a high degree of accuracy, much better than that of the EC for Tank S. The EC produced a significant model (F(1, 28) = 68.407p < 0.001) with an R 2 of 0.710.
Like Tank L, Tank S was clearly able to predict the nitrogen levels, producing a significant model (F(18, 11) = 6.251, p =0.002) with an R 2 of 0.911.All wavelengths were included in the model; however, none of the coefficients shown in Table 8 are significant.The Tank S absorbance rates, presented in Figure 11, showed wide variation, with 435 nm having no movement and wide movement observed in the 600 nm range.The highest standardized coefficients were 460 nm, 410 nm, 510 nm, and 680 nm.The coefficients with the greatest effect were 610 nm, 680 nm, and 730 nm.The only coefficient close to being significant from both models was 510 nm from Tank S, with a p value of 0.08.
The Tank S absorbance rates were plotted for each wavelength over 30 days, as shown in Figure 11.Tank S also produced a significant model (F(18, 11) = 62.51, p = 0.002) with an R 2 of 0.911.Figure 11 shows the model's predicted nitrogen plotted against the actual levels.This model was also able to predict the nitrogen levels with a high degree of accuracy, much better than that of the EC for Tank S. The EC produced a significant model (F(1, 28) = 68.407p < 0.001) with an R 2 of 0.710.Finally, the two datasets were combined, again producing a significant model (F(18, 41) = 6.76 p < 0.001) with an R 2 of 0.748.This also outperformed the significant EC model (F(1, 58) = 87, p < 0.001) created from the same data, with an R 2 of 0.6.Tables A1 and A2 show the correlation of potassium and phosphorus levels with the corresponding average raw spectral intensity readings for each day.Due to the limited data collected, there were no statistically significant results.However, an analysis with the limited data showed that there were potential correlations for both phosphorus and potassium, with implications for future research.

Discussion
The goal of this study was to demonstrate the feasibility of using an inline nutrient monitoring system with an optical sensor to measure individual nutrient changes, instead of relying on traditional EC measurements.The purpose of this proof-of-concept design was to show that it is possible to use this type of system to accurately monitor nutrient levels in real time.The results indicated that the NutriSpec sensor system was able to accurately detect changes in nitrogen levels for a hydroponic solution in a real-world MISH system setting.Figures 10 and 12 demonstrate the strong prediction power of the MLR models produced from the systems.When comparing these models to those produced using EC, the spectroscopic sensors performed much better.This shows the potential of future applications of simple submerged optical sensors to replace EC in MISH systems.The conditions of the MISH system used to test the NutriSpec sensor system were rigorously monitored and analyzed to ensure the internal validity of the experiment.The validity was well demonstrated through several findings.Firstly, the temperature and pH of both tanks, presented in Table 5, showed no significance difference throughout the experiment.Secondly, there was an observable decrease in nitrogen, as shown in Figure 7.Even though there are noticeable differences and fluctuations depicted in Figure 7, with pronounced dips in the nitrogen concentration on days 5, 10, 15, 20, and 25, there were strong significant correlations in nitrogen depletion between the tanks and no significant difference in mean nitrogen m/g per liter.Finally, the plant mass results, shown in Table 6, were proportionally consistent.Tank L, an 80 L tank, had both dry and fresh weights around double those of Tank S, a 40 L tank.Considering that Tank L had double the available nitrogen of Tank S, this growth was as expected.Taking all of this into account, the real-world setting of the apartment presented no confounding factors and provided a valid consistent environment to interpret the results of the experiment.
Despite the tanks exhibiting highly similar characteristics, the models produced for each tank were different.Both models had an R 2 of more than 90%.Although both models had a goodness-of-fit higher than 90%, the difference between the models appeared very distinct.However, on closer examination, there were unmistakable similarities that have implications for the future development of simple submerged transflective spectroscopy Predicted Nitrogen mg/L Actual Nitrogen mg/L The conditions of the MISH system used to test the NutriSpec sensor system were rigorously monitored and analyzed to ensure the internal validity of the experiment.The validity was well demonstrated through several findings.Firstly, the temperature and pH of both tanks, presented in Table 5, showed no significance difference throughout the experiment.Secondly, there was an observable decrease in nitrogen, as shown in Figure 7.Even though there are noticeable differences and fluctuations depicted in Figure 7, with pronounced dips in the nitrogen concentration on days 5, 10, 15, 20, and 25, there were strong significant correlations in nitrogen depletion between the tanks and no significant difference in mean nitrogen m/g per liter.Finally, the plant mass results, shown in Table 6, were proportionally consistent.Tank L, an 80 L tank, had both dry and fresh weights around double those of Tank S, a 40 L tank.Considering that Tank L had double the available nitrogen of Tank S, this growth was as expected.Taking all of this into account, the real-world setting of the apartment presented no confounding factors and provided a valid consistent environment to interpret the results of the experiment.
Despite the tanks exhibiting highly similar characteristics, the models produced for each tank were different.Both models had an R 2 of more than 90%.Although both models had a goodness-of-fit higher than 90%, the difference between the models appeared very distinct.However, on closer examination, there were unmistakable similarities that have implications for the future development of simple submerged transflective spectroscopy for MISH.
Tank L, the larger tank, produced a more accurate model than Tank S, with all coefficients having a standard error of less than one.Additionally, the range of absorbance, at different wavelengths, differed greatly from that of Tank S. The absorbance range for Tank L, Figure 9, showed an over-absorbance error, spanning from −4 to 2.5.Tank S had the highest standard error rates, despite having the better goodness-of-fit and absorbance rates in the acceptable range [57].Only six coefficients for Tank S had a standard error of less than one.The cause of these vast differences was unknown; there may have been issues related to a difference in sensitivity between the sensors depending on the manufacturer, or they could have resulted from the tank size or material anomalies.Differences in submerged applications can be addressed in future studies through local calibration prior to application, as demonstrated in Brito et al. [58] and Maribas et al. [59].
Despite these apparent differences, important similarities emerged when comparing the six most accurate wavelengths for each tank, presented in Table 9.The most accurate spectrum for both models, as shown in Table 9, was in the UV-Vis range.For both tanks, the wavelength with the lowest standard error was 410 nm.This finding was as expected and in-line with previous work using UV-Vis to detect nitrogen in hydroponic solutions via spectrophotometry [30].Considering the extensive work carried out to measure nitrogen with the IR and nearinfrared (NIR) spectrum [58][59][60][61], we expected to see the IR range among the most accurate wavelengths.Surprisingly, for both models, the IR wavelengths were not present.The IR wavelengths presented some of the highest standard error rates, as shown in Tables 7 and 8. Additionally, the lab that tested the samples for the study used 500 nm to determine the quantity of calcium nitrate, consistent with the findings shown in Table 9.Based on these similarities, it could be concluded that the sensors performed similarly.This suggested that the technique of simple submerged transflective spectroscopy for MISH systems is effective, particularly in the UV-Vis range.It is possible that other sensors even cheaper than the AS7265x could also be used in this application.
This study faced several limitations.Firstly, as the water in the tanks was depleted by plant consumption and evaporation, distilled water had to be added.However, rather than adding large quantities at intervals, adding smaller quantities every day at the end of the readings would have provided a more stable environment.Additionally, taking readings of the nitrogen before and after adding the distilled water would have allowed a useful analysis for tracking the impact.Secondly, the EC system and pH were incompatible with the water-level sensor.While the voltage of the water-level sensor was small, it was enough to foul both meters.This exacerbated the issues noted earlier with ISEs.The sensors were so sensitive that future designs must take this sensitivity into consideration.Thirdly, the sensors should have been examined to note any differences before application.It is normal for small differences to exist in commodity sensors; however, these need to be documented to establish comparable outputs.Lastly, the acrylic boxed leaked, as shown in Figure 13, just two days after the completion of the experiment, suggesting that an alternative means of waterproofing are required.
This study faced several limitations.Firstly, as the water in the tanks was depleted by plant consumption and evaporation, distilled water had to be added.However, rather than adding large quantities at intervals, adding smaller quantities every day at the end of the readings would have provided a more stable environment.Additionally, taking readings of the nitrogen before and after adding the distilled water would have allowed a useful analysis for tracking the impact.Secondly, the EC system and pH were incompatible with the water-level sensor.While the voltage of the water-level sensor was small, it was enough to foul both meters.This exacerbated the issues noted earlier with ISEs.The sensors were so sensitive that future designs must take this sensitivity into consideration.Thirdly, the sensors should have been examined to note any differences before application.It is normal for small differences to exist in commodity sensors; however, these need to be documented to establish comparable outputs.Lastly, the acrylic boxed leaked, as shown in Figure 13, just two days after the completion of the experiment, suggesting that an alternative means of waterproofing are required.Two notable areas for future studies are finding a common calibration and determining optimal pathlengths.Maribas et al. [58] and Brito et al. [59] established successful calibration models for target solutions, which may solve issues of irregular readings in future research.Next, future studies attempting to determine the optimal mirror distance for this application may eliminate the differences identified between the sensors and provide more accurate readings [47,48,62].

Conclusions
This paper presented NutriSpec, an inexpensive spectroscopic IoT sensor system designed to monitor changes in nitrogen in hydroponic solutions for real-world application.The system was designed, built, and successfully demonstrated in a residential apartment in Dubai, UAE.This study established a novel spectroscopic sensor system for MISH that has the potential to advance the field and open new avenues for citizen science contributions to research in this field, pushing forward the potential for cheap, simple, and accurate nutrient monitoring techniques that improve upon the opaque estimations of traditional EC.
This study showed that an AS7265x in a simple submerged transflective spectroscopic application could be used to accurately measure the changes in nitrogen in hydroponic solutions.The experimental results showed the clear superiority of the NutriSpec sensor system's ability to predict the nitrogen concentration compared to EC.While there were clear inconsistencies between the models produced for the different tank volumes, the results demonstrated the system's potential for future applications.
Future research is needed to establish a calibration methodology for the NutriSpec system.In addition, there is wide scope for analyzing other commonly used sources of nitrogen for hydroponics, as well as phosphate, potassium, and magnesium.With the use of artificial intelligence and machine learning, there is potential to develop spectral signatures for different elements that would allow for a single sensor to monitor different nutrients.

Figure 1 .
Figure 1.Unsealed acrylic boxes used for determining thickness.From left to right: 3 mm, 2.5 mm, and 2 mm.The same sensor was placed in each box and tested.Figure 1. Unsealed acrylic boxes used for determining thickness.From left to right: 3 mm, 2.5 mm, and 2 mm.The same sensor was placed in each box and tested.

Figure 1 .
Figure 1.Unsealed acrylic boxes used for determining thickness.From left to right: 3 mm, 2.5 mm, and 2 mm.The same sensor was placed in each box and tested.Figure 1. Unsealed acrylic boxes used for determining thickness.From left to right: 3 mm, 2.5 mm, and 2 mm.The same sensor was placed in each box and tested.

Figure 2 .
Figure 2. AS7265x waterproofed in 2 mm case, sealed with acrylic adhesive and epoxy resin.

Figure 3 .
Figure 3.The experimental setup for testing the effectiveness of the reflective and transflective spectrophotometric techniques.

Figure 2 .
Figure 2. AS7265x waterproofed in 2 mm case, sealed with acrylic adhesive and epoxy resin.

Figure 2 .
Figure 2. AS7265x waterproofed in 2 mm case, sealed with acrylic adhesive and epoxy resin.

Figure 3 .
Figure 3.The experimental setup for testing the effectiveness of the reflective and transflective spectrophotometric techniques.

Figure 3 .
Figure 3.The experimental setup for testing the effectiveness of the reflective and transflective spectrophotometric techniques.

Figure 4 .
Figure 4. NutriSpec sensor printed housing, cross-section, and 3D diagram.Mirror and sensor were placed in special slots 5 mm apart inside the housing.

Figure 4 .
Figure 4. NutriSpec sensor printed housing, cross-section, and 3D diagram.Mirror and sensor were placed in special slots 5 mm apart inside the housing.

Figure 5 .
Figure 5. Hardware and software architecture of the NutriSpec sensor system.

Figure 5 .
Figure 5. Hardware and software architecture of the NutriSpec sensor system.

Horticulturae 2023, 9 , 22 Figure 6 .
Figure 6.Experimental setup; bed A and B were swapped with each other at day 15.

Figure 6 .
Figure 6.Experimental setup; bed A and B were swapped with each other at day 15.

Figure 7 .
Figure 7. Nitrate nitrogen levels in mg/l for both tanks over the 28-day experiment.

Figure 7 .
Figure 7. Nitrate nitrogen levels in mg/l for both tanks over the 28-day experiment.

Figure 8 .
Figure 8. Experimental setup in residential flat.Photo taken in week three.

Figure 10 .
Figure 10.Tank L actual nitrogen plotted against the predicted nitrogen using the MLR model.

Figure 10 .
Figure 10.Tank L actual nitrogen plotted against the predicted nitrogen using the MLR model.

Figure 10 .
Figure 10.Tank L actual nitrogen plotted against the predicted nitrogen using the MLR model.

Figure 11 .
Figure 11.Tank S spectral absorbance rates over 28 days, plotted by wavelength.

Horticulturae 2023, 9 ,
x FOR PEER REVIEW 17 of 22 potential of future applications of simple submerged optical sensors to replace EC in MISH systems.

Figure 12 .
Figure 12.Tank S actual nitrogen plotted against the predicted nitrogen using the MLR model.

Figure 12 .
Figure 12.Tank S actual nitrogen plotted against the predicted nitrogen using the MLR model.

Figure 13 .
Figure 13.Leaking sensor box, two days after the completion of the experiment.

Table 1 .
Literature on applied spectroscopy for monitoring hydroponic nutrient solutions.

Table 2 .
Comparison of descriptive statistics of the raw spectral intensity readings grouped by color.Three conditions were examined: an empty beaker, 500 mL of drinking water, and 500 mL of distilled water.

Table 3 .
Comparison of the means of raw spectral intensity for each color group of the AS7265x.The 18 spectral channels were grouped by five colors, and the average is shown below.The 2 mm box was the closest to the raw sensor readings.

Table 3 .
Comparison of the means of raw spectral intensity for each color group of the AS7265x.The 18 spectral channels were grouped by five colors, and the average is shown below.The 2 mm box was the closest to the raw sensor readings.

Table 4 .
Nutrient break down for Greenoponics Growth XL hydroponic nutrient solutions.

Table 4 .
Nutrient break down for Greenoponics Growth XL hydroponic nutrient solutions.

Table 5 .
Means of the temperature and pH for Tank L and Tank S during the 28-day experiment.

Table 6 .
Total fresh and dry weight from the 28-day experiment.

Table 7 .
Tank MLR coefficients.Three wavelengths (560 nm, 645 nm, and 810 nm) were excluded from the model due to high collinearity.

Table 8 .
Tank S MLR coefficients.All coefficients were included in the model.

Table 9 .
Comparison of the most accurate wavelengths for Tank S and Tank L.