# IoT-Based Cotton Plant Pest Detection and Smart-Response System
## 3 IoT-Based Smart Detection and Response System Architecture
### IoT-Based Cotton Pest Detection  
Our proposed system consists of five tiers, as shown in Figure 7, in which the first tier is responsible for sensing the data indicative of insects while the second layer will analyze this data, and the third layer is based on this analytical data towards the sensor that sends the signal to the drone. The fourth layer will be drones that will go and spray the location from where the signal is received. _The Field Tier_. This is one of the most basic layers in the cotton field. It will have sensors and communication modules. The responsibility of this layer is to detect the presence of insects through sensors, and as soon as the presence of an insect is detected, it will transmit the signal of its presence to the base station through the communication module, as shown in the detection Algorithm see Appendix A. (detection algorithm consists of a Serial transmitter and receiver while the sensor's pin represents a separate sensor. Sensor values are threshold value between one to four as per the manufacturer's specs, which means one represent high sensitivity while four shows low sensitivity. Distance defines as an object's distance with a sensor.) Along with the sensor, the prototype is equipped with a ZigBee transmitter (ZED) that transmits signals, and we know that this ZigBee module covers a range of 10-100 m line of sight with 250 kbps data rates, while if we use LoRA instead, our coverage and data carrying capacity will increase. As shown in Figure 5, we have divided the whole field into four clusters, and with each cluster, we have installed sensors according to its area. Each sensor is capable of sending signals to the ZigBee gateway, which is located in the center of the field. We have shown a gateway in Figures 7 and 8, but we can install more than one gateway when needed. Figure 6: Detection-Response system flow diagram. Figure 7: Detection-Response Methodology Flow chart. * _The Gateway Tier_. The function of this layer is to collect the data sent by the sensors and respond accordingly. When sensors send messages about the presence of insects, it decides where to send the drones. For example, if a message is received once from a sensor and repeated messages are received from a sensor. It will send the drone to the side where the messages were coming from again and again. Because we are using ZigBee and we have not yet extended the range of our architecture, the whole system can be controlled from one or two central ZigBee Gateways, but if we use LoRa Gateway, it will be more manageable, and we will have to adopt it because it has a longer range and more data carrying capacity than ZigBee. * _The Control Tier:_ This tier will respond to the detection data packet from the sensors. We perform the following analysis based on this data I First, in which cluster did more insects move in and what could be the cause? II Second, the crop quality of this cluster may be different from other clusters. III Third, more spray is required in clusters with a high number of insect detections. IV Analysis of the overall testing results would help us optimize the detection and response system in future testing. * _Response Tier:_ This is a response layer, which is very useful and is the retaliation point of our entire system. This layer includes our ZigBee Controller (ZC) modules, drones, and the coordinates of the sensors from which we receive signals will be provided to the drones so that the drones perform targeted spray on the insects. If the insect had gone somewhere else by the time drone arrived, then we could increase the target region by including its neighborhood areas. In Figure 5, we have shown the whole  
Figure 8: Cup Carbon Simulation field, which consists of Clusters. framework, and apparently, four different drones are visible, but these will be only one or two drones, and they will continue to spray on the signals of different sensors on their specific routes.