An Integrated Approach to Dairy Farming: AI and IoT-Enabled Monitoring of Cows and Crops via a Mobile Application

. The globalized and fiercely competitive nature of the international market has expanded the range of demands across all sectors of the agri-food business. The dairy business needs to adjust to the prevailing market conditions by enhancing resource efficiency, adopting environmentally sustainable practices, promoting transparency, and ensuring security. The Internet of Things (IoT), Edge Computing (EC), and deep learning play pivotal roles in facilitating these advancements as they enable the digitization of various components within the value chain. Solutions that depend on human observation via visual inspections are susceptible to delayed detection and potential human mistakes and need more scalability. The growing herd numbers raise a significant worry due to the potential negative impact on cow health and welfare, particularly about extended or undiscovered lameness. This condition has severe consequences for cows, eventually leading to a decline in milk output on the farm. To address this issue, an Integrated Approach to Dairy Farming (IA-DF) has been developed, which utilizes sophisticated Artificial Intelligence (AI) and data analytics methodologies using mobile applications to continuously monitor livestock and promptly detect instances of lameness in cattle. Initially, the VGG16 model, pre-trained on the ImageNet dataset, was used as the underlying architecture to extract the sequence of feature vectors associated with each video. This approach was adopted to circumvent the limitations of conventional feature engineering methods, which tend to be both time-consuming and labor-intensive with deep learning-based classification algorithms. IA-DF can extract semantic details from historical data in both forward and backward directions, hence enabling precise identification of fundamental behaviors shown by dairy cows.


