Design and Development of Solar Powered Intelligent Irrigation \ Water Management System using Data Science

India is an agricultural country. Agriculture and its allied activities act as main source of livelihood for more than 80 percent population of rural India. Available irrigation systems are not efficient and lead to wastage of water. Literature revels that there is need to develop automated irrigation system with latest technology. In this paper we are proposing a system which will detect the moisture percentage of the respective farmland and compare it with the provided set point. Based on the difference our machine learning algorithms will decide how long the water pump will remain switched on, it will then close the pump after that particular time and give out final moisture percentage reading and final water level of the water storage tank. Also, there will be a website provided which will continuously show current moisture percentage, amount of water present in the tank, how long water in the tank will last, the usage statistics and predict preferred and nonpreferred crop to grow in that particular season. Plus a manual override will be provided for all systems.Usage statistics will consist of a graph showing water usage vs day. System display will show amount of water used vs date and below that the median and mode of the outcomes will also be indicated. Proposed in-house designed system has potential to provide the list of preferred and non-preferred crops.


Introduction
Water is one of the precious natural resources which is depleting severely in India. The past few decades we have witnessed a significant increase in demand for water across various sectors, thus facing the worst water crisis in history. Intelligent Irrigation System is the systematic approach to conserve existing water resources and efficiently managing them for agricultural usage with the latest technology. Data Science/ Machine Learning is one of such new techniques which can help our country to reduce the overall impact of faulty water management in agricultural sector. Many farms across India and the world still depend on manual gauges and minimal level of automation for executing this process. This leads to inefficiency and wastage. Hence if proper automated machines are implemented with latest technology, we can make amends to all the problems and make sure the deficit is minimum. In this paper, we are proposing to design and develop a prototype of Intelligent Irrigation and Water Management System for agriculture. Machine learning technology plays a vital role in the system. It is a data analytic technique which has different types of algorithms and models to learn information directly from data. For example, it optimizes water usage and provides essential amount of water and fertility to the field and hence improves yield production, reduces manual intervention (man hours), and also suggests or predicts preferred crop based on availability of water and available data. This system will be helpful for farmer to improve the productivity and adapt suitable system according to their requirements.
We are proposing a real time monitoring system for water usage during farming practices. The paper consists of two main parts hardware and software. The hardware is a basic implementation of any irrigation practice as it suits the user for eg. Sprinklers or drip irrigation methods. However, the control module used will be a Raspberry Pi based control circuit [6]. In this system the user will be able to monitor the water usage on a daily basis and also the whole system will be automated for the purpose of minimizing errors. The hardware part is basic and easy to understand but the software part is the heart of this system. Data science will be done by Data Analysis practices using Pandas. The website will consist of graphical representation of water usage vs time (days). The prediction of how long water in the tank will last, will be done based on previous data.
The hardware that we are going to use will vary from farm to farm depending upon the area. Thus enabling the scope of this system to higher levels. The machine learning algorithms are of various types; however, in this paper we are mainly going to focus on Supervised Learning and Associative Learning to get the desired outputs [3]. In Supervised Learning we are going to work with Linear Regression mainly and in some cases where the input/output curve may not be a straight line then we are going to choose Stochastic Gradient Descent (SGD) which is used for nonlinear parameters. Finally, in order to verify the output of the system to be genuine, we will be plotting a graph of usage vs day for the amount of water, using Matplotlib function in python. We can plot a graph with any desired input-outputs. We are also going to use Associative Learning to develop similarities between parameters of the system and we will be able to train it to provide the maximum duration, water inside the tank will last considering the use of water in the farm.
We cannot ignore the fact that farmers are the backbone of this country, so it is our duty to not only be grateful to them but also be able to share their load in any way possible. So we have decided to create a low budget system so that even farmers with low financial resourced could afford this system. There are regions in our country where water abundance is a major issue, as a measure to conserve water this system can be handy as it only uses the amount that is required. In our paper we are trying to create a solar powered electronic system which can be used for smart irrigation. Our main goal is to make this system user friendly so that even a non-technical person can operate it with ease. Easy use of website can help people understand its working without understanding the science behind it.
The rest of the paper is organized as follows: in the next section the block diagram and description of complete system is explained. Then we will look at the design and development section which further elucidates the working of the model for both hardware and software aspects after assembly. Here we will also learn in detail the learning process of machine learning in the system. Following this we will study the implementation of the model which provides insight on practical application on the system on a pre-decided test crop and the use case for this proposed system. The last section presents conclusion and the future scope for further advancements in the model.  Raspberry Pi: it is a credit card sized minicomputer which can be used for many small computing tasks and IoT's (Internet of Things).  FC28 moisture sensor; which is an easy to use digital soil moisture sensor. It has two electrodes and the amount of current passing through them is proportional to the amount of moisture in the soil. Now since Raspberry Pi only has digital pins and we need an output in analog, we are using an ADC (Analog to Digital Convertor).  A pump motor: It will be used to move water from storage tank to field. Although since Raspberry Pi cannot sustain enough power required for the pump to function, a Relay module will be used and an external battery connected to the solar panel will be used. Generally for Drip irrigation a 0.5 kW, 2-5 HP, 3-phase induction motor is used which gives a flow rate of about 100-500 LPM.  Ultrasonic sensors: They will be used for measuring the level of water in the tank.

