Design and Implementation of an IoT System for Smart Energy Consumption and Smart Irrigation in Tunnel Farming

: Efﬁcient and cost effective ways of irrigation have emerged as the need of the hour due to limited sweet water resources, especially the countries that are seriously hit by a lack of sweet water reservoirs. The majority of the water is wasted due to inefﬁcient ways of watering plants. In this paper, we propose an intelligent approach for efﬁcient plant irrigation that has a database of daily water needs of a type of plant and decides the amount of water for a plant type on the basis of the current moisture in soil, humidity, and time of the day. This approach not only saves sweet water by efﬁcient utilization, but also supports smart consumption of energy. Our approach employs IoT and a set of sensors to efﬁciently record plant data and their watering needs and the approach is implemented with a mobile phone application interface that is used to continuously monitor and control the efﬁcient watering system. The results of this study are easy to reproduce as the sensors used are cheap and easy to access. The study discusses in this paper is experimented on small area (such as tunnel farm) but the results of the experiments show that the used approach can be generalized and can be used for large size ﬁelds for efﬁcient irrigation. The results of the experiments also outperform the manual approach and the similar approaches for sensor based irrigation systems.


Introduction
Plastic tunnel farming is one of the types of farming in comparison to various types of green farming in terms of structure (tunnel shaped, shade houses, screen houses, etc.) and technology (low technology, mid technology, and high technology) [1].A plastic tunnel is a conventionally small sized greenhouse-like structure that covers the plants along the row.Plastic tunnel farming is successful in developing countries due to their low cast, off-season products and better efficiency in terms of high productivity.To design and develop a technically successful tunnel involve various variables such as tunnel material, tunnel-design, light management, atmosphere management, plant irrigation, choice of plants, fertilizers consumption, etc. [2].All these variables need to be handled carefully to achieve the targets of quality and high production that are an ultimate goal of tunnel farming.However, the aspect of tunnel farming that is studied in this paper is the intelligent and smart irrigation of plants in tunnel systems.The intelligent and smart irrigation aims at intelligent utilization of water to fulfill the watering needs of a particular plant and smart utilization of water to provide water to a plant in-time [3][4][5][6][7].
An intelligent and smart system for tunnel farming has become a need due to the scarcity of sweet water reservoirs is a main bottleneck in the modern agriculture.The efficient utilization of Energies 2018, 11, 3427 2 of 18 limited sweet water reservoirs has emerged as an eye catching challenge in recent years.To address this challenge, sensor-based irrigation systems for gardens and small-scale farms have been presented in the recent past [5] and they seemingly address this problem up to some extent, however the existing smart systems ae not intelligent and smart enough to provide maximum throughput of such modern irrigation systems.Just adding sensors to an irrigation system is not sufficient.There is need of a few other important components such as intelligent techniques (such as machine learning, fuzzy logic, etc.) for improved decision making, sensing technologies (such as IoT, sensors, etc.), positioning technologies (such as GPS, GIS, etc.), communication and cellular (internet, cloud, web, etc.) technologies, software and mobile applications (such as decision support systems, etc.), and big data analytics platforms [6,7].Figure 1 shows these important components required to design and develop a smart tunnel farming system.
An intelligent and smart system for tunnel farming has become a need due to the scarcity of sweet water reservoirs is a main bottleneck in the modern agriculture.The efficient utilization of limited sweet water reservoirs has emerged as an eye catching challenge in recent years.To address this challenge, sensor-based irrigation systems for gardens and small-scale farms have been presented in the recent past [5] and they seemingly address this problem up to some extent, however the existing smart systems ae not intelligent and smart enough to provide maximum throughput of such modern irrigation systems.Just adding sensors to an irrigation system is not sufficient.There is need of a few other important components such as intelligent techniques (such as machine learning, fuzzy logic, etc.) for improved decision making, sensing technologies (such as IoT, sensors, etc.), positioning technologies (such as GPS, GIS, etc.), communication and cellular (internet, cloud, web, etc.) technologies, software and mobile applications (such as decision support systems, etc.), and big data analytics platforms [6][7].Figure 1 shows these important components required to design and develop a smart tunnel farming system.Traditional tunnel farms use drip irrigation, overhead irrigation or a sprinkler irrigation method for better results.These typed of irrigation is better than normal flooding methods.Various irrigation methods provide various levels of water and energy efficiency [8].The surface irrigation and level irrigation methods provide low water and energy efficiency.The sub-irrigation, overhead irrigation and sprinkler irrigation methods provide low to medium efficiency.The sprinkler and drip irrigation methods provide similar energy efficiency, but drip irrigation is more water efficient than sprinkler irrigation [9].Table 1 shows the consumption of water and energy efficiency of the various types of irrigation methods:  Traditional tunnel farms use drip irrigation, overhead irrigation or a sprinkler irrigation method for better results.These typed of irrigation is better than normal flooding methods.Various irrigation methods provide various levels of water and energy efficiency [8].The surface irrigation and level irrigation methods provide low water and energy efficiency.The sub-irrigation, overhead irrigation and sprinkler irrigation methods provide low to medium efficiency.The sprinkler and drip irrigation methods provide similar energy efficiency, but drip irrigation is more water efficient than sprinkler irrigation [9].Table 1 shows the consumption of water and energy efficiency of the various types of irrigation methods: Due to the limited sweet water resources, in particular countries that are seriously hit by lack of sweet water reservoirs need an efficient and cost effective method of smart irrigation.As Table 1 shows, that the best irrigation method can provide 80 to 90% water savings in favourable conditions.Additionally, the previous studies addressing this problems with the help of sensors just achieved minor improvements.Table 2 shows that the majority of sensor-based smart irrigation systems are saving around 500 to 800 mm water [3][4][5][6][7][8].However, to achieve water saving efficiency near to 100% the water consumption saving should be more than 1000 mm.Additionally, these studies are area specific as well.After a detailed study, we have identified the four reasons of less water saving of the existing approaches [3][4][5][6][7][8][9][10], attributed as below:

•
Existing approaches mostly consider only one parameter i.e., a soil moisture sensor is used to measure the water needs of a plant.There is a need to consider other parameters as well such as type of plant, time of watering, humidity in the air, light intensity, type of soil, etc.

•
The existing approaches rely on sensor data and use simplistic approaches to decide the watering quantity and schedule of a plant without considering the plant type as different types of plants have different needs of water and weather conditions.Similarly, soil moisture levels for different plants are different in different weather and different areas.

•
Due to the continuous usage of sensors, the energy consumption is very high.Existing approaches of sensor-based irrigation systems do not focus on efficient energy consumption.

•
The previous approaches are used for small farms and small gardens and there in no particular study or approach to address the irrigation issues of tunnel farming.
In this paper, we propose an intelligent approach for efficient plant irrigation that has a database of the daily water needs of a plant type and decides the amount of water for that plant-type on the basis of the current moisture in the soil, humidity, and time of the day.This approach not only saves sweet water by efficient utilization, but also supports smart consumption of energy.Our approach employs IoT and a set of sensors to efficiently record plant data and their need for watering and the approach is implemented with a mobile phone application interface that is used to continuously monitor and control the efficient watering system.The proposed approach above mentioned four key issues in a robust manner.The following is the description of all four points addressed by the proposed approach:

•
The proposed approach uses four sensors: a soil moisture sensor, a humidity sensor, a temperature sensor and a light sensor for better efficiency.Additionally, the watering needs of a plant are also stored in a knowledge base.

•
Our approach uses an intelligent method based on a fuzzy logic approach to decide the watering quantity and schedule of a plant considering the plant's type, weather conditions, soil moisture level, humidity, temperature, etc.

•
Our approach focuses on efficient energy consumption as it does not turn ON all the sensors all the time.The sensors are periodically turned ON and turned OFF as needed.An intelligent algorithm handles the efficient utilization of sensors to ensure efficient energy consumption and to keep the operating cost of this system low.

•
The proposed approach specifically addresses irrigation issues of tunnel forming and can be equally efficiently used with either a sprinkling method or a drip irrigation method.
The results of this study are easy to reproduce as the sensors used are cheap and easy to access.The study discusses in this paper is experimented on small area (such as small tunnel farms, home gardens, etc.) but the results of the experiments show that the used approach can be generalized and can be used for the efficient irrigation of large size fields.
This paper targets a smart irrigation system for tunnel farming using IoT for not only saving energy, but also saving water.The rest of the paper is organized into a set of section: Section 2 discusses the work related to irrigation for tunnel farming and sensor-based irrigation.Section 3 presents the architecture and working of the proposed smart irrigation system.Section 4 presents implementation Energies 2018, 11, 3427 4 of 18 details along the experimental setup.The results and a discussion are given in Section 5 and the paper is concluded in Section 6.

Literature Review
Tunnel farming has become a successful solution of the recent times that not only enables farmers to produce out-of-season vegetables, but also allows farming with limited water resources in severe weather conditions [1,2].Though sprinkling and drip irrigation methods are frequently used for tunnel farming, even then uneven watering can put a plant under stress and lead to slow growth.Since water can quickly evaporate from the soil surface, especially in areas facing very hot weather, tunnel farming becomes the best solution.However, equal, timely and calculated watering need are still a challenge in tunnel farming.In the recent past, a few sensor-based irrigation solutions [3][4][5][6][7][8][9][10] have been presented (see Table 2), however, the previous methods are only focused on soil moisture and presented limited solutions.During the literature review it was found that drip irrigation and sprinkler irrigation are the two most recommended methods by experts in tunnel farming.These methods are comparatively better than other conventional methods.However, these methods are not highly efficient either in terms of water consumption or energy consumption.In the recent past a few sensor-based irrigation systems were presented [3][4][5][6][7][8][9][10] as shown in Table 2.
Qualls et al. presented a smart irrigation system that used soil moisture sensors for urban landscape irrigation.However, he relied on only one sensor and was able to save a limited quantity of water.A similar work was presented in 2007 by Vasanth, where he evaluated the performance of evapotranspiration and moisture of soil in turf.He used two sensors: an evapotranspiration (ET) one and a soil moisture sensor (SMS).However, the results of his experiments were not satisfactory.A similar set of sensors was also used by McCready in 2009 [5] for saving water on St. Augustine grass.The results were comparatively better than [4] due to the better approach.
Xiao et al. presented a smart water-saving irrigation system using a set of self-designed sensors [6] and their experiments targeted precise irrigation for agriculture.The approach was based on a wireless sensor network and generated low water saving results.Cardenas-Lailhacar presented a system to automatically identify dry conditions and water plants using an automated approach of irrigation on Bermuda grass.Similar contributions were made by Kumar et  conditions.Additionally, the previous studies [11][12][13][14][15][16][17][18][19] addressing this problem with the help of sensors just achieved minor improvements.
The related work discussed above and tabulated in Table 2 shows that the majority of sensorbased smart irrigation systems are not particularly efficient at saving water.Additionally, these studies are area-specific as well.After a detailed study, we have identified the four causes of less water savings of the existing approaches.Existing approaches [20][21][22][23] mostly consider only one parameter i.e., using a soil moisture sensor to measure the water needs of a plant.There is need to consider other parameters as well, such as the type of plant, time of watering, humidity in the air, light intensity, type of soil, etc.The existing approaches rely on sensor data and use simplistic approaches to decide the watering quantity and schedule of a plant without considering plant type as different types of plants have different need of water and weather conditions [24][25][26][27].Similarly, soil moisture level for different plants is different in different weathers and different areas.Due to the continuous usage of sensors, the energy consumption is very high [28,29].
Existing approaches of sensor-based irrigation systems do not focus on efficient energy consumption.The previous approaches [30,31] are designed for small farms and small gardens and there in no particular study or approach to address the irrigation issues of tunnel farming.Additionally, the role of sensor network economy is really important, as discussed by Konyha and Bányai [32].Such a sensor-based system can be useful for improved economics as well.

Architecture of Smart Irrigation System
The proposed smart irrigation system is designed with the ability of intelligent decision making in terms of watering the plant or not on the basis of considering features like the plant type, weather conditions, soil moisture level, humidity, temperature, etc.Our approach focuses on efficient energy consumption as it does not turn ON all the sensors all the time.The sensors are periodically turned ON and turned OFF as needed.An intelligent algorithm handles the efficient utilization of sensors to ensure efficient energy consumption and to keep the operating cost of this system low.The proposed approach specifically addresses the irrigation issues of tunnel farming and can be equally efficiently when used with either a sprinkling method or a drip irrigation method.The architecture of the proposed system is shown in Figure 2. water savings of the existing approaches.Existing approaches [20][21][22][23] mostly consider only one parameter i.e., using a soil moisture sensor to measure the water needs of a plant.There is need to consider other parameters as well, such as the type of plant, time of watering, humidity in the air, light intensity, type of soil, etc.The existing approaches rely on sensor data and use simplistic approaches to decide the watering quantity and schedule of a plant without considering plant type as different types of plants have different need of water and weather conditions [24][25][26][27].Similarly, soil moisture level for different plants is different in different weathers and different areas.Due to the continuous usage of sensors, the energy consumption is very high [28,29].
Existing approaches of sensor-based irrigation systems do not focus on efficient energy consumption.The previous approaches [30,31] are designed for small farms and small gardens and there in no particular study or approach to address the irrigation issues of tunnel farming.Additionally, the role of sensor network economy is really important, as discussed by Konyha and Bányai [32].Such a sensor-based system can be useful for improved economics as well.

Architecture of Smart Irrigation System
The proposed smart irrigation system is designed with the ability of intelligent decision making in terms of watering the plant or not on the basis of considering features like the plant type, weather conditions, soil moisture level, humidity, temperature, etc.Our approach focuses on efficient energy consumption as it does not turn ON all the sensors all the time.The sensors are periodically turned ON and turned OFF as needed.An intelligent algorithm handles the efficient utilization of sensors to ensure efficient energy consumption and to keep the operating cost of this system low.The proposed approach specifically addresses the irrigation issues of tunnel farming and can be equally efficiently when used with either a sprinkling method or a drip irrigation method.The architecture of the proposed system is shown in Figure 2.

Sensors Based Data Collection
As shown in Figure 2, the first step in the proposed system is to collect data from sensors such as soil moisture, air humidity, air temperature, light intensity, etc.The proposed system has a device

Sensors Based Data Collection
As shown in Figure 2, the first step in the proposed system is to collect data from sensors such as soil moisture, air humidity, air temperature, light intensity, etc.The proposed system has a device and perception layer that includes all the hardware devices such as sensors, actuators, microcontrollers and Wi-Fi devices.All the networking components, WiFi and Bluetooth modules are managed at the network and connectivity layer.Then the device management, cloud storage is handled at the management layer to provide channels for transmission of data between users (farmers) and hardware devices and cloud through remote server also provides resource handling and high-level processing.An application layer resides at top that provide features like irrigation scheduling, plant monitoring, light controlling and other recommendation services.Figure 3 explains the working of sensors and the process of collection of data and storage at data server for further analytics.microcontrollers and Wi-Fi devices.All the networking components, WiFi and Bluetooth modules are managed at the network and connectivity layer.Then the device management, cloud storage is handled at the management layer to provide channels for transmission of data between users (farmers) and hardware devices and cloud through remote server also provides resource handling and high-level processing.An application layer resides at top that provide features like irrigation scheduling, plant monitoring, light controlling and other recommendation services.Figure 3 explains the working of sensors and the process of collection of data and storage at data server for further analytics.Figure 3 represents the architectural design view of the physical components of the system.It contains all the hardware devices and architecture of the smart tunnel farm system as deployed in a real world environment.As shown in Figure 3 on the leftmost side there are light and moisture sensors which are connected through an analog input with a microcontroller the same as humidity and temperature sensors are connected through a digital input.Here, the microcontroller works as a centralized device that takes inputs from various sensors and transmits the values to a server through the internet.The server processes the data provided by microcontroller so that users can view it through an Android application or a web browser in response to a user performing some actions which will be transmitted to the server through the internet [20], then the server sends the specified commands to the microcontroller and finally the actuators perform the action.
The following section explains the workings of a fuzzy logic-based decision support system that is deployed at the server and helps the smart irrigation system make decisions regarding water scheduling and water quantity with respect to the type of a plant and the type of soil.Using fuzzy logic to decide water scheduling and water quantity with respect to the type of a plant and type of the soil is a novel idea.This system is fully automatic.The following sections describe the technical details of the proposed smart irrigation system for tunnel farming.

Fuzzy Logic Based Smart Irrigation System
The smart irrigation system gets real time inputs from sensors implanted in a smart tunnel farm to make recommendations for irrigation scheduling, quantity.A microcontroller (see Figure 3) grabs data from sensors and transmit it to a web server where a fuzzy logic [33]-based decision support system makes a decision on the basis of the predefined conditions and current state of plants grabbed through sensors.Then the values of the sensors are processed on the server and list of plants with their feasibility rating is sent to the user's mobile, from where users can plan a watering schedule for the plants.When the date and time of a predicted schedule arrives, or the water level gets lower in the tunnel farm, our system notifies the user and sets a water pump to its ON state for sufficient  It contains all the hardware devices and architecture of the smart tunnel farm system as deployed in a real world environment.As shown in Figure 3 on the leftmost side there are light and moisture sensors which are connected through an analog input with a microcontroller the same as humidity and temperature sensors are connected through a digital input.Here, the microcontroller works as a centralized device that takes inputs from various sensors and transmits the values to a server through the internet.The server processes the data provided by microcontroller so that users can view it through an Android application or a web browser in response to a user performing some actions which will be transmitted to the server through the internet [20], then the server sends the specified commands to the microcontroller and finally the actuators perform the action.
The following section explains the workings of a fuzzy logic-based decision support system that is deployed at the server and helps the smart irrigation system make decisions regarding water scheduling and water quantity with respect to the type of a plant and the type of soil.Using fuzzy logic to decide water scheduling and water quantity with respect to the type of a plant and type of the soil is a novel idea.This system is fully automatic.The following sections describe the technical details of the proposed smart irrigation system for tunnel farming.

Fuzzy Logic Based Smart Irrigation System
The smart irrigation system gets real time inputs from sensors implanted in a smart tunnel farm to make recommendations for irrigation scheduling, quantity.A microcontroller (see Figure 3) grabs data from sensors and transmit it to a web server where a fuzzy logic [33]-based decision support system makes a decision on the basis of the predefined conditions and current state of plants grabbed through sensors.Then the values of the sensors are processed on the server and list of plants with their Energies 2018, 11, 3427 7 of 18 feasibility rating is sent to the user's mobile, from where users can plan a watering schedule for the plants.When the date and time of a predicted schedule arrives, or the water level gets lower in the tunnel farm, our system notifies the user and sets a water pump to its ON state for sufficient watering of plants.The working of the proposed fuzzy logic system designed for the smart irrigation system is shown in Figure 4. watering of plants.The working of the proposed fuzzy logic system designed for the smart irrigation system is shown in Figure 4.The fuzzy logic system developed in the proposed smart irrigation system is composed of three modules: a fuzzification module, an inference engine and a defuzzification module.The fuzzy logic system works by developing a universe of discourse (U) that is a membership function.This universe of discourse U and an interval of U is represented by mS.According to [34], mS(e) is a membership function that that is based on a set of ordered pairs of elements e and probability of e that belongs to S. The proposed Smart irrigation system takes five inputs: temperature, time, humidity, light, and moisture denoted by a fuzzy subset of S i.e., A, B, C, D, and E, respectively.Here, temperature is denoted by a variable A, humidity is donated by a variable B, light is denoted by a variable C and moisture is denoted by a variable D. For these five variables, mA(x), mB(x), mC(x), mD(x) denote degree of membership of x in A, B, C, and D variables, respectively.Equations ( 1) and ( 2) showing the fuzzy intersection and union set, are given below: The decision-making ability of a fuzzy logic system is supported by a defined rule set.Abovementioned Equations ( 2) and (3) help in computing the strength of a decision rule.Conventionally, value of a linguistic variable is described as a fuzzy set [34]. in the defined universe of discourse of a fuzzy logic system, each input value is mapped to a membership value in the range of 0 and 1 by a typical membership function [35].Here, if-then rules are used to implement the fuzzy rule set that represent knowledge in the proposed smart watering system.The components and workflow of the fuzzy logic module is shown in Figure 4 as it has the three basic components: fuzzifier, rule and inference, and defuzzifier.

The Fuzzification Module
The proposed fuzzy logic system works by following a typical methodology.A fuzzification module receives input crisp values from a set of sensors.The processes of converting these crisp The fuzzy logic system developed in the proposed smart irrigation system is composed of three modules: a fuzzification module, an inference engine and a defuzzification module.The fuzzy logic system works by developing a universe of discourse (U) that is a membership function.This universe of discourse U and an interval of U is represented by mS.According to [34], mS(e) is a membership function that that is based on a set of ordered pairs of elements e and probability of e that belongs to S. The proposed Smart irrigation system takes five inputs: temperature, time, humidity, light, and moisture denoted by a fuzzy subset of S i.e., A, B, C, D, and E, respectively.Here, temperature is denoted by a variable A, humidity is donated by a variable B, light is denoted by a variable C and moisture is denoted by a variable D. For these five variables, mA(x), mB(x), mC(x), mD(x) denote degree of membership of x in A, B, C, and D variables, respectively.Equations ( 1) and ( 2) showing the fuzzy intersection and union set, are given below: The decision-making ability of a fuzzy logic system is supported by a defined rule set.Abovementioned Equations ( 2) and (3) help in computing the strength of a decision rule.Conventionally, value of a linguistic variable is described as a fuzzy set [34]. in the defined universe of discourse of a fuzzy logic system, each input value is mapped to a membership value in the range of 0 and 1 by a typical membership function [35].Here, if-then rules are used to implement the fuzzy rule set that represent knowledge in the proposed smart watering system.The components and workflow of the fuzzy logic module is shown in Figure 4 as it has the three basic components: fuzzifier, rule and inference, and defuzzifier.

The Fuzzification Module
The proposed fuzzy logic system works by following a typical methodology.A fuzzification module receives input crisp values from a set of sensors.The processes of converting these crisp values to the fuzzy values is mentored by a membership function.The used membership function handles multiple variables such as temperature_change_rate, humidity_change_rate, light_change_rate, and moisture_change_rate.The values of these variables attribute as low, medium, and high, while value of timer variable is attributes as short or long.The used fuzzified value set is represented in Equation ( 4): The concept of "kernel of fuzzification" is implemented using relation of fuzzy set K(x i ) as shown in Equation (3).The fuzzy set K(x i ) is implemented using µ i constant and x i .The used fuzzy logic module in smart irrigation system the process of fuzzification is implemented using the triangular membership function [35].The triangular membership function is a typical choice in multivariant decision support systems.The Equation (4) shows the typical structure of a triangular membership function that handles three valued fuzzification system: The three parameters denoted in Equation ( 4) represent a membership function's lower boundary with variable a, peak with variable m and upper boundary with variable b.To find the minimum and maximum possession of these variables Equation (5), given below, is typically used: In our proposed fuzzy logic module for the smart irrigation system, Equations ( 4) and ( 5) play an important role in the fuzzification phase.We have implemented these equations in MATLAB.These equations help in developing a set of four membership functions aimed at a set of input linguistic variables and a membership function for an output variable.The four membership functions are designed for the input parameters such as temperature_change_rate, humidity_change_rate, light_change_rate, and moisture_change_rate.A membership function is also defined for the output linguistic variable water_need.The MATLAB Fuzzy Logic toolbox is used to define all these six membership functions help in the fuzzification process of all these six linguistic variables.

The Fuzzy Inference Module
A fuzzy inference module plays an important role in the decision-making process of the proposed smart watering system.A set of if-then rules were defined to work with the membership functions defined in the previous section.The fuzzy inference module used in our fuzzy logic system is mapped using Mamdani fuzzy inference system [35] concept and it maps the fuzzy inputs to a fuzzy output.The number of steps were followed to implement the proposed inference module using Mamdani fuzzy inference concept such to combine the fuzzified inputs, build a set of fuzzy rules, combine rule strength, apply output membership function, finally combine outputs to generate an output distribution and defuzzify the output membership function.The process of defuzzification is explained in Section 3.2.3.The defined fuzzy rules are implemented using a if-then statement for each rule.Equations ( 6) and ( 7) represent the used inference module behavior of four inputs and two rules stored in a rule-base: Energies 2018, 11, 3427 The fuzzy inference module works as described in [36].Once the four inputs are fuzzified by processing of the four input membership functions, the fuzzified inputs are combined to find the rule strength with the help of AND operator.The output membership function follows the in the previous section.The fuzzy inference module used in our fuzzy logic system is mapped using Mamdani fuzzy inference system [34] concept to process each rule and finally concludes a fuzzy output.

The Defuzzification Module
The last step in implementation of the smart irrigation system is defuzzification.Since, a rule set is used to evaluate the output.The rules are applied to the fuzzified values and a fuzzy output is generated by a single fuzzy rule and that fuzzy output is converted to a scalar quantity.The proposed defuzzification module is based on centroid defuzzification method is as it provides with accurate result as shown in Equation ( 8): As shown in Equation ( 8), the defuzzified output is denoted by x* that is generated by µ i (x) for the output variable x.

Implementation Details
The smart irrigation system for tunnel farming was implemented in MATLAB.The system implemented in lab uses an Arduino UNO (ATmega328P) controller.The microcontroller receives data from sensors and forward to the fuzzy logic decision support system that is deployed the main server.Following section briefs the details of the sensors used to implement the proposed smart irrigation system for tunnel farming.

Used Hardware
The proposed smart irrigation system for tunnel farming uses a set of sensors to collect data from soil and air.For soil moisture, we have used the HL-69 Soil Hygrometer sensor.Similarly, for temperature and humidity, we have used an AM2302 DHT22 sensor.For light, the BH1750 FVI light sensor is used.A brief description of these sensors is given below:

HL-69 Soil Hygrometer Moisture Sensor
The HL-69 hygrometer is used to detect the humidity of the soil.It provides better reading than other soil moisture sensors.Experts recommend this sensor for real-time monitoring of the soil moisture of plants in a tunnel farm and to build an automatic irrigation system.A typical HL-69 hygrometer is shown in Figure 5.
The following are a few key features of the HL-69 Soil Hygrometer used for soil moisture sensing in a tunnel farm:

. AM2302 DHT22 Sensor
The DHT22 is a common and cheap sensor used for detecting the humidity in air and temperature.In our experiments, we have used AM2302 model of DHT22 sensors that provides a calibrated and accurate output.A typical AM2302 DGT22 sensor is shown in Figure 6.

AM2302 DHT22 Sensor
The DHT22 is a common and cheap sensor used for detecting the humidity in air and temperature.In our experiments, we have used AM2302 model of DHT22 sensors that provides a calibrated and accurate output.A typical AM2302 DGT22 sensor is shown in Figure 6.The DHT22 is a common and cheap sensor used for detecting the humidity in air and temperature.In our experiments, we have used AM2302 model of DHT22 sensors that provides a calibrated and accurate output.A typical AM2302 DGT22 sensor is shown in Figure 6.The BH1750 is a common sensor that can detect the light intensity.For implementation of the proposed system, the Bh1750 FVI light sensor is also used.A typical BH1750 FVI sensor is shown in Figure 7.
The BH1750 is a calibrated digital light sensor and it can measure the even small traces of light and can convert it into a 16-bit digital numeric value.It measures light intensity in the range of 0 to 65,535 Lux (L).In our experiments, we have used the H-resolution mode.The following are key features of BH1750 light sensor:

•
Chip: BH1750FVI The BH1750 is a common sensor that can detect the light intensity.For implementation of the proposed system, the Bh1750 FVI light sensor is also used.A typical BH1750 FVI sensor is shown in Figure 7.

Design of A Medium Size Tunnel Farm
There is no standard size for a high tunnel, but it should be large enough for the grower to plant, monitor and harvest the crop from inside the structure.Tunnels are usually 14 to 28 feet wide, 7 to 12 feet tall at the center (depending on width), and 48 to 96 feet long, or a length in any four-foot interval.It is usually recommended that tunnels should be no wider than 30 feet for cross ventilation and to avoid snow accumulation on the roof.Design of the testbed tunnel farm for smart irrigation is shown in Figure 8.

Design of A Medium Size Tunnel Farm
There is no standard size for a high tunnel, but it should be large enough for the grower to plant, monitor and harvest the crop from inside the structure.Tunnels are usually 14 to 28 feet wide, 7 to 12 feet tall at the center (depending on width), and 48 to 96 feet long, or a length in any four-foot interval.It is usually recommended that tunnels should be no wider than 30 feet for cross ventilation and to avoid snow accumulation on the roof.Design of the testbed tunnel farm for smart irrigation is shown in Figure 8.A typical moisture sensor normally reads diameter of 10-15 cm around the probe.However, the HL-69 hygrometer with long needles is sufficient to cover area of 2-3 feet in diameter.Here, the length of the sensor rod and number of sensors on the rod determines the area of coverage by a sensor.The measurements by HL-69 hygrometer are normally taken from 30 cm to 150 cm deep.To cover an area of 14 × 48 feet of a tunnel form, 30 to 36 sensors are sufficient.Similarly, two AM2302 sensors per field are suggested for sensing temperature and humidity.In a field of 14 × 48 feet, two BH1750 sensors are sufficient.An experimental testbed was established at the outdoor agriculture lab at the Islamia University of Bahawalpur. Figure 9a  A typical moisture sensor normally reads diameter of 10-15 cm around the probe.However, the HL-69 hygrometer with long needles is sufficient to cover area of 2-3 feet in diameter.Here, the length of the sensor rod and number of sensors on the rod determines the area of coverage by a sensor.The measurements by HL-69 hygrometer are normally taken from 30 cm to 150 cm deep.To cover an area of 14 × 48 feet of a tunnel form, 30 to 36 sensors are sufficient.Similarly, two AM2302 sensors per field are suggested for sensing temperature and humidity.In a field of 14 × 48 feet, two BH1750 sensors are sufficient.An experimental testbed was established at the outdoor agriculture lab at the Islamia University of Bahawalpur. Figure 9 shows the different stages of a green chili plant.The area of experiment was Bahawalpur and the time of experiment was July to September and in these months outdoor temperature ranges from 35-40 °C during the daytime and 30-35 °C at night-time.Table 3 shows the statistics of the proposed design of a 14 × 48 tunnel form.The data shown in Table 3 explains how the study was implemented in a small tunnel farm.However, it can also be expanded to implement at a large tunnel farms.3 shows the statistics of the proposed design of a 14 × 48 tunnel form.

Results and Discussion
The data shown in Table 3 explains how the study was implemented in a small tunnel farm.However, it can also be expanded to implement at a large tunnel farms.

Results and Discussion
The smart irrigation system for tunnel farming is an intelligent system that enjoys the benefits of the true decision making ability of the fuzzy logic approach.The use of intelligent approaches for sensor-based irrigation systems is a new idea.The architecture of the proposed system and its implementation details are given in the previous sections.To test the performance of the proposed system, three types of sensors (light, temperature & humidity and moisture sensors) were planted on a testing field.The input data received from the sensors is forwarded to the server and results are shown at an Android application and a web browser and in response a user can perform some actions.This system is fully automatic.The four types of sensor data is received from three sensors and the calibrated output is processed using fuzzy logic approach with the help of classification tables shown below.Table 4 shows three classes (high/wet, normal, low/dry) for various levels of soil moisture detected by the HL-69 Hygrometer sensor.A typical HL-69 Hygrometer sensor gives output in the range of 0 to 870.Table 7 shows the five classes (very high, high, normal, low, very low) for various levels of light intensity detected by the BH1750 FVI sensor.A typical BH1750 FVI sensor gives real-time light intensity values in a range from 0 to 64,000 lux.Table 8 that the accuracy of proposed SWS in near to 100%, which means that the system is working according to our defined rules for SWS.The overall accuracy of the proposed SWS is calculated using Equation ( 9): Equation ( 9) is used to calculated the accuracy of smart irrigation system where µ(ai) represents the accuracy percentage of each experiment and n represents the total number of experiments.According to experiments we achieved an average accuracy of 98.0%.
The performance of the system was tested.Table 9 shows the results of three cases that show the saving of water at three stages of plant's growth such as tiller phase, mid-age and mature phase.In Case 1, the water consumption with the normal method is 935.22 at the tiller phase and 591.51 with the smart irrigation phase.Overall the total savings of water in Case 1 was 864 m 3 •m −3 .Similarly, the savings of water in Case 2 were 982 and in Case 3 the savings were 898.The saving of water is more than all the previous studies, particularly those shown in Table 10.The results of three case studies are also graphically represented in Figure 11.The results of the experiments reveal that the use of an intelligent approach for efficient decision making certainly helps in improving the results of a sensor-based system.An approach that is intelligent can not only improve the performance of IoT-and sensor-based systems but also the throughput of such systems can be enhanced but more accurate and intelligent decisions taken by such smart systems.Figure 9 clearly highlights the way the smart irrigation system is helping in saving water in tunnel farming and achieving high productivity.
As discussed in Section 2, there are many sensor-based irrigation systems but none of them specifically address irrigation for tunnel farming.Additionally, previous approaches do not use intelligent approaches with IoT to get accurate decisions for efficient watering of plants.Our approach presents a novel idea of using fuzzy logic for efficient decision-making of watering quantity and watering schedule.The results show that our approach saves more water than the previous approaches.Our approach for smart irrigation of tunnel farming has the following novelties and contributions: • This is the first approach that presents a smart irrigation system for tunnel farming.

•
Previous sensor-base irrigation systems rely on simplistic decision-making approaches, we propose the use of fuzzy logic and achieved far better results.

•
None of the previous approaches address the issue of energy consumption in smart irrigation systems.

•
Previous approaches mostly rely on soil moisture to decide the water needs of a plant.Our approach considers four parameters (soil moisture, temperature, humidity, and light intensity) for more accurate decision-making that is a novel idea.

•
A knowledge base of plants and their watering needs with respect to the soil type (clay, silt, sand, etc.) is used for efficient watering and it is a novel idea.

•
The results given in Table 9 clearly show that our system is more efficient and effective in saving more water and achieving more productivity in tunnel farming.The results of our approach (Table 9) beat all the previous approaches in efficient water saving.
The results of the experiments and comparison of the results of our smart irrigation system approach with the manual approach of watering is shown in Figure 11.

Conclusions and Future Work
The proposed approaches use four sensors soil moisture sensor, humidity sensor, temperature sensor and a light sensor for better efficiency.Additionally, the watering needs of a plant are also stored in a knowledge base.Our approach uses an intelligent method based on a fuzzy logic approach to decide watering quantity and schedule of a plant considering plant type, weather conditions, soil moisture level, humidity, temperature, etc.Our approach focuses on efficient energy consumption as it does not turn ON all the sensors all the time.The sensors are periodically turned ON and turned OFF as needed.An intelligent algorithm handles the efficient utilization of sensors to ensure efficient energy consumption and to keep the operating cost of this system low.The proposed approach specifically addresses irrigation issues of tunnel forming and can be equally efficiently used with either a sprinkling method or a drip irrigation method.The results of this study are easy to reproduce as the sensors used are cheap and easy to access.The study discusses in this paper was tested on a small area (such as small tunnel farms, home gardens, etc.) but the results of the experiments show that the used approach can be generalized and can be used for for efficient irrigation of large size fields.The results of the experiments support the effectiveness of the proposed approach and its implementation with the help of a fuzzy logic approach.

Conclusions and Future Work
The proposed approaches use four sensors soil moisture sensor, humidity sensor, temperature sensor and a light sensor for better efficiency.Additionally, the watering needs of a plant are also stored in a knowledge base.Our approach uses an intelligent method based on a fuzzy logic approach to decide watering quantity and schedule of a plant considering plant type, weather conditions, soil moisture level, humidity, temperature, etc.Our approach focuses on efficient energy consumption as it does not turn ON all the sensors all the time.The sensors are periodically turned ON and turned OFF as needed.An intelligent algorithm handles the efficient utilization of sensors to ensure efficient energy consumption and to keep the operating cost of this system low.The proposed approach specifically addresses irrigation issues of tunnel forming and can be equally efficiently used with either a sprinkling method or a drip irrigation method.The results of this study are easy to reproduce as the sensors used are cheap and easy to access.The study discusses in this paper was tested on a small area (such as small tunnel farms, home gardens, etc.) but the results of the experiments show that the used approach can be generalized and can be used for for efficient irrigation of large size fields.The results of the experiments support the effectiveness of the proposed approach and its implementation with the help of a fuzzy logic approach.

Figure 1 .
Figure 1.Important components of a smart tunnel farming system.

Figure 1 .
Figure 1.Important components of a smart tunnel farming system.

Figure 2 .
Figure 2. Smart irrigation system for tunnel farming.

Figure 2 .
Figure 2. Smart irrigation system for tunnel farming.The proposed system works in communication with a set of embedded and external sensors, an IoT server, Cloud storage and gateways' support.as shown in Figure 2.These four layers of the proposed smart irrigation system are the Application layer, Management layer, Network and Connectivity layer and Device and Perception layer.

Figure 3 .
Figure 3. Hardware integration design of the smart irrigation system.

Figure 3 .
Figure 3. Hardware integration design of the smart irrigation system.

Figure 3
Figure3represents the architectural design view of the physical components of the system.It contains all the hardware devices and architecture of the smart tunnel farm system as deployed in a real world environment.As shown in Figure3on the leftmost side there are light and moisture sensors which are connected through an analog input with a microcontroller the same as humidity and temperature sensors are connected through a digital input.Here, the microcontroller works as a centralized device that takes inputs from various sensors and transmits the values to a server through the internet.The server processes the data provided by microcontroller so that users can view it through an Android application or a web browser in response to a user performing some actions which will be transmitted to the server through the internet[20], then the server sends the specified commands to the microcontroller and finally the actuators perform the action.The following section explains the workings of a fuzzy logic-based decision support system that is deployed at the server and helps the smart irrigation system make decisions regarding water scheduling and water quantity with respect to the type of a plant and the type of soil.Using fuzzy logic to decide water scheduling and water quantity with respect to the type of a plant and type of the soil is a novel idea.This system is fully automatic.The following sections describe the technical details of the proposed smart irrigation system for tunnel farming.

Figure 4 .
Figure 4.The fuzzy logic system for the smart irrigation system.

Figure 4 .
Figure 4.The fuzzy logic system for the smart irrigation system.

Figure 8 .
Figure 8.A tunnel form of 14 × 48 feet planned with smart irrigation.
,b show the external and internal view of the testbed developed for the smart irrigation system experiments.

Figure 8 .
Figure 8.A tunnel form of 14 × 48 feet planned with smart irrigation.

Figure 9
Figure 9 shows the different stages of a green chili plant.The area of experiment was Bahawalpur and the time of experiment was July to September and in these months outdoor temperature ranges from 35-40 • C during the daytime and 30-35 • C at night-time.Table3shows the statistics of the proposed design of a 14 × 48 tunnel form.The data shown in Table3explains how the study was implemented in a small tunnel farm.However, it can also be expanded to implement at a large tunnel farms.

Table 1 .
Comparison of efficiency in various irrigation methods[2].

Table 1 .
Comparison of efficiency in various irrigation methods[2].

Table 2 .
Comparison of the efficiency of various irrigation methods.
al., Parameswaran, et al. and Rawal et al.Due to the limited sweet water resources the countries that are seriously hit by lack of sweet water reservoirs especially need an efficient and cost effective method of smart irrigation.As Table2shows, the best irrigation method can provide 80 to 90% of water saving in favourable

Table 3 .
Design statistics of a 14 × 48 tunnel farm.

Table 3 .
Design statistics of a 14 × 48 tunnel farm.

Table 5
shows three classes (high, normal, low) for various levels of temperature detected by the AM2302 DHT22 sensor.A typical AM2302 DHT22 sensor gives a real-time temperature value in the range of −40 to +125.

Table 5 .
Classes of humidity.

Table 6 .
Classes of humidity.

Table 7 .
Classes of light intensity.

Table 10 .
Water consumption in irrigation at different stages of the plants' life (m 3 •m −3 ).