Introduction to Dairy farming
Dairy farming plays a crucial role in the agri-food industry, serving as a cornerstone for global nutrition and making substantial contributions to the financial security of farmers and the sustainability of rural areas [1].As the world population experiences sustained growth, there is a corresponding increase in the demand for dairy products.In the year 2021, worldwide milk production achieved an estimated quantity of 843 million metric tons, therefore highlighting the significant impact of the dairy sector on the global food supply.
The difficulties presented by the rapidly expanding worldwide dairy population emphasize the need to observe and enhance dairy farming methods closely [2].In 2021, the global dairy cow population exceeded 300 million, highlighting the significant implications that health and welfare concerns have on individual cows and the dairy industry.The issue of lameness is recognized as an essential factor that substantially reduces milk supply [3].
Research findings indicate that lameness in dairy cows leads to a noteworthy decline in milk production, with potential reductions of up to 14.5%.This outcome has significant financial implications for farmers, resulting in substantial economic losses.
The need for surveillance goes beyond cattle to include crops, an essential element of dairy production [4].The optimization of crop yields is a critical aspect of agricultural practices, and precision agriculture plays a vital role in achieving this objective.This is made possible via the use of modern monitoring systems.According to research published by the Food and Agriculture Organization (FAO), implementing precision agriculture techniques, including data-driven decision-making processes, can enhance crop yields by as much as 20%.However, conventional approaches that depend on human observation and manual data collecting include inherent limitations [5].The methodologies are susceptible to delayed detection and human mistakes, impeding the industry's capacity to grow effectively.The increasing need for dairy products highlights the need for monitoring systems that are realtime, accurate, and scalable.
The main contributions are • Integrated Approach to Dairy Farming (IA-DF) uses deep learning, the Internet of Things (IoT), and Edge Computing (EC).• IA-DF gets over the constraints of conventional feature engineering by effectively extracting features from dairy cow footage using a pre-trained VGG16 model.• The Bidirectional Long Short-Term Memory (Bi-LSTM) model is used to identify dairy cows' actions accurately by identifying temporal relationships in feature vectors.• The algorithm for Spreading Factor (SF) assignment optimization is introduced in use-weighted IoT Deployment, which guarantees balanced channel use and enhanced connectivity for IoT gadgets on dairy farms.The following sections are organized in the given manner: The studies and insights that are now available in dairy farming, cattle behavioral analysis, and monitoring technology are covered in Section 2. For thorough monitoring and optimization in dairy farming, Section 3 presents the IA-DF and describes how to use VGG16, Bi-LSTM, and a utilization-weighted algorithm.The experimental setup and results analysis are presented in Section 4, emphasizing the accuracy, efficiency, and scalability of the suggested IA-DF.The study's conclusion is provided in Section 5, which also summarizes the main findings and suggests possible future research topics and improvements for the proposed method.
The literature review examines the current body of research on dairy production, including both traditional methods and innovative technology.This study investigates the present condition of monitoring methods, strategies for behavioral analysis, and technology solutions within the domain of dairy herd management.
The study conducted by Adriaens et al. (2021) examined the milk losses that occur due to mastitis treatments in dairy farms that use automated milking systems [6].The approach under consideration, Mastitis Linked to Automatic Milking Treatments (MLAMT), examines data obtained from mechanical milking systems to identify instances of milk loss associated with mastitis.The study's findings revealed a statistically significant decrease in milk losses, with an average reduction of 12% seen after implementing the MLAMT.[20].The present research presented the Grass Measurement Decision Model (GMDM), which evaluated the many aspects influencing farmers' decision-making processes.The GMDM extensively examines socio-economic variables and agricultural attributes.The experiment results demonstrated a significant increase in the adoption of grass measurement practices, as shown by a 30% increase in farmer participation among those who used the GMDM system.
The study conducted by Mercogliano et al. (2021) centered on the presence of bisphenol A in the milk supply chain [8].The study sets a monitoring framework to evaluate the potential risks associated with bisphenol A at a dairy firm.Bisphenol A Risk Monitoring (BARM) uses a systematic monitoring strategy to assess bisphenol A concentrations throughout the whole milk supply chain.The experimental findings provided evidence of a significant decrease in the concentration of bisphenol A by 25% in the dairy industry, confirming the efficacy of the BARM.
Goharshahi et al. (2021) introduced a technique that employs an accelerometer affixed to calves' ears to track certain behaviors to identify early signs of diarrhea [9].Ear-attached diarrhea (EAD) monitoring used accelerometer data to detect alterations in behavior indicative of early-stage diarrhea in calves.The experimental results demonstrated the high level of accuracy of the EAD system, as it achieved a success rate of 90% in identifying early indications of diarrhea in the calves under observation.
Ji et al. (2022) presented a novel machine-learning framework designed to forecast the daily milk output, milk composition, and milking frequency for the subsequent month within the context of a robotic dairy farm [10].The Machine Learning for Robotic Dairies (MLRD) architecture leveraged machine learning to assess past data and provide precise predictions for cows' daily milk output, milk composition, and milking frequency.The experimental findings provided evidence for the efficacy of MLRD, as it achieved an average prediction accuracy of 94% across the factors under consideration.
Pereira et al. ( 2021) evaluated the RumiWatch system to assess its efficacy as a benchmark for monitoring eating and locomotor behaviors shown by grazing dairy cows [11].The RumiWatch Benchmark (RWB) system thoroughly evaluated eating and locomotor patterns.The experimental results demonstrated the efficacy of RWB, with an accuracy rate of 88% in monitoring eating behaviors and 92% in tracking locomotor behaviors in grazing dairy cows.
The intelligent tracking approach for dairy goats, presented by Su et al. (2022), utilizes a Siamese network [12].The Siamese Network for Goat Tracking (SNGT) developed an advanced tracking system to monitor the locomotion patterns of dairy goats.The experimental results demonstrated the efficacy of SNGT, as it achieved a high accuracy rate of 86% in efficiently monitoring dairy goats' locomotion and behavior patterns across various environmental conditions.
Tassinari et al. ( 2021) introduced a computer vision methodology that relies on deep learning to identify dairy cows inside a free-stall barn environment [13].The Deep Learningbased Cow Detection (DLCD) approach uses a computer vision model to accurately recognize and classify dairy cows in a free-stall barn setting.The efficacy of DLCD was confirmed by experimental validation, resulting in a 94% accuracy rate for effectively detecting and recognizing dairy cows in diverse circumstances inside the free stall barn.
The literature review highlights many obstacles encountered in the dairy farming industry.These challenges include milk loss resulting from mastitis treatments, the need to effectively monitor grazing habits, track dairy goat activities, and use deep learning techniques to ensure precise cow recognition.The difficulties above underscore the urgent need for sophisticated, integrated methodologies to augment efficiency and production within the dairy sector.

