Next Article in Journal
The ‘Pick-Your-Own’ Model of Production and Marketing of Ethnic Crops in Central New Jersey, USA
Previous Article in Journal
Transcriptome Analysis Reveals Genetic Factors Related to Callus Induction in Barley
Previous Article in Special Issue
Current Skills of Students and Their Expected Future Training Needs on Precision Agriculture: Evidence from Euro-Mediterranean Higher Education Institutes
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:

Ontology-Based IoT Middleware Approach for Smart Livestock Farming toward Agriculture 4.0: A Case Study for Controlling Thermal Environment in a Pig Facility

Department of Natural Resources Management and Agricultural Engineering, Agricultural University of Athens, Iera Odos 75, 11855 Athens, Greece
Department of Industrial Design and Production Engineering, University of West Attica, Thivon 250 and P. Ralli, 12244 Athens, Greece
Center for Research and Technology Hellas (CERTH), Institute for Bio-Economy and Agri-Technology (iBO), Dimarchou Georgiadou 118, 38333 Volos, Greece
Author to whom correspondence should be addressed.
Agronomy 2022, 12(3), 750;
Received: 20 December 2021 / Revised: 9 March 2022 / Accepted: 19 March 2022 / Published: 21 March 2022
(This article belongs to the Special Issue Smart Farming in Service of Modernizing Agriculture)


Integrated farm management (IFM) is promoted as a whole farm approach toward Agriculture 4.0, incorporating smart farming technologies for attempting to limit livestock production’s negative impacts on the environment while increasing productivity with regard to the economic viability of rural communities. The Internet of Things (IoT) may serve as an enabler to ensure key properties—such as interconnectivity, scalability, agility, and interoperability—in IFM systems so that they could provide object-based services while adapting to dynamic changes. This paper focuses on the problem of facilitating the management, processing, and sharing of the vast and heterogeneous data points generated in livestock facilities by introducing distributed IoT middleware as the core of a responsive and adaptive service-oriented IFM system, specifically targeted to enable smart livestock farming in view of its unique requirements. The proposed IoT middleware encompasses the context-awareness approach via the integration of a flexible ontology-based structure for modeling and reasoning. The IoT middleware was assessed in actual conditions on the grounds of a case study for smart control of the thermal environment in a medium-sized pig farming facility. As derived from the obtained evaluation results, the system appears to perform quite satisfactorily in terms of computational performance as well as ontology coherence, consistency, and efficiency.

1. Introduction

Agriculture, as a major sector of primary industry engaged in the provision of food commodities, has evolved throughout time alongside the four industrial revolutions, progressing from Agriculture 1.0 to 4.0. While Agriculture 1.0 refers to the era when farming productivity was kept to low levels due to its reliance on heavy human manual labor and animal power, during the second agricultural revolution, termed as ‘Agriculture 2.0’, the utilization of mechanized equipment and agrochemicals resulted in substantial increase in production efficiency and had far-reaching environmental impacts. Since the mid-20th century, advancements in computing and electronics marked the Agriculture 3.0 era, enabling targeted actions for sophisticated farming production strategies [1]. In this context, the advent of precision agriculture (PA) approach in the early 1990s, established a farm management strategy [2] based on quality and quantity coefficients [3] aiming to control environmental hazards as well as financial hazards. In 2013, the German National Academy of Science and Engineering (acatech) introduced the Industry 4.0 concept [4] which defined the fourth industrial revolution as the establishment of a smart digitized environment involving entirely new capabilities for people and machines [5]. It was not more than a few years later that the advance of this revolution within agriculture set forth to be attributed with the term “Agriculture 4.0” [6,7,8].
Indeed, the PA approach—as defined by the International Society for Precision Agriculture (ISPA) in 2019 [9]—along with the ubiquitous digital technologies involved in Industry 4.0, as in [10], tends to transform agriculture into an information-intensive industry where most of the on- and off-farm management actions rely on a great deal of data. Beyond their large volume, these data are characterized by extended heterogeneity since they are generated through the constant monitoring of various cultivation and livestock related features (location, behavior, environmental conditions, sanitary status, ecological footprint, product safety, etc.) by specialized sensory infrastructure, as well as by third parties (i.e., weather stations) [11].
At any rate, farmers and other agricultural stakeholders—such as agricultural engineers, or veterinary practitioners—seem to encounter difficulties in handling these vast amounts of information [12] and conforming them with their “internal system of practical knowing and learning” [13]. This results correspondingly to difficulty in setting evidentiary and accurate plans of action for financially rewarding production [14], without failing to be in accordance with the established policies for sustainable development [15]. It is therefore essential that dynamic data-driven solutions are made available in order to support farm management not only with regard to the constantly increasing quantity of information that needs to be assessed, but also to some requirements and critical issues which are encompassed in the highly complex concept of sustainable farming, as expanded upon below:
  • Productivity increase. As reported in projections of the United Nations (UN) Population Division, the world’s population is expected to increase from 7.7 billion in 2019 to 8.5 billion by 2030 and up to 9.7 billion by 2050, reaching 10.9 billion by 2100 (42% increase) [16]. Accordingly, agricultural productivity has to be increased by 60% during the 21st century so as to address the challenge of ensuring adequate food supply not only at present, but in the long term as well [17].
  • Reasonable allocation of resources. Industrialization, urbanization, as well as the increase in demand resulting from higher living standards are globally exerting escalating pressures on natural resources. As a matter of fact, 25% of the farmlands and pastures are characterized by severe degradation due to deforestation, vegetation overcutting, and insufficient fallow periods [18]. Additionally, water resources are being excessively consumed compared to water availability while transbasin diversions usually result in grave environmental issues [19]. Last but not least, improper work distribution of agricultural machinery and infrastructure is resulting in excessive energy consumption [20].
  • Climate change mitigation. Climate change has massive ramifications on ecosystems and biodiversity including frequent occurrences of droughts, floods, and extreme weather conditions [21]. Moreover, the atmospheric temperature is expected to rise by 2 °C until 2100 due to the greenhouse effect aggravated by manmade greenhouse gas (GHG) emissions [22]. On top of this, the agricultural sector in particular was responsible for 11% of global manmade GHG emissions in 2013 [23]. Since farming production is exceptionally vulnerable and exposed to the impacts of climate change [24], this could present a considerable threat to global food safety.
  • Food loss elimination. Food loss refers to all edible products that are wasted at any point along the supply chain, including not only products that remain unconsumed in stores and households or those that are blemished during transport [25], but also commodities that are damaged at the early stages of production. Concerning farming production in particular, food loss may occur as a result of agrochemical misuse, lack of pest management in farmlands and pastures, inappropriate disease control of crops and livestock [26,27], etc. Eliminating food loss is a critical issue from an environmental point of view, considering that processing and recycling of wasted food consumes even more resources than producing new commodities [28].
Within the context of the aforementioned guidelines for the so-called “sustainable intensification” [29], the concept of integrated production (IP) is regarded as a solution which contributes to the development of sustainable, resilient, robust, and profitable farming systems. According to the International Organization for Biological and Integrated Control (IOBC) as in [30], IP considers the farming system as a basic unit wherein all interactions among various agricultural features are being performed and synergy among objectives might be realized. Based on this frame of reference, integrated farm management (IFM) [31,32], is being promoted as a whole farm approach that could take advantage of traditional and modern methods for attempting to limit the negative impact of farming production on the environment, while increasing productivity and retaining a focus on the economic viability of rural communities [33].
Currently, a variety of solutions—widely known as farm management systems (FMSs) [34] or farm management information systems (FMISs) [35]—have been developed to assist farmers in managing their farms more effectively. In general, these systems conform to specified reference models [36] and their operations focus on distinct tasks—such as data monitoring and targeted control services—via standalone applications which could be characterized as rather unwieldy, since they are tightly connected to each system’s specifications. Seeing that interoperability and scalability are the main determinants of successful IFM, offering intelligent systems that will be based on the potent synergy of infrastructure, technologies, applications, and stakeholders is considered to be of fundamental importance. Furthermore, limitations regarding computation power, data storage, and farmers’ hesitance in adapting to change need to be overcome for the pervasive implementation of IP in agriculture.
The Internet of Things (IoT) is a cutting-edge technology according to which an intelligent network, such as the Internet, is employed for virtually representing and interconnecting physical objects (things) [37,38]. Based on these characteristics, the IoT is considered to be the best means for ensuring key features—such as interconnectivity, scalability, agility, and interoperability—in IFM systems, enabling them to provide object-related services, as well as to be potent in adjusting to dynamic changes [39]. In particular, consolidating the IoT in IFM may empower the automated control of farming activities beyond the making of decisions, via the partially or fully autonomous real-time interaction among the various embedded devices (sensors, actuators, RFIDs, NFC tags, etc.) and farm machinery [40] in collaboration with management systems. In this way, precision agriculture practices are being further developed, advancing into the knowledge-based approach of smart farming as in [38,41,42,43].
Nevertheless, since an abundant number of heterogeneous IoT smart devices is being deployed in farms involving various sensing, communication, and processing schemes, there is still a main issue that has to be addressed in order to develop a functionally powerful IFM system involving the IoT technologies, especially taking into account that by 2050 a typical farm is estimated to generate about 4.1 million raw data points per day [6]. According to literature, a way to meet this challenge is by enhancing machine-to-machine (M2M) interaction through the concerted application of universal standards and protocols as in [44,45,46,47]. This solution however does not seem to be operational at present since most proprietary smart devices comply to their own specifications, while manufacturers are quite unwilling to intensify the interoperability of their products [48]. Another more feasible option that could facilitate the system’s interoperability is the implementation of a middleware centric solution, capable of structuring heterogeneous sensory raw data into processable and exchangeable information formats [49].
Middleware, which can be defined as a software that enhances interoperability among incompatible devices and applications, may provide fundamental—as well as multidisciplinary—functions and services such as data management, access control, and service discovery [50]. In a basic layered IoT architecture approach as shown in Figure 1, the middleware acts as an interface between the physical devices (low level) and the applications (high level).
Since farming environments tend to be rather complex, as they involve diverse features related to ambient parameters which quite obviously vary depending on the physiology and the environmental conditions of distinct exploitations [51], advanced IFM systems corporate an assortment of applications with various inputs and outputs. Hence, due to this obvious disparity, it is essential for the IoT middleware to have an effective higher abstraction level in order to eradicate the communication complexity in the low level as well as the applications diversity in the high level, even if these are unknown at the stage of the design. Additionally, given the fact that the constant advancement of novel smart devices is evenly increasing the demand for more sophisticated services, the performance of such functions in the devices themselves or within local computing infrastructures could result in unscalable and inadequate IFM systems. For this, it is important to transfer middleware operations centrally into a cloud-distributed environment for facilitating the provision of composite services.
Provided that the research community has already recognized the high significance of enabling the Industry 4.0 technologies in farming operations toward the context of Agriculture 4.0 and for the benefit of sustainable intensification [29], this paper aims to propose a functional architecture of an IFM system utilizing IoT middleware as an enabling technology. Our scope was not to develop an entirely new architectural framework for IFMs, but rather to focus on those functions that can be optimized via the integration of the IoT middleware capabilities, with an emphasis on context awareness as well as on the context modeling structure and reasoning process. Taking further into consideration that during our previous research (as in [52]) we have already coped with the design and application of a context-aware middleware approach for consolidating the IoT into arable farming facilities, in this paper we attempt to present an ontology-based solution which will be adapted to smart livestock farming with regard to the particularities as well as the special demands of animal husbandry.
The remainder of the paper is organized into four sections as follows. Section 2 overviews the state of the art regarding smart livestock farming with a focus on IoT technologies and context-aware middleware approaches. In addition, some open issues are reported and motivational objectives are identified. In Section 3, which concerns the materials and methods of our work, at first the operational and architectural overview of the integrated information system is presented; subsequently, the IoT middleware design is analyzed. Finally, a thorough description of the IoT middleware context modeling structure is provided with an emphasis on the development of the related ontologies. Section 4 deals with a case study on the smart control of the thermal environment in a pig farming facility which was performed in order to evaluate the performance of the proposed IoT middleware with an emphasis on its modeling structure and reasoning techniques. As proof of concept, the results derived by the performance evaluation are presented at the end of this section. Finally, in Section 5 the outcomes of our work are discussed and some future directions for further research are outlined. The paper is concluded in Section 6.

