of Fuzzy- Development of Fuzzy-Based Smart Drip Irrigation System for Chili Cultivation

Chili plants often fail to harvest in the cultivation process due to improper irrigation. Soil temperature and humidity are essential parameters that affect the amount of water needed by plants in the watering process. This research aimed to apply fuzzy logic to the chili plants' irrigation system. The function of this system was to regulate watering due to the needs of the Chili plant automatically in a real-time fashion. The Sugeno fuzzy inference system (FIS) is embedded in a microcontroller to regulate the water based on the plant's needs appropriately. The system was tested on Chili plants located in the iSurf Computer Science Lab IPB University greenhouse. After four days of testing, the soil moisture sensor results were stable at optimal conditions, between 60%-80% after watering. It shows that the irrigation system has automatically regulated watering due to the Chili plant's needs.


I. INTRODUCTION
Chili (Capcisum annuum L.) is a vegetable commodity that is needed by the people of Indonesia, both for consumption by households and the food industry. According to [1], the total consumption of chili by the household sector in 2020 reached 1.03 million tons. This value decreased by 11.88% (138,65 thousand tons) from 2019. Most of the chili consumption was from the household sector, 90.64% of the total chili consumption. The chili production in 2020 reached 2.77 million tons, an increase of 7.11% (183,96 thousand tons) from 2019. Chili production is also exported to Saudi Arabia, Nigeria, and Malaysia. In 2020, The export value of chili reached US$ 25.18 million, an increase of 69.86% (US$ 10.36 million) from 2019. This fact shows that chili is one of the essential commodities for Indonesia. The price of chili fluctuates compared to other commodities [2][3]]. The weather and several national events in Indonesia affect the price fluctuation [4][5].
Chili commodity has become a contributor to recent inflation, which is happened due to weather conditions [6]. Chili plants planted and harvested at the proper season will produce plants of good quality, which will affect their selling price [7]. The chili selling price is also determined by various factors such as market demand [8], weather conditions [9], and planting costs [10][11] . Weather factors such as rainfall [12], humidity [13], temperature [14], and intensity of sunlight [15] also significantly affect the growth of chilies. In order to avoid harvest failure, a proper irrigation system that is appropriate with the plant condition is needed because chili is a plant that is sensitive to excess and lacks water [16].
Appropriate control of water intake during chili cultivation is crucial to avoid damage and crop failure [17]. Air temperature is one of the critical parameters to control soil moisture [18]. The high air temperature causes the water evaporation in the soil to be high, so the soil dries quickly. If the soil becomes dry with the moisture content below the lower threshold, the plants will absorb less water, and it is possible to wilt [19]. On the other hand, if the plant is overwatered, the soil will contain much water. Overwatered can result in poor soil aeration, inhibit root growth, and stunted growth and thin plant [16]. Therefore, it is necessary to have watering that can regulate the appropriate water amount needed by chili plants so that the amount of water in the soil remains optimal [20]. In addition, appropriate irrigation can help for reducing water consumption [21].
Technological developments in agriculture are rapidly increasing, one of which is the application of automation in crop irrigation [22]. Automation in irrigation is helpful to keep the soil moisture in an optimal state [23]. Soil moisture is commonly used to detect plants' water conditions [24]. [25] developed a system for irrigation using fuzzy logic on soil moisture and pH. [26] applies fuzzy logic to the automatic watering system for celery plants by adding a Real-Time Clock (RTC) as a watering schedule. The fuzzy logic algorithm is used because it is easier to understand than other artificial intelligence algorithms [27][28]. The fuzzy algorithm also has tolerance for inaccurate data [28]. Based on these facts, this study will design and implement a fuzzy-based intelligent drip irrigation system for chili (Capcisum annuum L.) plants. This research was developed in the greenhouse environment of the Department of Computer Science, IPB University.

II. METHOD
The research begins by conducting a literature study related to microcontrollers, fuzzy algorithms, membership functions for soil moisture, air temperature, chili plants, and all data supporting research. A literature study was also carried out by discussing with Prof. Dr. Ir Muhammad Syukur, an expert on chili plants from the Department of Agronomy and Horticulture (AGH) of the Bogor Agricultural University (IPB) to obtain information on optimum soil moisture for chili plants. At this stage, observations are made on similar systems with almost the same object of study, method, or development environment. The stages of this research are represented in Fig. 1.