Proposed Integrated Approach to Dairy Farming
This section presents an overview of the IA-DF, which incorporates cutting-edge technology like VGG16, Bi-LSTM, and a utilization-weighted algorithm for comprehensive monitoring.The primary objective of the IA-DF initiative is to tackle the many issues encountered in the domain of dairy farming.This initiative endeavors to provide a comprehensive solution that effectively monitors animal and agricultural activities.Incorporating these technologies not only addresses the constraints associated with conventional approaches but also guarantees prompt, precise, and adaptable solutions to meet the dynamic requirements of the dairy sector [7].The techniques offered have the potential to bring about a paradigm shift in dairy farming operations characterized by enhanced efficiency, sustainability, and production [21].

Fig. 1. Architecture and test-bed design
Figure 1 illustrates the comprehensive structure of the test bed.The Receiver is the primary unit responsible for transmitting the information received to the communications unit via a physical link.The communications unit transfers the information to the gateway unit, a computer.The gateway assumes the role of a controller and edge node.The system used for this study consists of an Intel® CoreTM 3rd Generations i7-3540 M Central Processing Unit (CPU) operating at a frequency of 3.00 GHz, accompanied by 16.0 GB of Random Access Memory (RAM) and 500 GB of local space.The link to the system is established by a wired connection utilizing a Universal Serial Bus (USB) interface.The edge node comprises a localized database that retains all sensor information before undergoing preprocessing.The unprocessed information gathered is further subjected to preprocessing and aggregation at the edge node to generate behavioral activities.These events are then combined to create daily periods.This research included three behavioral tasks, namely step count, laying time, and swaps, for analysis.A detailed explanation of each activity is provided below: 1.
Step count refers to quantifying the number of steps taken by an animal.
2. Resting duration is the quantification of hours an organism dedicates to reclining.
, 050 (2024) BIO Web of Conferences MSNBAS2023 https://doi.org/10.1051/bioconf/2024820502020 82 3. Swaps refer to the frequency with which an animal transitions from a resting position to an upright stance.The communication protocol utilized among the edge node and cloud was Message Queue Telemetry Transmission (MQTT).The MQTT architecture consists of two primary functional parts: MQTT customers, which include publishers and customers, and an MQTT broker, which serves as an intermediary for message exchange between authors and consumers.The parts in the system consist of an MQTT publisher, an MQTT Broker, and an MQTT Consumer.

Dairy Cow Behaviour Detection
The approach aimed to identify fundamental behaviors within a complicated setting characterized by low-quality surveillance footage, intricate lighting conditions, and changing weather.

Fig. 2. Dairy cow behavior detection system
The method under consideration primarily has two distinct components.The initial application of the VGG16 architecture was using it as the foundational structure of the network for obtaining the sequence of features associated with every video.This approach successfully mitigated the challenges posed by conventional feature engineering designs' intricate and delicate nature in the face of environmental fluctuations.The subsequent component included the identification of fundamental behavioral patterns.The test videos' feature vector order, obtained by the VGG16 approach, was inputted into the Bi-LSTM system.This model incorporates forward and reversed Long Short Term Memory (LSTM) units to capture concealed data from past and future frames.The outputs from these two units are subsequently merged to produce the final understanding of basic actions in dairy cows.The primary procedures for identifying cow behaviors using the Bi-LSTM model were as follows: • Data organization The first step included dividing the database into a training set (5600 films) and an evaluation set (1400 videos) in a 7.5:2.5 ratio after collecting the vector of feature sequences from every clip.The characteristic vector sequence of each footage was recovered, and distinct labels were assigned to various actions.
• Classification The model variables were established, and training data was employed for learning the Bi-LSTM models.The primary model variables included the input dimensions, the number of hidden units, the number of batches, and the dropout rate for every training iteration.The vector containing the feature sequence in the video, which was analyzed in this work, was derived from the Fully Connected (FC) layer and transformed into a row matrix.The FC layer had a result size of 4096.The input length of the Bi-LSTM algorithm was configured accordingly.The categorization accuracy of the components was affected by the number of concealed features during the creation of the Bi-LSTM framework.The precision of the training for the learning set reached its peak while using 256 concealed units, a Dropout rate of 0.6, and a Batch size of 25.Among the several factors considered, the regularization's impact was more apparent when the Dropout rate was selected as 0.6.Determining the Batch size was primarily contingent upon the processor's capabilities.
The training materials and the test set were utilized to develop models and evaluate accordingly.The initial training curve exhibited a faster convergence rate at the beginning of training the model, suggesting a greater efficiency in learning the algorithm.As the algorithm's training progressed, there was a progressive reduction in the slope of the learning curve.When the number of training iterations approached about 7000, the system's effectiveness in learning achieved a state of saturation and exhibited minor variations.