2. Smart Livestock Farming: State of the Art and Open Issues

Livestock farming is one of the main pillars of the agricultural industry by contributing to food safety [17] as well as by providing employment and generating income. In fact, as in [53], products of animal origin (bovines, swine, sheep and goats, poultry, etc.) accounted for 40% of the European Union’s (EU) total value of agricultural production in 2017. Globally, the livestock industry is quickly evolving, as a result to the increasing demand for animal origin commodities (e.g., meat, dairy products, eggs, wool, leather, etc.) which is driven by population expansion and the rapid rate of urbanization, as well as by the increasing prosperity in the industrialized world and most developing countries [54]. Besides the opportunities associated with the prompt evolution of the livestock sector, there are also several challenges arising from operational, environmental, health, and socio-economic issues [55].
What presently characterizes livestock farming is its intense nature which is related to higher levels of input (such as farm size, human labor, financial assets, etc.) and output per farming unit. In this regard, the number of farms is reduced while the number of animals which are being bred in enclosed, climate-controlled, automated facilities is increasing [56]. Furthermore, vertical integration is customary in the sense that a singular enterprise may be in control of the entire production system (e.g., from the feed mill up to the processing plant) which is set up for maximum output with all of its parts operating consistently at full capacity [57]. Consequently, any flow agitations at whichever part of the production chain have immediate imprints both upstream and downstream, resulting in instant ramifications not only for animal welfare but also for humans and the environment. This is in line with the recent concept of “One Welfare” which, as in [58], acknowledges the direct and indirect interconnections among animal welfare, human well-being, and the environment.
Natural events and disasters (i.e., fire, floods, earthquakes, hurricanes, tornadoes, etc.) are typical incidents which immensely disrupt the farming production chain on a regular basis. On top of this, the swine influenza (H1N1) pandemic which resulted in a high number of infections in more than 214 countries with over 18,449 deaths worldwide during 2009 [59]—along with the outbreak of the more severe COVID-19 pandemic [60], occurring since the end of 2019 and up to the time of writing—highlighted the complex interconnections that are encompassed by the “One Welfare” concept. These two pandemics further revealed the impact of flow agitations in intensive livestock production systems due to extensive interruptions in the process and supply chain, causing increased food loss [61,62]. Within the context of sustainability, it is essential that whenever systems encounter a sudden distress—such as a natural disaster or even a pandemic outbreak—that they be able to quickly absorb it and recover normal outputs while also acquiring the knowledge to promptly respond to any unexpected future adversities [62].
The emergence of Information and Communication Technology (ICT) and its implementation in animal husbandry has given way to precision livestock farming (PLF) which has expanded sustainable intensification in livestock production systems since the early 2000s. PLF, which is actually the adaption of the PA concept into livestock, has been attributed with several, slightly diverse definitions in literature as in [63,64,65,66,67]. The most acknowledged among these definitions is the one given by D. Berckmans as in [66] according to which PLF focuses on the development of a management system based on the constant real-time monitoring of parameters which are related to the health, welfare, breeding, as well as production and reproduction of each animal (even within large herds), leading to evidence-based decisions on livestock production with regard to the environmental impact. For this, PLF incorporates various corresponding fields—such as bio-engineering, animal sciences, socio-economics, and computing—in order to be capable of providing systems that could perform advanced monitoring and managing techniques for the benefit of the livestock, implicated stakeholders, the environment, and society in general [68].
Although, in the literature, PLF is frequently attributed with the term “Smart Livestock Farming” [69] as well, this not entirely substantiated, since (as in [70]) PLF focuses mostly on the digital processing of specific information for the support of decision making by the stakeholders. Smart livestock farming, on the other hand, is considered to be a knowledge-based concept, since the farm machinery—as well as the devices [40] themselves—should be capable of performing automated operations according to real-time, autonomously acquired and processed information [38,41,42,43]. Nevertheless, it has to be clearly stated that stakeholders—such as farmers, veterinary practitioners, and agricultural engineers—should always have the ability to take any required corrective actions according to their expertise, especially since the biological data from animals, which are acquired by technological devices, do not always provide desirable rates as reported in extensive studies [71,72,73] concerning field experiences in various animal production value chains.
Toward this objective and according to the guidelines for the operative implementation of the Agriculture 4.0 concept [10] into livestock farming, IFM is considered to be potent in promoting a whole-farm approach as in [74], wherein the system’s capabilities can be grouped into four smart interconnected stages, which are: monitoring, control, optimization, and autonomy. To this end, each stage is structured based on the preceding one as shown in Figure 2.
As a case in point, for the system to be capable of performing control operations, it is essential to have a monitoring capability and so on. The IoT acts as the enabling technology for interconnecting these four stages. Practically, the IoT (as in [38,39]) benefits the system with sensory and computational support as the optimum interconnection to be achieved among the four stages via a highly distributed public network, such as the Internet. In particular, the IoT is regarded to be essential for: (a) decentralizing advanced analytics and enable real-time decision making, (b) optimizing the management of assets, and (c) enhancing the performance of the production process.
Since the smart farming approach relies highly on the acquisition—as well as the processing and analyzing—of large amounts of heterogeneous data for optimizing the processes, equipping IFM systems with scalable middleware solutions is considered to be of high importance for their responsive and adaptive operation [75].
A holistic literature search yielded several results about the utilization of the IoT technologies in livestock farming. The indicative literature finally selected [75,76,77,78,79,80,81,82,83], and presented in Table 1, reflects the results of thorough study, conducted according to the methodology as in [84,85] since it is considered quite efficient for finding related research sources that meet strict qualitative criteria.
Additionally, in our previously published research (as in [52]), information may be found regarding standards and data models that were established on the grounds of the FIWARE and the oneM2M projects. These cover some critical issues concerning the interoperability and the semantic annotation of heterogeneous data that have to be handled in IoT agricultural applications and services.
Nevertheless, to the best of our knowledge there are not significant works focusing on the issue of developing an IoT middleware specially addressing the requirements of IFM systems for smart livestock farming. Provided that the field of animal husbandry is characterized by excessive complexity due to its nature, we consider that proposing a distributed IoT middleware-centric solution for the IFM systems could be of benefit to the further development of smart livestock farming, especially toward sustainable intensification in the context of Agriculture 4.0.

3. Materials and Methods

3.1. IFM System Operational and Architectural Overview

The agility of an IFM system consolidating the IoT technologies lies in its capacity to use the cloud for self-discovery and self-configuration, and to provide on-demand services to livestock facilities in remote rural areas. According to the IFM system operational framework shown in Figure 3, the raw data that are collected remotely from the sensory devices of a Wireless Sensor and Actuator Network (WSAN) deployed at a livestock facility are forwarded along with external data inputs to the cloud distributed middleware through gateways.
Therein, all data are analyzed and processed into information using data fusion [86] and machine learning (ML) techniques [87] to achieve higher reliability and lower probability of error occurrences. Subsequently, the cloud middleware responds with control actions to the smart devices of the IFM system as well as to the end users, providing them with monitoring information and services. The end users can intervene at any time to the IFM system operations with corrective or assistive actions. It is worth noting that all cloud services (IaaS, PaaS, and SaaS) should preferably be offered through a public or hybrid cloud for use by all the stakeholders. Due to the fact that most livestock farming facilities are small-to-medium-sized, hosting the proposed system in a public cloud is considered to be the most suitable solution, as the cloud services will use the hardware infrastructure and computing power of the cloud service provider.
As aforementioned, the IoT may serve as the enabling technology for effective IFM that could ensure maximum livestock production with optimal quality and increased profitability taking into regard the policies for sustainable intensification. According to this, an IFM architectural framework consisting of three main layers is shown in Figure 4 and explained below.

3.1.1. Perception Layer

In the event of consolidating the IoT into typical IFM systems, wireless technologies are considered as the most important feature to enable real-time intelligent interactions between animals and multiple embedded devices with or without human mediation [76,88]. To this end, the lower level represents the perception layer which involves a WSAN integrated in a livestock facility. The WSAN consists of groups of self-powered nodes deployed in a mesh network topology as in [89] with sufficient communication range for long-distance operation [48], as well as data rate and power consumption. These nodes are equipped with sensors (such as wearable sensing and biometric devices) that remotely collect real-time data on various parameters related to the animals’ physiology and behavior [90,91,92], as well as to the livestock facility in general. Additionally, the WSAN involves actuators that interact with the farm machinery and devices, enabling the corresponding physical actions. Regarding the hardware architecture of the wireless nodes, different solutions have been presented, specifically designed for the harsh operating environment in rural areas. The block diagram of a typical WSAN node for the livestock industry is shown in Figure 5.

3.1.2. Middleware Layer

The middleware layer acts as an interface between the perception and the application layers which provides perceptive and collective functions, as well as services including (but not limited to) device and data management, access control, and service discovery. In particular, depending on the IFM system’s requirements, the middleware is accountable for generating the required information in order for various operations to be applied and processed in parallel [68] such as:
  • Monitoring/control of (a) the animals’ physical and biological parameters such as heart rate, temperature, behavior as well as location; and (b) ambient conditions such as environmental temperature and humidity, gas emissions, etc.
  • Forecast/control of imminent animal diseases such as tetanus, parturient paresis (milk fever), listeriosis, etc.
  • Surveillance and security control of the animals and the livestock facilities in general.
Considering that the main objective of our work is to propose a middleware-centric solution for consolidating the IoT into arable farming facilities, the middleware design is going to be thoroughly described in Section 3.2.

3.1.3. Application Layer

The application layer consists of three cloud components (real-time monitoring, facilities control, and services) that include Software as a Service (SaaS) capabilities and are accountable for providing all important applications (apps) for end-user interaction with the IFM system. By subscribing and logging into the cloud platform, end-users cannot only receive services related to the observed conditions of the animals and the farming facilities (such as symptom detection and advisory services), but also provide rules for control actions using simple query mechanisms. All rules stored in the cloud context repository can be retrieved by using appropriate service provisioning techniques. In this sense, the application layer is enhanced with logic which significantly contributes to the middleware self-adaptation, since it can retrieve high-level contextual information at any time and receive corresponding decisions upon equivalent actions.

3.2. IoT Middleware Design Analysis

The functionalities required by the proposed IoT middleware are primarily defined by the need of processing and managing the voluminous and heterogeneous amounts of data that are generated in the complex livestock farming environments in order to achieve the effective interconnection of smart devices involved in it. Context awareness—which refers to the property of a system to be constantly aware of its current state both in the physical and virtual environment—has been proven to be a substantial asset of the IoT [93,94], enabling exactly these desired functionalities. Additionally, by properly integrating a semantic ontology model [95] in the context-aware middleware, the proficiency, flexibility, and scalability of the entire IFM system are expected to be ensured. Furthermore, the proposed IoT middleware aims to add to the system’s robustness by encompassing the Infrastructure as a Service (IaaS) properties of cloud computing for reserving the required computational power and storage capacity. A more detailed analysis of the IoT middleware design, as depicted earlier in Figure 4, can be found in the following subsections.

