Smart Farming: An Enhanced Pursuit of Sustainable Remote Livestock Tracking and Geofencing Using IoT and GPRS

The farmers of agricultural farms manage and monitor different types of livestock. The manual inspection and monitoring of livestock are tedious since the cattle do not stay at fixed locations. Fencing many cattle requires a considerable cost and involves farmers’ physical intervention to keep an eye to stop them from crossing beyond the access points. Visual tracking of livestock and fencing is a time-consuming and challenging job. This research proposes a smart solution for livestock tracking and geofencing using state-of-the-art IoT technology. The study creates a geographical safe zone for cattle based on IoT and GPRS, where the cattle are assigned dedicated IoT sensors. The cattle can be easily remotely monitored and controlled without having any need for farmers to intervene for livestock management physically. The smart system collects the data regarding the location, well-being, and health of the livestock. This kind of livestock management may help prevent the spread of COVID-19, lower the farming costs, and enable remote monitoring.


Introduction
Food is a basic need for every individual, and the importance of agricultural industry cannot be overstated. The rapidly growing population of the world reduced farming area because of industrialization, exodus of farmers to urban areas, and climate change which are some of the factors that are challenging the agricultural industry to the next level. A stable and progressive agricultural industry is extremely important to feed the ever-increasing population of the world.
The world economy was driven mostly by agriculture until the 18 th century. Around 1760, the first industrial revolution started with the invention of the steam engine. The large-scale mechanization resulting from this revolution started luring farmers to abandon their farms and move to urban areas for socioeconomic benefits. The second and third industrial revolutions in the next two centuries accelerated this migration process resulting in increased abandonment of farmlands. Shengfa and Li [1] analyzed farmland abandonment in various regions of the world since the 1950s. The study argues that the phenomenon is more pronounced in more advanced regions of the world, and this trend is expected to continue in the future too.
Today, we are at the cusp of the fourth industrial revolution which is driven by several disruptive technologies including but not limited to sophisticated machine learning algorithms, Artificial Intelligence (AI), Internet of Things (IoT), Unmanned Aerial Vehicles (UAVs), robotics, and quantum computing [2,3]. Such powerful technologies have already changed our lives dramatically. They have found application in almost every domain of life, and agriculture is no exception. Artificial Intelligence and machine learning technologies have been applied in analyzing and managing soil [4], crops [5], livestock [6], and water resources [7]. Computer vision techniques have been employed for addressing several issues in agriculture such as plant disease detection [8], insect detection [9], farmland management [10], and crop yield analysis [11]. References [12,13] provide excellent reviews of the application of IoT technologies in agriculture. Precision farming is another technique in agriculture that has seen significant boost because of invention of cheap sensors and UAVs [14].
A satellite navigation device (commonly called a GPS receiver) can be used to determine its position using a satellite navigation system. As of today, there are four active satellite navigation systems that provide global coverage, namely, Global Positioning System (GPS) by the United States, Galileo by Europe, GLObal NAvigation Satellite System (GLONASS) by Russia, and BeiDou by China. A satellite navigation device may be attached to any object to track and monitor its position in real time. A geofence can be established by defining a closed polygon referring to a geographic area on earth. A location-aware device can then make use of this geofence to trigger alerts when the object enters or leaves the area defined by the geofence.
Internet of Things (IoT) is an extremely exciting set of technologies that is already shaping the future of humankind. IoT is based on the concept of uniquely identifiable interconnected devices (such as sensors, computers, and mechanical devices), collecting the data, and storing it in the cloud that is processed by intelligent algorithms to achieve common goals. IoT has several applications in almost all domains of life. References [15][16][17] provide excellent reviews of some such applications.
Livestock monitoring is another important aspect of farming. Traditionally, cattle were monitored manually and confined in farms by building physical fences. However, advanced technologies have made it possible to track and monitor the cattle automatically. Navigation satellites and Global Positioning System (GPS) are extensively used for tracking the position of cattle. UAVs have made real-time monitoring of cattle a cost-effective and hassle-free task. Radio-frequency identification (RFID), wireless sensor networks, and the Low Power Wide Area Network (LPWAN) are other potential technologies for establishing virtual fences to keep the farm animals in a confined area.