Utilization-Weighted Method
The Utilization-Weighted (UW) approach is classified as one of the Spreading Factor (S) assignment methods.The strategy was developed using the M/D/1 queuing approach, which was used upstream of a category A gadget and a solitary gateway.In the M/D/1 waiting approach, the arrival of packages follows a Poisson process with a rate of λ, while the servicing of packets is performed at a constant rate of μ.The delivery rate, denoted as   , for each S is the ratio of the duty cycle to the transmitting duration.The arrival rate is shown in Equation (1).
The duty cycles of the actual channel (  ) are expressed as a percentage, whereas the entire transmission duration on air of the packets delivered by a node (  ) is measured in seconds.The variable x represents a value ranging from 1 to 6, corresponding to  7 to  12 correspondingly.The variable y represents a value ranging from 1 to c, where c represents the number of streams.The calculation of the arrival rate   for a node is determined by Equation (2).
The variable   represents the time delay, measured in seconds, between creating two uplink packets.The link usage of a node, denoted as   , or the busy proportion of the channel for every S, is computed using Equation (3).
The arrival rate is   , and the delivery rate is denoted   .To maintain a balanced use of virtual channels or S to prevent channel overloading, the deployment strategy is implemented to balance the usage of each S grouping, as shown in Equation (4).
, 050 (2024) BIO Web of Conferences MSNBAS2023 https://doi.org/10.1051/bioconf/2024820502020 82 The variable   represents the count of nodes that possess the element S inside group x.The nodes outside are denoted   .The weight, denoted as   , for the total amount of nodes in each S is defined as the reciprocal of the usage, as shown in Equation ( 5).This variable will facilitate the redistribution of loads from routes with greater loads to those with lower loads.
The nodes outside the group are denoted   .The ideal number of nodes for each S is computed using Equation (6).
where K is the total amount of nodes that have been allocated.The weight is denoted   .
The method used for weight utilization is presented in the Algorithm below:

End do End while End for
The process for implementing the UW algorithm is elucidated as follows.The variable S will be allocated consistent with the conventional approach relying on the Received Signal Strength Indicator (RSSI).In a more particular way, the node will initially undergo configuration with the minimum attainable S value, which has a gateway sensitivity lower than the node's RSSI.However, the ideal number of nodes for each S group or   will be determined by using the computation or   , which aims to equalize the utilization of virtual channels.To minimize packet loss, the node will be reconfigured to possess only a more significant value of S.
This section presents the IA-DF, incorporating VGG16, Bi-LSTM, and a utilizationweighted algorithm to provide complete monitoring.The IA-DF system aims to tackle the many obstacles faced in the dairy farming industry by providing a comprehensive approach encompassing animal and crop monitoring, resulting in enhanced efficiency.The techniques offered can improve the dairy business's efficiency, sustainability, and production.

Experimental Analysis and Outcomes
The research study utilizes a simulated environment replicating a dairy farm's operations.This simulation incorporates the VGG16 and Bi-LSTM models to analyze animal behavior.This includes incorporating a Graphics Processing Unit (GPU) to facilitate expedited processing.The study employs an extensive dataset of video recordings of dairy cow actions, including step count, laying duration, and swap annotations.These annotations are crucial for the training and evaluating of the models suggested in this research.The effectiveness and generality of the proposed IA-DF are ensured by validating the simulated environment against real-world data obtained from dairy farms.