3.2.1. Context Detection

Although several definitions of “context” can be found in literature, the one appointed by Dey and Abowd [96] simplifies the context detection for a specific application scenario. According to this definition, “context is any information that can be used to characterize the situation of an entity. An entity is a person, place, or object that is considered relevant to the interaction between a user and an application, including the user and applications themselves”.
Context detection refers to the collection of the raw data that are acquired by the IFM system’s sensory devices in the perception layer as well as to the identification of the main factors which affect the system’s responses. The context providers, along with the context aggregator, are responsible for converting the sensory acquired data into recognizable forms of context by applying reasoning procedures.
Reasoning, which is triggered instantly as the first raw sensory data are acquired, involves three operations: data preprocessing, sensor fusion, and context inference [97]. During data preprocessing and sensor fusion, numerical sensory data are converted into coherent strings and can be enhanced via fuzzy logic for increasing their quality. While the context providers perform the fundamental abstraction, the context aggregator reasoning mechanism handles the conversion into standard information suitable for recognition by the set of system entities. In more detail, the context aggregator refers to a distributed cloud service equipped with computational logic [98] for the integration as well as the interpretation of the whole context, which is considered to be essential for the interoperability between the data information of the sensors and the service-providing entities. On this basis, individual classification techniques are being applied, whereas in case the classification is unknown, unsupervised learning techniques facilitate the preprocessing step by performing the identification of unusual measurements involving outliers and/or missing values [99]. Nevertheless, the output of the data preprocessing and sensor fusion operations is considered to be still low-level context and for this it will be further converted into high-level context by the context inference engine as part of the context processing operations which are going to be detailed in a following subsection.
Furthermore, for the context to be functional, it must be specified and stored in a machine-readable and editable form. This could be achieved by using a modeling structure that defines, represents, and edits the context data in a uniform, understandable, and shareable format. Without a precise, unambiguous, and flexible modeling structure, applications would not be able to adequately capture and use the contextual data. On top of this, the structure should be able to integrate not only current functionality, but also any future changes and requirements. Since the context modeling structure is of great significance for the operability and scalability of the IoT middleware, this is described in detail in Section 3.3.

3.2.2. Context Processing

Context processing, which is the core part of the context aware IoT middleware, involves a number of four distributed engines that interact with each other, fusing their operations as shown previously in Figure 4 and described as follows:
Context Retrieval Engine
This engine is responsible for initiating requests to periodically retrieve context information via the context aggregator and distribute it to the appropriate system components. Moreover, all system components can initiate context requests by simply using a web service running in the cloud server with an ID and an attribute context set. In more detail, all system components requiring particular contextual information are capable of subscribing into the IoT middleware cloud so as to receive notifications each time an update of their interest occurs while they can also address active queries for critical contextual information at any time. After infiltrating any duplicate and inappropriate contextual data, the retrieval engine returns the most relevant and accurate information as a response to the corresponding system component.
Context Inference Engine
Although, as aforementioned, most of the reasoning process is performed during context detection, the output result is still low-leveled. The context inference engine is thus responsible for the completion of the reasoning process by converting low-level contextual data to high-level information that can be of good use into the IFM system for efficient service delivery. The main reasoning operations that are being performed in the inference engine deal with: (a) the validation and complex representation of context values, (b) the elimination of the uncertainty that may be caused by context inconsistencies and/or missing contextual data, and (c) the reassurance of the required computational performance in order to extract high-level quality contextual information. Thus, the context inference engine applies specific reasoning techniques based on their suitability to address each one of the aforementioned specific issues.
Service Mapping Engine
Service mapping is the operation of implementing appropriate matching criteria and algorithms in order to discover all of the best possible matches between context and the corresponding services, as well as to combine these matches together with suitable actions. In this sense, the service mapping engine maps all dependencies based on a connection between context, services, and actions. This method, which can be referred to as top-down mapping, follows a tree-like modeling structure in which context is placed at its root at the top level while its branches are constituted by nodes which represent the main entities followed by children nodes and so on. This top-down mapping assists in easily discovering the best possible matches by following the traffic connections between them, as well as in immediately identifying the impact of a problematic entity on the rest of the service operation.
Service Discovery Engine
Service rules regarding several operational aspects are generated by end users (agricultural stakeholders) along with the IoT middleware itself. In this sense, the detection, association, and coordination of the already existing services is essential for the high-functioning performance of the entire IFM system. For this, the service discovery engine is responsible for using centralized or distributed repositories to store appropriate service profiles with parameters, attributes, and locations that are required to execute further queries according to specified protocols such as simple service discovery protocol (SSDP) and service discovery service (SDS).

3.2.3. Self-Adaptation

The ability of self-adaptation is an essential prerequisite in the context aware middleware, such that context is provided as input to generate the right services and control actions [100]. In this process, self-adaptation takes over the diagnosis, detection, and correction of possible errors in the middleware workflow. In particular, due to the self-adaptation, the context aware middleware is able to reduce the proposed system’s cycle of development each time a similar pattern is detected in the context by identifying action sets, storing this information and improving the knowledge base. It is further considered that the requirements of processing and obtaining the most accurate results will be met while respecting the real-time constraints during the analysis.

3.2.4. Context Repository

Taking into consideration the voluminous amount of data that are generated and processed, a distributed cloud repository should be incorporated into the system to ensure the conservation of contextual information. Progressive data and their respective contexts are stored in the context aware middleware cloud as an expandable knowledge base of ontologies while all attributes are stored as key-value pairs in various ontology repositories, simplifying the query versions. All of the system components, as well as the devices, are assigned with a unique ID for the context repository to distinct the incoming contextual data. The storage of context is highly required since context history is a critical source of knowledge for the planning of processes, the prediction of future actions that need to be undertaken, as well as for the inference processes.

3.2.5. Security

Great emphasis is placed on ensuring security and privacy, as several of the data collected, processed, and managed within the context aware middleware cloud is sensitive. In this sense, the security is expected to be ensured by executing specific functions that detect and monitor possible irregularities or unauthorized accesses to data. Precisely identifying access control and encryption or authentication of contextual data during transmission and storage processes are the two basic mechanisms used to execute security functions.

3.3. IoT Middleware Context Modeling Structure

Among the various existing modeling techniques that can be found in literature, the semantic ontology approach is the most effective in terms of formality, interoperability, and reusability [101], focusing on a generic model design which can assist the composition of context aware services for smart livestock management. Taking into account that the modeling structure should represent—in the best possible way—not only the conceptual data correlation to a situation but also the data generation circumstances and their variability, a synthesis of three widely accepted context categorization approaches is applied, that is the “5 Ws and H” as in [102] along with event driven representation as in [103] and an operational schema as in [104]. According to this, context is described by five core parent ontologies that may have attributes describing their basic properties. In addition, entities are included as part of the parent ontologies, while they may also have some other children entities to describe them.
The five core ontologies are associated with relations, according to which each single instance represents the monitoring of a unique situation that describes an event involving a thing and occurring at specified location and time. The event is identified or triggered based on one or more rules. The proposed ontology-based context modeling structure is developed in the form of the Web Ontology Language (OWL) 2.0 [105] while it can be implemented in extensible markup language (XML) which is a platform-independent and resilient tool, suitable for use in different phases of information representation as well as for communication based on the simple object access protocol (SOAP). The five core ontologies, along with their associations, are demonstrated in Figure 6 and are described comprehensively in the following subsections.

3.3.1. Thing Ontology

The thing ontology constitutes the core of the context model, since this is the major building block of the IoT. Since, a ‘thing’ can be either a user, an object (in this case an animal), or a device, it is modeled by three subclasses which are defined by a number of static properties, while each ‘thing’ subclass may have children subclasses for further categorization.
Moreover, the ‘thing’ requirements and restrictions—along with the corresponding location and time constraints for a particular situation—are defined by various profiles that may be multiply employed, while on top of this, location and time constraints also apply to the various roles a ‘thing’ might have. For instance, more than one animal (thing) may be piglets (role) sharing the same profile that sets particular environmental requirements for their housing during the first 7 to 10 days after their birth. Finally, each ‘thing’ has a location and is associated to a variety of events establishing in this way dynamic relations which descend by the inference process that is repeatedly executed to sustain such information up to date. The thing ontology as aforementioned described is demonstrated as follows in Figure 7 with emphasis on the device subclasses for the sake of brevity. Finally, a legend for the schemes used in the representation of the ontologies is presented in Table 2.

3.3.2. Location Ontology

Events occur in places which refer to physical ambient spaces and are strongly correlated to the operation of livestock farming facilities. For this purpose, a location ontology is required to be developed, taking into account the location context for events as depicted in Figure 8.
This ontology involves two location subclasses which correspond to indoor and outdoor spaces. A location may be part of, or adjacent to, one or more other locations, thus the inheritance and proximity functionalities are modeled with suitable self-referential relations. Additionally, a location may have several positions which can be absolute (e.g., exact geo-positioning) for qualifying the modeling of outdoor spaces, or relative (e.g., quarters, corridors, pens) for permitting the modeling of places that cannot be defined by absolute positioning, such as indoor spaces. Finally, a location may have various profiles depending on their scope that can be either general for modeling the correlated requirements and properties, or authorized for modeling the corresponding privileges and accessibility options. The location ontology is also related to two external ontologies, ‘thing’ and ‘event’, since one more thing can be placed in the same or adjacent locations, while events may occur correspondingly. The sensory measurement of environmental parameters (e.g., temperature, humidity) is, for instance, an event which is performed by a ‘thing’ that is a sensor in a location that is a pig house.

3.3.3. Time Ontology

The time context is employed to define the temporal occurrences of an event that need to be timestamped, thus in order to model the corresponding properties, a time ontology is required to be developed as shown in Figure 9.
For modeling the time context, it has been additionally taken into account that time is not explicitly limited to the occurrence of events but to their scheduling as well. In addition, the time is considered as ‘instant’ to represent an exact timestamp attributed to events without continuance, such as alarm activation, or as ‘interval’ to represent a timeframe with duration. Each ‘interval’ has an instant beginning or ending in order to express the start and end time. Finally, time also has a profile for modeling any requirements and restrictions.

3.3.4. Event Ontology

The event context is employed to define events; thus, an event ontology is required to be developed as shown in Figure 10 in order to represent a wide range of events from typical livestock farming activities to events triggered by device actuation or stakeholders’ (users) decisions.
This ontology involves two event subclasses which correspond to instant (e.g., the ventilator is activated) or continuing (e.g., the CCTV is recording) events. In this scheme, modeling the triggering of an event by apprehending all relevant context, including the one deriving by rules, is considered to be more efficient, since an event can be triggered by a ‘thing’ or a ‘rule’ while the event itself might also trigger a thing (e.g., manure emissions increase, triggering the ventilator activation) or a rule stored in the repository. An event can also be part or follow another event and for this it is modeled with suitable self-relations. Furthermore, as previously mentioned in Section 3.3.3, an event is also related to the time ontology while, as in Section 3.3.2, an activity can also have various profiles for modeling the corresponding privileges and accessibility options (e.g., device usage permissions). Finally, the event ontology is indirectly associated to the location one, through the ‘things’ that are engaged in the events and placed in certain locations.

3.3.5. Rule Ontology