Proposed system's block diagram & description
Since different tanks will be of different sizes and shapes proper calibration will be done.  A Battery: Specification of battery will depend on the field into consideration. Although, a 1800 W battery is generally preferred for large scale applications.  Solar panels: They will be our primary source of energy. We will be using 4 panels of 250W each [1]. In normal conditions, minimum to no external supply will be needed as this assembly can charge a 1800 W battery (preferable) in about 2-3 hours.  MCP3008: This is an Analog to Digital Convertor used in the system because Raspberry pi only has digital pins but we need the output from moisture sensor to be analog.

Design and development
The whole system has been divided into three essential parts such as: (a) Moisture calibration and analysis.
(b) Prediction of how long water in tank will last, usage statistics and preferred crop prediction on the given Website (using Machine Learning).
(c) Storage of data on firebase for back end purposes. Fig. 3.1 shows the proposed design of the entire system. The pump connected to Raspberry Pi 3 is the output of this system. Raspberry Pi is the CPU for the system [6].

Hardware working
Moisture sensors will be placed in the field to sense moisture content present in the soil [1,6]. This reading will be processed further by machine learning algorithms. Train test split method will predict the duration of the pump running.

Fig. 3.1: Proposed Design
The Ultrasonic sensor will continuously provide signals in the form of pulses. The amount of water in the tank can be calculated using: Where, S = speed of ultrasonic waves in air D = distance travelled by ultrasonic waves T = time take by ultrasonic waves to reach the receiver Hence as given in Eqn. (1) by calculating D, we will get the level of water in the tank as ultrasonic waves will be reflected from the surface of water. The level before and after the use of system will be stored and its difference will give the amount of water used in one cycle. The outputs of average moisture and daily water requirements will be stored in a database which will be updated regularly. This database will be used to display a graph using python library matplotlib. It helps in understanding further the use of various hardware with its placement and also the working of system.

Software working
Supervised and Associative Learning are being used in the system [3]. The pump will be B SOL controlled by a relay which will be given some delay by using Linear Regression. We have created a dataset after calculating the flow rate of the pump, thereby collecting the time intervals for particular moisture levels to reach the desired value.
Train_Test_Split is the model from Scikit-Learn library that will be used to train the data. For crop prediction we have decided to use Associative Learning model.
For our prototype we provided the data set given in the  Clicking on usage statistics will redirect user to the 2 nd page which is a calendar, and selecting a particular month will redirect user to the 3 rd page which consists of the graph mentioned above. Below the graph will be the median and mode values. On scrolling down a list of preferred and non-preferred crop will be given.

Learning process in machine learning
Supervised learning is used in our paper to determine the time for which pump stays on for that particular amount of moisture content [3]. The data set for this purpose is predominantly linear in nature so Linear Regression is being used. The dataset contains set of percentages of moisture level that have been converted using interp function and the time intervals that are provided to the relay. The time interval vs moisture percentage is calibrated manually. For example: if value of moisture is 30% and set point is 70%, the time pump takes to increase moisture level to 70% is recorded and thus added to the dataset against that particular level. The whole dataset consists of percentages from 0-70, divided by an interval of 10. Now the role of linear regression algorithm is to analyse the dataset. Train_Test_Split algorithm will divide the dataset in provided ratio for eg. 80:20. The dataset is split randomly into training (80) and testing (20). Training is when model uses the given data set to get answers, whereas Testing is when model uses the gained knowledge to predict answer. Now when any specific percentage of moisture content is sensed by the sensor and passed to the model to predict the time interval, the algorithm will go through the dataset in the training model and find a correlation between them. This value is compared with testing model and a linear result is provided as output. The linearity of the model can be checked by plotting a graph using matplotlib function.
Associative learning is used to predict preferred crops. Prediction will depend on water usage, moisture content and soil testing results [2].

Prototype Implementation
This section explains the complete prototype of the proposed system shown in Fig. 4 Also we have developed the use case diagram for the system as shown in figure 4.3. A use case is a methodology used in system analysis to identify, clarify, and organize system requirements. It also helps us understand the various inputs and outputs for all the considered elements. As is depicted in the use case: a farmer, Firebase, and Agricultural department are the main elements of the use case. All actions that can be performed by the elements in regard to our proposed system are joined the respective element with the use of arrows. The headings (intelligent irrigation and website) show the domain in which the actions will take place. The function <<includes>> is used to extract common parts of the respective element or action, whereas the function <<extends>> is used to show optional actions after performing the given action.