# An IoT-Based System for Efficient Detection of Cotton Pest
## 2 Materials and Methods
### Implementation Scenarios
#### 2.4.2 Scenario 2 Control Environment  
The proposed prototype operation was set up in an empty room where two hundred bees were arranged. A favorite food of bees was placed around the devices to make sure that the bees would hover close to the devices. As soon as the bees passed across the sensors, the sensors could sense them and generate a signal of their presence with the assistance of the Zigbee wireless device. The generated signals could be received at the monitoring device. A similar scenario was created for mosquitoes where a mosquito-friendly light was set up around the prototypes so that the mosquitoes would fly over the devices and their presence could be sensed as soon as they flew over a sensor. An array of sensors was developed that could detect and send a signal to the monitoring device to indicate that an insect was detected flying over a sensor.  
Based on the light received after reflection by the sensor, the number of insects that crossed the light was calculated. There was little variation in the number of the reflected light signals received by the sensor, as it was heavily dependent on the presence of the flies and/or mosquitoes in the sensors' sensing ranges. For the detection of insects, reflected light signals must be examined thoroughly together with other aspects, such as air, dust, noise, and the device in use.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Sensor** & **Type A** & **Type B** \\ \hline Range & 04–30 cm & 0.2–1.5 m \\ \hline Resolution & 1 cm & 1 cm \\ \hline Weight & 4 g & 4.8 g \\ \hline Package size & 29.5 \(\times\) 13 \(\times\) 13.5 mm & 29.5 \(\times\) 13 \(\times\) 21.6 mm \\ \hline Supply Voltage & 4.5–5.5 V & 4.5–5.5 V \\ \hline \hline \end{tabular}
\end{table}
Table 2: Sensor manufacturer specifications [31].  
In Figure 3B, showing the acrylic box, and Figure 3A, the Zigbee console demonstrates the test session. Some unwanted values can be observed in the figure, but all of the unwanted signals were filtered out with the help of a low pass and a high pass filter using the threshold values of the received power. Due to the importance of data accuracy in such experiments, the filters were implemented in the code. The values that might be the signal of a flying mosquito or a fly were investigated, while the higher values were removed using a low-pass filter and lower values were removed using a high-pass filter.  
The interference by a moving or stationary Angoumois grain moth distracted the light received by PSD, which was received after a reflection by the sensor as a signal. The sensation of an insect or a moth's exposure to the light of a sensor would be considered a good signal, as its values would be much better than any other signal (in which case, the insect passed at a long distance from the sensor or half of the pest's body was exposed to a sensor or its light). It was also observed that the tools or nearby light did not affect the results. Detection electronics and communication were designed as the outer parts of the prototype, while processing was the inner part of the device. This system could be easily used to detect all types of flying insects, some of which were detected through this device in this study.