The rule ontology refers to the context which derives by the circumstances of a monitored event occurrence as depicted in Figure 11, in order to enable the modeling of inference results that can be of benefit during other subsequent inference processes.
In this sense, rule context is created for each monitored occurrence as well as for each thing, location, time, and event that is associated to it. For instance, an air-conditioning unit is automatically activated as a result of a sensing/actuating automated mode event in a pig housing facility during a specified timeframe. In the case that a farmer decides to interfere in the event by increasing or decreasing the desired temperature, this event—along with the reason for its emergence—is registered as a new rule.

3.3.6. Properties of Ontology Entities

The ontology entities described in the aforementioned subsections have properties which define their internal features and associate them with other classes. The number and range of such properties depend on each particular application as well as on the automation level provided by the IFM system. Some indicative properties of the ontology entities are overviewed in Table 3.

4. Case Study: Smart Control of Thermal Environment in Pig Farming Facility

In order to evaluate the performance of the proposed IoT middleware with emphasis on its modeling structure and reasoning techniques, a case study on the smart control of the thermal environment in a pig farming facility was performed. Considering that pig farming is one of the most technologically advanced and continuously growing livestock production sectors, IFM could assist in the assessment of each individual animal and assure its welfare and feed efficiency. To be able to adjust the IoT middleware parameters, as well as to interpret and understand the data collected during the performance evaluation, it is worth mentioning some key components of a pig’s environment as in [106,107]. By comprehending the environmental needs of a pig, appropriate actions can be taken to provide the best environment and reach the optimal production.
A most critical factor for a pig’s health is the thermoneutral zone (TNZ), that is the range of the ambient temperature wherein a pig can maintain its internal temperature with minimum effort. The normal TNZ for a pig ranges approximately from 15 °C to 30 °C, depending on its age and weight (the ideal TNZ for an adult pig is about 20 °C). Thermal environment is created by the interaction of air temperature, moisture, and airflow and its control is essential in swine production since it affects the behavior and welfare of pigs. With the exception of very young and small piglets, pigs cope better with cold weather than hot weather. In cold ambient temperatures, pigs feed more, huddle together, and more energy is expended to maintain their body temperature. On the other hand, high environmental temperatures reduce pig performance more than the low ones. High temperatures make pigs breathe heavily and reduce the consumption of food while increasing their water intake. In any case, if ambient temperatures remain either low or above the TNZ for long periods of time, the ability of pigs to maintain their body temperature may be overwhelmed (heat stress) and even result in mortality. Pig behavior under the different environmental temperatures, as well some indicative corresponding assistive actions that need to be taken in order to optimize performance, are overviewed in Table 4.
For the purpose of accuracy, the raw data were collected under actual operating conditions at a medium-sized pig farming facility in the regional unit of Fthiotida, approximately 120 km north of Athens, Greece. The acquisition of raw data was performed over a period of two months (May to June 2021), incorporating wireless environmental sensors as well as proprietary wearable sensory devices (RFID ear tags) which were already being used on the pigs housed in the facility (more information about the environmental sensors and RFID tags may be found in Section 4.2). The acquired data from the sensory devices, as well as the data obtained by user devices, were transmitted to the cloud IoT middleware employing Wi-Fi protocols. The main scope of the model’s pilot implementation was primarily to test the IoT middleware response, as well as its ability to successfully structure context by the sensory acquired raw data and control certain equipment operations in the pig house with emphasis on the modeling structure and reasoning techniques.
To investigate the functionality of the IoT middleware for IFM management, as described in the previous section, a model was developed using the Python programming language [108] for prototyping and the Microsoft Azure platform [109] for cloud computing infrastructure and services. An overview of the software features that were incorporated to the IoT middleware development is presented in Table 5.

4.1. Context Modeling and Reasoning

Taking into account the modeling structure that was thoroughly described in Section 3.3, a number of required ontologies and their subclasses were incorporated and adjusted for the needs of the specified case study as follows:
  • Thing (Device Subclass): It involves all types of devices. In particular: (a) environmental sensors are incorporated for monitoring ambient temperature and humidity, (b) RFID tags are used to monitor the pigs’ physiology features of interest (body temperature and heart rate) as well as to identify their exact ID and position, (c) actuators are employed for triggering the proper equipment (air-conditioning system) of the facility, and (d) smart devices such as smartphones and tablets are used for establishing the users interaction to the system.
  • Thing (Animal Subclass): It involves the animal species of interest, in this case pigs.
  • Thing (User Subclass): It involves two types of users, that is farmers and veterinarians, as notification recipients for undertaking further proactive actions related to the wellbeing of the pigs housed in the facility.
  • Location (Indoor Space Subclass): It involves the building layout (area) as well as the points of interest such as the quarters, corridors, and pens that are involved in the process. It also involves a profile including the environmental requirements of the location of interest.
  • Time: It involves various daily timeframes that may affect the ambient conditions. For instance, temperature tends to be higher during the noon hours (maximum effect). Furthermore, time refers to the occurrence of events that are triggered by internal or external rules.
  • Event: It involves the entire IoT activity, such as the monitoring of parameters and the control of the corresponding devices as well as the user interactions to the system.
  • Rule: It involves the rules applied during the entire IoT activity. The rules may be applied according to the reasoning process or be dictated into the middleware by the users.
Despite the fact that the main ontologies of the modeling structure were developed for a wide range of IFMs, it results that they are easily adjusted to the scenario of the specified case study. An instance of the indicative modeling structure for smart control of the thermal environment in the pig farming facility of interest is depicted in Figure 12.
According to the specified case study scenario and the corresponding modeling structure, a number of wireless sensors (as in Section 4.2) which maintain certain properties (ID, node and network) are placed in a specified quarter of a pig house building for measuring the ambient temperature and humidity. The quarter contains a number of pens which are divided by corridors. The location has a relative position in terms of a certain ID and area dimensions (m2) as well as a certain profile which describes the spatial environmental requirements and restrictions (temperature, humidity, luminosity). The animals involved in the case study scenario are obviously pigs which have special characteristics (ID, breed, gender, and birthdate) and are attached with proprietary RFID tags. The sensors acquire certain observation values which are processed into contextual information that subsequently triggers one or more rules responding with another event, that is the actuation of the proper equipment (air-conditioning system), for the maintenance of the ideal thermal environment for the pigs. The observation instances also trigger notification events which are targeted to the users’ composed devises (smartphones and tablets) via smart applications. In this way, the authorized users can be able to intervene in the process by triggering new rules.
Regarding context reasoning, this is an effective process for advancing a query system of logical consequences based on the entities of the context modeling structure. Taking into account that the modeling structure was developed based on “5 Ws and H” approach along with event driven representation, answering any query about the pig farming facility as well as its thermal environment is considered to be quite useful. The context reasoning involving queries is implemented by applying the Semantic Query-Enhanced Web Rule Language (SQWRL) [110] over thing, location, time, and event contexts. In accordance with this, a query asking about the position of temperature increase is formed as “temperatureIncrease (?event) ∧ occurs (?event, ?position) → sqwrl:select (?position)” in terms of SQWRL.
Furthermore, the inference process which is accountable for generating new knowledge in the context model, is implemented by applying the classic if-then logic rules in the Semantic Web Rule Language (SWRL) [111] as it enables the expression of inferences in terms of the OWL approach. For instance, a logical consequence stating that an event is detected by a particular sensor node which is placed in a specific position and therefore the event occurred in this position is expressed as “temperatureIncrease (?event) ∧ location (?position) ∧ sensor (?deviceID, ?node) ∧ detectedBy (?event, ?deviceID, ?node) ∧ sensorIsLocated (?deviceID, ?node?, position) → happensIn (?event, ?position)” in terms of a SWRL rule.
Finally, considering that the sensory data may be characterized by a certain degree of uncertainty, various abstraction levels and a number of feature selection techniques—such as classification and clustering—are required in order to enhance the accuracy of content values and obtain lower error probability as well as higher reliability [112]. To this purpose, in addition to typical if–then logic rules, the unsupervised outlier detection using the local outlier factor (LOF) method along with the isolation forest algorithm are employed for enhancing the unsupervised identification of patterns so that abnormal observations can be identified and irregular values can be isolated. The output results of these methods are stored in the context repository and are being retrieved by the rules whenever required.
The performed case study addresses the necessity of smart controlling the thermal environment in a pig farming facility based on an ontology-based IoT middleware for IFM systems. Nevertheless, the open architecture of the proposed system enables the development of additional applications for performing specialized monitoring and control, decision support services, management and optimization of livestock farming facilities, etc.

4.2. Performance Evaluation and Results

As aforementioned, the IoT middleware was deployed in a medium-sized pig farming facility for a period of two months (May to June 2021). At first, raw data were acquired by a number of environmental sensors incorporating the SensoTube open architecture as previously introduced by Piromalis and Arvanitis [113], as well as by other devices such as proprietary RFID tags Figure 13 (Mifare S-50 and Monza-5 RFID ear tags manufactured by the Card Cube Group in China).
Simulation tests regarding the performance and scalability of the IoT middleware have also been performed involving a considerable amount of data derived by simulated devices. The implementation process originally involved 300 datasets and gradually increased up to approximately 8000 sample sets, considering a sampling rate of 60 min on a daily basis. The sample sets were containing parameters in the form of numerical values about air temperature and humidity. Nevertheless, testing the proposed system in actual conditions allowed its proper analysis and evaluation in terms of computational performance as well as ontology coherence, consistency, and efficiency.
To begin with, during the actual implementation of the IoT middleware in the pig farming facility, it has been verified that the raw sensory data were adequately captured, transmitted, stored, and managed in the Microsoft Azure cloud platform to retrieve relevant information, as shown in Figure 14. Metrics—as numerical values that help understand the health, operation, and performance of the system—are also available by the Azure Platform.
The computational performance evaluation originally involved the incorporation of approximately 60 deployed devices (sensors, actuators, and mobile smart devices). During this experiment, the IoT middleware has not revealed any bottlenecking, as expected due to the small amount of context data and rules to be processed. Following this, the number of deployed devices was progressively increased up to 300, involving additionally proprietary RFID tags, which correspondingly escalated the load of context data and rules. At the final step of the evaluation process, a considerable amount of data derived by simulated devices has been involved in order to test the computational performance under conditions of data overload. For validating the computational performance of the system, the average inference cycle time, along with the average response time, have been examined. The inference cycle time refers to the average time that is required by the IoT middleware for processing a number of corresponding rules while the response time refers to the average time which is required for the process of a request from its arrival into the IoT middleware until the dissemination of the processed contextual information to the applications of interest. The findings of the computational performance evaluation are listed in Table 6.
According to Figure 15, it appears that both the inference cycle time—as well as the response time—are linearly correlated to the number of the added devices and rules to be processed, indicating that the IoT middleware responds efficiently to greater volumes of context data. The aspect that the IoT middleware can completely scan context-aware situations of interest in an efficient timeframe is additionally justified by the linear correlation between the inference cycle time and the response time as in Figure 16.
In terms of context representation and reasoning, the proposed modeling structure has been verified by running the Pellet incremental reasoner, available in the “Protégé”, which is a free, open-source ontology framework for building intelligent systems [114]. As shown in Figure 17, the entire modeling structure consists of 1277 axioms (858 logical), 31 classes, 36 object properties, 51 data properties, and 1039 individuals, running with no inferences.
As part of the system’s evaluation, the performance of implementing unsupervised outlier detection using the local outlier factor (LOF) method—along with the isolation forest algorithm for enhancing the unsupervised identification of patterns—has also been tested. Let as note that, for this purpose, the Python programming language was used. The graph in Figure 18 illustrates two scatter plots of data regarding observed values of the thermal environment during the evaluation period. The two clusters are considered as two groups of breeds based on the data provided by the correlation of the Animal and Device entities as shown in Figure 12. The two groups of breeds indicate different kinds of behavior under the two different scenarios of temperature requirements. Outlier or anomaly detection identifies unusual data patterns compared to the normal data. In this case, when a pig’s behavior (e.g., body temperature) slightly deviates from normal conditions due to the thermal environment, then it is regarded as an anomaly (outlier) and attention has to be paid. In this sense, the points marked in white color in Figure 18a refer to the training of the system for identifying regular observations (yellow points) as well as abnormal observations (red points) that are regarded as anomalies. Correspondingly, in Figure 18b, the outlier scores marked in blue color that deviate from the two clusters are also regarded as anomalies. Both methods appear to perform reasonably well in identifying the outliers for multi-modal data sets.