3(b). Precision analysis
Figure 3(a) shows the average performance among techniques, which displays the results of many measures.The accuracy obtained is Support Vector Machine (SVM) of 89.3% [14], Random Forest (RF) of 91.59% [15], Naïve Bayes (NB) of 80.48%, [16] Convolutional Neural Network (CNN) of 94.92% [17], Linear Discriminant Analysis (LDA) of 86.01%[18], Principal Component Analysis (PCA) of 79.91% [19], and IA-DF of 96.65%.The results of the precision tests are shown in Figure 3(b), where SVM is 87.26%,RF is 89.35%,NB is 85.86%, CNN is 92.76%,LDA is 86.52%,PCA is 81.53%, and IA-DF is 97.04%, exceeding the other models.As seen by its better performance in thoroughly monitoring dairy farming, the suggested IA-DF technique routinely outperforms other methods across various parameters.The recall findings are shown in Figure 4(a), which also offers the average performance among techniques.Recall averages for SVM were 86.02%,RF was 86.81%, NB was 82.28%, CNN was 89.79%, LDA was 85.7%, PCA was 77.72%, and IA-DF was outstanding with an average recall of 96.67%.The F1 score findings are shown in Figure 4(b), where IA-DF outperformed the other models with an average F1 score of 96.28%, followed by SVM at 85.15%, RF at 89.07%, NB at 85.15%, CNN at 89.95%, LDA at 86.72%, and PCA at 79.07%.The suggested IA-DF approach routinely performs better than other approaches on a range of measures, demonstrating its superiority in the all-encompassing surveillance of dairy farming.The results of the computational efficiency analysis, which demonstrate the average performance across approaches, are shown in Figure 6(a).The average computational efficiency for SVM was 79.68%, RF was 86.19%, NB was 77.07%, CNN was 94.69%, LDA was 80.7%, PCA was 70.32%, and IA-DF was 96.36%.The mean squared error findings are shown in Figure 6(b).SVM, RF, NB, CNN, LDA, PCA, and 14.1% are the highest percentages of 6.98%, 6.58%, 12.13%, and 4.73%, respectively, while IA-DF outperforms the rest with a deficient mean squared error of 2.67%.The efficacy of the suggested IA-DF approach in thorough dairy farming monitoring is shown by its persistent higher computing efficiency and decreased mean squared error compared to other methods.
The IA-DF approach that was presented exhibited outstanding performance, with an average accuracy of 96.65%, precision of 97.04%, recall of 96.67%, F1 score of 96.28%, processing time of 5.77 seconds, system memory use of 478.32 MB, computational efficiency of 96.36%, and mean squared error of 2.67%.The results demonstrate the effectiveness of IA-DF in delivering thorough and precise surveillance of dairy farming, illustrating its superiority across several parameters compared to other approaches.

Conclusion and Future Study
The dairy farming industry is crucial and central in fulfilling the worldwide need for dairy products.Efficient monitoring and management are to addressing the issues associated with preserving the health and well-being of dairy cows, particularly in light of the growing complexity of farm management.This calls for the development of creative solutions.The Integrated Approach to Dairy Farming (IA-DF) is a suggested solution that addresses the urgent need by using sophisticated technologies like VGG16, Bi-LSTM, and a utilization-weighted algorithm.The IA-DF system presents a sophisticated approach for comprehensively monitoring dairy cow activities, including distinctive attributes such as the ability to do real-time analysis of step count, laying time, and exchanges.The experimental investigation revealed that IA-DF demonstrated remarkable performance, achieving an average accuracy of 96.65%, precision of 97.04%, recall of 96.67%, F1 score of 96.28%, processing time of 5.77 seconds, system memory use of 478.32 MB, computational efficiency of 96.36%, and mean squared error of 2.67%.
The results highlight the effectiveness of IA-DF in delivering precise and prompt observations on the behaviors of dairy cows, hence contributing to the enhancement of agricultural management techniques.Despite these accomplishments, problems persist, such as more processing speed improvements and system memory utilization.Future research investigates the implementation of IA-DF in practical agricultural contexts, considering its potential for expansion and its capacity to adjust to various ecological conditions.