Related Work
Smart farming concept relates to location-aware devices to monitor the movement of animals and raise alerts when they violate the boundary of the geofence of the farm or pasture. Additionally, IoT sensors may be used to monitor the health and well-being of farm animals. References [18,19] proposed a device that is based on the satellite navigation system to track the position of an object to which it is attached. The position is transmitted through an available wireless transmission medium such as a radio frequency, wireless, or cellular network. References [20][21][22] described a geofencing scheme based on the geographic area being divided into one or more grids. The proposed scheme exploits this grid structure to optimize computational resources required for location monitoring because a complex polygon requires more calculations to achieve the desired goal. Figure 1 presents the number of research articles published from 2010 to 2020 on remote livestock tracking. It can be seen that there is significant scope of remote monitoring of livestock employing the latest technologies. With the passage of time, the researchers have devised enhanced solutions in this problem domain. Despite a good number of cited works, still, the need to address the issues related to optimized geofencing is on the way.
References [23][24][25] also proposed the concept of geofencing by providing auditory feedback and light electric shocks to an animal wearing a tracking device. Through these feedback mechanisms, the device can effectively guide an animal from one to another location. It may also be used to keep an animal within a geofence defined by its owner.
References [26,27] proposed an implant device for tracking the location of an animal in addition to monitoring its health and well-being. The device also contains enough storage to record medical information about an animal such as past surgeries, any disease, medication, and owner contact information.
Safeguarding against theft of animals is an obvious application of the ability to monitor the location of an animal in real time. To this end, researchers have proposed several systems that can be used to minimize the chances of animal theft. Reference [28] proposed such a system based on a centralized database to store livestock details, radio-frequency identification (RFID) tags, and an available communication technology such as a cellular network. The proposed system employs several heuristics to identify theft of animals. One such heuristics marks an animal as "stolen" if the animal is found in a geographic location that is considered "far" from the registered location of the animal and its geofence for gazing. Another heuristic is discovery of an animal having registered a location drastically different from that of other animals in a herd. Reference [29] proposed a similar system that uses wireless sensor networks and unmanned aerial vehicles for animal tracking and identification.
Several researchers have proposed IoT-based frameworks for geofencing as well as other aspects of smart farming. References [30][31][32][33][34][35] proposed various systems for monitoring of livestock through data recorded using sensors and network communication nodes. References [36][37][38], in addition to collecting the data, also proposed means for automatically analyzing the data and an interface to monitor the livestock. Reference [39] proposes the use of a long-range Low Power Wide Area Network (LPWAN) technology to collect and process several parameters related to the health of cattle as well as their environment. The data recorded by sensors is relayed to one or more gateways through long-range end devices. This data is subsequently processed by an application server and presented to the user for visualization and analytics. A C++ simulation shows that the proposed architecture can effectively cover an area of 7 km 2 in a rather harsher hilly terrain. Reference [40] proposed a similar solution based on Long-range Wireless Access Network (LoRa-WAN) technology. The use of LoRaWAN makes such solutions more feasible in rural areas with poor cellular or Internet coverage. Many different satellite navigations have been considerably employed to determine the position of livestock. We can observe four active satellite navigation systems providing global coverage, namely, the Global Positioning System (GPS) by the United States, Galileo by Europe, GLObal NAvigation Satellite System (GLONASS) by Russia, and BeiDou by China. It is very contemporary to navigate through satellite nowadays. Commonly, a satellite navigation device is attached to the livestock under monitoring, and the device can promptly track and monitor the position of the livestock in a real-time scenario. In addition to this navigation, a dedicated geofence can greatly help in defining a closed shape, normally a polygon, that refers to a geographic area on earth. A location-aware device can then make use of this geofence to trigger alerts when the object enters or leaves the area defined by the geofence. A number of cited works highlight that geofencing-related solutions are more appealing for remote livestock monitoring. Table 1 presents a brief summary and comparison of the research works discussed above. We can see many different solutions of remote livestock tracking. We can see that safeguarding the livestock appears as an obvious application of the ability to monitor the location of an animal in real time. Until now, the researchers have proposed several systems that can be used to minimize the chances of animal theft based on RFID tags, wireless sensor networks, unmanned aerial vehicles for animal tracking and identification, long-range Low Power Wide Area Network (LPWAN) technologies, GPS, IoT, and GPRS. Despite a good number of cited works, only a few researches can be identified that focus on the geofencing for livestock monitoring.

