Development and Implementation of an IoT-Enabled Optimal and Predictive Lighting Control Strategy in Greenhouses

Global population growth has increased food production challenges and pushed agricultural systems to deploy the Internet of Things (IoT) instead of using conventional approaches. Controlling the environmental parameters, including light, in greenhouses increases the crop yield; nonetheless, the electricity cost of supplemental lighting can be high, and hence, the importance of applying cost-effective lighting methods arises. In this research paper, a new optimal supplemental lighting approach was developed and implemented in a research greenhouse by adopting IoT technology. The proposed approach minimizes electricity cost by leveraging a Markov-based sunlight prediction, plant light needs, and a variable electricity price profile. Two experimental studies were conducted inside a greenhouse with “Green Towers” lettuce (Lactuca sativa) during winter and spring in Athens, GA, USA. The experimental results showed that compared to a heuristic method that provides light to reach a predetermined threshold at each time step, our strategy reduced the cost by 4.16% and 33.85% during the winter and spring study, respectively. A paired t-test was performed on the growth parameter measurements; it was determined that the two methods did not have different results in terms of growth. In conclusion, the proposed lighting approach reduced electricity cost while maintaining crop growth.


Introduction
The global population is predicted to grow to around 9.15 billion by 2050, which will increase the amount of food that needs to be produced [1]. Furthermore, the limitations of natural resources and productive land, as well as climate constraints raise concerns about food security. The rising demand for food has attracted researchers' attention towards the application of Internet of Things (IoT) technology in agriculture. The IoT is a network of physical objects that transfer data to other devices over the Internet [2]. Applying the IoT in controlled environment agriculture (CEA) has reduced human effort, time, and cost and resulted in yield improvements [3]. The IoT integrates several technologies such as wireless sensor networks (WSNs), radio-frequency identification (RFID), cloud and edge computing, and human-computer interaction (HCI) [4].
The application of the IoT in agriculture includes monitoring, control of agriculture machinery, tracking and tracing, precision agriculture, and greenhouse production [3].
Monitoring and acquiring data about some environmental factors in crop farming such as temperature, humidity, solar radiation, pest movement, and rainfall help to understand the patterns and maximize farm production [5]. Other than crop farming, monitoring the water quality, water level, and temperature levels in aquaponics is another application of the IoT [6]. Furthermore, factors to be monitored in forestry [7] and livestock [8] are other In our prior studies [25,26], we developed optimal supplemental lighting strategies for both LEDs and HID lamps in greenhouses, which significantly reduced the electricity cost. We formulated the supplemental lighting control problem as a constrained convex optimization problem, and we aimed at minimizing the electricity cost of supplemental lighting, while considering sunlight prediction, plant light needs, and variable electricity pricing in our model. This strategy used a Markov model to predict future sunlight intensities. The simulation studies showed that the proposed method could reduce electricity cost significantly [25]. To control the light intensity of HID lamps, we formulated a discrete constrained optimization problem, which was solved using the method of multipliers and a reinforcement learning (RL) algorithm, considering the Markov-based sunlight prediction [26]. Although we made sure to provide sufficient light for good crop growth as the constraint of the optimization problem, it is necessary to implement the method in the greenhouse and monitor plant growth through experimental studies.
In the present paper, we implemented our proposed lighting strategy for LEDs in a research greenhouse equipped with IoT technology. Lettuce was grown under two treatments with different lighting control strategies over two seasons with low and high natural light (winter and spring). To evaluate the proposed lighting control approach in terms of plant growth, we collected data related to growth during both experiments. The main contributions of this work are as follows: (1) We implemented an optimal supplemental lighting control strategy in a greenhouse equipped with IoT technology. (2) We evaluated the advantages of our proposed optimal lighting method based on not only the electricity cost, but also the plant growth through experimental studies.

Preliminaries and Problem Formulation
Photosynthesis is a photon-driven process. Thus, photosynthetic light levels are measured as the photosynthetic photon flux density (PPFD) with units of µmol m −2 s −1 . The PPFD is the light-photon numbers in the photosynthetically active wavelength range (400-700 nm) per square meter per second. The daily light integral (DLI) in mol m −2 d −1 is the integral of the PPFDs over 24 h. To ensure sufficient growth for plants in greenhouses, it is recommended that they receive a minimum amount of DLI during the photoperiod, which is the time period each day (up to 24 h) during which plants receive light [23]. To formulate the optimization problem, the relation between two important parameters in plant photosynthesis was considered. These parameters are the PPFD and electron transport rate (ETR), which is the number of electrons transported through photosystem II per square meter of leaf area per second (with units of µmol m −2 s −1 ). The daily photochemical integral (DPI) in mol m −2 d −1 is the integral of the ETRs over 24 h. Furthermore, the ETR and PPFD generally have an exponential rise to a maximum relation. The authors in [23] derived a relationship between the ETR and PPFD as: where a is the asymptote of the ETR and k is the initial slope of the ETR divided by a. For "Green Towers" lettuce, which was used in this study, a = 121 µmol m −2 s −1 , and k = 0.00277 [23].
For many greenhouse crops, to guarantee high-quality production and adequate growth, a minimum DLI is suggested. In some cases, a specific photoperiod must also be achieved. However, the DPI and plant growth depend on the combination of the DLI and photoperiod; longer photoperiods with the same DLI result in a higher DPI and more biomass [27,28]. Therefore, the DPI is a better predictor of plant growth and better suited for lighting optimization algorithms than the DLI. "Green Towers" lettuce requires a DPI of 3 mol m −2 d −1 , corresponding approximately to a DLI of 17 mol m −2 d −1 under ambient sunlight conditions [23]. The optimization problem was formulated to minimize the total amount of supplemental lighting cost to reach a specified DPI within a specified photoperiod.
The theory behind the experiments considered in this study is based on the constrained nonlinear optimization problem presented in [25], which is as follows: where x t is the ETR resulting from supplemental light provided by the LEDs at time step t, s t is the ETR resulting from sunlight, s t is the PPFD received from the Sun, U LED is the maximum ETR that can be achieved with LEDs, C t is the electricity price in cents/kWh, D is the minimum DPI needed for the plant during the entire photoperiod, m is the length of each time step in seconds, and T is the number of time steps. The first constraint in (1) guarantees supplying sufficient light to the plants to reach the recommended DPI, and the other constraints define the ETR bounds according to the PPFD of LEDs. A photoperiod of 16 h is common for greenhouse lettuce production and used to illustrate the performance of the control strategy. The optimization problem was solved at each time step (with the length of m seconds) during the allowed photoperiod for each day, and supplemental light was provided up to the optimal PPFD calculated for that time step. The process was repeated every m seconds time step, for a total number of T = 16 × 3600/m when a 16 h photoperiod was used. The Markov-based predictive values are substituted in (1), instead of the actual future sunlight intensities (which are not obtainable in real time). For a detailed description on sunlight prediction using Markov chains, we refer to our previous work [25]. Consequently, (1) can be demonstrated as: The optimization problem (2) was solved once before sunrise and once after sunset. Throughout the day, (2) was solved repeatedly at each time step. The interested reader is referred to [25] for more details on how to calculate the optimal lighting strategy.