5. Discussion

The use of IoT on integrated farm management (IFM) [31,32] is considered to be of major importance for many areas of farming production [39,40] among which animal husbandry is included [56]. The purpose of this paper was to present a competitive architectural framework of a context-aware based IoT middleware [49,50] for IFM using cloud infrastructure and resources to efficiently support real-time remote monitoring and control of livestock facilities [52]. In this sense, context-awareness enables the comprehension of the situational context deriving by raw sensory data and provides personalized intelligent services tailored to the needs of the end-users and the environment [38,39,51]. In addition, cloud computing resources reduce the computational load of sensing devices, provide centralized storage systems, and enable the dissemination of information under flexible usage scenarios to all stakeholders [50].
For this work, the related state of the art in the recent literature was briefly overviewed [52,75,76,77,78,79,80,81,82,83] and the open issues were identified in order to focus on the challenges in developing a single middleware framework with scalable and flexible computational capabilities that meet the demanding requirements of smart livestock farming trends towards Agriculture 4.0 practices [29]. The literature review revealed that IoT technologies may enable intelligent, ubiquitous, and autonomous connectivity with and between physical and virtual objects, leading to the vision of Agriculture 4.0 [6,7,8]. Incorporating the IoT technologies in IFM systems is expected to increase the level of intelligence in monitoring, control, and decision making. This could also increase the efficiency and quality of livestock production while improving the use of natural resources and reducing climate dependency, helping to protect the environment and ecosystem and promoting sustainable intensification [15,29].
The system model proposed in this paper, as in Figure 2, adopts a layered hierarchical structure consisting of the IFM facility at the lower level and three main components integrated into a cloud platform at the higher level. According to this model, all the functional elements of the system cope with the context, while context awareness is achieved in the cloud-based distributed middleware that forms the core of the whole system and acts as the decision support system (DSS) in the backend. Emphasis has been placed on the context modeling structure, which is based on ontologies [102,103,104] as well as on the reasoning techniques [98] performed by the inference engine of the IoT middleware. The proposed ontology-based context modeling structure, consisting of five core ontologies as shown in Figure 6, was developed in the form of the Web Ontology Language (OWL) 2.0 [105] and implemented in extensible markup language (XML) which is a platform-independent and resilient tool, suitable for use in different phases of information representation as well as for communication based on the simple object access protocol (SOAP).
In order to assess the performance of the IoT middleware, a case study was performed for the smart control of the thermal environment [106,107] in a Greek medium-sized pig farming facility over a two-month period. The model under assessment was developed in the Python programming language [108] for prototyping and using the Microsoft Azure platform [109] resources for cloud computing infrastructure and services. The performance evaluation of the IoT middleware in actual conditions allowed its proper analysis and testing in terms of state, operation, and performance, paying great attention to the validation of inference cycle and response time parameters. Simulation tests regarding the performance and scalability of the IoT middleware have also been performed, involving a considerable amount of data derived by simulated devices.
According to the obtained results, both the inference cycle time as well as the response time respond efficiently to large volumes of context data, whereas the aspect that the IoT middleware can completely scan context aware situations of interest in an efficient timeframe is justified by the linear correlation between the inference cycle time and the response time. In terms of context representation and reasoning the proposed modeling structure is operating with no inferences as verified by running the Pellet incremental reasoner, available in the “Protégé”. Finally, the performance of implementing unsupervised outlier detection using the local outlier factor (LOF) method along with the isolation forest algorithm for enhancing the unsupervised identification of patterns has also been tested and verified. As derived from the obtained evaluation results, the proposed system appears to perform quite satisfactory for the control of a pig farming facility’s thermal environment, since the sensory data could be adequately acquired, processed, stored in the knowledge base, retrieved, and forwarded to the applications of interest, consequently leading to the correct actions.
Future work on this topic should include an in-depth performance evaluation of the middleware by incorporating multiple livestock farming environments with different specifications and at different locations. Since the usage of smart mobile devices and social networks has not been particularly considered, these features will be included as part of the ongoing work. Finally, reliability analysis and security issues will have to be investigated.

6. Conclusions

The open architecture of the proposed system enables the development of various applications for performing specialized monitoring and control, decision support services, management and optimization of livestock farming facilities, etc. Whatever the requirements or specifications of the IFM system, the consolidation of the ontology-based IoT middleware is expected to create a unique framework for livestock management that will depend on the types of devices, the services available, or the complete design of the system. In this way, the IFM systems could be capable of maintaining animal welfare standards while efficiently managing available resources and ensuring maximum livestock production with optimal quality, while also operating in environmentally and economically sustainable conditions.
Given the interest shown for innovative solutions in the agricultural sector in general, it is expected that more affordable and viable solutions that address the challenges of implementing IoT in IFM will become widely available, transforming the entire sector into a smart network of interconnected objects that are remotely identified, sensed, and controlled. Eventually, livestock farms may transform into self-learning, autonomous systems with smart, connected objects capable of making decisions and operating without human intervention.

Author Contributions

Conceptualization, E.S., K.G.A., D.P., D.T. and A.T.B.; Methodology, E.S. and K.G.A.; Data curation, E.S., D.P. and A.T.B.; Validation, E.S., K.G.A. and D.P.; Formal analysis, E.S., K.G.A., D.P. and A.T.B.; Writing—original draft preparation, E.S., K.G.A., D.T. and A.T.B.; Writing—review and editing, E.S., K.G.A., D.P., D.T. and A.T.B.; Supervision, K.G.A., D.T. and A.T.B. All authors have read and agreed to the published version of the manuscript.


This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data sharing is not applicable to this article.

Conflicts of Interest