Methodology
Varieties of cattle in a paddock have genetically different grazing, sleeping, and playing patterns. Goats and sheep are more active, and they have different food intake and digestion systems than cows and buffalos. The current livestock management systems mostly employ IoT and GPS sensors connected to satellite and GPRS for navigation and communication, respectively. GPS and GPRS sensors consume device energy and communication bandwidth. Besides, the same set of sensors is installed for all livestock categories despite genetic diversity among animals in the same herd. In addition, the conventional tracking systems track the movements of livestock without any profound geographical boundaries that become challenging in case the animals go very far from the main access points. To address these issues, this research study proposes an enhanced management system that provides convenience to farmers to define a geographical safe zone for livestock. The farmers are notified by the system when cattle try to go beyond the defined boundary of the zone. Besides, the navigation and communication are automatically controlled according to the genetic diversity of different animals. Figure 2 presents an overview of the conceptual framework of the proposed system. The red ellipse represents a drawn geographical safe zone for the livestock. Ultrasonic sensors installed at the elliptical boundary of the safe zone identify the movements of the cattle. The ultrasonic sound waves propagate and discover the presence of livestock, and its distance is calculated. If the distance of the cattle crosses the defined safe-distance threshold, the communication navigator is activated. The animals in the herd are equipped with navigation sensors that sense the locations of animals by navigating through the satellite. The system calculates the distance of each animal from the safe zone geographical boundary and alarms the farmer when the distance of the animal gets close to a threshold value. The proposed system glimpses the exact location of animals in case the animals are out of the safe zone for a specified period. The motion sensor suspends the navigation and communication when the animal is recorded in a static state to optimize the energy and communication bandwidth for significant utilization. Figure 3 presents the implementation scenario of the proposed framework described in Figure 2. We can see different steps involved in tracking a whole herd or particular cattle in the herd based on sensing the location coordinates and having communication with the system through the communication channel. An elaborative presentation is presented in the following algorithm: (1) A herd H may contain a variety of livestock with any number depending on the nature of business and local facilities available to farmers for keeping and managing animals. For the moment, we suppose that a typical herd H can contain a maximum of N animals defined as H = fH 1 , The conventional livestock tracking and management for a large herd is challenging for farmers in remote areas.
Spatial and temporal interaction of traditionally herded livestock and wildlife using GPS and GSM technologies in Northern Kenya This study demonstrated the feasibility of tracking cattle using radio collars. It shows the complexity of spatial use for cattle and wildlife. [42] The tracking system available on commercial basis lacks the data storage capacity required for frequent collection of livestock data.
The study designed the Clark GPS Animal Tracking System to satisfy the needs of stakeholders attached to livestock management.
An evolving demand of ecological research requires adoption of the latest technology for tracking and managing the livestock. [43] The cost of GPS technology is a big barrier for efficient livestock tracking and management.
The study reviewed the GPSbased technologies being used for cattle management and suggested the improvements.

Review of literature involving GPS technology
Ecologists have been employing best efforts towards livestock management using the latest technologies. [44] The animal behavior and grazing patterns are a very important measure for livestock health, tracking, and management.
The GPS system is used for tracking cows in six summer grazing areas having different environmental conditions and livestock managements.

