###### Abstract  
Precision agriculture and smart farming have received significant attention due to the advancements made in remote sensing technology to support agricultural efficiency. In large-scale agriculture, the role of unmanned aerial vehicles (UAVs) has increased in remote monitoring and collecting farm data at regular intervals. However, due to an open environment, UAVs can be hacked to malfunction and report false data. Due to limited battery life and flight times requiring frequent recharging, a compromised UAV wastes precious energy when performing unnecessary functions. Furthermore, it impacts other UAVs competing for charging times at the station, thus disrupting the entire data collection mechanism. In this paper, a fog computing-based smart farming framework is proposed that utilizes UAVs to gather data from IoT sensors deployed in farms and offloads it at fog sites deployed at the network edge. The framework adopts the concept of a charging token, where upon completing a trip, UAVs receive tokens from the fog node. These tokens can later be redeemed to charge the UAVs for their subsequent trips. An intrusion detection system is deployed at the fog nodes that utilize machine learning models to classify UAV behavior as malicious or benign. In the case of malicious classification, the fog node reduces the tokens, resulting in the UAV not being able to charge fully for the duration of the trip. Thus, such UAVs are automatically eliminated from the UAV pool. The results show a 99.7% accuracy in detecting intrusions. Moreover, due to token-based elimination, the system is able to conserve energy. The evaluation of CPU and memory usage benchmarks indicates that the system is capable of efficiently collecting smart-farm data, even in the presence of attacks. recision agriculture; unmanned aerial vehicles; smart farming; intrusion detection; fog nodes +
Footnote †: journal: Applied Sciences  
1
Footnote 1: [[https://www.mdpi.com/journal/applsci](https://www.mdpi.com/journal/applsci)]([https://www.mdpi.com/journal/applsci](https://www.mdpi.com/journal/applsci))  
2023338573  
creates new security challenges [5]. As UAVs navigate in an open environment, they are increasingly susceptible to attacks that can cause them to be misguided, disrupted, or even physically taken over. Due to the omnipresence of UAV technology, several issues with UAV networks need to be taken into account, including communication, data collection, data security, storage, and supervision [6]. In precision agriculture, several UAVs work together to tackle the task of large-scale data gathering [7]. Due to the wireless nature of devices, it is important to consider the security aspect of the entire system before deployment. In many cases, the deployed devices are interconnected through short-range communication and are also able to connect through the internet [8]. A consequence of this increased connectivity is that such platforms become susceptible to vulnerabilities associated with GPS spoofing, GPS jamming, radio frequency interference, malware infiltration, man-in-the-middle, denial of service [9], denial of sleep [10], message replay and data feed interception [11]. If successfully exploited, these vulnerabilities can cause these systems to become a target of cyberattacks, where an intruder can penetrate and take control of the UAVs, interrupt activities, or modify the data gathered [12]. Besides vulnerabilities in wireless connectivity, UAVs are also susceptible to physical attacks whereby the attacker is physically adjacent and uses the close proximity to take control of the devices [13]. In the context of UAV-assisted precision agriculture where UAVs assist in a variety of tasks across several farms as illustrated in Figure 1, such attacks can have devastating impact. This impact includes but is not limited to completely damaging cropland, flooding of farm fields, and malicious spraying of pesticides, which might result in a significant consumption of chemicals [14]. These threats are classified as agricultural terrorism.