The authors declare no conflict of interest.


  1. Zhai, Z.; Martínez, J.F.; Beltran, V.; Martínez, N.L. Decision Support Systems for Agriculture 4.0: Survey and Challenges. Comput. Electron. Agric. 2020, 170, 105256. [Google Scholar] [CrossRef]
  2. Crookston, R.K. A Top 10 List of Developments and Issues Impacting Crop Management and Ecology during the Past 50 Years. Crop Sci. 2006, 46, 2253–2262. [Google Scholar] [CrossRef]
  3. Mulla, D.; Khosla, R. Historical Evolution and Recent Advances in Precision Farming. In Soil-Specific Farming Precision Agriculture, 1st ed.; Rattan, L., Stewart, B.A., Eds.; CRC Press: Boca Raton, FL, USA, 2015; pp. 1–36. [Google Scholar]
  4. Kagermann, H.; Wahlster, W.; Helbig, J. Final Report of the Industrie 4.0 Working Group; Acatech-National Academy of Science and Engineering: München, Germany, 2013; Available online: (accessed on 25 November 2021).
  5. WEF. Mastering the Fourth Industrial Revolution. In Proceedings of the World Economic Forum Annual Meeting, Davos-Klosters, Switzerland, 20–23 January 2016; Available online: (accessed on 25 November 2021).
  6. Bonneau, V.; Copigneaux, B.; Probst, L.; Pedersen, B. Industry 4.0 in Agriculture: Focus on IoT Aspects; Digital Transformation Monitor; European Commission: Brussels, Belgium, 2017; Available online: (accessed on 25 November 2021).
  7. Ozdogan, B.; Gacar, A.; Aktas, H. Digital agriculture practices in the context of Agriculture 4.0. J. Econ. Financ. Account. 2017, 4, 186–193. [Google Scholar] [CrossRef]
  8. De Clercq, M.; Vats, A.; Biel, A. Agriculture 4.0: The Future of Farming Technology. World Government Summit in Collaboration with Oliver Wyman. 2018. Available online: (accessed on 25 November 2021).
  9. ISPA. Precision Ag Definition. 2019. Available online: (accessed on 25 November 2021).
  10. Arvanitis, K.G.; Symeonaki, E.G. Agriculture 4.0: The Role of Innovative Smart Technologies towards Sustainable Farm Management. Open Agric. J. 2020, 14, 130–135. [Google Scholar] [CrossRef]
  11. Bauer, J.; Aschenbruck, N. Design and Implementation of an Agricultural Monitoring System for Smart Farming. In 2018 IoT Vertical and Topical Summit on Agriculture—Tuscany (IOT Tuscany); IEEE: Piscataway, NJ, USA, 2018; pp. 1–6. [Google Scholar] [CrossRef]
  12. Siebrecht, N. Sustainable Agriculture and Its Implementation Gap—Overcoming Obstacles to Implementation. Sustainability 2020, 12, 3853. [Google Scholar] [CrossRef]
  13. McCown, R.L. A cognitive systems framework to inform delivery of analytic support for farmers£ intuitive management under seasonal climatic variability. Agric. Syst. 2012, 105, 7–20. [Google Scholar] [CrossRef]
  14. Carli, G.; Canavari, M.; Grandi, A. Introducing Activity-Based Costing in Farm Management: The Design of the FarmBO System. In Innovations and Trends in Environmental and Agricultural Informatics; IGI Global: Hershey, PA, USA, 2018; pp. 252–272. [Google Scholar] [CrossRef]
  15. Hammouda, M.; Wery, J.; Darbin, T.; Belhouchette, H. Agricultural Activity Concept for Simulating Strategic Agricultural Production Decisions: Case Study of Weed Resistance to Herbicide Treatments in South-West France. Comput. Electron. Agric. 2018, 155, 167–179. [Google Scholar] [CrossRef]
  16. World Population Prospects—Population Division—United Nations. Available online: (accessed on 25 November 2021).
  17. FAO. The Future of Food and Agriculture—Trends and Challenges. Available online: (accessed on 25 November 2021).
  18. Li, L.; Li, X.; Chong, C.; Wang, C.-H.; Wang, X. A Decision Support Framework for the Design and Operation of Sustainable Urban Farming Systems. J. Clean. Prod. 2020, 268, 121928. [Google Scholar] [CrossRef]
  19. Dong, C.; Huang, G.; Cheng, G.H.; Zhao, S. Water resources and farmland management in the Songhua River watershed under interval and fuzzy uncertainties. Water Resour. Manag. 2018, 32, 4177–4200. [Google Scholar] [CrossRef]
  20. Fountas, S.; Sorensen, C.G.; Tsiropoulos, Z.; Cavalaris, C.; Liakos, V.; Gemtos, T. Farm machinery management information system. Comput. Electron. Agric. 2015, 110, 131–138. [Google Scholar] [CrossRef]
  21. Sojka, M.; Kozłowski, M.; Kęsicka, B.; Wróżyński, R.; Stasik, R.; Napierała, M.; Jaskuła, J.; Liberacki, D. The Effect of Climate Change on Controlled Drainage Effectiveness in the Context of Groundwater Dynamics, Surface, and Drainage Outflows. Central-Western Poland Case Study. Agronomy 2020, 10, 625. [Google Scholar] [CrossRef]
  22. Malhi, G.S.; Kaur, M.; Kaushik, P. Impact of Climate Change on Agriculture and Its Mitigation Strategies: A Review. Sustainability 2021, 13, 1318. [Google Scholar] [CrossRef]
  23. Global Emissions. Available online: (accessed on 25 November 2021).
  24. Kmoch, L.; Pagella, T.; Palm, M.; Sinclair, F. Using local agroecological knowledge in climate change adaptation: A study of tree-based options in Northern Morocco. Sustainability 2018, 10, 3719. [Google Scholar] [CrossRef][Green Version]
  25. Borodin, V.; Bourtembourg, J.; Hnaien, F.; Labadie, N. Handling uncertainty in agricultural supply chain management: A state of the art. Eur. J. Oper. Res. 2016, 254, 348–359. [Google Scholar] [CrossRef]
  26. Van Evert, F.K.; Fountas, S.; Jakovetic, D.; Crnojevic, V.; Travlos, I.; Kempenaar, C. Big Data for Weed Control and Crop Protection. Weed Res. 2017, 57, 218–233. [Google Scholar] [CrossRef][Green Version]
  27. Chaters, G.L.; Johnson, P.C.D.; Cleaveland, S.; Crispell, J.; de Glanville, W.A.; Doherty, T.; Matthews, L.; Mohr, S.; Nyasebwa, O.M.; Rossi, G.; et al. Analysing Livestock Network Data for Infectious Disease Control: An Argument for Routine Data Collection in Emerging Economies. Philos. Trans. R. Soc. Lond. B Biol. Sci. 2019, 374, 20180264. [Google Scholar] [CrossRef][Green Version]
  28. Pourmoayed, R.; Nielsen, L.R.; Kristensen, A.R. A hierarchical Markov decision process modeling feeding and marketing decisions of growing pigs. Eur. J. Oper. Res. 2016, 250, 925–938. [Google Scholar] [CrossRef]
  29. Buckwell, A.; Nordang Uhre, A.; Williams, A.; Polakova, J.; Blum, W.E.H.; Schiefer, J.; Lair, G.J.; Heissenhuber, A.; Schieβl, P.; Krämer, C.; et al. The sustainable intensification of European agriculture. In A Review Sponsored by the RISE Foundation; The RISE Foundation: Brussels, Belgium, 2014; Available online: (accessed on 25 November 2021).
  30. Wijnands, F.; Malavolta, C.; Alaphilippe, A.; Gerowitt, B.; Baur, R. Integrated Production. IOBC-WPRS Objectives and Principles, 4th ed.; IOBC—WPRS: Rennes, France, 2018; Available online: (accessed on 25 November 2021).
  31. Rose, D.C.; Sutherland, W.J.; Barnes, A.P.; Borthwick, F.; Ffoulkes, C.; Hall, C.; Moorby, J.M.; Nicholas-Davies, P.; Twining, S.; Dicks, L.V. Integrated Farm Management for Sustainable Agriculture: Lessons for Knowledge Exchange and Policy. Land Use Policy 2019, 81, 834–842. [Google Scholar] [CrossRef]
  32. Liebig, M.A.; Herrick, J.E.; Archer, D.W.; Dobrowolski, J.; Duiker, S.W.; Franzluebbers, A.J.; Hendrickson, J.R.; Mitchell, R.; Mohamed, A.; Russell, J.; et al. Aligning Land Use with Land Potential: The Role of Integrated Agriculture. Agric. Environ. Lett. 2017, 2, 170007. [Google Scholar] [CrossRef][Green Version]
  33. European Initiative for Sustainable Development in Agriculture (EISA). European Integrated Farming Framework. 2012. Available online: (accessed on 25 November 2021).
  34. Carli, G.; Canavari, M. Introducing Direct Costing and Activity Based Costing in a Farm Management System: A Conceptual Model. Procedia Technol. 2013, 8, 397–405. [Google Scholar] [CrossRef][Green Version]
  35. Tummers, J.; Kassahun, A.; Tekinerdogan, B. Obstacles and Features of Farm Management Information Systems: A Systematic Literature Review. Comput. Electron. Agric. 2019, 157, 189–204. [Google Scholar] [CrossRef]
  36. Yezekyan, T.; Benetti, M.; Armentano, G.; Trestini, S.; Sartori, L.; Marinello, F. Definition of Reference Models for Power, Mass, Working Width, and Price for Tillage Implements. Agriculture 2021, 11, 197. [Google Scholar] [CrossRef]
  37. Nižetić, S.; Šolić, P.; López-de-Ipiña González-de-Artaza, D.; Patrono, L. Internet of Things (IoT): Opportunities, Issues and Challenges towards a Smart and Sustainable Future. J. Clean. Prod. 2020, 274, 122877. [Google Scholar] [CrossRef] [PubMed]
  38. Madushanki, R.; Wirasagoda, H.; Halgamuge, M. Adoption of the Internet of Things (IoT) in Agriculture and Smart Farming towards Urban Greening: A Review. Int. J. Adv. Comput. Sci. Appl. 2019, 10, 11–28. [Google Scholar] [CrossRef][Green Version]
  39. Talavera, J.M.; Tobón, L.E.; Gómez, J.A.; Culman, M.A.; Aranda, J.M.; Parra, D.T.; Quiroz, L.A.; Hoyos, A.; Garreta, L.E. Review of Iot applications in agro-industrial and environmental fields. Comput. Electron. Agric. 2017, 142, 283–297. [Google Scholar] [CrossRef]
  40. Waleed, M.; Um, T.-W.; Kamal, T.; Usman, S.M. Classification of Agriculture Farm Machinery Using Machine Learning and Internet of Things. Symmetry 2021, 13, 403. [Google Scholar] [CrossRef]
  41. Friha, O.; Ferrag, M.A.; Shu, L.; Maglaras, L.; Wang, X. Internet of Things for the Future of Smart Agriculture: A Comprehensive Survey of Emerging Technologies. IEEE CAA J. Autom. Sin. 2021, 8, 718–752. [Google Scholar] [CrossRef]
  42. Navarro, E.; Costa, N.; Pereira, A. A Systematic Review of IoT Solutions for Smart Farming. Sensors 2020, 20, 4231. [Google Scholar] [CrossRef]
  43. Balafoutis, A.T.; Beck, B.; Fountas, S.; Tsiropoulos, Z.; Vangeyte, J.; van der Wal, T.; Soto-Embodas, I.; Gómez-Barbero, M.; Pedersen, S.M. Smart Farming Technologies—Description, Taxonomy and Economic Impact. In Progress in Precision Agriculture; Springer International Publishing: Cham, Switzerland, 2017; pp. 21–77. [Google Scholar] [CrossRef][Green Version]
  44. Ponnusamy, K.; Rajagopalan, N. Internet of Things: A Survey on IoT Protocol Standards. In Advances in Intelligent Systems and Computing; Springer: Singapore, 2018; pp. 651–663. [Google Scholar] [CrossRef]
  45. Zhongchao, W.; Ligang, H.; Baojun, T.; Wensi, W.; Jinhui, W. Design and Verification of a Novel IoT Node Protocol. In Proceedings of the 2017 13th IEEE International Conference on Electronic Measurement & Instruments (ICEMI), Yangzhou, China, 20–22 October 2017. [Google Scholar] [CrossRef]
  46. Yassein, M.B.; Shatnawi, M.Q.; Aljwarneh, S.; Al-Hatmi, R. Internet of Things: Survey and Open Issues of MQTT Protocol. In Proceedings of the 2017 International Conference on Engineering & MIS (ICEMIS), Monastir, Tunisia, 8–10 May 2017; pp. 1–6. [Google Scholar] [CrossRef]
  47. Bahashwan, A.A.O.; Manickam, S. A Brief Review of Messaging Protocol Standards for Internet of Things (IoT). J. Cyber Secur. Mobil. 2018, 8, 1–14. [Google Scholar] [CrossRef][Green Version]
  48. Kassab, W.; Darabkh, K.A. A–Z survey of Internet of Things: Architectures, protocols, applications, recent advances, future directions and recommendations. J. Netw. Comput. Appl. 2020, 163, 102663. [Google Scholar] [CrossRef]
  49. Lee, J.; Park, G.-L.; Kang, M.-J.; Kwak, H.-Y.; Lee, S.J.; Han, J. Middleware Integration for Ubiquitous Sensor Networks in Agriculture. In Computational Science and Its Applications—ICCSA 2012; Springer: Berlin/Heidelberg, Germany, 2012; pp. 217–226. [Google Scholar] [CrossRef]
  50. Farahzadi, A.; Shams, P.; Rezazadeh, J.; Farahbakhsh, R. Middleware Technologies for Cloud of Things: A Survey. Digit. Commun. Netw. 2018, 4, 176–188. [Google Scholar] [CrossRef]
  51. Tarazona, A.M.; Ceballos, M.C.; Broom, D.M. Human Relationships with Domestic and Other Animals: One Health, One Welfare, One Biology. Animals 2020, 10, 43. [Google Scholar] [CrossRef][Green Version]
  52. Symeonaki, E.; Arvanitis, K.; Piromalis, D. A Context-Aware Middleware Cloud Approach for Integrating Precision Farming Facilities into the IoT toward Agriculture 4.0. Appl. Sci. 2020, 10, 813. [Google Scholar] [CrossRef][Green Version]
  53. Peyraud, J.-L.; MacLeod, M.; European Commission. Directorate-General for Agriculture and Rural Development. Future of EU Livestock: How to Contribute to a Sustainable Agricultural Sector? Final Report; Publications Office of the European Union: Luxembourg, 2020. [Google Scholar] [CrossRef]
  54. Van der Linden, A.; de Olde, E.M.; Mostert, P.F.; de Boer, I.J.M. A review of European models to assess the sustainability performance of livestock production systems. Agric. Syst. 2020, 182, 102842. [Google Scholar] [CrossRef]
  55. Busch, G.; Gauly, M.; Spiller, A. Opinion Paper: What Needs to Be Changed for Successful Future Livestock Farming in Europe? Animal 2018, 12, 1999–2001. [Google Scholar] [CrossRef][Green Version]
  56. Saitone, T.L.; Sexton, R.J. Agri-Food Supply Chain: Evolution and Performance with Conflicting Consumer and Societal Demands. Eur. Rev. Agric. Econ. 2017, 44, 634–657. [Google Scholar] [CrossRef]
  57. Robinson, S.; Petrick, M. Sustainable Development Goals and the Livestock Sector in Central Asia: A Course Outline; Universitätsbibliothek Gießen: Gießen, Germany, 2021. [Google Scholar] [CrossRef]
  58. Pinillos, R.G.; Appleby, M.C.; Manteca, X.; Scott-Park, F.; Smith, C.; Velarde, A. One Welfare—A Platform for Improving Human and Animal Welfare. Vet. Rec. 2016, 179, 412–413. [Google Scholar] [CrossRef][Green Version]
  59. Carvalho, T.A.; Lima, T.M.; Melani, V.F.; Mendes, M.F.; Pereira, L.R.; Marson, F.A.L. The Scientific Production during 2009 Swine Flu Pandemic and 2019/2020 COVID-19 Pandemic. Pulmonology 2020, 26, 340–345. [Google Scholar] [CrossRef]
  60. Carvalho, T.; Krammer, F.; Iwasaki, A. The First 12 Months of COVID-19: A Timeline of Immunological Insights. Nat. Rev. Immunol. 2021, 21, 245–256. [Google Scholar] [CrossRef]
  61. FAO. Agricultural Trade & Policy Responses during the First Wave of the COVID-19 Pandemic in 2020; FAO: Rome, Italy, 2021. [Google Scholar] [CrossRef]
  62. Marchant-Forde, J.N.; Boyle, L.A. COVID-19 Effects on Livestock Production: A One Welfare Issue. Front. Vet. Sci. 2020, 7, 1–16. [Google Scholar] [CrossRef]
  63. Banhazi, T.M.; Lehr, H.; Black, J.L.; Crabtree, H.; Schofield, P.; Tscharke, M.; Berckmans, D. Precision Livestock Farming: An international review of scientific and commercial aspects. Int. J. Agric. Biol. Eng. 2012, 5, 1. Available online: (accessed on 25 November 2021).
  64. Borchers, M.R.; Bewley, J.M. An Assessment of Producer Precision Dairy Farming Technology Use, Prepurchase Considerations, and Usefulness. J. Dairy Sci. 2015, 98, 4198–4205. [Google Scholar] [CrossRef][Green Version]
  65. Halachmi, I.; Guarino, M. Editorial: Precision Livestock Farming: A “per Animal” Approach Using Advanced Monitoring Technologies. Animal 2016, 10, 1482–1483. [Google Scholar] [CrossRef][Green Version]
  66. Berckmans, D. General Introduction to Precision Livestock Farming. Anim. Front. 2017, 7, 6–11. [Google Scholar] [CrossRef]
  67. Rutter, S.M. Advanced Livestock Management Solutions. In Advances in Sheep Welfare; Elsevier: Amsterdam, The Netherlands, 2017; pp. 245–261. [Google Scholar] [CrossRef]
  68. Symeonaki, E.; Arvanitis, K.G.; Loukatos, D.; Piromalis, D. Enabling IoT Wireless Technologies in Sustainable Livestock Farming toward Agriculture 4.0. In IoT-Based Intelligent Modelling for Environmental and Ecological Engineering; Springer International Publishing: Cham, Switzerland, 2021; pp. 213–232. [Google Scholar] [CrossRef]
  69. Hostiou, N.; Fagon, J.; Chauvat, S.; Turlot, A.; Kling-Eveillard, F.; Boivin, X.; Allain, C. Impact of Precision Livestock Farming on Work and Human-Animal Interactions on Dairy Farms. A Review. Presses Agron. Gembloux 2017, 21, 268–275. [Google Scholar] [CrossRef]
  70. Munz, J.; Gindele, N.; Doluschitz, R. Exploring the Characteristics and Utilisation of Farm Management Information Systems (FMIS) in Germany. Comput. Electron. Agric. 2020, 170, 105246. [Google Scholar] [CrossRef]
  71. Cappai, M.G.; Picciau, M.; Nieddu, G.; Bitti, M.P.L.; Pinna, W. Long Term Performance of RFID Technology in the Large Scale Identification of Small Ruminants through Electronic Ceramic Boluses: Implications for Animal Welfare and Regulation Compliance. Small Rum. Res. 2014, 117, 169–175. [Google Scholar] [CrossRef]
  72. Cappai, M.G.; Rubiu, N.G.; Nieddu, G.; Bitti, M.P.L.; Pinna, W. Analysis of fieldwork activities during milk production recording in dairy ewes by means of individual ear tag (ET) alone or plus RFID based electronic identification (EID). Comput. Electron. Agric. 2018, 144, 324–328. [Google Scholar] [CrossRef]
  73. Cappai, M.G.; Rubiu, N.G.; Pinna, W. Economic assessment of a smart traceability system (RFID+DNA) for origin and brand protection of the pork product labelled “suinetto di Sardegna”. Comput. Electron. Agric. 2018, 145, 248–252. [Google Scholar] [CrossRef]
  74. Porter, M.E.; Heppelmann, J.E. How Smart, Connected Products Are Transforming Competition. Harv. Bus. Rev. 2014, 92, 64–88. Available online: (accessed on 25 November 2021).
  75. Akhigbe, B.I.; Munir, K.; Akinade, O.; Akanbi, L.; Oyedele, L.O. IoT Technologies for Livestock Management: A Review of Present Status, Opportunities, and Future Trends. Big Data Cogn. Comput. 2021, 5, 10. [Google Scholar] [CrossRef]
  76. Iwasaki, W.; Morita, N.; Nagata, M.P.B. IoT Sensors for Smart Livestock Management. In Chemical, Gas, and Biosensors for Internet of Things and Related Applications; Elsevier: Amsterdam, The Netherlands, 2019; pp. 207–221. [Google Scholar] [CrossRef]
  77. Germani, L.; Mecarelli, V.; Baruffa, G.; Rugini, L.; Frescura, F. An IoT Architecture for Continuous Livestock Monitoring Using LoRa LPWAN. Electronics 2019, 8, 1435. [Google Scholar] [CrossRef][Green Version]
  78. Pan, L.; Xu, M.; Xi, L.; Hao, Y. Research of Livestock Farming IoT System Based on RESTful Web Services. In Proceedings of the 2016 5th International Conference on Computer Science and Network Technology (ICCSNT), Changchun, China, 10–11 December 2016. [Google Scholar] [CrossRef]
  79. Ilyas, Q.M.; Ahmad, M. Smart Farming: An Enhanced Pursuit of Sustainable Remote Livestock Tracking and Geofencing Using IoT and GPRS. Wirel. Commun. Mob. Comput. 2020, 2020, 6660733. [Google Scholar] [CrossRef]
  80. Su, J.-J.; Ding, S.-T.; Chung, H.-C. Establishing a Smart Farm-Scale Piggery Wastewater Treatment System with the Internet of Things (IoT) Applications. Water 2020, 12, 1654. [Google Scholar] [CrossRef]
  81. Alonso, R.S.; Sittón-Candanedo, I.; García, Ó.; Prieto, J.; Rodríguez-González, S. An Intelligent Edge-IoT Platform for Monitoring Livestock and Crops in a Dairy Farming Scenario. Ad Hoc Netw. 2020, 98, 102047. [Google Scholar] [CrossRef]
  82. Akbar, M.O.; Shahbaz khan, M.S.; Ali, M.J.; Hussain, A.; Qaiser, G.; Pasha, M.; Pasha, U.; Missen, M.S.; Akhtar, N. IoT for Development of Smart Dairy Farming. J. Food Qual. 2020, 2020, 4242805. [Google Scholar] [CrossRef]
  83. Dineva, K.; Atanasova, T. Design of Scalable IoT Architecture Based on AWS for Smart Livestock. Animals 2021, 11, 2697. [Google Scholar] [CrossRef]
  84. Webster, J.; Watson, R.T. Analyzing the past to prepare for the future: Writing a literature review. MIS Q. 2002, 26, xiii–xxiii. Available online: (accessed on 25 November 2021).
  85. Tranfield, D.; Denyer, D.; Smart, P. Towards a methodology for developing evidence-informed management knowledge by means of systematic review. Br. J. Manag. 2003, 14, 207–222. [Google Scholar] [CrossRef]
  86. Alam, F.; Mehmood, R.; Katib, I.; Albogami, N.N.; Albeshri, A. Data Fusion and IoT for Smart Ubiquitous Environments: A Survey. IEEE Access 2017, 5, 9533–9554. [Google Scholar] [CrossRef]
  87. Jha, K.; Doshi, A.; Patel, P.; Shah, M. A Comprehensive Review on Automation in Agriculture Using Artificial Intelligence. Artif. Intell. Agric. 2019, 2, 1–12. [Google Scholar] [CrossRef]
  88. Zhang, J.; Kong, F.; Zhai, Z.; Han, S.; Wu, J.; Zhu, M. Design and Development of IOT Monitoring Equipment for Open Livestock Environment. Int. J. Simul. Syst. Sci. Technol. 2016, 17, 2–7. [Google Scholar] [CrossRef]
  89. Singh, M.K.; Amin, S.I.; Imam, S.A.; Sachan, V.K.; Choudhary, A. A Survey of Wireless Sensor Network and Its Types. In Proceedings of the 2018 International Conference on Advances in Computing, Communication Control and Networking (ICACCCN), Greater Noida, India, 12–13 October 2018. [Google Scholar] [CrossRef]
  90. Gameil, M.; Gaber, T. Wireless Sensor Networks-Based Solutions for Cattle Health Monitoring: A Survey. In Advances in Intelligent Systems and Computing; Springer International Publishing: Cham, Switzerland, 2020; pp. 779–788. [Google Scholar] [CrossRef]
  91. Vidic, J.; Manzano, M.; Chang, C.-M.; Jaffrezic-Renault, N. Advanced Biosensors for Detection of Pathogens Related to Livestock and Poultry. Vet. Res. 2017, 48, 11. [Google Scholar] [CrossRef] [PubMed][Green Version]
  92. Hussain, S.J.; Khan, S.; Hasan, R.; Hussain, S.A. Design and Implementation of Animal Activity Monitoring System Using TI Sensor Tag. In Cognitive Informatics and Soft Computing; Springer: Singapore, 2020; pp. 167–175. [Google Scholar] [CrossRef]
  93. Non-Alisavath, K.; Kanthavong, S.; Luangxaysana, K.; Louangvilay, X. Context-Awareness Application to Control Multiple Sensors for Monitoring Smart Environment. In Proceedings of the 2017 14th International Conference on Electrical Engineering/Electronics, Computer, Telecommunications and Information Technology (ECTI-CON), Phuket, Thailand, 27–30 June 2017. [Google Scholar] [CrossRef]
  94. Perera, C.; Zaslavsky, A.; Christen, P.; Georgakopoulos, D. Context aware computing for the internet of things: A survey. IEEE Commun. Surv. Tutor. 2013, 16, 414–454. [Google Scholar] [CrossRef][Green Version]
  95. Mishra, S.; Jain, S. Ontologies as a Semantic Model in IoT. Int. J. Comput. Appl. 2020, 42, 233–243. [Google Scholar] [CrossRef]
  96. Dey, A.K.; Abowd, G.D.; Salber, D. A conceptual framework and a toolkit for supporting the rapid prototyping of context-aware applications. Hum. Comput. Interact. 2001, 16, 97–166. [Google Scholar] [CrossRef]
  97. Sezer, O.B.; Dogdu, E.; Ozbayoglu, A.M. Context-aware computing, learning, and big data in internet of things: A survey. IEEE Internet Things J. 2017, 5, 1–27. [Google Scholar] [CrossRef]
  98. Bettini, C.; Brdiczka, O.; Henricksen, K.; Indulska, J.; Nicklas, D.; Ranganathan, A.; Riboni, D. A survey of context modelling and reasoning techniques. Perv. Mob. Comput. 2010, 6, 161–180. [Google Scholar] [CrossRef]
  99. Abidin, N.Z.; Ismail, A.R.; Emran, N.A. Performance analysis of machine learning algorithms for missing value imputation. Int. J. Adv. Comput. Sci. Appl. 2018, 9, 442–447. [Google Scholar] [CrossRef]
  100. Preuveneers, D.; Berbers, Y. Adaptive context management using a component-based approach. In Proceedings of the 5th IFIP International Conference on Distributed Applications and Interoperable Systems, Athens, Greece, 15–17 June 2005; Springer: Berlin/Heidelberg, Germany; Volume 3543, pp. 14–26. [Google Scholar] [CrossRef][Green Version]
  101. Lee, K.-C.; Kim, J.-H.; Lee, J.-H.; Lee, K.-M. Implementation of Ontology Based Context-Awareness Framework for Ubiquitous Environment. In Proceedings of the 2007 International Conference on Multimedia and Ubiquitous Engineering (MUE’07), Seoul, Korea, 26–28 April 2007. [Google Scholar] [CrossRef]
  102. Zhang, J.; Huang, M.L. 5Ws model for big data analysis and visualization. In Proceedings of the 2013 IEEE 16th International Conference on Computational Science and Engineering, Sydney, Australia, 3–5 December 2013; pp. 1021–1028. [Google Scholar] [CrossRef]
  103. Pradeep, P.; Krishnamoorthy, S. The MOM of context-aware systems: A survey. Comput. Commun. 2019, 137, 44–69. [Google Scholar] [CrossRef]
  104. Zimmermann, A.; Lorenz, A.; Oppermann, R. An operational definition of context. In International and Interdisciplinary Conference on Modeling and Using Context; Springer: Berlin/Heidelberg, Germany, 2007; pp. 558–571. [Google Scholar] [CrossRef]
  105. W3C, OWL 2 Web Ontology Language Quick Reference Guide, 2nd ed.; World Wide Web Consortium (W3C): Cambridge, MA, USA, 2012; Available online: (accessed on 25 November 2021).
  106. Tzanidakis, C.; Simitzis, P.; Arvanitis, K.; Panagakis, P. An Overview of the Current Trends in Precision Pig Farming Technologies. Livest. Sci. 2021, 249, 104530. [Google Scholar] [CrossRef]
  107. Lammers, P.J.; Stender, D.R.; Honeyma, M.S. Environmental Needs of the Pig. Environment Iowa Pork Industry Center. 2007. Available online: (accessed on 25 November 2021).
  108. Python. Available online: (accessed on 25 November 2021).
  109. Microsoft Azure. Available online: (accessed on 25 November 2021).
  110. Wang, F.; Zhang, Y.Z.; Luo, X.F. Semantic Query of Ontology Knowledge Base Based on SQWRL. Comput. Technol. Dev. 2017, 2, 24–29. Available online: (accessed on 25 November 2021).
  111. Lezcano, L.; Sicilia, M.A.; Rodríguez-Solano, C. Integrating reasoning and clinical archetypes using OWL ontologies and SWRL rules. J. Biomed. Inform. 2011, 44, 343–353. [Google Scholar] [CrossRef][Green Version]
  112. Castanedo, F. A review of data fusion techniques. Sci. World J. 2013, 2013, 704504. [Google Scholar] [CrossRef]
  113. Piromalis, D.; Arvanitis, K. SensoTube: A scalable hardware design architecture for wireless sensors and actuators networks nodes in the agricultural domain. Sensors 2016, 16, 1227. [Google Scholar] [CrossRef][Green Version]
  114. Protégé. Available online: (accessed on 25 November 2021).