✓ ✓
The GPS positions of animals help to collect information relating to their grazing, resting, and playing patterns. [37] The traditional livestock management methods are tedious that involve human intervention and other resources.
The integrated system is comprised of tags, beacons, and base station nodes. Tag nodes communicate with other nodes to transmit location information of livestock.

✓ ✓ ✓ Beacon, tags
The android-based application outperformed the existing conventional tracking and cattle management systems. [45] The welfare breading of individual cattle is an important aspect especially in case of a large herd. Traditional methods of welfare breading are insufficient for managing a large number of cattle.
A remote monitoring system based on computer vision and wireless technologies was developed for remote monitoring of pigs in addition to measuring other parameters, i.e., humidity, temperature, and harmful gases.

Computer vision
The study improved the traditional CAMShift algorithm for an enhanced tracking of pigs using computer vision and WSN for remote sensing technologies. [46] The livestock are under high threat of landslides, earthquakes, and other natural disasters. Remote sensing of such natural disasters is viable to save the precious cattle.
The study integrated Landsat-8 and phased array type L-band synthetic aperture radar-2 (PALSAR-2) datasets and adopted the analytical hierarchy process (AHP) method in mapping landslides in the Kelantan river basin, Peninsular Malaysia.

Landsat-8 and PALSAR-2
The study demonstrated that employment of Landsat-8 and PALSAR-2 tools for remote sensing data along with GIS techniques were promising tools to map landslide assessment for tropical environments. [47] The conventional livestock monitoring parameters are insignificant for sustainable ranching of sheep.
The study integrated the global information system with remote sensing to analyze environmental variables to monitor and track sheep grazing.

✓ ✓ Remote sensing tool
The GIS-based time analysis tool helped in collecting point data from GPS collars installed on sheep that enabled the remote sensing significantly. [36] The precision livestock farming in agriculture and food industries requires sustained BOSCA and CyberBar were developed for real-time product visibility to ensure The tracking of agrifood products with remote environmental monitoring 4 Wireless Communications and Mobile Computing significantly assisted in timely decision-making to all stakeholders. [48] The monitoring of livestock for safety, security, grazing, and health aspects is always very challenging due to animal nature and habits of livestock.
An open sourced framework that could capture the health parameters of livestock was developed. A wireless location acoustic sensing system was utilized to intake the health parameters of cattle.

✓ ✓
Open sourced framework The system provides high quality support to farmers in rural areas because of low cost and portability. The system outperformed the existing systems for monitoring the livestock. [49] The lamb industry in Victoria, which is a big industry, requires tracking and other visualization parameters of livestock for better herd management.
A comprehensive designing of spatial-temporal location movements of livestock with respect to the environmental parameters greatly helps in designing the paddocks to improve the management and performance of cattle welfare.

Remote visualization systems
The GIS-based system significantly helps the farmers to seek frequent information about nitrogen emission to meet the local and global greenhouse gas targets. This helps in improving life quality of livestock ultimately. [50] Wild stocking animals are often lost due to a poor and old style cattle management system that increases the farming cost considerably.
The study combined GPS and wireless mobile cell network as positioning technologies to monitor the wild animals. The system is based on mobile beacons and network base stations.

Wireless mobile cell networks
The traditional GPS, compass, and Wi-Fi technologies are useful for common tracking and management of livestock, but these technologies are still inadequate for monitoring of wild animals. [51] Conventional livestock management for a large herd is challenging for farmers in remote areas.
An RFID-based system is used to track and monitor the livestock for their identity and vaccination procedures.

RFID
The analysis concentrated on the colossal measure of RFID for better query processing.    Figure 3: Implementation scenario of a conceptual framework. 6 Wireless Communications and Mobile Computing Let us create the instances Δt 1 , Δt 2 , Δt 3 , Δt 4 ,…, Δt n , where n ≤ t (forward and backpropagation of waves from the ultrasonic sensor).
The time t can be defined by (9) In this case, if the result is t 1 (calculated D is not less than threshold T), then the system alarms the farmer to locate the animal and get it back to the safe zone (10) Otherwise, the system resenses the current location of livestock after a defined period T Contrary to the conventional livestock tracking system where the farmers have to sometimes do a physical exertion for tracing the cattle that go beyond the common access points, the defined safe zone provides convenience with secure and prompt management. Besides, in the case of lazy livestock that do not change their locations more frequently, the system can significantly save power consumption and communication channel utilization. In the scenario where the farmers require a more substantial safe zone, there is very low probability for livestock to go beyond safe zones by exceeding the location threshold. The proposed system is equally suitable for the sensing devices equipped with a solar panel for power supply.

Experimentation
This study designed a geographical paddock to monitor the spatial, temporal behaviors of livestock. It is a contemporary phenomenon that different livestock animals have different patterns of grazing, movement, and resting events. The frequency of these events varies from animals to animals, and mostly, they are related to the genetics of individuals and the current psychological states in rare cases. The tracking phenomenon of livestock is tremendously attributed to such spatial, temporal events reflecting the allocation of appropriate sleep time units to hardware for saving energy and communication bandwidth. Figure 4 describes the visual implementation of monitoring of livestock using a defined geographical paddock through remote sensing of their spatial, temporal activities. The yellow and red circles represent warning and alarming zones for the farmers or caretakers. The ultrasonic sensors sense the cattle H i crossing the safe zone S and initiate the GPS to trace the location of H i . The application calculates the geographical distance of each animal H i , i ≤ N for an N number of animals in the herd H. The application also defines a distance threshold T that helps to match the current difference of H i with the safe zone S = fS 1 , S 2 , S 3 , ⋯, S j g. When H i (having geographical coordinates P j ) approaches S j , the absolute geographical distance |P j − S j | is calculated and compared with threshold T. The application warns the farmer in case the difference of two geographical distances seeks the threshold value. Similarly, the farmer gets a warning notification when the said difference of distances exceeds the defined threshold T. The warning alarm helps the farmer to get an alert on the current location of H i , and the farmer may carefully observe the movement of H i . Figure 5 describes the detection and tracking phases of the proposed system. The ultrasonic sensors connected to Arduino sense the presence of cattle. The ultrasonic sensor data is sensed through ThingSpeak. At first, the Arduino initializes the ultrasonic sensor to collect its data. The distance of the cattle is calculated, and the Arduino forwards the distance to the ESP8266 module using serial communication. We need to choose a threshold value for the sensors to sense the obstacle and to calculate the distance. Based on the calculated distance, the serial communication helps ESP8266 to convey the distance to ThingSpeak using a communication channel.