A. Research Environment Plan
The research is conducted in the Internet of Things for Smart Urban Farming (iSurf) laboratory of IPB Dramaga. The research environment is designed at this stage, starting from determining the water source, installing drip irrigation, and arranging pots on chili plants.

B. Hardware Design.
Hardware design is carried out at this stage, which will be the primary system in this research. The input device of this system consists of four YL-69 sensors to measure soil moisture and a DHT11 sensor to measure air temperature. Arduino Uno is utilized as the main process and controller of this system; it is also responsible for communication devices for sending and storing data to web server services. The output from this system is an automatic watering system that will distribute water according to the needs of the chili plant.
The sensor used in this research is calibrated prior to use to ensure that the sensor measurement results are valid. Calibration is done to uniform the input value from the sensors because each sensor has a different sensitivity. The YL-69 sensor is used to retrieve soil moisture data. We compare the YL-69 sensors' result to the measurement results from a three-in-one analog moisture meter EU004. The humidity measurement was carried out in three different conditions: dry, moderately moist, and wet. Measurements were carried out more than three times to obtain accurate data. The calibration of the DHT11 sensor is carried out by comparing the results of air temperature data collected by the sensor with the HTC 01 room temperature measuring device. Measurements are carried out simultaneously. Temperature data were taken at four conditions, namely at 9.30, 11.10, 15.00 and 17.00. This calculation aims to obtain a watering time following the watering design. Watering time needs to be known so that the system can carry out watering according to the needs of chili plants. The calculation of this watering time is significantly influenced by the primary source of water and the watering installation. The results of this calculation will then be used as the output of the fuzzy system that will be used.

D. Fuzzy Model Development.
The software developed in this study will be built using a fuzzy algorithm. The program structure starts with activating both types of sensors and then takes air temperature and soil humidity data. The reading values of the two sensors will be used as input parameters in the fuzzy inference system. These two values (soil humidity and air temperature) will be processed according to the rule base made to produce an output in watering time.

E. Fuzzy inference system.
A fuzzy inference system (FIS) is a process of drawing conclusions based on available parameters and a rule base to produce specific outputs [29]. This fuzzy inference system has four main parts in making a fuzzy logic control system: fuzzification, rule base, inference, and defuzzification.
The fuzzification method in this study uses the Takagi-Sugeno method. The Takagi-Sugeno method makes the system output in the form of a singleton function. The output value is a crisp number. Defuzzification uses the high-method method. In this method, the crisp solution is obtained by taking the crisp value which has the maximum degree of membership in the singleton membership

F. Fuzzy Inference System Testing.
At this stage, the fuzzy system is tested. The test is carried out to determine whether the fuzzy system can produce the appropriate output. An actual environment in a greenhouse is used to perform the test. The test is said to be successful if the system output on the serial monitor has displayed the appropriate output, namely the value of watering time according to the needs of chili plants.

G. Data Transfer Testing.
The data will be sent to the webserver service provider. The communication device used is NodeMCU which includes the esp-8266 WiFi module. Data transmission is tested to ensure the data is sent correctly. The test is successful if the humidity, air temperature, and watering time data appear well on the Thingspeak.com page.

H. System Integration Testing and Evaluation.
At this stage, the entire system is integrated and ready for testing. The test will be carried out for three days. Then observations are made to determine the system's success in producing output that follows the needs of chili. If the system can maintain the soil moisture in optimum conditions, it is an indication that the system has been successful. This soil moisture can be seen in real-time on the Thingspeak.com webserver service provider application.