Figure 1. Basic layered IoT architecture approach.
Figure 1. Basic layered IoT architecture approach.
Agronomy 12 00750 g001
Figure 2. Whole farm approach in integrated farm management (IFM) systems.
Figure 2. Whole farm approach in integrated farm management (IFM) systems.
Agronomy 12 00750 g002
Figure 3. IFM system operational framework.
Figure 3. IFM system operational framework.
Agronomy 12 00750 g003
Figure 4. IFM system layered architecture design.
Figure 4. IFM system layered architecture design.
Agronomy 12 00750 g004
Figure 5. Block diagram of a typical WSAN node for livestock management.
Figure 5. Block diagram of a typical WSAN node for livestock management.
Agronomy 12 00750 g005
Figure 6. Modeling structure the five core ontologies and their relations.
Figure 6. Modeling structure the five core ontologies and their relations.
Agronomy 12 00750 g006
Figure 7. Thing ontology.
Figure 7. Thing ontology.
Agronomy 12 00750 g007
Figure 8. Location ontology.
Figure 8. Location ontology.
Agronomy 12 00750 g008
Figure 9. Time ontology.
Figure 9. Time ontology.
Agronomy 12 00750 g009
Figure 10. Event ontology.
Figure 10. Event ontology.
Agronomy 12 00750 g010
Figure 11. Rule ontology.
Figure 11. Rule ontology.
Agronomy 12 00750 g011
Figure 12. Instance of indicative modeling structure for smart control of the thermal environment in a pig farming facility.
Figure 12. Instance of indicative modeling structure for smart control of the thermal environment in a pig farming facility.
Agronomy 12 00750 g012
Figure 13. (a) SensoTube environmental sensor, (b) Mifare S-50 RFID ear tag, (c) Monza-5 RFID ear tag [113].
Figure 13. (a) SensoTube environmental sensor, (b) Mifare S-50 RFID ear tag, (c) Monza-5 RFID ear tag [113].
Agronomy 12 00750 g013
Figure 14. Screenshot for ambient temperature and air humidity measurements.
Figure 14. Screenshot for ambient temperature and air humidity measurements.
Agronomy 12 00750 g014
Figure 15. Correlation between (a) number of devices and inference cycle time, (b) number of devices and response time, (c) number of rules and inference cycle time, (d) number of rules and response time.
Figure 15. Correlation between (a) number of devices and inference cycle time, (b) number of devices and response time, (c) number of rules and inference cycle time, (d) number of rules and response time.
Agronomy 12 00750 g015
Figure 16. Correlation between inference cycle time and response time.
Figure 16. Correlation between inference cycle time and response time.
Agronomy 12 00750 g016
Figure 17. Verification of modeling structure clarity.
Figure 17. Verification of modeling structure clarity.
Agronomy 12 00750 g017
Figure 18. Unsupervised outlier detection with the (a) isolation forest algorithm, (b) LOF method.
Figure 18. Unsupervised outlier detection with the (a) isolation forest algorithm, (b) LOF method.
Agronomy 12 00750 g018
Table 1. Indicative literature results about the utilization of the IoT technologies into livestock farming.
Table 1. Indicative literature results about the utilization of the IoT technologies into livestock farming.
CitationPaper’s Objective/Outcome
[75]Identifying the ecosystem, architectures, and technologies of the IoT as well as the present status, opportunities, and expected future trends regarding its role in livestock management.
[76]Overviewing and interpreting the requirements for IoT sensors that are applicable for smart livestock monitoring.
[77]Designing, implementing, and evaluating the performance of an IoT hardware and software architecture that adopts the LoRa low-power wide-area network (LPWAN) technology for continuously monitoring livestock located in barns during grazing.
[78]Introducing the design of an integrated framework of smart livestock farming IoT system by means of RESTful (REST: representational state transfer) web services.
[79]Presenting the design of a geographical paddock to monitor spatiotemporal behaviors of livestock using the IoT and GPRS technologies.
[80]Establishing a smart piggery wastewater treatment system, which was upgraded from a self-developed fully automatic wastewater treatment system by using IoT applications.
[81]Introducing a platform which combines IoT, edge computing, artificial intelligence, and blockchain technologies based on the Global Edge Computing Architecture to monitor the state of dairy cattle and feed grain, as well as to ensure the traceability and sustainability of the different processes involved in the production.
[82]Presenting various aspects of smart dairy farming (SDF), as well as the state-of-the-art framework that can assist farmers in increasing their milk yields by using IoT and data-driven technologies.
[83]Introducing a scalable cloud-based architecture for a smart livestock monitoring system following Agile methodology and featuring environmental monitoring, health, growth, behavior, reproduction, emotional state, and stress levels of animals.
Table 2. Representation forms used in the ontology modeling structure.
Table 2. Representation forms used in the ontology modeling structure.
Representation FormsAttribute
Agronomy 12 00750 i001Class
Agronomy 12 00750 i002External Class
Agronomy 12 00750 i003Subclass
Agronomy 12 00750 i004One-to-One Relation
Agronomy 12 00750 i005One-to-Many Relation
Agronomy 12 00750 i006Derived
Table 3. Indicative properties of ontology entities.
Table 3. Indicative properties of ontology entities.
Entity PropertyDomain Class/SubclassType of Context
UserIDThing/User/subclassString to identify the user ID
NameThing/User/subclassShort text to name the user
emailThing/User/subclassString to identify email address
AnimalIDThing/Animal/subclassString to identify the animal ID
BreedThing/Animal/subclassShort text to name the breed
GenderThing/Animal/subclassMale, female
BirthdateThing/Animal/subclassString to identify date of birth
DeviceIDThing/Device/subclassString to identify the device ID
NodeThing/Device/subclassString to identify the node ID
NetworkThing/Device/subclassString to identify the connection type/IP
LocNameLocation/Outdoor Space/subclassShort text name
LocDescriptionLocation/Outdoor Space/subclassShort text description of the location
AreaDimensionsLocation/Outdoor Space and Indoor SpaceNumber to measure the area in m2, km2
CoordinatesLocation/Outdoor Space/subclassLatitude and longitude to identify absolute position
PositionIDLocation/Indoor Space/subclassString to identify the relative position (Building, Quarter, Corridor, Pen)
TimestampTime/Instant and IntervalExact timestamp
Table 4. Pig behavior and indicative assistive actions under the different environmental temperatures.
Table 4. Pig behavior and indicative assistive actions under the different environmental temperatures.
Pig BehaviorAssistive Actions
  • Lie apart
  • Maximize contact with concrete
  • Use dunging areas for lounging to cool themselves
  • Create wallows
  • Become irritable and aggressive
  • Pant
  • Decrease feed intake
  • Increase water consumption
  • Allow more space per pig
  • Wet concrete floors
  • Increase airflow (volume and speed)
  • Spray pigs with water
  • Spray bedding with water
  • Insulate pig housing
  • Huddle together
  • Burrow into bedding
  • Increase feed intake
  • Extremities (ears and tail may become frost-bitten)
  • Reduce draft
  • Provide additional bedding
  • Provide compositing bedding pack
  • Provide supplemental heating for newborn pigs
  • Insulate buildings
  • Increase stocking density
