AI based pest detection and alert system for farmers using IoT

. Agriculture plays an important role in economy and it is the backbone of the economic system for developing countries. India is one of the key players in agricultural precinct worldwide. Although there are many sophisticated technologies in the field of agriculture, still there is no proper technology to control the problems related to pests. Disinclination to pesticides for controlling agricultural pests is a worldwide problem. To overcome this particular problem, an AI based pest detection model is designed. The purpose of this model is to further illustrate, through classification using an artificial neural network, the effectiveness of acoustic approaches in pest detection. Numerous types of research have demonstrated the viability of acoustic technologies for insect detection and monitoring using different sound parameterization and classification methods. IR sensors and sound sensor are employed to identify the presence of insects. Deep learning technique is used to analyse and categorize the audio signal with the help of AI model to detect the type of pest. This model not only aims on detecting the pest but also alerting the farmers by notifying through their mobile phones with the help of Wi-Fi module and IoT.


Introduction
Agriculture is one of the oldest and most important human activities which is a major contributing factor for human development in this world. About 37.6% of the area in the world is used for agriculture [1]. Pests are detrimental to human beings. They damage crops, livestock, and forestry and are a burden to people. Pests are of various types and they include weeds, plant pathogens, rodents, aphids, beetles, thrips, all kinds of borers, and also insects that feed on leaves, roots and stems. But the most dangerous out of these is the plant-feeding insects as they damage the crop yield. They interfere with the growth of the plant and vandalise cultivation. About 30 to 40% of the global agricultural production is being destroyed by the pests [2]. In addition to destroying the crops they also disseminate bacterial, viral or fungal infection. These can be controlled with the help of pesticides and insecticides. The purpose of pesticide is to fight off pest to regulate the proper growth of plants. They improve the crop quality and contribute to the reduction in crop wastage. Pesticide usage results in abundant harvest and helps to protect the storage. Some pesticides are biodegradable and some are organic. Organic pesticides come from the organic substances such as botanical and mineral sources and so they do not have any adverse effects on the plants. On the other hand, the disadvantages to widespread pesticide use are significant. They may cause problems like domestic animal contaminations and deaths, honeybee and pollination decline, losses to adjacent crops etc., So the amount of pesticides used should be minimized. Pesticides are sprayed on the plants by the process of fumigation. Natural occurrences like rainfall washes away the pesticides from the crops and lead them to the water-bodies like ponds and lakes near the agricultural land. This in turn results in the formation of algae on the surface of the water-body making it difficult to breathe for the aquatic organisms by preventing the oxygen from entering into the bottom of the water body. So, minimizing the usage of the pesticide is an essential factor to the environment. World Health Organisation (WHO) also recommends reducing the use of pesticides whenever possible. Pests and insects can damage crops, reduce yields, and increase the cost of production, which can have a significant economic impact on farmers and the overall agricultural sector. In developing countries, where agriculture is often a key component of the economy, their damage can be devastating. In developed countries, where the agricultural sector is more mechanized and technology-driven, pests and insects can still cause significant problems. The cost of controlling pests can be high, and the use of chemical pesticides can have environmental and health impacts. Strategic Agri product storage strategies are required since agricultural yield is unpredictable, ensuring that there are always enough supplies available. So, there is a need for a model to reduce the usage of pesticide.

Literature survey
Article [1] explains the amount of land needed for agriculture and its importance. Article [2] explains the crop systems that are being followed by farmers in day-to-day life. Application of IoT technology in agriculture has been studied in [3]. Article [4] explains how the techniques of ML and IoT are being applied to the agricultural sector inorder to predict any factors that affect agriculture and also to monitor moisture and pH value of soil. Article [5] presents the use of soil temperature sensor manufactured from nanomaterials. Based on the soil temperature, farmers can decide the crop for that soil. Article [6] employs soil moisture, temperature and humidity sensors and uses IoT for monitoring the agricultural field. When the user logs in to the webpage, all the above parameters can be viewed. In article [7], AI and image recognition technologies are combined with IoT for pest detection. Input signals for the controller are obtained through the audio and interrupt sensors. Article [8] focuses on digital image processing for plant protection in field and crop management. The approach suggested uses a technique in which the pest location and detection is done with the help of sensors and the location is sent to the farmers mobile. Article [9] focuses on finding out pests that affect the vegetables and also identification of vegetable diseases so as to reduce the spreading of diseases. Once the disease is detected, it is sent to the owner through their mobile phones.
In [10], an intelligent agent-based prediction system is presented. It provides a methodology to construct a consolidated product prediction system through RFID to extract product messages and information regarding which products can be suggested to customer.. Article [11] deals with knowledge graph and deep learning-based pest detection and identification system for fruit quality, as fruits can be easily affected by disease causing pests. It uses an automated system based on Raspberry Pi to identify pests and insects. Detection of pests on leaves using Image Processing is done in [12]. It also illustrates an approach which uses wavelet transformation. Article [13] deals with pest detection using Deep CNN by using a database of insect pictures of several kinds. In Article [14] which is pest detection on agricultural fields using Video Processing Technique, early pest discovery and recognition of pest in agricultural crops is done by detecting the movement of pests using video processing. It involves capturing the video of pests so as to find its presence and the location. Smart Automated Pesticide spraying bot is proposed in [15]. It explains about how bot is used to spray pesticides with the help of mobile phones and other devices. Article [16] suggests a crop recommendation system for farmers who are not able to choose which kind of crop is fit for their land. It also predicts crop yield and suggests the price for crops. Article [17] focuses on monitoring the farmer's personal health and work environment, mainly their pesticide use and medical professionals to get data regarding the farmer's health.
Article [18], which deals with acoustic methods of invasive species detection in agriculture shipments focuses on minimizing the menace posed by invasive species. It also presents the use of acoustic sensors for detection of rodents and small insects in grains. Article [19] focuses on application of IoT and AI to notify the user with location of pest. Article [20] focuses on pest detection using CNN which belongs to a class of deep neural network.
All these above researches include pest detection using different techniques like image processing, ANN, Deep Convolutional neural network (CNN), etc. But there is no technique to eliminate pest from the field. This paper includes detection of pest with the help of IR and acoustic sensors and elimination of pest by spraying pesticide on the location of pest affected areas. All the studies that have been reviewed show that methods developed for pest detection using Artificial Intelligence and Image Processing are efficient. Hence, this paper focuses on AI based model with acoustic and IR sensors with IoT which enables the sharing of message to the farmer's phone. This helps them to control the amount of pesticide to be used, and also reduce the pest and decrease the pesticide wastage, thus leading to a pollution free environment.

Proposed methodology
The AI based pest detection system proposed in this paper, is an effective method to provide support to farmers in order to reduce pests. Various methods have already been implemented in the field of agriculture, but they are intricate and have some impediments. This paper presents a system that is useful for farmers in order to reduce pests and control the usage of pesticide. Block diagram of pest detection system is shown in Figure 1. A prototype is developed which consists of sound sensor and IR sensors. The sound sensor is used to detect the insects' sound and is displayed in the liquid crystal display with the help of Arduino UNO. Four IR sensors are placed in the field and are used to detect the insects whenever they move across the sensors. As soon as the presence of pest is detected, an SMS is sent to the farmer's mobile with the help of Microcontroller and Wi-Fi module. In addition, the output signal from the microcontroller is given to the relay driver which drives the relay to run the pesticide motor which sprinkles the pesticide on the plants.  Initially, the training model is developed and is shown in Figure 2. The ANN is trained for pest detection using several thousands of sample insect sounds. The testing model is shown in Fig. 3. The audio input for the model is given in the form of .csv file. ANN consists of three layaers. Input Layer : This is the layer where the input data is fed into the network. Hidden Layers: These are the layers between the input and output layers. They are called "hidden" because their values are not observed directly. Hidden layers can vary in number and size depending on the specific network architecture. Output Layer : This is the layer where the final output of the network is produced based on the input data and the weights learned by the network during training. These layers will process the input audio signal and will direct it to the trained model. This trained model is already trained with the help of dataset collected from the insects in the field in the form of analog values. This model will compare the real time audio with the trained model and classify the type of insect with the help of real time data collected through sound sensor.

Techniques adopted
Deep learning technique and Artificial neural networks are adopted for detecting the pest.

Deep learning technique
Deep learning is a subfield of machine learning that uses artificial neural networks with multiple layers to learn from large amounts of data and improve the accuracy of predictions or decisions. It has achieved remarkable success in various applications such as image or speech recognition, natural language processing, recommendation systems, and autonomous vehicles, among others. Deep learning is continuing to drive advances in many fields and is a key technology in the development of artificial intelligence.

Artificial neural networks
Artificial Neural Networks (ANNs) are computing systems modeled after the structure and function of biological neural networks in the human brain. ANNs are composed of interconnected processing nodes, known as neurons, which work together to process and transmit information. ANNs are widely used in various fields of research and industries, including Machine Learning, image and face recognition.

Flow charts for Arduino and ANN programming
There are five sensors placed in the field, four IR sensors and one sound sensor. First, with the help of IR sensor, the system senses the presence of insects continuously and if an insect passes through IR sensor, it gives high value as 1 or else 0. If IR1 detects insects, then it is displayed in the LCD as "IR1: H", then other IRs are displayed as "IR2: L", "IR3: L", "IR4: L". The sound sensor senses the input sound and when no sound is detected, it will be displayed as "Unknown" or if there is a presence of any insect then the name of the insect, for example "Root Borer" will be displayed. Flow chart for Arduino programming is shown in Figure 4.

Fig. 4. Flow chart for Arduino programming
Flow chart for training the model is shown in Figure 5. The audio inputs are collected in the form of analog values. The audio inputs of the insects namely Root Borer, Stem Borer, Berry Borer and Thrips are collected. This dataset is pre-processed and data visualization is also done. The next step is to split the data into 2 parts namely data which is trained and testing data. Then the model is trained with the help of the ANN algorithm. The model is trained with the dataset to identify the type of insect.

Hardware Setup
The Hardware setup of the above suggested system is shown in Figure 6 and various sample displays shown in LCD display are depicted in Figures 7,8 and 9. Initially, when supply is given to the setup, the LCD display will turn ON. When anyone of the IR sensor's output is high, the corresponding IR will be shown as "IR1: H" in LCD display and AT indicates the automatic mode. Then the mic will be scanned for any input for audio signal and if any sound is not detected, then the display will be "Unknown" as shown in the Figure 9. Once when there is an input sound, then the trained model will identify the type of insect and display the name of the insect as "Root Borer" as shown in the figure 10.    The input sound to the sound sensor is identified as Root Borer. So, the LCD display shows "Root Borer" in the display. Similarly the system is trained for detecting other insects like Berry Borer, Stem Borer and Thrips.
This model has a relay driver which is activated by the signal from the farmer's mobile. In turn this relay driver will control the amount of pest to be sprayed on the crop thus resulting in protection of crops from the wastage and contribute to the environmental safety. This also results in the minimization of pesticide wastage thus increasing the profit of the farmer.  Figure 11shows the website designed. This website is created for the farmers where they can control the mode of operation that is both automatic and manual for spraying pesticide. When the system is in automatic mode, once the type of insect present is identified it will be displayed on the website and also the pesticide sprinkler mechanism will work on its own. When the mode is manual, only the type of insect present will be displayed on the website and no sprinkler mechanism will come into action.
In this paper, an AI based pest detection system is designed for controlling agricultural pests. This model uses the effectiveness of acoustic approach in pest detection and uses AI for pest classification. This system also alerts the farmers when pests are detected by sending the message to their mobile phones with the help of Wi-Fi module. This system also has the facility of automatic spraying of pesticide. With the use of this system, farmers can remotely access the pesticide application device, eliminating the need for them to physically visit the field. This pest detection system is very important to society. Farmers can use this system to keep an eye on their fields at any time, and remote control is possible. By detecting and destroying the pests at an early stage, both agricultural productivity and the nation's gross domestic product can be significantly increased.