A. Research Environment
The research was conducted at the Internet of Things (IoT) for Smart Urban Farming (iSurf) laboratory, Bogor Agricultural University (IPB) Dramaga. Fig. 2 shows an automatic watering design consisting of a control system, water tower, and chili plants arranged in five pots in two rows. Field conditions can affect watering time. The water discharge flowed by a 12V DC pump is certainly different from the water flowed by a water tower. In addition to the water source, the surface area of the flush hose also affects the length of watering.
The primary water source in this study is a large water tank tower which is placed on two-meter-high support. The water pressure in the tower is continuously maintained to remain relatively the same. The tower uses an automatic valve, so the water will automatically be refilled when it has reached a certain height. The water used in this study has not used any nutrient mixture. The water is then channeled through pipes to the plant area. In the plant area, the pipe is fitted with a solenoid valve. Pipes along the planting area are fitted with hoses to drain water into each chili pot. Soil moisture sensors are placed in four pots closest to the control system. The sensor value taken is the smallest value to anticipate water shortages in chili plants. Chili plants are arranged into two rows, with five chili pots in each row. Chili was planted in pots measuring 25 cm in diameter using planting media without soil mixture. Fig. 3 shows the implementation of the system in an actual environment.

B. Smart drip irrigation design
The hardware design used in this study can be seen in Fig. 4. The circuit consists of a DHT11 sensor, four YL-69 sensors, NodeMCU, LCD, and relay. DHT11 sensor is a sensor for measuring air temperature and humidity.
Soil moisture data is obtained by utilizing the YL-69 sensor. The NodeMCU is the main processor and controller; it also sends the data to the ThingSpeak IoT platform and LCDs system. Relays are implemented to automatically adjust the solenoid valve opening and closing based on the FIS output.

Fig. 4 Hardware block diagram
As shown in Fig. 4, the voltage source for Arduino and the solenoid valve uses a 12V DC adapter. Meanwhile, the voltage for NodeMCU is obtained from the same adapter; the voltage input is lowered to 5v using a step-down module. The LCD and the air temperature sensor get a 5v voltage source from the Arduino.
This study uses NodeMCU as a communication device to the internet. The NodeMCU has an ESP-12E WiFi module embedded which has an esp8266 chip. NodeMCU is used because it is easier than directly using the ESP8266 WiFi module. The NodeMCU does not draw power from the Arduino directly to avoid interrupting the power supply to the NodeMCU while testing is in progress. An HSDPA network is utilized as the source of the internet network.
Soil humidity and air temperature sensors must be calibrated before proceeding to the software design stage. This calibration is conducted to determine the conventional truth of the value of the designation of measuring instruments and materials by comparing them to traceable measuring standards to national or international measurement standards (IPQI 2016). Sensor calibration in this study was carried out by comparing the sensor with standard measuring instruments used. The YL-69 sensor is calibrated with a moisture meter, while the DHT11 sensor is calibrated with the HTC01 room temperature measuring instrument. Fig. 5 shows a graph and a comparison function between the sensor and the moisture meter. The equation y=-0.1323x + 129.99 is for sensor one, equation y = -0.1307x + 129.4 is for sensor two, equation y = -0.1228x + 122.95 is for sensor three, and equation y = -0.1287x + 122.97 is for sensor four. This equation is used for writing program code. This function normalizes sensor measurements to be uniform with commonly used measuring instruments. The regression function is negative because the moisture meter shows a higher reading for more moist soil. At the same time, the YL-69 sensor will give a lower value for more moist soil. This value already indicates that the relationship between the two measuring instruments is linear. The regression equation is then used for writing program code. The number on the sensor reading is multiplied by the function. The result of the multiplication is used in writing the program. The calibration is done so that the sensor value is close to the standard value of the moisture meter measuring instrument.

D. DHT11 Sensor Calibration
Temperature data were collected at four different times. The recorded data was then compared with the HTC-01 room temperature measuring instrument. The data is then made a comparison function to normalize the sensor to the HTC-01 measuring instrument. Fig. 6 shows the regression function of the air temperature taken by the DHT11 and HTC-01 sensors. The regression equation obtained is y = 0.9231x + 2.0304, where x is the sensor reading value. The regression equation is then used for writing program code. The number on the sensor reading is multiplied by the function. The result of the multiplication is used in writing the program. This is done so that the sensor value is close to the standard value of the HTC-01 measuring instrument.

E. Watering time calculation
The watering time will be used as the output of the fuzzy inference system. Watering time will be different for each watering environment. The length of watering is related to the discharge and the increase in humidity. The water discharge needs to be calculated to determine how much water comes out every second. In addition, it is also necessary to know how much humidity increases every second.
As seen in Fig 2 above, the primary water source is a water tower that already uses an automatic valve. The water will be automatically filled when reduced by about 20%. The water amount in the tank allows the water pressure in the tower to tend to be the same. The calculation is done by flowing water into each hose for 30, 45, and 60 seconds. The water was collected by the tray and then measured with a 1000 ml measuring cup, and the data was recorded. The treatment was repeated three times to get the average value. The water flow time of 30, 45, 60 seconds respectively resulted in a discharge of 5.08, 5.84, and 4.76 ml/s. Based on the discharge calculation, the average water output per second is 5.23 ml (5.23 ml per second).
The increase in soil moisture value was measured by arranging pots containing planting media and chili plants, as shown in Fig 2. A mixture of fertilizer and rice husks as planting media in a pot with a 25 cm diameter is used in this research. We set the sensors in the first four pots with a distance of around 2,5 cm to the drip hose. 315ml of water was flowed (60 seconds of watering) on dry soil conditions. Then the difference in changes in soil moisture was observed before and after watering. Based on measurements and calculations, the result of the increase in soil moisture every second is 1.185%. It means that every second watering (5.23 ml) can increase the humidity by 1.185% (sensor reading value after calibration).
The watering duration is obtained by calculating the humidity value from dry conditions to the most optimal conditions. Determination of watering time is based on the optimal water requirement of chili plants as the main reference for research. Based on the discussions with chili plant experts from IPB, chili plants can grow optimally at 60% -80% humidity. We set 70% as a threshold value to avoid the shortage and excess water during the watering process. Based on the increase in humidity calculation, the increase in humidity per second is 1,185%. Therefore, increasing the humidity value from 10% to 70% takes 50.53 seconds (rounded up to 51 seconds) or the equivalent of 264 ml of watering water.
Furthermore, the watering duration is made into five different times, starting from the longest to the fastest. The calculation results are 51 seconds, 41 seconds, 31 seconds, 21 seconds, and 12 seconds [26]. This calculation will later be used as a reference in the output membership function of watering time in the fuzzy inference system, represented in a singleton curve.

F. Fuzzy Model for Smart Irrigation System
A fuzzy logic system controls this automatic watering system. This step developed the temperature and humidity membership functions in fuzzification, rule bases, fuzzy associative memory (FAM), fuzzy inference system (FIS), and membership functions for defuzzification. Sending data to the webserver will be discussed in the next sub-chapter. Fig. 7 shows the system workflow. The process starts with the sensors' data input, fuzzification, rule base, inference, defuzzification, sending data to a web server to be viewed in real-time, and downloading the data for further analysis. Two inputs become parameters in this watering system: air temperature and soil humidity. Thus, these two parameters are fuzzified into a fuzzy set. The membership value of air temperature and soil moisture are presented in Table I. Four linguistic values were used in temperature membership: cold, slightly cold, normal, and hot. Soil moisture is divided into three linguistic values: dry, moist, and wet. The membership value was developed based on the [26] and discussions with chili plant experts. Meanwhile, the watering duration membership value is obtained from calculating the water discharge and the increase in humidity.
After collecting fuzzy values (fuzzification), the formation of a fuzzy rule base is carried out. The statement rules are grouped into fuzzy associative memory (FAM) matrix. This FAM matrix has a size of n × m, where n is the number of membership inputs for linguistic values of air temperature and m is the number of membership inputs for linguistic soil moisture values. Rules are formed to express the relationship between input and output. The operator used to connect between two inputs is the AND operator, and the one that maps between inputs and outputs is IF-THEN [26]. Table II is the FAM matrix which shows the 15 rule bases formed. Furthermore, the FAM matrix from the fuzzy rule base is used as a knowledge base processed in the inference block. The inference is evaluating rules to produce output from each rule. The implication function is applied to get the output in the fuzzy domain. The implication function used is the MIN implication (using the AND operator).
In the defuzzification stage, five linguistic values were chosen to represent the system output in the form of watering time. Watering duration is represented by a singleton curve, as shown in Fig. 8. The system output is watering duration. The High Method is the defuzzification method used to determine the watering duration. This method obtains a crisp value solution by taking the crisp value with the maximum degree of membership in the singleton membership.

G. Fuzzy Inference System Test
At this stage, testing is carried out on the fuzzy inference system. Tests are conducted to check whether the fuzzy rules correctly follow the design and function in actual conditions. Before testing, it is essential to ensure the drip irrigation can drain water properly. The test was carried out in the morning at 08:00 and in the afternoon at 17.00. The indicator of the success of the test at this stage is that the fuzzy inference system can produce outputs in the form of an appropriate length of watering and an increase in humidity. Fig. 9 presents the fuzzy system output on the serial monitor. The air temperature and soil humidity reading before watering are shown in the first line, and in the following line is the fuzzification value of each parameter. Fuzzification of soil moisture from left to right shows wet, moist, and dry. Fuzzification of air temperature from left to right shows cold, slightly cold, normal, and hot. In Fig 9, it can be seen that the fuzzification of soil moisture in the morning (Fig. 9b) indicates that the soil tends to be moist and slightly wet because it has not been watered at all. In the afternoon (Fig. 9a), the system shows that the soil is predominantly wet because it has been watered. Then in the next row, the FAM matrix with each weighted degree of membership is presented. The weight value is obtained from the results of fuzzy inference using the MIN implication. The following two lines show the result of the defuzzification. The output is the maximum degree of membership in the singleton membership. The membership value finally indicates the length of watering required by the plant . Fig 9b shows Fig. 9a shows rapid watering. The following line shows the duration of watering and the value of soil moisture taken after watering. The test is quite successful because this fuzzy inference system can maintain soil moisture in optimal conditions.

H. Data Transfer Testing
The success indicator at this stage is that the NodeMCU can send data on soil moisture, air temperature, and watering time to the Thingspeak.com web page. The test was carried out for 18 hours, from 16.00 to 10.00 the next day. It is enough to observe whether there is an error in the NodeMCU. Fig. 10 shows the sensor readings for soil moisture, air temperature, and watering time. This testing stage is considered quite successful because it can display the three data well.
The test was carried out by dividing the watering into every four hours. It aims to observe variations in watering time and to observe the ability of the fuzzy inference system to maintain soil moisture in optimal conditions. According to experts, the optimal soil moisture for chili development is 60%-80%. The test was carried out three times in 24 hours. The data is sent to the Thingspeak.com webserver service provider. The data sent is soil moisture every 10 seconds, air temperature every 10 seconds, and watering time every four hours. In addition to data that can be viewed in real-time, thingkspeak.com provides an export feature of all recorded data for analysis. Indicators of the success of this system test are that watering can run well every four hours, data can be sent correctly to the Thingspeak.com web server, and soil moisture can be maintained in optimal conditions. Table III shows the data from thingspeak.com, which has been normalized. Data collection was carried out at 16.30 and ended at 16.14 on the fourth day. The system carried out 19 waterings. The soil moisture data sent is the minimum moisture data from the readings of the four available sensors. It is done to anticipate water shortages in chili plants.
Average humidity after watering is stable at between 60% and 80%. The average soil moisture after watering on day 1 to day 4 was 65.5%, 71.67%, 70.5%, and 68.6%. The average soil moisture after total watering was 69%. Based on the test data for three days, it is sufficient to show that the system can carry out watering optimally according to the needs of chili plants.

IV. CONCLUSION
The fuzzy-based intelligent drip irrigation system that was built can function well for irrigating the chili plant in the iSurf laboratory of the Department of Computer Science, IPB University. The inputs of Sugeno FIS were soil humidity and ambient temperature. The Sugeno FIS applied can produce a real-time decision of watering time according to the needs of chili plants. After watering, the average soil moisture is 69%, which means the system can keep the soil moisture in optimal conditions in the range of 60%-80%.