IoT Framework for Smart Irrigation using Machine Learning Technique

: The scarcity of freshwater around the world is becoming a serious issue, so there is a dire need to come up with a solution for effective utilization of water resources. Basically, agriculture depends on monsoon which is not a sufficient water source. The Internet of Things (IoT) and Machine Learning (ML) based smart irrigation system is employed in the field of agriculture to overcome the problem of water resource management. In this work, a smart irrigation system is proposed to predict the irrigation requirement of the field using several environmental parameters along with weather forecasting that assists the growth of the crop. This system proposes the idea of training the ensemble method in ML using the collected real-time data to make an optimized decision. This prediction model helps in reducing the traditional irrigation methods, thereby conserving water, labor and plant nutrients. This system provides a low-cost prototype model with advanced technological features with a fully functional system and the observed results are optimal with 90% accuracy.


Introduction
Agriculture is important not only from an economic point of view but has a deep-rooted influence on our social, political and cultural life. A survey report from February 2018 says, "58% of rural people in India are employed in the agricultural sector which contributes around 17-19% to the country's GDP". Nowadays, the agricultural field is facing a lot of problems due to inefficient and impromptu use of water resources. Agriculture is both the victim as well as the cause for the water scarceness. Irrigation currently consumes about 84% of the total available water in the country. Water management in fields is the most significant contributor to the ecosystem and water scarcity. Rain may be plentiful for some farmers, but in many places, it falls when it is not needed and vanishes during drought. The other challenge faced by the agricultural sector is to match the growing demand of the population in India and also to ensure food products when resources on land are limited. According to South China Morning Post (SCMP), the researchers found that the highest yield came from the smart farming technique giving 97-99% of the maximum yield and this was achieved at far less cost to the environment.
Internet of Things (IoT) according to Goapa et al. (2018) is changing and transforming everything from business-business to person-person. IoT is an advanced technology that provides the capability to communicate the data over the network without any human intervention. With the growing adoption of the IoT, connected devices have penetrated every aspect of our lives, from agriculture, health and fitness, home automation, automotive and logistics, to smart cities and industrial IoT as stated in Aqeel-ur-Rehman et al. (2014). The adoption of IoT solutions Shekhar et al. (2017) for agriculture is constantly growing. Namely, BI intelligence foretells that the number of agricultures IoT device installations will hit 75 million by 2020, growing 20% annually. Farming has become more advanced and technologydriven over the last decades. By using various smart gadgets, farmers have gained more control over crops growth by making it more predictable and effective. Farmers are spending more time and energy traveling between locations as they monitor ongoing activities such as irrigation, planting, harvesting and grain drying, or check on livestock; control equipment and communicate with other nodes in the network. Infusing IoT technology in the agriculture domain Li et al. (2014) can automate many of these tasks, with minimal human intervention. With advancement in technology, the size of the sensors is reduced and used in almost in all the applications in IoT. The soil quality and water requirement information from the agricultural fields can be collected using sensors, Actuators are being used to control the pumps based on the decision made using data collected by the sensors in WSN.
To achieve water management in agriculture, many smart irrigation techniques have been proposed, e.g., Chenafi Azzeddine et al. (2019) explains the use of Subsurface Drip Irrigation (SDI), drones for imaging and planting, thermal imaging. SDI is already a prevalent irrigation method that allows farmers to control when and how much water their crops receive. Drones help farmers get the detailed information about the field area regarding the growth of the crop as well as water requirement of the soil by using a thermal camera which gives the shade temperature distribution of the field. Most of the earlier irrigation monitoring system did not take into consideration the precipitation while predicting the amount of water required for crop growth. It ended up in wastage of water and loss of crop growth once the rain was followed straight away by the watering of the crop. In order to help the farmers, overcome the uncertainty of rainfall and to improve their yield, IoT based smart irrigation system is proposed with an efficient machine learning algorithm which provides a better decision-making model Tantithamthavorn et al. (2016); for irrigation. This work presents a Machine Learning (ML) technique to manage the irrigation effectively and ultimately increase the yield of the crop. First, these works consist of data acquisition model for collecting agricultural field data using sensor nodes. Next, the data is trained using the ML algorithm for predicting the soil moisture and nutrients for yield maximization. Finally, based on the weather condition and the water required for production, the irrigation motor is being switched on. Goldstein et al. (2017) proposed a recommendationbased irrigation management system using the ML algorithm with the knowledge of the agronomist. The system shows that Gradient Boosted Regression Trees as the best regression model of 93% accuracy and Boosted Tree Classifier with 95% accuracy as the best classifier model provides better irrigation prediction decision than the linear regression model. The models were trained with eight different sets of features to enhance the decisionmaking process of the agronomist. Al Zu'bi et al. (2019) proposed an Internet of Multimedia Things (IoMT) which focuses on the employment of multimedia sensors in the field for optimized irrigation process. Digital Image Processing is used to monitor the crops and the soil. The cracks in the soil and yellow leave determine the amount of water required by the crops. The multimedia sensor transmits the collected images of the crops to the image processing system, the decision is made based on the soil crack percentage and the yellow pigments in the leaves using Digital image processing system and Unsupervised ML algorithm. This paves the way for the Future No-Man irrigation management system. The estimation of soil moisture required by the crop depends on the evapotranspiration as stated by Zhao et al. (2018) which can be calculated based on extra-terrestrial radiation and temperature. Using the data collected from the field and weather forecast report, the evapotranspiration (ET j ) of the crop is calculated using Reduced-set Penman Montieth model which is expressed by Yanga et al. (2018) as:

Related Works
Where, the T max and T min are the maximum and minimum temperature respectively, Temp j is the average of the maximum and minimum temperature and R a is the extraterrestrial radiation. Rushika Ghadge et al. (2018) developed a system which uses both supervised and unsupervised ML algorithm to predict the crop and soil quality and type of the land and also analyze the nutrients present in the soil to increase the productivity of the crop depending on the data mining approach. This work helps the farmers to cultivate better crops in the appropriate soil to get better yield and also it will act as the medium to give efficient information about the crop quality and the nutrients required to the farmers. A Support Vector Regression (SVR) and K-means clustering based learning model was developed for soil moisture estimation. Humidity, radiation, soil moisture, air and soil temperature collected from the field was given as input to train SVR model. The output of the SVR model is given to the K-means clustering to improve accuracy and decrease the error rate. The final output from k-means is used in managing the water pump controller for effective yield management. But most of the earlier prediction model suffers from high variance which leads to degradation in the performance of the machine learning model. To handle such high variance, ensemble learning as mentioned in Zhao et al. (2018), Catolino and Ferrucci (2018), Joshi and Srivastava (2014), Ren et al. (2016) can be used. Ensemble methods provide better performance by combing multiple learning models for predicting the output of a single system. Some ensemble models especially bagging tend to reduce the problem of over and underfitting of the trained data. Bootstrap Aggregation technique is the improvement of single regression trees, which makes use of several models each of which are trained randomly chosen samples from the original dataset. The prediction error of the bagging method is lower compared to the other single models. Gonzalez et al. (2014) presents a bagging method for predicting electricity price and the results are compared with the random forest approach for both classification and regression models.
Based on the literature survey all the techniques used in making the irrigation management system effective is analyzed and a system that is farmer-friendly and applicable to the entire environment is proposed. Mahajan et al. (2018) explains bagging model used in predicting the soil moisture difference of the upcoming days using sensor data collected from the field and the weather forecasting data. The predicted result of the IoT prototype is compared with the predicted output from the SVR model and the mean squared error and the correlation score of the two models are also compared.

Proposed System Model
The proposed system aims at helping the farmers to manage their agricultural farm wisely by using limited resources. This system incorporates IoT and ML features in developing a smart irrigation system. It could really help in effective decision making for smart irrigation with seamless water usage. Figure 1 depicts the schematic representation of the proposed system. The system aims at training the machine learning model with the weather data report and sensed information which results in the optimized irrigation decision based on the implemented machine learning model. The work is categorized into 5 sections: Data acquisition model, online weather data collection, soil prediction model, real-time monitoring using web interface, IoT based motor controller.

Data Acquisition Model
Initially the agriculture land is segregated into different regions; in each region, the sensor nodes are deployed at random places in order to cover the entire field. Each sensor node is a collection of 4 sensors and the gateway node. The field data are the data measured from the 4 low-cost sensors -DHT11 Relative Humidity sensor commonly used temperature and humidity sensor which gives a calibrated serial data output when connected to the microcontroller with 1-wire interface, DS18B20 is a 9 bit digital thermometer to find the temperature of the soil, GUVA-S12SD Gallium nitridebased UV sensor chip for detecting the UV radiation incident on the soil and VH400 soil moisture sensor probe to calibrate the moisture content of the soil. The sensors are connected to the ESP32 microcontroller with integrated Wi-Fi and dual-mode Bluetooth to digitally output the measured data from field. The data read by all the ESP32 nodes are sent to the gateway node which is the Raspberry pi3 B+ board, of the corresponding regions using a lightweight communication protocol -MQTT (Message Queuing Telemetry Transport). MQTT is broker based publish-subscribe protocol designed for one-to-many message distribution based on the topic of interest of the subscriber. The ESP32 node acts as the publisher which publishes the data collected from the field and the Raspberry pi node acts as the subscriber which subscribes to all the sensor data published by the ESP32 node of the respective region. The broker acts as the mediator between the publisher and the subscriber in order to send the data to the correct subscriber. In this work we have used CloudMQTT broker service for data exchange between ESP32 node and the gateway node. Python code is written to fetch the data for every 10 minutes from the agriculture field. The data collected by the gateway nodes of the different regions are aggregated and finally stored locally or sent to the server through MQTT protocol services. The algorithm-1 gives a detailed procedure about data acquisition model. Dataset collected from Field-1 is listed in Table 1 and Abbreviations used in the algorithm is listed in Table 2.