Table 5. Software features for the IoT middleware development.
Table 5. Software features for the IoT middleware development.
SystemSimulated ModelDevelopment PlatformOutput
Sensory DevicesPython servletPython script in SQL serverData files
Context ProvidersPython script running in AzureAPI using AzureHigh level context
Context AggregatorPython script running in AzureAPI using AzureContext model in XML
Context ModelingOWLAzure data sourceContext model
Service MappingPython script running in AzureAPI using AzureList of actions in XML
Context RepositoryStatic databaseAzure data sourceDatabase records
Service ProvidersStatic XML in various web serversAzure web serverService rules with actions
Table 6. Performance evaluation results.
Table 6. Performance evaluation results.
Inference Cycle Time (ms)Response Time
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Symeonaki, E.; Arvanitis, K.G.; Piromalis, D.; Tseles, D.; Balafoutis, A.T. Ontology-Based IoT Middleware Approach for Smart Livestock Farming toward Agriculture 4.0: A Case Study for Controlling Thermal Environment in a Pig Facility. Agronomy 2022, 12, 750.

AMA Style

Symeonaki E, Arvanitis KG, Piromalis D, Tseles D, Balafoutis AT. Ontology-Based IoT Middleware Approach for Smart Livestock Farming toward Agriculture 4.0: A Case Study for Controlling Thermal Environment in a Pig Facility. Agronomy. 2022; 12(3):750.

Chicago/Turabian Style

Symeonaki, Eleni, Konstantinos G. Arvanitis, Dimitrios Piromalis, Dimitrios Tseles, and Athanasios T. Balafoutis. 2022. "Ontology-Based IoT Middleware Approach for Smart Livestock Farming toward Agriculture 4.0: A Case Study for Controlling Thermal Environment in a Pig Facility" Agronomy 12, no. 3: 750.

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop