Intelligent Control of the Microclimate of an Agricultural Greenhouse Powered by a Supporting PV System

: An agricultural greenhouse is a complex and Multi-Input Multi-Output MIMO system in which the internal parameters create a favorable microclimate for agricultural production. Temperature and internal humidity are two parameters that have a major impact on greenhouse yield. The objective of this study was to propose a simulated dynamic model in a MATLAB / Simulink environment for experimental validation. Moreover, a fuzzy controller was designed to manage a greenhouse indoor climate by means of an asynchronous motor for ventilation, heating, humidiﬁcation, etc. An intelligent system to control these actuators for an optimal inside climate was implemented in the model. The dynamic model was validated by comparing the simulation results to experimental measurements. These results showed the e ﬀ ectiveness of the control strategy in regulating the greenhouse indoor climate. Finally, a photovoltaic generator was modeled, with the aim of reducing the costs of agricultural production. It feeds the asynchronous motor with a vector control optimized by fuzzy logic that drives a variable speed fan.


Introduction
Due to the enormous increase and instability of oil and derivatives markets, countries are constantly looking for alternative sources of energy to ensure the independence of their economies from fluctuations in oil prices. Photovoltaic energy can have undeniable advantages, especially due to its cleanliness and low cost. In addition, it can be used in various applications such as in agronomy, where different variables, e.g., temperature and humidity, have to be monitored and controlled. These include temperature and humidity. A greenhouse is a known solution for protecting plant cover from diseases and bad weather. A greenhouse is a complex system, the internal climate of which is influenced by many factors, such as wind speed, solar radiation, external temperature, and humidity. Two main problems have limited the expansion of greenhouse agricultural production.
Firstly, control over the indoor climate is an important aspect in achieving microclimate comfort for plant growth. Many research activities have focused on controlling the indoor climate of a greenhouse with different strategies. Predictive neural control [1] has been developed to optimize the greenhouse climate, while a fuzzy controller that was developed to describe a dynamic model in MATLAB/Simulink was described in Reference [2]. In addition, Reference [3] studied several PI control structures that showed strong stationary performance. In Reference [4], the authors introduced a decentralized decoupled fuzzy logic controller (FLC), showing its usefulness in comparison to the conventional PID storage, and convection. Control over the internal microclimate can be automatized (for example, by using a fuzzy controller, as in this paper) only if a physical model of the greenhouse is available. This model must be able to foresee changes in the indoor environmental parameters, which are based on several boundary conditions. For this reason, this section proposes-and validates experimentally-a simplified thermal model of a test lab greenhouse. The proposed model of the greenhouse is based on four layers ( Figure 1) that participate in thermodynamic exchanges: the cover, the internal air, the plants, and the soil. The role of each layer is as follows: • The main function of the cover is heat retention; usually, the cover is made of polyethylene film or glass; • The interior air represents an internal climate that is mainly governed by temperature and humidity; • The plants play a strategic role in water and heat balance, thanks to the evapotranspiration process [10]; • The soil influences the absorbance and diffusivity of the thermal radiation [11].
microclimate conditions for fixed cultivation. In fact, a greenhouse is a heat storing system that converts incident solar radiation into heat gain. This physical process is based on conduction, heat storage, and convection. Control over the internal microclimate can be automatized (for example, by using a fuzzy controller, as in this paper) only if a physical model of the greenhouse is available. This model must be able to foresee changes in the indoor environmental parameters, which are based on several boundary conditions. For this reason, this section proposes-and validates experimentally-a simplified thermal model of a test lab greenhouse. The proposed model of the greenhouse is based on four layers ( Figure 1) that participate in thermodynamic exchanges: the cover, the internal air, the plants, and the soil. The role of each layer is as follows:  The main function of the cover is heat retention; usually, the cover is made of polyethylene film or glass;  The interior air represents an internal climate that is mainly governed by temperature and humidity;  The plants play a strategic role in water and heat balance, thanks to the evapotranspiration process [10];  The soil influences the absorbance and diffusivity of the thermal radiation [11].

Test Lab Greenhouse under Study
The greenhouse under investigation is in the north of Tunisia in the Borj Cedria region (36°43′10.25′′ N) and is a typical model for greenhouses located in the Mediterranean area.
The greenhouse is a small, semi-insulated capel and occupies an area equal to 14.8 m 2 (width 3.7 m, length 4 m, ridge height 3 m), with a volume of 36 m 3 . Therefore, it is a test lab greenhouse. Its shape, dimensions, and measuring equipment are presented in Reference [28]. The specific design of the semi-insulated greenhouse maximizes the contribution of solar radiation and reduces the loss of heat to the ground. The structure has a 0.4-m-thick panel on the side walls and on the ground. To prevent heat exchange between the soil and the climate inside the greenhouse, a wooden plate with a thermal conductivity = 0.04 (W m −1 K −1 ) is used. Therefore, simplified modeling of the test lab greenhouse neglects heat transfer to the ground.

Test Lab Greenhouse under Study
The greenhouse under investigation is in the north of Tunisia in the Borj Cedria region (36 • 43 10.25" N) and is a typical model for greenhouses located in the Mediterranean area.
The greenhouse is a small, semi-insulated capel and occupies an area equal to 14.8 m 2 (width 3.7 m, length 4 m, ridge height 3 m), with a volume of 36 m 3 . Therefore, it is a test lab greenhouse. Its shape, dimensions, and measuring equipment are presented in Reference [28]. The specific design of the semi-insulated greenhouse maximizes the contribution of solar radiation and reduces the loss of heat to the ground. The structure has a 0.4-m-thick panel on the side walls and on the ground. To prevent heat exchange between the soil and the climate inside the greenhouse, a wooden plate with a thermal conductivity C t = 0.04 Wm −1 K −1 is used. Therefore, simplified modeling of the test lab greenhouse neglects heat transfer to the ground.

Heat Balance
The air exchanges between the internal air and the external environment produce losses that affect the heat and water balance. The internal heat balance is governed by Equation (1) [2,13]: where is the air density , and is the air heat capacity (1003 J·Kg −1 ·°C −1 ). The shortwave radiation absorbed by the greenhouse is given by where is the cover absorptivity of the solar radiation, is the cover transmittance, A is the surface area (m 2 ), and I is the solar radiation (Wm −2 ).
The rate of convection and conduction heat transfer is calculated as where is the internal temperature , is the outside temperature (K), and U is the heat transfer coefficient through the greenhouse walls (W·m −2 · K −1 ).
Infiltration through the greenhouse produces heat loss, which is calculated as

Heat Balance
The air exchanges between the internal air and the external environment produce losses that affect the heat and water balance. The internal heat balance is governed by Equation (1) [2,13]: where is the air density , and is the air heat capacity (1003 J·Kg −1 ·°C −1 ). The shortwave radiation absorbed by the greenhouse is given by where is the cover absorptivity of the solar radiation, is the cover transmittance, A is the surface area (m 2 ), and I is the solar radiation (Wm −2 ).
The rate of convection and conduction heat transfer is calculated as where is the internal temperature , is the outside temperature (K), and U is the heat transfer coefficient through the greenhouse walls (W·m −2 · K −1 ).
Infiltration through the greenhouse produces heat loss, which is calculated as

Heat Balance
The air exchanges between the internal air and the external environment produce losses that affect the heat and water balance. The internal heat balance is governed by Equation (1) [2,13]: where is the air density , and is the air heat capacity (1003 J·Kg −1 ·°C −1 ). The shortwave radiation absorbed by the greenhouse is given by where is the cover absorptivity of the solar radiation, is the cover transmittance, A is the surface area (m 2 ), and I is the solar radiation (Wm −2 ).
The rate of convection and conduction heat transfer is calculated as where is the internal temperature , is the outside temperature (K), and U is the heat transfer coefficient through the greenhouse walls (W·m −2 · K −1 ).
Infiltration through the greenhouse produces heat loss, which is calculated as

Heat Balance
The air exchanges between the internal air and the external environment produce losses that affect the heat and water balance. The internal heat balance is governed by Equation (1) [2,13]: where ρ a is the air density [1.25 Kg·m −3 ], and C a is the air heat capacity (1003 J·Kg −1 · • C −1 ). The shortwave radiation absorbed by the greenhouse is given by where α c is the cover absorptivity of the solar radiation, τ c is the cover transmittance, A is the surface area (m 2 ), and I is the solar radiation (Wm −2 ). The rate of convection and conduction heat transfer is calculated as Appl. Sci. 2020, 10, 1350 5 of 20 where T in is the internal temperature, T out is the outside temperature (K), and U is the heat transfer coefficient through the greenhouse walls (W·m −2 ·K −1 ). Infiltration through the greenhouse produces heat loss, which is calculated as where R is the number of air changes per hour (m 3 ·h −1 ). The longwave radiation absorbed by the greenhouse is calculated as where with V w being the wind speed and T sky being the sky temperature (as suggested by Swinbank in Reference [29]), which is calculated as The heating system provides thermal energy, which is calculated as with N h being the number of heaters, and R h being the capacity of the heating system (Wm −2 ). The thermal energy lost from the cooling system is calculated as where V r is the ventilation rate (m 3 s −1 ).

Water Balance
After the heat balance, the dynamics of the relative humidity inside the greenhouse need to be modeled. This is based on the following equation : where h in is the inside dynamic humidity calculated over time by a differential equation, while where p in and p out are the inside and outside saturated vapor pressure (Pa), respectively; V is the volume of the greenhouse; V w is the wind speed; and C e is the transfer coefficient of the water vapor in the air (Kg. (Wm −2 ).s −1 .Pa −1 ). Q in f iltration inside the greenhouse is calculated as where H in and H out are the inside and outside relative humidity, respectively.

Validation of the Proposed Dynamic Model
The proposed system was validated in a MATLAB/Simulink environment using a weather database of real measurements. This included measurements of solar radiation, wind speed, temperature, and Appl. Sci. 2020, 10, 1350 6 of 20 relative humidity. This also contained thermal properties of the greenhouse's response to external solar radiation. Some details are reported in Section 4.
The results of the theoretical simulations of the temperature and humidity were compared to the experimental measurements and are reported in  Appl. Sci. 2020, 10, x FOR PEER REVIEW 6 of 20 Figure 5. Measured and simulated data of the temperature inside the greenhouse. Figure 5 shows a simulation of the greenhouse temperature over three days: the measured temperature (green curve) was measured by a sensor (Figure 3), the interior temperature (red curve) was calculated by a differential equation (Equation (1)), and the outside temperature (blue curve) was measured by a sensor outside the greenhouse. The indoor and outdoor humidity are reported in Figure 6: the internal humidity (red curve) was calculated by a differential equation (Equation (10)), and the external humidity was measured by a sensor. Figure 7 presents a database measuring solar radiation during the investigated period. The solar radiation data were measured using a sensor placed outside the greenhouse. The northern region of Tunisia is usually cold, so radiation is not particularly high. In fact, the authors in Reference [28] did the same measurements in that region (in another period), obtaining a maximum value of 700 W/m 2 .  Figure 5 shows a simulation of the greenhouse temperature over three days: the measured temperature (green curve) was measured by a sensor (Figure 3), the interior temperature (red curve) was calculated by a differential equation (Equation (1)), and the outside temperature (blue curve) was measured by a sensor outside the greenhouse. The indoor and outdoor humidity are reported in Figure 6: the internal humidity (red curve) was calculated by a differential equation (Equation (10)), and the external humidity was measured by a sensor. Figure 7 presents a database measuring solar radiation during the investigated period. The solar radiation data were measured using a sensor placed outside the greenhouse. The northern region of Tunisia is usually cold, so radiation is not particularly high. In fact, the authors in Reference [28] did the same measurements in that region (in another period), obtaining a maximum value of 700 W/m 2 .    Figure 5 shows a simulation of the greenhouse temperature over three days: the measured temperature (green curve) was measured by a sensor (Figure 3), the interior temperature (red curve) was calculated by a differential equation (Equation (1)), and the outside temperature (blue curve) was measured by a sensor outside the greenhouse. The indoor and outdoor humidity are reported in Figure 6: the internal humidity (red curve) was calculated by a differential equation (Equation (10)), and the external humidity was measured by a sensor. Figure 7 presents a database measuring solar radiation during the investigated period. The solar radiation data were measured using a sensor placed outside the greenhouse. The northern region of Tunisia is usually cold, so radiation is not particularly high. In fact, the authors in Reference [28] did the same measurements in that region (in another period), obtaining a maximum value of 700 W/m 2 .   Figure 5 shows a simulation of the greenhouse temperature over three days: the measured temperature (green curve) was measured by a sensor (Figure 3), the interior temperature (red curve) was calculated by a differential equation (Equation (1)), and the outside temperature (blue curve) was measured by a sensor outside the greenhouse.
The indoor and outdoor humidity are reported in Figure 6: the internal humidity (red curve) was calculated by a differential equation (Equation (10)), and the external humidity was measured by a sensor. Figure 7 presents a database measuring solar radiation during the investigated period. The solar radiation data were measured using a sensor placed outside the greenhouse. The northern region of Tunisia is usually cold, so radiation is not particularly high. In fact, the authors in Reference [28] did the same measurements in that region (in another period), obtaining a maximum value of 700 W/m 2 .

Fuzzy Logic Controller for the Greenhouse
The studied system is described in Figure 8.

Fuzzy Logic Controller for the Greenhouse
The studied system is described in Figure 8. The operation of the FLC is as follows: a comparison between the temperature (Tin) and the humidity (Hin) (with their set points) gives the errors ΔT and ΔH for the regulation of the internal factors of the greenhouse controlled by the actuators (ventilation, heating, etc.). In the next section, the architecture and design of the fuzzy controller are discussed.
When the actuators are active, the heat flow supplied by the heating system and the air flow of the ventilation system will be part of the thermodynamic model. Therefore, the temperature and the humidity inside the greenhouse are governed by Equations (1) and (10), respectively.

Architecture of the Fuzzy Control Unit
The fuzzy controller is based on a fuzzy inference engine (FIS), which consists of three main processing subsystems ( Figure 9):


A fuzzification interface that converts linguistics input variables into numerical values;  A database unit that includes membership functions that need an "interface engine" in the fuzzy rules; and  A defuzzification processor that generates crisp control output for specific actuators.

Temperature Control
The input state variable of the temperature fuzzy controller is ΔT (see The membership functions of the input temperature error are reported in Figure 10, where NB is negative big, NM is negative medium, Z is zero, PM is positive medium, and PB is positive big.

Fuzzification interface
Interface engine Defuzzification processor Database unit The operation of the FLC is as follows: a comparison between the temperature (Tin) and the humidity (Hin) (with their set points) gives the errors ∆T and ∆H for the regulation of the internal factors of the greenhouse controlled by the actuators (ventilation, heating, etc.). In the next section, the architecture and design of the fuzzy controller are discussed.
When the actuators are active, the heat flow supplied by the heating system and the air flow of the ventilation system will be part of the thermodynamic model. Therefore, the temperature and the humidity inside the greenhouse are governed by Equations (1) and (10), respectively.

Architecture of the Fuzzy Control Unit
The fuzzy controller is based on a fuzzy inference engine (FIS), which consists of three main processing subsystems ( Figure 9): • A fuzzification interface that converts linguistics input variables into numerical values; • A database unit that includes membership functions that need an "interface engine" in the fuzzy rules; and • A defuzzification processor that generates crisp control output for specific actuators.

Fuzzy Logic Controller for the Greenhouse
The studied system is described in Figure 8. The operation of the FLC is as follows: a comparison between the temperature (Tin) and the humidity (Hin) (with their set points) gives the errors ΔT and ΔH for the regulation of the internal factors of the greenhouse controlled by the actuators (ventilation, heating, etc.). In the next section, the architecture and design of the fuzzy controller are discussed.
When the actuators are active, the heat flow supplied by the heating system and the air flow of the ventilation system will be part of the thermodynamic model. Therefore, the temperature and the humidity inside the greenhouse are governed by Equations (1) and (10), respectively.

Architecture of the Fuzzy Control Unit
The fuzzy controller is based on a fuzzy inference engine (FIS), which consists of three main processing subsystems ( Figure 9):


A fuzzification interface that converts linguistics input variables into numerical values;  A database unit that includes membership functions that need an "interface engine" in the fuzzy rules; and  A defuzzification processor that generates crisp control output for specific actuators.

Temperature Control
The input state variable of the temperature fuzzy controller is ΔT (see The membership functions of the input temperature error are reported in Figure 10, where NB is negative big, NM is negative medium, Z is zero, PM is positive medium, and PB is positive big.

Fuzzification interface
Interface engine Defuzzification processor Database unit

Temperature Control
The input state variable of the temperature fuzzy controller is ∆T (see The membership functions of the input temperature error are reported in Figure 10, where NB is negative big, NM is negative medium, Z is zero, PM is positive medium, and PB is positive big.  The membership function of the outputs is calculated as the maximum value of Vr = 50 m 3 /min and Hr = 500 W/m 2 .

Relative Humidity Control
The input state variable of the humidity fuzzy controller is ΔH in Figure 8, where ΔH = Hsetpoint − Hin ϵ (NB, NM, Z, PM, PB).
(14) Figure 12 reports the membership functions of the input humidity error.   The membership function of the outputs is calculated as the maximum value of Vr = 50 m 3 /min and Hr = 500 W/m 2 .

Relative Humidity Control
The input state variable of the humidity fuzzy controller is ΔH in Figure 8, where ΔH = Hsetpoint − Hin ϵ (NB, NM, Z, PM, PB). Figure 12 reports the membership functions of the input humidity error. The membership function of the outputs is calculated as the maximum value of Vr = 50 m 3 /min and Hr = 500 W/m 2 .

Relative Humidity Control
The input state variable of the humidity fuzzy controller is ∆H in Figure 8 If (ΔT is negative big) then (ventilation is high) and (heating is zero); and  If (ΔH is zero) then (humidification is zero) and (dehumidification is zero). The membership functions of the output variables are shown in Figure 13.  • If (∆T is negative big) then (ventilation is high) and (heating is zero); and • If (∆H is zero) then (humidification is zero) and (dehumidification is zero).

Simulations and Results
The simulation results of the fuzzy-controlled agricultural greenhouse are presented in Figure 14. Two different set points were set for the inside temperature: 15 • C for the night and 24 • C during the day. These reference values were fixed to guarantee optimal thermal conditions for cultivation (for tomato plants) in this test lab. Other reference values could be fixed for other cultivations. The same test for the inside humidity set two reference points: 70% during the day, and 80% during the night.

Simulations and Results
The simulation results of the fuzzy-controlled agricultural greenhouse are presented in Figure  14. Two different set points were set for the inside temperature: 15 °C for the night and 24 °C during the day. These reference values were fixed to guarantee optimal thermal conditions for cultivation (for tomato plants) in this test lab. Other reference values could be fixed for other cultivations. The same test for the inside humidity set two reference points: 70% during the day, and 80% during the night.
For this study, a real database was applied for 3 days, from 5 March 2017 to 7 March 2017, at the CRTEn Center: the database included solar radiation, temperature, and humidity. The selected period was characterized by a high variation in wind speed and in global average solar radiation between 0 and 800 W/m 2 , due to the position of the greenhouse (very close to the sea).

Temperature
During the night, the inside temperature was low (7 °C), as is shown in Figure 14. During the same period, the heating system was activated, and the heating rate became more intensive (380 W/m 2 )-see Figure 15a-to maintain the inside temperature around its set point of 15 °C (see Figure  14). Meanwhile, the heating rate was at an average level of 120 W/m 2 when the inside temperature was close to the set point. During the day, the ventilation system started operating to remove hot air and to push in cooler outside air; thus, the ventilation rate (Figure 15b  For this study, a real database was applied for 3 days, from 5 March 2017 to 7 March 2017, at the CRTEn Center: the database included solar radiation, temperature, and humidity. The selected period was characterized by a high variation in wind speed and in global average solar radiation between 0 and 800 W/m 2 , due to the position of the greenhouse (very close to the sea).

Temperature
During the night, the inside temperature was low (7 • C), as is shown in Figure 14. During the same period, the heating system was activated, and the heating rate became more intensive (380 W/m 2 )-see Figure 15a-to maintain the inside temperature around its set point of 15 • C (see Figure 14). Meanwhile, the heating rate was at an average level of 120 W/m 2 when the inside temperature was close to the set point. During the day, the ventilation system started operating to remove hot air and to push in cooler outside air; thus, the ventilation rate (Figure 15b

Humidity
The simulation results of the indoor relative humidity (with the control) are reported in Figure  16. The dehumidification system (Figure 17b) was activated with a maximum value of 15 g H2O/min during the night in order to remove the water vapor accumulated in the indoor climate of the greenhouse. This was needed to maintain the inside humidity around its predefined set point of 80%, but this value could reach more than 97% without the control, as is reported in Figure 6. During the day, the internal humidity was relatively low ( Figure 6) without the control due to the effect of the thermal load trapped inside the greenhouse (this reduced the air in the contained water). During this period, the humidification system was activated at a high rate (Figure 17a) to stabilize the humidity level around the set point of 70%.
The simulation results showed the effectiveness of the FLC in controlling the indoor parameters of the agricultural greenhouse. A fuzzy controller was designed to control the inside climate using appropriate actuators. The results of the simulation showed the efficiency of the developed FLC in meeting the requirements of factories in terms of temperature and humidity and in obtaining a favorable microclimate for the agricultural production of tomato plants.

Humidity
The simulation results of the indoor relative humidity (with the control) are reported in Figure 16. The dehumidification system (Figure 17b) was activated with a maximum value of 15 g H 2 O/min during the night in order to remove the water vapor accumulated in the indoor climate of the greenhouse. This was needed to maintain the inside humidity around its predefined set point of 80%, but this value could reach more than 97% without the control, as is reported in Figure 6. During the day, the internal humidity was relatively low ( Figure 6) without the control due to the effect of the thermal load trapped inside the greenhouse (this reduced the air in the contained water). During this period, the humidification system was activated at a high rate (Figure 17a) to stabilize the humidity level around the set point of 70%.

Humidity
The simulation results of the indoor relative humidity (with the control) are reported in Figure  16. The dehumidification system (Figure 17b) was activated with a maximum value of 15 g H2O/min during the night in order to remove the water vapor accumulated in the indoor climate of the greenhouse. This was needed to maintain the inside humidity around its predefined set point of 80%, but this value could reach more than 97% without the control, as is reported in Figure 6. During the day, the internal humidity was relatively low (Figure 6) without the control due to the effect of the thermal load trapped inside the greenhouse (this reduced the air in the contained water). During this period, the humidification system was activated at a high rate (Figure 17a) to stabilize the humidity level around the set point of 70%.
The simulation results showed the effectiveness of the FLC in controlling the indoor parameters of the agricultural greenhouse. A fuzzy controller was designed to control the inside climate using appropriate actuators. The results of the simulation showed the efficiency of the developed FLC in meeting the requirements of factories in terms of temperature and humidity and in obtaining a favorable microclimate for the agricultural production of tomato plants.  The simulation results showed the effectiveness of the FLC in controlling the indoor parameters of the agricultural greenhouse. A fuzzy controller was designed to control the inside climate using appropriate actuators. The results of the simulation showed the efficiency of the developed FLC in meeting the requirements of factories in terms of temperature and humidity and in obtaining a favorable microclimate for the agricultural production of tomato plants.

Energy Management Approach
In this part, we present the main contribution of this work, which is represented by the coupling of photovoltaic energy in the agricultural sector and by efficiency in the control of the parameters of the agricultural greenhouse.
An agricultural greenhouse requires a lot of energy over the production period in order to promote optimal control of the inside climate.
During the day, the temperature of the environment frequently reaches a high value, so the inside air temperature of the agricultural greenhouse exceeds the predefined set point. Since there is no internal relative humidity, Figures 15b and 17a show the need for ventilation and humidification during the day, when solar radiation reaches a high value. The presence of photovoltaic energy provides an alternative use to avoid burdening the electrical grid; moreover, a solar-powered ventilation system based on a variable speed fan can be adopted using a vector control optimized by fuzzy logic to manage the ventilation flow rate in order to obtain robust control.

System Description
The PV-based ventilation system ( Figure 18) is constituted by the following:


A PV generator, whose maximum power is assured by the maximum power point tracking MPPT command based on the perturb and observe (P&O) method;  A power stage consisting of a continuous-to-continuous converter, called single ended primary inductor converter "SEPIC", and an inverter (red block);  An asynchronous motor that drives the fan; and  A vector control optimized by fuzzy logic for asynchronous motor speed control (yellow block).

Energy Management Approach
In this part, we present the main contribution of this work, which is represented by the coupling of photovoltaic energy in the agricultural sector and by efficiency in the control of the parameters of the agricultural greenhouse.
An agricultural greenhouse requires a lot of energy over the production period in order to promote optimal control of the inside climate.
During the day, the temperature of the environment frequently reaches a high value, so the inside air temperature of the agricultural greenhouse exceeds the predefined set point. Since there is no internal relative humidity, Figures 15b and 17a show the need for ventilation and humidification during the day, when solar radiation reaches a high value. The presence of photovoltaic energy provides an alternative use to avoid burdening the electrical grid; moreover, a solar-powered ventilation system based on a variable speed fan can be adopted using a vector control optimized by fuzzy logic to manage the ventilation flow rate in order to obtain robust control.

System Description
The PV-based ventilation system ( Figure 18) is constituted by the following: • A PV generator, whose maximum power is assured by the maximum power point tracking MPPT command based on the perturb and observe (P&O) method; • A power stage consisting of a continuous-to-continuous converter, called single ended primary inductor converter "SEPIC", and an inverter (red block); • An asynchronous motor that drives the fan; and • A vector control optimized by fuzzy logic for asynchronous motor speed control (yellow block).

Parameters of the PV Modules
The PV generator consists of four series-connected modules. Some parameters of the datasheet of the PV module are shown in Table 3 under standard test conditions (STCs) [30]. The current-voltage (I-V) and power-voltage (P-V) curves of Figure 19 describe the behavior of the PV generator under the STCs (G = 1000 W/m 2 and the ambient temperature T = 25 °C).

Parameters of the PV Modules
The PV generator consists of four series-connected modules. Some parameters of the datasheet of the PV module are shown in Table 3 under standard test conditions (STCs) [30]. The current-voltage (I-V) and power-voltage (P-V) curves of Figure 19 describe the behavior of the PV generator under the STCs (G = 1000 W/m 2 and the ambient temperature T = 25 • C).

Parameters of the PV Modules
The PV generator consists of four series-connected modules. Some parameters of the datasheet of the PV module are shown in Table 3 under standard test conditions (STCs) [30]. The current-voltage (I-V) and power-voltage (P-V) curves of Figure 19 describe the behavior of the PV generator under the STCs (G = 1000 W/m 2 and the ambient temperature T = 25 °C).

SEPIC Converter
The SEPIC converter chosen for this application is similar to a buck-boost converter, but it has the advantage of noninverted output. SEPIC essentially consists of three capacitors (Cin, Cout, and Cp), two coupled inductors (L1 and L2), a diode (D1), and a transistor (Q1). The output voltage pins are highlighted in red in Figure 21. In the proposed test lab greenhouse, the converter model DV51-322-2K2 is used, with the following values of the components:
Moreover, the efficiency varies from 0.78 to 0.91, with the maximum value being valid for nominal conditions.

DC/AC Inverter
Asynchronous machine speed control systematically includes the use of a static power converter to vary the speed of the inverter. By means of a well-tuned sequence of opening and closing the switching cells (using a DC voltage source), the static converter can switch the current in the phases of the machine in order to obtain a perfectly controllable three-phase current system. The inverter is controlled by a pulse width modulation strategy. Figure 22 shows a schematic diagram of the inverter feeding a three-phase motor, while the technical specifications are reported in Reference [31]. The three arms of the inverter are controlled by the vector ( ) , with

SEPIC Converter
The SEPIC converter chosen for this application is similar to a buck-boost converter, but it has the advantage of noninverted output. SEPIC essentially consists of three capacitors (Cin, Cout, and Cp), two coupled inductors (L1 and L2), a diode (D1), and a transistor (Q1). The output voltage pins are highlighted in red in Figure 21.

SEPIC Converter
The SEPIC converter chosen for this application is similar to a buck-boost converter, but it has the advantage of noninverted output. SEPIC essentially consists of three capacitors (Cin, Cout, and Cp), two coupled inductors (L1 and L2), a diode (D1), and a transistor (Q1). The output voltage pins are highlighted in red in Figure 21. In the proposed test lab greenhouse, the converter model DV51-322-2K2 is used, with the following values of the components:
Moreover, the efficiency varies from 0.78 to 0.91, with the maximum value being valid for nominal conditions.

DC/AC Inverter
Asynchronous machine speed control systematically includes the use of a static power converter to vary the speed of the inverter. By means of a well-tuned sequence of opening and closing the switching cells (using a DC voltage source), the static converter can switch the current in the phases of the machine in order to obtain a perfectly controllable three-phase current system. The inverter is controlled by a pulse width modulation strategy. Figure 22 shows a schematic diagram of the inverter feeding a three-phase motor, while the technical specifications are reported in Reference [31]. The three arms of the inverter are controlled by the vector ( ) , with In the proposed test lab greenhouse, the converter model DV51-322-2K2 is used, with the following values of the components: Moreover, the efficiency varies from 0.78 to 0.91, with the maximum value being valid for nominal conditions.

DC/AC Inverter
Asynchronous machine speed control systematically includes the use of a static power converter to vary the speed of the inverter. By means of a well-tuned sequence of opening and closing the switching cells (using a DC voltage source), the static converter can switch the current in the phases of the machine in order to obtain a perfectly controllable three-phase current system. The inverter is controlled by a pulse width modulation strategy. Figure 22 shows a schematic diagram of the inverter feeding a three-phase motor, while the technical specifications are reported in Reference [31]. The three arms of the inverter are controlled by the vector ρA ρB ρC where Pwm1, 2, and 3 represent the control signals' pulse width modulation (PWM), which is generated by the command.
Appl. Sci. 2020, 10, x FOR PEER REVIEW 15 of 20 where Pwm1, 2, and 3 represent the control signals' pulse width modulation (PWM), which is generated by the command.

Vector Control Optimized by Fuzzy Logic
A vector command allows for controlling the motor speed, the electromotive flow, and the torque of a three-phase AC electric motor. In general, vector control consists of a PI controller that calculates the speed reference as a function of its nominal speed: this technique is not suitable for the speed regulation of a motor. Therefore, a fuzzy controller provided by a variable speed fan was developed to regulate the reference: this control strategy gave robustness to the proposed command. The calculation of the reference speed (using fuzzy logic based on measurements) is done based on the ventilation rate of the agricultural greenhouse (due to outdoor climate conditions). The ventilation rate depends on the fan speed, so the desired speed is the input of the vector control. The fan speed is calculated by the linear fan law described by the equation [32] where k is a constant and V and w are the required air flow rate (m 3 /min) and the motor speed in RPMs, respectively. In the hot season, the temperature exceeds the predefined set point; thus, the ventilation system operates at a maximum speed to refresh the indoor climate and to lower the temperature around its set point. When this on-off sequence is iterated several times to regulate the temperature, the energy consumption is high. The main advantage of this technique is its easy control algorithm, because only the stator current and voltage are measured in estimating the torque and flux [31]. This control strategy allows for a reduction in energy consumption. For the ventilation system, the use of this control is justified in view of its electrical performance, robustness, and simplicity. The structure of the vector control implemented in the proposed model is represented in Figure 23.

Vector Control Optimized by Fuzzy Logic
A vector command allows for controlling the motor speed, the electromotive flow, and the torque of a three-phase AC electric motor. In general, vector control consists of a PI controller that calculates the speed reference as a function of its nominal speed: this technique is not suitable for the speed regulation of a motor. Therefore, a fuzzy controller provided by a variable speed fan was developed to regulate the reference: this control strategy gave robustness to the proposed command. The calculation of the reference speed (using fuzzy logic based on measurements) is done based on the ventilation rate of the agricultural greenhouse (due to outdoor climate conditions). The ventilation rate depends on the fan speed, so the desired speed is the input of the vector control. The fan speed is calculated by the linear fan law described by the equation [32] where k is a constant and V and w are the required air flow rate (m 3 /min) and the motor speed in RPMs, respectively. In the hot season, the temperature exceeds the predefined set point; thus, the ventilation system operates at a maximum speed to refresh the indoor climate and to lower the temperature around its set point. When this on-off sequence is iterated several times to regulate the temperature, the energy consumption is high. The main advantage of this technique is its easy control algorithm, because only the stator current and voltage are measured in estimating the torque and flux [31]. This control strategy allows for a reduction in energy consumption. For the ventilation system, the use of this control is justified in view of its electrical performance, robustness, and simplicity. The structure of the vector control implemented in the proposed model is represented in Figure 23.   Figure 23) that determines the electromagnetic field torque Cem, using the speed measurement and its reference.

Simulations
The entire system in Figure 23 was simulated in a MATLAB/Simulink environment. The ventilation system was stimulated for a period of two days, with a database of real solar radiation. Motor speed, PV power, and voltage under the control MPPT, solar radiation, and ventilation rate are shown in Figure 25.
The simulation results showed that the control strategy's efficiency and robustness were developed such that during the day, the solar radiation was relatively high (see Figure 25e), and a constant voltage of 260 V (see Figure 25a) (provided by the photovoltaic generator) confirmed the efficiency of the fuzzy MPPT control. This voltage guaranteed a power value of 800 W (Figure 25b) in powering the asynchronous motor that drives the fan at a variable speed. The inside temperature for periods during the day exceeded the reference point, and a high ventilation flow rate of 50 m 3 /min (see Figure 25c) was necessary to cool the indoor climate. On the other hand, the active fan had a maximum speed of 480 RPM, as shown in Figure 25d, which was controlled by the fuzzy vector control and lowered the heat accumulation in the indoor climate.
The results obtained showed the speed and performance of the speed control system in different periods and the usefulness of the developed fuzzy controller in meeting the speed instructions.   Figure 23) that determines the electromagnetic field torque Cem, using the speed measurement and its reference.   Figure 23) that determines the electromagnetic field torque Cem, using the speed measurement and its reference.

Simulations
The entire system in Figure 23 was simulated in a MATLAB/Simulink environment. The ventilation system was stimulated for a period of two days, with a database of real solar radiation. Motor speed, PV power, and voltage under the control MPPT, solar radiation, and ventilation rate are shown in Figure 25.
The simulation results showed that the control strategy's efficiency and robustness were developed such that during the day, the solar radiation was relatively high (see Figure 25e), and a constant voltage of 260 V (see Figure 25a) (provided by the photovoltaic generator) confirmed the efficiency of the fuzzy MPPT control. This voltage guaranteed a power value of 800 W (Figure 25b) in powering the asynchronous motor that drives the fan at a variable speed. The inside temperature for periods during the day exceeded the reference point, and a high ventilation flow rate of 50 m 3 /min (see Figure 25c) was necessary to cool the indoor climate. On the other hand, the active fan had a maximum speed of 480 RPM, as shown in Figure 25d, which was controlled by the fuzzy vector control and lowered the heat accumulation in the indoor climate.
The results obtained showed the speed and performance of the speed control system in different periods and the usefulness of the developed fuzzy controller in meeting the speed instructions.

Simulations
The entire system in Figure 23 was simulated in a MATLAB/Simulink environment. The ventilation system was stimulated for a period of two days, with a database of real solar radiation. Motor speed, PV power, and voltage under the control MPPT, solar radiation, and ventilation rate are shown in Figure 25.
The simulation results showed that the control strategy's efficiency and robustness were developed such that during the day, the solar radiation was relatively high (see Figure 25e), and a constant voltage of 260 V (see Figure 25a) (provided by the photovoltaic generator) confirmed the efficiency of the fuzzy MPPT control. This voltage guaranteed a power value of 800 W (Figure 25b) in powering the asynchronous motor that drives the fan at a variable speed. The inside temperature for periods during the day exceeded the reference point, and a high ventilation flow rate of 50 m 3 /min (see Figure 25c) was necessary to cool the indoor climate. On the other hand, the active fan had a maximum speed of 480 RPM, as shown in Figure 25d, which was controlled by the fuzzy vector control and lowered the heat accumulation in the indoor climate.
The results obtained showed the speed and performance of the speed control system in different periods and the usefulness of the developed fuzzy controller in meeting the speed instructions.

Conclusions
This paper presents a control system for an agricultural greenhouse powered by a PV system. The dynamic model was presented and experimentally validated. The simulations showed an agreement between the calculated data and the measured data. A fuzzy controller was developed for the smart control of the indoor temperature and humidity, which increases the indoor air temperature overnight to 15 °C and decreases the temperature during the day to 24 °C, keeping a constant value of relative humidity of 70% during the day and 80% during the night. The electrical feeding of the asynchronous motor that drives the variable speed fan is guaranteed by a PV system, with the aim of significantly reducing the use of grid utilities, which results in lower agricultural costs. The power delivered by the photovoltaic generator is 800 W, which is sufficient for the operation of the engine during the day, because the engine absorbs 700 W. A fuzzy vector control was designed for the purpose of controlling the ventilation speed. The simulation results showed the efficiency and the robustness of the fuzzy controller, which guarantees a maximum ventilation speed of 450 RPM. Although the proposed model was applied to the cultivation of a specific plant (tomato plants) (fixed thresholds of temperature and humidity), it can also be easily extended to other typologies of cultivation. In fact, the values of the geometric and physical parameters of the greenhouse, the threshold values of temperature and humidity, the power of both electrical loads and the PV plant,

Conclusions
This paper presents a control system for an agricultural greenhouse powered by a PV system. The dynamic model was presented and experimentally validated. The simulations showed an agreement between the calculated data and the measured data. A fuzzy controller was developed for the smart control of the indoor temperature and humidity, which increases the indoor air temperature overnight to 15 • C and decreases the temperature during the day to 24 • C, keeping a constant value of relative humidity of 70% during the day and 80% during the night. The electrical feeding of the asynchronous motor that drives the variable speed fan is guaranteed by a PV system, with the aim of significantly reducing the use of grid utilities, which results in lower agricultural costs. The power delivered by the photovoltaic generator is 800 W, which is sufficient for the operation of the engine during the day, because the engine absorbs 700 W. A fuzzy vector control was designed for the purpose of controlling the ventilation speed. The simulation results showed the efficiency and the robustness of the fuzzy controller, which guarantees a maximum ventilation speed of 450 RPM. Although the proposed model was applied to the cultivation of a specific plant (tomato plants) (fixed thresholds of temperature and humidity), it can also be easily extended to other typologies of cultivation. In fact, the values of the geometric and physical parameters of the greenhouse, the threshold values of temperature and humidity, the power of both electrical loads and the PV plant, and the constraints of the FLC can be modified to extend the use of the proposed model to any greenhouse with other characteristics and other cultivations. Thus, in our opinion, the proposed model can be useful both for greenhouse designers-during the first design stage-and for researchers who focus on greenhouse R&D. Indeed, it is worth noting that greenhouses are increasingly taking on a crucial role in circular economies and in sustainable social and economic development.