Online Weather Data Collection
In this module, the daily weather data of the agricultural farm were collected including the maximum and minimum temperature, precipitation rate etc., Using both the weather data and sensor data collected from the location the evapotranspiration rate Goldstein et al. (2017) of the crop is calculated which is the main element that contributes to the water consumption in the agricultural field and has more significance in irrigation scheduling. The Reduced-set Penmann-Montieth model is used in the calculation of the evapotranspiration rate. This model is considered as the simple model and the modified version of the Penman-Montieth model as it requires minimum parameters in predicting the ET0 rate calculation. The calculated ET0 rate is also stored in the same database on the server.

Soil Moisture Prediction Model
The complete algorithm for predicting the soil moisture content is developed as in Figure 2 based on the field data, weather data and the ET0 parameter using Bagging ensemble learning model. The bagging model is used in this work as it is an ensemble method which takes numerous models into account and averages those models to produce one final model. The idea of bagging is that instead of adjusting the model to a sample of the dataset, several models fit different samples (with replacement) of the dataset. Then, these models are added using their average, weighted average or a voting system. Initially, multiple bootstrap samples are created so that each bootstrap sample will act as the independent dataset from the distribution. Then, weak learners are used to fit these samples and finally aggregate them to obtain an ensemble model with less variance. Suppose, there are k different datasets D each of size N:  The strong model S k (.) with low variance is obtained by averaging the k independent models: The dataset collected at the server is split as 70% of the data into a training dataset and the remaining as testing dataset. The model is trained using the training dataset and it is tested using the testing dataset. The output from this model gives information about the soil moisture of the forecoming days. The algorithm-3 describes the bagging model.

Real-Time Monitoring using the Web Interface
In Web interface for real-time monitoring, a web-based real-time monitoring interface is developed using flask python web framework. The web interface views the sensor data collected from the field, predicted soil moisture value and the weather forecast information. The user can set the minimum and maximum threshold value of water required by the crop for its growth. The system can be used monitor the threshold moisture value of the crop based on the predicted soil moisture value and the forecasted precipitation rate. The interface can automatically start or stop the irrigation process to achieve the threshold moisture value required for plant growth depending on the precipitation rate of the upcoming days.

IoT based Motor Controller
Finally, the web interface is developed using Python code to start and stop the motor. Based on the response from the web-based interface and by using Wi-Fi enabled node the relay switch can be operated to start/stop the water motor. The water motor can be accessed automatically using this web-based interface. The algorithm-2 gives the procedure for controlling the water motor.

Results and Discussion
The performance of the proposed work depends on the Mean squared error and the correlation score of the machine learning algorithm used. To validate the performance of the proposed algorithm, the air temperature, soil temperature, humidity, soil moisture and UV radiation are recorded for every 20 min from the field for 2 weeks. The collected dataset is divided into training (75% of the data) and testing (25% of the data) set for applying the ensemble algorithm. Initially, the difference between the actual soil moisture and the predicted soil moisture using the bagging algorithm is found and comparison of the predicted value using SVR and bagging methods are tabulated in Table 3. The graph Figure 3 shows the comparison of predicted soil moisture value using Bagging method and SVR along with the actual soil moisture measured using the sensor. This graph shows that the soil moisture value predicted using Bagging method is almost similar to the actual value when compared with the prediction of the SVR model. Figure 4 shows the R-square value for a various dataset using Bagging and SVR model and it is observed that the R-square value for Bagging model is highest and nearing to unity compared to the other. In Figure 5 the Mean Squared Error of the Bagging and SVR is compared using various datasets and it is observed that the MSE of the Bagging model is less compared to the SVR algorithm Due to higher score value and minimum MSE, Ensemble Bagging has been used in irrigation planning module.

Conclusion
The proposed system presents a smart irrigation technique of managing the irrigation effectively by adopting the machine learning methods to predict the critical parameters related to agriculture. The physical parameters like temperature, humidity, soil temperature, UV radiation, evapotranspiration, air temperature, etc. and also weather forecasting data which affects the soil moisture content of the soil as the input parameters for training the machine learning model. This machine.
Learning model performs better compared to the other machine learning model in the prediction process with better accuracy and reduced error rate. The irrigation process can be monitored by using a web interface. Further, this prototype model integrates open standard technologies with commercially available sensors to develop a prediction model in a cost-effective approach and ensures the best fit model in smart agriculture applications.