Wireless Communications and Mobile Computing
The distance of cattle from the sensors is measured using the following formula: Measured Distance = 1/2 Time × Speed; here, the level of humidity and temperature impacts the speed of the sound wave at a particular place.
Once the system detects the cattle going beyond the safe zone, the GPS module attached to Arduino is activated, and the module connects to nearby satellites and starts reading the current location coordinates of the cattle. These location coordinates are passed to the farmer's mobile through the communication channel attached to Arduino. Figure 6 presents an overview of hardware components employed for livestock detection and tracking. Figure 6(a) depicts an Arduino Uno microcontroller board manufactured using Microchip ATmega328P. This microcontroller board has been used to connect the detection and navigation components. Figure 6(b) shows an ultrasonic HC-SR04 sensor that uses SONAR to detect the livestock and determines its distance from the safe zone. Figure 6(c) is the NRF24L01 wireless module used as a communication module in the setup. Figure 6(d) presents the hardware modules installed for livestock identification and tracking. In the experimentation, the ultrasonic module detects the presence of livestock by calculating and comparing its distance with the safe zone threshold defined in the system. The navigation module is activated to track the current location of the animal once the system identifies the cattle breaching the designated safe zone. The navigation coordinates are communicated to the network using a communication channel. The farmer can locate the current location of those cattle that are outside the safe zone. This provides automated fenceless farming to farmers by remotely identifying the current situation of all cattle in a heterogeneous herd. Table 2 presents an experimental scenario in which a variety of livestock H i at different instances of time access the safe zone boundary. The ultrasound sensors sense their distance comparing it with the defined threshold T. The farmers receive the mobile notifications for the cattle that cross the safe zone, and their location coordinates assist the farmers in tracking the current location of livestock. The sound waves emitted by sensors are mechanical in nature and travel using a medium. It has been noticed that certain environmental conditions, i.e., humidity and temperature, may also impact the performance of such sensors. Since these sensors are being employed for the detection of livestock pertaining to a distance threshold compared with the distance of cattle from the safe zone boundary, the environmental conditions do not impact the sensor performance degradation for the detection of cattle. The significant outcome of this detection mechanism is to detect the livestock without impacting any physical damage to them in the course of longitudinal compression of waves having a frequency of 100 kHz to 50 MHz.
The significance of the proposed livestock management system reflects in reducing the time and energy complexity of the system and integrated modules, as shown in Figure 7. A variety of livestock have different grazing patterns genetically, and thus, their physical activities are proportional to these genetic behaviors [52][53][54]. It has been observed that certain livestock, e.g., cows and buffaloes, are sluggish as compared to goats and sheep. Once the cattle have gone through the graze period, the physical excitement to intake more food is considerably reduced, and the livestock prefers to have rest or lay down for a long time. During this inactive or passive activity, the safe zone ensures that the cattle This way, the tracking system is not required to be initiated to record the locations of cattle since the cattle are already inside the safe zone parameters. Goats and sheep, on the other hand, are more physically active even after the intake of proper food. The probability of such livestock is higher than the sluggish or passive livestock. The tracking of active livestock might be frequently required in this case as compared to cows and buffaloes. The proposed system signifies the avoidance of unnecessary utilization of resources, i.e., time, energy, and effort. All three scenarios defined in Figure 6 describe that the probability for goat or sheep to cross the geographical threshold is much higher than cows followed by buffalos. Figure 8 presents the average probability values for tracking different livestock under certain restrictions, i.e., considering different scenarios of the safe zone and without a safe zone. The red line in the legend describes a uniform    Wireless Communications and Mobile Computing probability of tracking all livestock without having consideration of a safe zone. The existing approaches, cited in the literature, track the livestock right away, syncing with the initialization of the tracking system. This phenomenon assigns the same probability values to all livestock irrespective of their genetic type and behaviors and thus results in wastage of system resources. On the contrary, the concept of adopting a geographical safe zone ensures that genetic behaviors and activities of different livestock are taken care of while tracking their movements. In all scenarios described in Figure 6, it can be observed that the average tracking probability of different livestock is quite different from each other. For instance, the average likelihood of tracking goats or sheep is higher than that of cows and buffaloes. Besides, the cows have a somehow higher average tracking probability as compared to the average likelihood of buffaloes. Hence, the proposed livestock detection and tracking system are significantly context-aware (as per genetics of different livestock).

Conclusion
This study proposes design of a geographical paddock to monitor spatiotemporal behaviors of livestock. In a conventional livestock tracking system, the farmers have to do physical exertion for tracing the cattle that go beyond the common access points. The proposed solution addresses these issues by providing convenience to farmers to define a geographical safe zone for livestock. The farmers are notified by the system when cattle try to go beyond the defined boundary of the zone. Besides, the navigation and communication are automatically controlled according to the genetic diversity of different animals. The system calculates the distance of each animal from the safe zone geographical boundary and alarms the farmer when the distance of the animal gets close to a threshold value. The proposed system glimpses the exact location of animals in case the animals are out of the safe zone for a specified period. The motion sensor suspends the navigation and communication when the animal is recorded in a static state to optimize the energy and communication bandwidth for significant utilization. The significance of the proposed livestock management system is reflected in reducing the time and energy complexity of the system and integrated modules.

Data Availability
The data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
The authors declare that they have no conflicts of interest.