IoT Structure
Four essential components of an IoT ecosystem include: (1) IoT devices; (2) communication technology; (3) the Internet; and (4) data storage and processing [3]. The description of each component is provided as follows: (1) IoT devices: IoT devices consist of embedded systems, which include microprocessors, field programmable gate arrays (FPGAs), and input/output interfaces that interact with sensors and actuators [3]. In this study, a quantum light sensor was used to measure sunlight irradiance in the greenhouse, and an infrared (IR) night vision camera was deployed to monitor growth and calculate the projected canopy size (PCS) (a morphological indicator of plant growth). A Raspberry Pi was also used as the microprocessor, which was connected to the camera and the light sensor through an analog-to-digital converter (ADC). Data were stored on the Raspberry Pi SD card and then transferred through WiFi. Reliability, portability, security, and cost were taken into account while choosing the IoT devices; (2) Communication technology: Communication technology in IoT systems can be categorized based on the standards, spectrum, and application scenarios. In the deployment of wireless connectivity, the range of the communication distance, data rate, security and resilience, and cost of gateway modems are some of the parameters that should be considered [3]. For our study, WiFi was chosen as the wireless technology with a WLAN and WPA2 security; (3) Internet: The connection between IoT devices and the Internet allows transferring data towards a remote infrastructure for storage, processing, and further analysis. Security, accessibility, and support for real-time data should be taken into account while transferring data [3]; (4) Data storage and processing units: Data collected in agriculture applications can be in different forms including images, text, audio, and video. Cloud IoT platforms have been used to store big data collected from sensors. Some of the commercial platforms that provide data storage and analysis are Onfarm systems, Cropx, KAA, Farmx, Easyfarm, and Farmlogs [3]. In our experiment, data in the form of text and images were stored on the Raspberry Pi SD card and retrieved remotely using WPA2 and RealVNC software (RealVNC is available at https://www.realvnc.com/en/, accessed on 20 November 2020).

Experimental Setup
To evaluate the performance of the proposed lighting control approach in terms of plant growth, as well as electricity cost, two experiments were conducted inside of a research greenhouse for "Green Towers" lettuce in Athens, GA, USA. The experimental unit consisted of a group of 15 plants in 10 cm 2 pots on each bench. Those pots were filled with a soil-less substrate (80% peat: 20% perlite (v/v) (Fafard 1P; SunGro Horticulture, Agawam, MA, USA)). Plants were grown under two supplemental lighting treatments (the proposed method and a heuristic one) and were manually irrigated every two or three days with a nutrient solution containing 100 mg L −1 N made with a water-soluble fertilizer (15N-2.2P-12.45K, Peters Excel 15-5-15 Cal-Mag Special; Everris NA Inc., Dublin, OH, USA).
We compared the lighting electricity cost of our proposed method to two supplemental lighting strategies: (1) baseline, which is also optimal and solves the optimization problem (2) assuming perfect prior knowledge of sunlight throughout the day; (2) heuristic, in which the goal was to supply enough supplemental light to reach a minimum PPFD, unless the PPFD from sunlight alone exceeded the threshold. Thus, by the end of photoperiod, the plants will have received enough supplemental light to reach a DPI greater than or equal to the suggested quantity. In this method, sunlight prediction and real-time electricity price are not taken into account. Since the assumption of perfect prior knowledge of sunlight is not realistic nor practical, only the heuristic method and the proposed method were implemented in the greenhouse to grow lettuce under those treatments and compare plant growth. However, the simulation results related to the electricity cost for the baseline method are provided and represent a theoretical optimal scenario.
Our control algorithms were implemented on the Raspberry Pi 3 Model B (a low-cost, small microprocessor) using the Python programming language. Raspberry Pi operates as a control hardware to decide on how much supplemental lighting the plants need based on the predicted sunlight. CVXPY, a domain-specific language (DSL) that enables solving convex optimization problems with the high-level features of Python [29,30], was used to calculate the optimal lighting (CVXPY is available at http://www.cvxpy.org, accessed on 1 January 2020).
To develop the Markov model for sunlight prediction, sunlight data collected from the NREL database [31] were taken as representative of the sunlight intensity outside our greenhouse. Often, 40-70% of the sunlight PPFD represents the PPFD measured at a leaf surface in a greenhouse because of the building materials of the greenhouse ceiling and the sunlight radiation angle [32]. For the development of the Markov model, we considered 40% as the light transmission rate since the greenhouse had an internal shade cloth, which was used to achieve low sunlight levels and facilitate lighting research. This model was used in both experiments to predict sunlight based on real-time PPFD measurements by a light sensor inside the greenhouse, underneath the shade cloth. These measurements represent the amount of sunlight that reached the plants. The parameters used in our optimization problem were similar to those considered in our prior study [25] and for the type of LEDs used in the experiments (given in Table 1).

Variable
Value Variable Value To measure the sunlight PPFD over the plant canopy in the greenhouse, an analog full-spectrum quantum sensor (SQ-500-SS, Apogee instruments, Logan, UT, USA) with an improved spectral range of 389-692 nm ± 5 nm was used. SQ-500-SS is a self-powered PAR light sensor with a 0-40 mV output and calibration factor of 100 µmol m −2 s −1 mV. Sunlight intensity was measured by the light sensor using a Python script every three minutes, then averaged to be representative of sunlight at each time step (15 min). Since the Raspberry Pi only reads digital inputs, the analog output of the sensor was converted to digital using ADS1115, which is a high-precision 16 bit ADC. ADS1115 uses the I2C communication protocol to read analog values; therefore, I2C should be enabled on the Raspberry Pi before interfacing.
The supplemental lighting source used in our setup was the GE Arize TM element L1000 LED grow light bars with a 3:1 red-to-blue light ratio (HPPB4) and a power of 627 W. Several methods of controlling the output signal of LED drivers are available; the 0-10 V dimming approach was used for our purposes. In this method, there is a near-linear relationship between the dimming voltage of the LED driver and the output light of the LED. To control the output light of the LEDs, two GPIO pins of the Raspberry Pi (GPIO 13 and GPIO 18) were used to generate two pulse-width modulation (PWM) signals. One PWM signal controls the LEDs under the heuristic treatment, and the other one controls the LEDs under the prediction-based treatment. These PWM signals of the Raspberry Pi need to be amplified and filtered to become compatible with the dimming voltage of the LED driver; thus, a signal-conditioning circuit (using the TL081 operational amplifier (op-amp)) was designed to supply the proper signal to the LED drivers. Based on the calculated supplemental lighting strategy, the duty cycle of the PWM signals was determined by the Raspberry Pi and converted to the compatible dimming voltage (control signal) for LED drivers by the signal-conditioning circuit. At each time step (15 min), the control signals for the two treatments were adjusted, thereby changing the output light of the LEDs.
Every morning, the Raspberry Pi automatically runs the Python code, which reads real-time light sensor data, predicts future sunlight, solves the optimization problem, and calculates the supplemental lighting for both treatments at each time step (every 15 min) for a 16 h photoperiod. Once the photoperiod is over and plants receive sufficient light, the LEDs are turned off.
To monitor the plant growth and PCS for the two treatments, Arducam day-night vision cameras were installed above the benches. The camera was mounted facing downward above the crop. These cameras have an IR cut filter that switches automatically. The filter is on for daylight color accuracy and off for IR night vision. Therefore, the camera can take pictures at night in complete darkness using its small IR LEDs. Moreover, this camera is an inexpensive choice (less than USD 30) for monitoring plant growth. Each camera was connected to a Raspberry Pi, which was set to automatically take pictures every night when the LEDs were off, so that there would be no sunlight or LED light interfering with the plant images. Figure 1 shows the imaging setup. We accessed the data related to supplemental lighting, sunlight, cost, and plant images through real-time remote monitoring of the Raspberry Pi using WPA2 and RealVNC software. Plant images were processed using PlantCV, which is an image analysis package for plant phenotyping [33] (PlantCV is available at https://plantcv.readthedocs.io/en/ stable/, accessed on 20 November 2020). The PCS was measured by using a reference with a known area and counting the number of detected leaf pixels.
Shown in Figure 2 is the experimental setup in the greenhouse. The light sensor was installed above the LED fixtures so that it was not affected by the LED light and was connected to the ADC. The ADC converts the analog measurements to digital, and hence, the Raspberry Pi can read them. After predicting sunlight and solving the optimization problem, the duty cycle of the PWM signals was determined and amplified. These control signals were connected to the dimming wires of the LED driver, thereby changing the output light of the LED. The camera was installed above the crops and connected to the Raspberry Pi through a ribbon cable. The materials used in the proposed setup are presented in Table 2.  The first experiment ran from 11 December 2020 through 28 January 2021, when sunlight levels were low. The daily minimum temperature, max temperature, minimum vapor pressure deficit (VPD), and maximum VPD inside the greenhouse were 12.4 ± 3.4°C, 22.4 ± 2.8°C, 0.46 ± 0.15 kPa, and 1.81 ± 0.63 kPa (mean ± SD), respectively. The CO 2 level was at the ambient level; the average DLI from sunlight under the shade cloth was 2.22 ± 0.6 mol/m 2 d, and the daily amounts are provided in Figure 3. The setup in Figure 2 was installed, and three lettuce replicates for the heuristic method and three for the proposed optimal method with six LEDs were considered. Figure 4 depicts the greenhouse section in the first experiment. On each bench, 15 plants were grown as 1 experimental unit. This section of the greenhouse was surrounded by windows except for the west wall, where the cooling pad was. Therefore, the benches on the west side may received less sunlight late in the day. It is also possible that the temperatures may have been slightly lower on the west side due to the cooling pad. However, very little cooling was required in winter. Ambient light and temperature can affect plant growth, and the treatments were blocked to account for such effects. Further details are provided in the Results and Discussion Section. Plants were harvested 49 d after seeding, and the proposed method was evaluated in terms of both the electricity cost and plant growth. For the imaging part, only two cameras were installed above the two benches, one controlled by the heuristic method (Bench Number 8 in Figure 4) and the other one by the prediction-based method (Bench Number 7 in Figure 4). Thus, we used two Raspberry Pis in this experiment, one connected to a camera for taking pictures of one replicate of the heuristic method and another to take pictures of the plant under the predictionbased treatment and to control the output light of all six LED fixtures. During the first experiment, the photoperiod started at 4:30 a.m. and ended at 8:30 p.m. At 8:30 p.m., the LEDs turned off, and the camera automatically took images at 11:30 pm when there was no supplemental light in the greenhouse. We obtained a variable hourly electricity price profile from a website (https://www.ieso.ca/power-data, accessed 1 December 2019) and scaled the numbers to account for the U.S. electricity prices based on government rates. The electricity price profile considered in this experiment is given in Figure 5 and was the same throughout the study.

Remark 1.
The units of f in (1) are cents (kWh) −1 µmol m −2 s −1 ; therefore, a conversion factor is needed to convert these units to cents/m 2 . Converting the PPFD of GE LEDs to kW m −2 , 2.9 µmol J −1 (or equivalently 2.9 × 10 3 µmol (kW) −1 s −1 ) was performed [34]. Assuming the length of each time step (15 min or 0.25 h), the conversion factor q is defined as: Therefore, q × f represents the electricity cost of supplemental lighting with units of cents/m 2 .
Other than the PCS, the leaf chlorophyll content index (CCI), anthocyanin content index (ACI), specific leaf area (SLA), and shoot dry weight were measured to compare plant growth for the two lighting approaches. The CCI and ACI were measured using chlorophyll and anthocyanin meters (CCM-200 plus and ACM-200 plus; Apogee Instruments, Logan, UT, USA) on the uppermost fully expanded leaves at two different times, once partway through the study and again near the end. Each time, 10 measurements on each experimental unit (group of 15 plants) were collected. The average value of these measurements was considered for each unit. A higher CCI can increase the light absorptance [35], and the anthocyanins in leaves have a protective role against intense light [35].
The SLA was calculated by dividing the leaf area of a plant by the shoot dry weight. For each experimental unit (15 plants), 3 plants were selected, and the total leaf area was measured using a leaf area meter (LI-3100 leaf area meter; LI-COR Biosciences, Lincoln, NE, USA). When drying the plants in the oven, these three plants were placed separately from the other plants. After drying them at 70°C for 7 d, the shoot dry weight of each group of plants was also measured, thereby achieving the SLA per plant. Furthermore, dividing the total dry weight over the number of pots for each unit (15), we obtained the shoot dry weight per plant.
A paired t-test (two-tailed form) was performed for each growth parameter to determine if the two lighting methods had different results. In this test, each replicate was considered to be a pair, and the mean values for the two treatments were compared. If the p-value was less than the significance level (here, 0.05), the null hypothesis was rejected, which means there was a significant difference between the two methods.
The second experiment was conducted using the same crop species in the same place, from 2 April 2021 through 18 May 2021, when sunlight levels were higher than in the first experiment. The minimum temperature, max temperature, minimum vapor pressure deficit (VPD), and maximum VPD inside the greenhouse were 18.7 ± 1.5°C, 25.8 ± 1.5°C, 0.52 ± 0.21 kPa, and 1.86 ± 0.75 kPa (mean ± SD), respectively. The CO 2 level was at the ambient level; the average DLI from sunlight under the shade cloth was 7.45 ± 3.11 mol/m 2 d, and the daily amounts are given in Figure 6. Not only were the sunlight levels much higher than in the first experiment, they were also more variable, thus increasing the potential benefits of an optimized lighting control approach. This time, we experimented on more replicates, i.e., five replicates for each treatment, which is represented in Figure 7. Plants were harvested 47 d after seeding. The same hardware setup was utilized for this experiment; however, the PCS was monitored for three replicates of each treatment using six Arducam cameras. The cameras were installed above Bench Numbers 1 and 2, 7 and 8, and 14 and 15 (see Figure 7). Moreover, the lighting control started at 5 am every day and ended at 9 pm. This change was made to ensure that the photoperiod fully encompassed the natural photoperiod. Another different factor compared to the first experiment was the use of a fixed electricity price (13.19 cents/kWh), rather than real-time pricing. Considering real-time pricing is advantageous to reduce the electricity cost of lighting. However, for the second experiment, we intended to use the electricity price available to our research greenhouse, which is fixed. Measurements of the growth parameters were repeated for the second experiment, and paired t-tests (two-tailed form) were performed to accept or reject the null hypothesis.

Results and Discussion
First, we discuss the results of the first experiment. The lighting control performance and sunlight prediction throughout different days with different sunlight levels are shown in Figures 8-10. Figure 8 is representative of a rainy day with very low sunlight irradiance. January 14th's irradiance was close to a day with regular sunlight during that period, and Jan 28th had a relatively high sunlight irradiance (presented in Figures 9 and 10, respectively). The cost increase on each day compared to the baseline was calculated and shown in Table 3. Moreover, the average of actual sunlight, its prediction, and supplemental light for different methods were calculated throughout this experiment and displayed in Figure 11. Based on the results in Table 3, the cumulative cost increase for the heuristic method was 5.45%, while for the prediction-based method, it was 1.06% compared to the baseline. Therefore, our prediction-based lighting approach showed about a 4.16% electricity cost reduction compared to the heuristic method throughout the first experiment. In the baseline approach, perfect prior knowledge of sunlight throughout the day is assumed, which is not practical and only represents a theoretical optimal scenario. A predictive model is not able to predict sunlight with 100% accuracy; therefore, the sunlight information in the baseline approach is always more accurate than that in the proposed method. In other words, the baseline is an ideal optimal scenario with the least electricity cost, which is not practical. However, the prediction-based method is optimal and practical, which resulted in a very close solution to the baseline (the global optimal solution of the lighting problem). The heuristic lighting strategy generally provided more light than the minimum DPI and resulted in extra supplemental lighting cost; thus, it is not optimal.    Some of the images taken by our setup (see Figure 1) are shown in Figure 12. The top images were taken of the plants under prediction-based lighting, and the bottom images were taken of the plants under the heuristic lighting method. The left pairs in Figure 12 were captured 32 d after seeding (January 11th), and the right pairs were captured at the end of the experiment (January 28th). Arducam took the left images of each pair at night in darkness, and then, the images were transferred to a computer through the VNC viewer. Hence, we could access the images remotely and in real time via WiFi. Using the PlantCV package, the images were analyzed, and the PCS was measured by thresholding, thereby resulting in the right images of each pair in Figure 12. The results of the statistical analysis on all growth parameters are provided in Table 4. The p-value for all parameters was greater than 0.05; consequently, the means of the two treatments were almost equal for each growth parameter (especially shoot dry weight, which was the most important growth parameter). Therefore, the proposed approach did not affect the plant growth adversely or positively. We calculated another parameter, which was the total dry weight divided by the total electricity cost (in cents/m 2 ), for each approach. This parameter includes both cost and growth information, which for the prediction-based method was 0.0797 (g/cent) and for the heuristic method was 0.0738 (g/cent), a 7.4% reduction. Hence, the proposed optimal lighting approach resulted in a reduction of the electricity cost and did not affect plant growth adversely.  Figures 13-15 show the performance of the lighting strategies and sunlight prediction throughout different days with different sunlight levels in the second experiment. Figure 13 is representative of rainy days with low sunlight irradiance compared to the mean irradiance in April. April 7th irradiance was close to a day with regular sunlight during that period, and May 6th had high sunlight irradiance (presented in Figure 14 and Figure 15, respectively). The cost increase in each day compared to the baseline was calculated and shown in Table 5. Moreover, the average of actual sunlight, its prediction, and supplemental light for different methods were calculated throughout this experiment and displayed in Figure 16. Based on the results in Table 5, the cumulative cost increase for the heuristic method was 62.86%, while for the prediction-based method, it was 7.74% compared to the baseline. Our prediction-based lighting approach showed about a 33.85% electricity cost reduction compared to the heuristic method throughout the second experiment.
Some of the images taken by our setup (see Figure 1) during the second experiment are illustrated in Figure 17. The left pairs were captured 33 d after seeding (May 4th), and the right pairs were captured at the end of the experiment (May 18th). The PCS was measured using PlantCV package, and we monitored the plant growth remotely via WiFi in real-time, the same method as the first experiment. The average of the PCS for those replicates that had a camera was measured for each treatment and shown in Figure 18.
Other than the lighting approach, different temperatures and ambient light in the greenhouse had at most minor effects on our results, since our treatments were blocked to account for east to west environmental gradients within the greenhouse.       The results of the statistical analysis on the growth parameters for the second experiment are provided in Table 6. The p-value for all parameters was greater than 0.05, except for the SLA (t(4) = 3.37, p = 0.03). The SLA was greater for the proposed strategy (µ = 131.24, σ = 8.1 cm 2 /g per plant), compared to the heuristic method (µ = 116.69, σ = 7.34 cm 2 /g per plant). However, this difference was not necessarily due to a true biological effect. It was more likely due to a Type I error. Thus, the statistical analysis did not show meaningful differences in plant growth between the two treatments. The total shoot dry weight divided by the total cost for the prediction-based method was 0.2166 (g/cent), while for the heuristic method, it was 0.1475 (g/cent), 32% lower. Hence, the proposed strategy resulted in a higher efficiency than the heuristic method in terms of electricity cost together with plant growth. Both experiments validated that the prediction-based method can reduce cost while maintaining plant growth. As shown in Figures 3 and 6, the sunlight levels were much lower during the first study compared to the second study; therefore, more supplemental light was provided to reach the minimum DPI during the first study, which resulted in a higher electricity cost (for both approaches). Since the dry weight at the end of the experiments was almost the same, the total dry weight/total cost was lower for the first study. The difference in the DLI from sunlight also affected the electricity cost savings of the proposed method for the two experiments. During the first study, the DLI was very low, and that resulted in providing so much supplemental light to satisfy the light requirements of the plants with both lighting approaches (the heuristic and the proposed method). The heuristic method provided the greatest benefits when the light levels are variable, both in the short term (15 min) and longer term (day to day). Thus, there was not a huge difference in the cost of the lighting methods. However, during the second study, the DLI levels were much higher, and much less supplemental lighting was needed to reach the minimum lighting requirement. Hence, the proposed method reduced the cost by a higher percentage in the second study (33.85% compared to 4.16%).
The cost profile in the second experiment was a fixed price, since we wanted to consider the actual conditions in our research greenhouse. The simulation results in our previous work [25] showed that the proposed method with variable electricity pricing contributed to a cost reduction in different months of the year. If we used a variable cost profile for the second study, as well as the first one, the cost reduction in the second study would have been even higher.
The proposed strategy for controlling supplemental lighting significantly differs from the previous approaches. Most of the previous approaches that were mentioned in the Introduction Section are rule-based methods and do not use sunlight prediction [15,17,22]. Among all the methods proposed for HID lamps, the DynaLight system and DynaLight IND are the most efficient ones since they use weather forecast, a photosynthesis model, and a variable electricity profile. However, these methods are still not optimal because providing the weather forecasts twice daily is not enough to obtain the optimal lighting strategy, and for the improved version of this system (DynaLight IND), practical experiments should be conducted to validate its efficiency [20,21]. On the other hand, our proposed method was evaluated through both simulations and practical experiments.
A study on an adaptive control approach for LEDs [15] showed that a method similar to the heuristic method reduces the cost of supplemental lighting, compared to two other rule-based methods. In the present paper, we concluded that the prediction-based approach reduced the cost significantly compared to the heuristic method. Therefore, our strategy outperformed the other methods by taking advantage of the sunlight predictive model, the minimum DPI requirement, and variable electricity pricing. The shortcoming of our method is that the sunlight predictive model uses the mean value of the historical data at the beginning of the day, and for rainy days with too low sunlight levels, this may result in overestimating sunlight. Therefore, this approach may not perform as expected in this case.
There has been much research on growing lettuce with 24 h photoperiods [36]. Nonetheless, this practice has not (yet) been adopted by the industry, where photoperiods of 16-20 h are more commonly used. To make our research relevant to the greenhouse industry, we decided to use a photoperiod that is commonly used in commercial greenhouses. The energy savings that can be realized may indeed depend on the photoperiod that is used. Our lighting optimization protocol was formulated in such a way that any photoperiod can be used, and it is not specific to a 16 h photoperiod.
Finally, we note that lighting can provide a substantial amount of heat to a greenhouse; but the effects of more efficient lighting methods and greenhouse heating requirements are often ignored. A major challenge is that the interaction between lighting and heating is location specific and requires advanced models to estimate [37]. We thus opted to focus solely on lighting costs in this study.

Conclusions
In this paper, a new optimal approach was developed and implemented for supplemental lighting control in greenhouse environments using IoT technology. This method solves an optimization problem to satisfy plant light needs using Markov-based sunlight prediction and variable electricity pricing. Two experimental studies during two different seasons in the same greenhouse were conducted, where the proposed lighting approach was validated in terms of electricity cost reduction (4.16% reduction during the winter study and 33.85% during the spring study) while maintaining plant growth.