Next Article in Journal
Design and Testing of a Soil-Removal Device for Peanut Harvesting in Saline–Alkali Soils: Using a Squeezing and Rubbing Method
Next Article in Special Issue
An Operation-Centered Review of Deep-Learning Computer Vision for Dairy Cow Management
Previous Article in Journal
Passable Area Evaluation of Tractor Road Based on Improved YOLOv5s and Multi-Factor Fusion
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Low-Power Piglet Crushing Detection System Based on Multi-Modal Fusion

1
Department of Basic Sciences, Shanxi Agricultural University, Jinzhong 030801, China
2
College of Agricultural Engineering, Shanxi Agricultural University, Jinzhong 030801, China
3
College of Engineering, Northeast Agricultural University, Harbin 150030, China
4
College of Animal Science, Shanxi Agricultural University, Jinzhong 030801, China
5
Dryland Farm Machinery Key Technology and Equipment Key Laboratory of Shanxi Province, Jinzhong 030801, China
*
Author to whom correspondence should be addressed.
Agriculture 2026, 16(7), 753; https://doi.org/10.3390/agriculture16070753
Submission received: 3 March 2026 / Revised: 18 March 2026 / Accepted: 27 March 2026 / Published: 28 March 2026

Abstract

Accidental crushing by sows is the primary cause of pre-weaning piglet mortality in intensive production, often due to the spatiotemporal lag of manual inspection. While Internet of Things (IoT) solutions exist, they frequently face challenges such as vision occlusion, high hardware costs, and latency. To address these, this study developed a low-cost multi-modal edge computing system based on TinyML. Using an ESP32-S3 microcontroller, the system employs a “Motion-Gated Acoustic Detection” strategy, activating a lightweight 1D-CNN model to identify piglet screams only when an IMU detects high-risk postural transitions of the sow. Results show the quantized model (5.1 KB) achieves 95.56% accuracy and 2 ms inference latency. The total end-to-end response latency is within 179 ms, ensuring intervention within the early “golden rescue window.” The low-power design enables the battery life to cover the entire lactation period. Field tests demonstrated that the system intercepted identified crushing risks within the monitored cohort, supporting its potential for significantly improving piglet survival probability. This research overcomes the limitations of single-modal monitoring and provides a scalable, cost-effective engineering intervention for enhancing animal welfare and achieving intelligent, unattended supervision in precision livestock farming.

1. Introduction

In the intensifying swine industry, pre-weaning mortality (PWM) remains a critical indicator of production efficiency, typically ranging from 10% to 15% [1,2]. Accidental crushing by sows accounts for 40% to 50% of these deaths [3,4], posing significant economic losses and welfare concerns. While farrowing crates are standard for restricting sow movement [5], they cannot entirely eliminate crushing events [6,7]. Ethological studies show that newborn piglets, seeking warmth near the sow, are often trapped during postural transitions (e.g., standing to lying) due to the sow’s postpartum fatigue and the piglets’ slow reactions [1]. Currently, the primary challenge lies in the limitations of manual inspection, which is economically and operationally impractical for 24 h monitoring as farm scales expand and labor-to-animal ratios decrease [8]. Therefore, a low-cost, automated monitoring system capable of real-time intervention is urgently needed as a digital node in Precision Livestock Farming (PLF) to ensure piglet safety within farrowing crate environments [9,10].
To address this industry pain point, relevant research has primarily explored non-contact monitoring technologies based on computer vision and bioacoustics. Vision-based technology determines risks by analyzing the spatial relationship between the sow and piglets. Recent studies have employed deep learning models (such as the YOLO series) to achieve high-precision identification and quantification of key sow postures and sow–piglet spatial relationships [11,12,13]. However, in practical applications, vision-based solutions are constrained by line-of-sight occlusion (e.g., by farrowing crates or creep boxes), light dependency (requiring infrared compensation at night), and high GPU computational costs. In contrast, monitoring technologies based on acoustic signals offer inherent advantages in complex farming environments due to their omnidirectional propagation characteristics. Bioacoustic research has long established that high-frequency screams emitted by piglets during crushing differ significantly in spectral features from routine grunts [14,15,16], providing a solid biological foundation for automated acoustic detection. Regarding algorithmic evolution, the field has transitioned from traditional signal processing to deep learning architectures. Early studies, such as Moura et al. (2008) and Jahns (2008), validated the feasibility of acoustic monitoring primarily through manual features like energy thresholds and Fast Fourier Transform (FFT) [17,18]. In recent years, Convolutional Neural Networks (CNN) have become the mainstream choice. Latest research by Vinayagam et al. (2025) and Pann et al. (2026) demonstrates that CNN possess feature extraction capabilities far superior to traditional methods in complex acoustic environments [19,20]. Furthermore, Chen et al. (2020, 2021) successfully integrated these models into IoT prototype systems such as “iDN” and “PigTalk” [21,22]. Nevertheless, existing acoustic solutions still face severe challenges in real-world implementation. On one hand, pig houses are filled with non-stationary noise, such as fan roars and metal clanging; single-modal audio models are highly susceptible to misidentifying these as screams, leading to frequent false alarms [23,24]. On the other hand, complex models designed for high precision (such as PANNs [25]) often involve massive parameter counts and rely excessively on cloud servers or high-performance PCs for inference. Their high bandwidth costs and transmission latencies struggle to meet the requirements for real-time rescue at the resource-constrained edge.
To transcend the constraints of computational capacity and energy consumption, TinyML (Tiny Machine Learning) has emerged, aimed at deploying AI models directly onto microcontrollers (MCUs). This technological shift addresses a universal challenge in smart agriculture: the need to balance high-precision event detection with the limited power resources of edge-deployed devices. In a broader context, the integration of deep learning and intelligent decision-support systems is driving a transformative shift across various agricultural domains—from high-throughput plant phenotyping [26] to the optimization of entire crop production chains [27]. Within this evolving landscape, the transition from simple data acquisition to real-time, closed-loop intervention represents a critical frontier. Studies by Mihigo and Gookyi et al. have demonstrated that quantization techniques enable the execution of complex inference tasks on ultra-low-power hardware [28,29]. Simultaneously, multi-modal fusion has become a prevalent trend for mitigating false alarms. In a comprehensive review, Reza et al. highlighted that integrating acoustic data with behavioral (postural) information is a critical pathway for enhancing monitoring accuracy [23]. Despite significant algorithmic advancements, practical engineering implementation still faces formidable challenges [30,31]. First, most high-precision models rely on computationally intensive hardware, lacking lightweight solutions specifically optimized for low-cost embedded terminals. Second, current “always-on” acoustic monitoring schemes struggle to isolate interference from adjacent pens. In densely packed farrowing crate environments, these systems often fail to distinguish whether a scream originates from the target crate or a neighboring one, leading to frequent erroneous triggering of intervention mechanisms. Finally, most existing research is confined to “passive monitoring,” lacking closed-loop validation that spans from perception to physical intervention.
To address these issues, this paper proposes a low-cost, multi-modal edge collaborative computing system based on TinyML, designed to provide a highly robust closed-loop intervention solution for piglet crushing. The core contributions of this study are as follows:
  • A “Motion-Gated Acoustic Detection” multi-modal fusion strategy: This research innovatively combines contact-based posture sensing with non-contact acoustic inference. By utilizing a back-mounted IMU to monitor the sow’s status in real-time, the system activates the acoustic recognition module only when high-risk postural transitions (e.g., standing/lying or rolling over) are detected. This mechanism fundamentally eliminates false alarms caused by environmental noise and “adjacent pen interference” at the physical source, serving as a resource-efficient paradigm for event-driven sensing in precision farming.
  • An ultra-low-overhead edge inference architecture: A lightweight 1D-CNN specifically designed for scream recognition was developed and compressed to 5.1 KB using Int8 quantization. This achieved a classification accuracy of 95.56% and an ultra-fast inference latency of 2 ms on low-cost ESP32-S3 nodes, with a battery life sufficient to seamlessly cover the entire piglet lactation period.
  • A cloud-free, closed-loop physical intervention system: Given that physical stimuli can effectively prompt sows to change postures [32], this study established an “Edge-Fog-Cloud” heterogeneous network based on ESP-NOW and MQTT protocols. The end-to-end intervention latency was strictly controlled within 179 ms, successfully triggering the edge physical intervention unit. This established a low-latency, highly reliable edge rescue link that operates independently of central servers.

2. Materials and Methods

2.1. Data Acquisition and Acoustic Characteristic Analysis

Field data collection for this study was conducted from October 2024 to May 2025 at a standardized commercial pig farm in Deshenggou Village, Guxian Town, Qin County, Changzhi City, Shanxi Province (112.62° E, 36.60° N). Figure 1a illustrates the environment of the standardized sow farrowing house where the experiments were performed. To ensure comprehensive feature capture, a multidimensional audio-video synchronized acquisition system was established; its detailed spatial layout is presented in Figure 1b. The system comprised two sets of high-definition cameras (C8C, EZVIZ, Hangzhou, China) and two sets of Takstar SGC-578 high-sensitivity condenser microphones (Takstar, Huizhou, China), which were installed diagonally in a cross-layout above the farrowing crates to provide an all-encompassing monitoring field. Specifically, the microphones were suspended 1.0 m above the ground, while the cameras were mounted at a height of 1.5 m. This diagonal cross-layout not only eliminated visual blind spots caused by occlusions but also optimized the signal-to-noise ratio (SNR) through multi-point pickup, effectively suppressing far-field reverberation interference. Audio signals were digitized via a Realtek ALC257 high-fidelity sound card (Realtek, Hsinchu, Taiwan) at a sampling rate of 44.1 kHz and 16-bit depth. Simultaneously, dual cameras recorded video streams at a frame rate of 30 fps, serving as the ground truth reference for subsequent ethological labeling. Additionally, the figure marks the relative positions between the acquisition units and the designed edge intervention components, demonstrating the complete closed-loop monitoring architecture.
During the data construction process, a stratified collection strategy was implemented to address the heterogeneity in occurrence frequency across different sound categories. For high-frequency sounds in the pig house—including nursing, interactions, and environmental noise—a “behavior-sound” cross-validation method was employed. By manually backtracking synchronized video footage, audio segments within specific temporal windows of behaviors (e.g., sow nursing or piglet play) were precisely intercepted to ensure strict correspondence between acoustic labels and behavioral characteristics. Given that piglet distress screams (Distress) are rare, occasional stressful events with an extremely low probability of occurrence, a hybrid strategy combining “opportunistic collection and multi-source data augmentation” was designed to mitigate positive sample scarcity and data imbalance. Specifically, approximately two-thirds of the high-confidence distress samples were captured during routine veterinary and management procedures at the farm, such as routine tail docking, teeth clipping, or vaccinations post-birth. This study did not apply any additional experimental physical stimuli to the animals; instead, it non-invasively recorded acute distress calls produced during these standard operations. Bioacoustic research indicates that the piercing screams emitted by piglets in response to various physical pain stimuli exhibit high consistency in their core spectral features [33], characterized by significant energy concentration in the high-frequency range and a broadband noise structure. Due to this high acoustic similarity in distress vocalizations triggered by acute physical pain, these signals serve as effective acoustic proxies for distress calls specifically occurring during crushing events. Additionally, the remaining one-thirds of the samples were sourced from public multimedia databases. By retrieving and strictly cleaning multi-source heterogeneous video materials of distressed piglets, the generalization capability of the model across different microphone frequency responses and spatial acoustics was effectively enriched. While these diverse sources improve robustness, it is acknowledged that signals from veterinary procedures or web-sourced multimedia may present different spatial reverberations or background noise profiles compared to the target farrowing crates. To address this potential limitation and strengthen the biological interpretation, a comprehensive data processing and augmentation pipeline was implemented (as detailed in Table 1), ensuring the model’s resilience against varying acoustic environments.
To accommodate the computational resource constraints of the ESP32-S3 at the edge and optimize inference efficiency, all raw audio was uniformly downsampled to 16 kHz. While significantly reducing data throughput, this sampling rate remains sufficient to fully preserve the core formant features of high-frequency piglet screams. The audio was then segmented into standard 2.0 s time windows. Subsequently, amplitude normalization was applied to all samples to eliminate energy variations caused by different recording devices and distances. To enhance the model’s generalization capability in complex acoustic environments and prevent overfitting, a fourfold data augmentation strategy was adopted. Crucially, to ensure experimental rigor, the dataset was split into training and testing sets (80% and 20%, respectively) at the level of original recording files before any augmentation was applied. This prevents the model from “cheating” by having augmented versions of the same original audio clip appearing in both the training and testing sets. As shown in Table 1, the final augmented dataset contains a total of 7132 valid samples. The distribution of samples across categories (scream, interaction, nursing, and environment) was kept relatively balanced, providing a solid data foundation for the subsequent training of the lightweight neural network.
Based on the preprocessed dataset, Log-Mel spectrograms were generated for four typical categories of acoustic events (as shown in Figure 2). Comparative analysis reveals that each sound category exhibits highly identifiable “acoustic fingerprint” characteristics in the time-frequency domain. As the primary recognition target of the system, piglet distress screams (Distress) are characterized by high-energy, wideband transient impulse responses. Their energy is densely concentrated in the mid-to-high frequency range from 1000 Hz to 6000 Hz, featuring a distinct and persistent harmonic structure. This high-frequency resonance characteristic aligns closely with the specific vocalization mechanism triggered by intense vocal cord tension when pigs experience acute physical pain, as established by Düpjan et al. [33]. This provides strong biological evidence for the system to precisely pinpoint crushing events. In contrast, nursing sounds (Nursing) appear as periodic low-frequency pulses below 500 Hz, reflecting the rhythmic nature of the sow’s nursing behavior. Piglet interaction sounds (Interaction) exhibit short, intermittent spectral textures with narrow frequency bands and relatively scattered energy. Ambient noise (Ambient) shows a disordered distribution across the entire frequency spectrum with low energy density, lacking any discernible formant structure. These significant differences in the time-frequency domain validate the separability of the data, providing a solid physical prior for subsequent feature extraction by the deep learning model.

2.2. Edge Computing System Design

2.2.1. “Edge-Fog-Cloud” Hierarchical Collaborative Architecture

To address the dual requirements of high-fidelity feature capture and rapid closed-loop intervention in piglet crushing events, this study developed a highly robust hierarchical collaborative IoT architecture (as shown in Figure 3). This architecture achieves deep integration from perception to execution through functional decoupling and collaborative control: First, the Edge Layer consists of wearable nodes deployed on the sow’s back, which are responsible for real-time multi-modal data acquisition and local lightweight model inference tasks. Second, the Fog Layer, acting as the core hub of the system, establishes millisecond-level communication links with the edge nodes using the decentralized ESP-NOW proprietary wireless protocol. Leveraging its “edge autonomy” capability, the fog layer directly drives actuators, such as DC fans, via integrated relays upon receiving alarm commands. This effectively eliminates interference from external network fluctuations on the rescue link. Finally, the Cloud Layer publishes JSON-formatted data encapsulated by the gateway to an EMQX server via the MQTT protocol. This supports real-time telemetry, fault highlighting, and historical event logging through a responsive Web dashboard for multi-node management. This hierarchical architecture not only ensures the deterministic real-time performance of rescue commands but also provides digitized management tools for large-scale livestock operations.

2.2.2. Hardware Prototyping and Deployment Strategy

To verify the engineering feasibility, a lightweight prototype system consisting of a wearable transmitter node and a receiver gateway was developed (Figure 4). The edge node (Figure 4a) utilizes an ESP32-S3 microcontroller (Espressif Systems, Shanghai, China), integrating a MEMS microphone (INMP441; TDK InvenSense, San Jose, CA, USA) and a 6-axis IMU (MPU6050; TDK InvenSense, San Jose, CA, USA) for real-time sensing. The node adopts a split-module configuration: the main unit is secured behind the sow’s scapula, while the tactile vibration motor is attached to the ear. This design ensures that weight is distributed to the shoulder to minimize physical constraints while delivering stimuli directly to the sensitive ear nerves, adhering to animal welfare standards. The receiver gateway (Figure 4b) manages command relaying and intervention execution. It utilizes industrial-grade relays to control high-power fans for secondary rescue. This architecture ensures electrical stability and reliable driving of actuators in the high-humidity barn environment. Additionally, a DHT11 sensor (ASAIR, Guangzhou, China) is integrated to provide micro-climate context, assisting in the comprehensive assessment of piglet survivability [34].
To ensure maintenance-free operation throughout the entire lactation period, the system implements a “Motion-Gated” ultra-low-power collaborative mechanism at the hardware level. During non-high-risk periods, the ESP32-S3 MCU and the audio module remain in Deep Sleep mode. The system utilizes the IMU’s built-in Digital Motion Processor (DMP) to implement a monitoring algorithm based on Signal Vector Magnitude (SVM), designed to precisely capture torso gravity shifts and acceleration transients caused by the sow standing up or rolling over. Once the transient SVM exceeds a preset high-risk threshold, the IMU immediately triggers a hardware interrupt (Wake-on-Motion, WOM) to instantaneously wake the MCU and initiate the acoustic inference program (detailed algorithmic principles are provided in Section 2.4). By drastically compressing standby power consumption, this strategy enables the theoretical battery life of the edge node to seamlessly cover the entire lactation period from farrowing to weaning.

2.3. Lightweight Edge Neural Network Design

To achieve efficient inference on the resource-constrained ESP32-S3, this study designed a compact 1D-CNN architecture, featuring a Base-1D-CNN version for stable initial deployment and an optimized SE-1D-CNN variant incorporating an attention mechanism for enhanced feature recalibration, both developed under the TinyML paradigm.
First, the input layer of the model was constructed. Acoustic data from the preprocessing module were reshaped into a two-dimensional feature tensor X R T × F , where the time steps T are determined by the duration of the temporal window. This window length was systematically calibrated through a trade-off analysis between recognition accuracy and system latency. Our preliminary tests demonstrated that a 1.0 s window was insufficient for the model to extract necessary temporal dependencies, resulting in a 4.5% decrease in recall due to feature truncation. While a 2.5 s window provided richer acoustic context, it introduced an additional 500 ms processing overhead and increased susceptibility to ambient noise. Consequently, a 2.0 s window was adopted as the optimal balance for edge inference, amounting to T frames calculated with a 10 ms frame shift; F (Features) denotes the spectral feature dimension. To identify the optimal trade-off between recognition accuracy and computational overhead, three sets of comparative experiments were designed to extract Mel-frequency cepstral coefficients (MFCC) with dimensions of F { 8 , 13 , 32 } . The specific impacts of these dimensions are discussed in detail in Section 3.1.
As shown in Figure 5, the network adopts a hierarchical feature extraction strategy consisting of two cascaded convolutional blocks. The first block contains 8 kernels ( k = 3 ), while the second expands to 16 kernels to aggregate high-level semantic information. To further enhance the model’s sensitivity to critical bioacoustic fingerprints, the optimized SE-1D-CNN variant integrates a lightweight Squeeze-and-Excitation (SE) attention module ( r = 4 ) after the second convolutional layer. This module, introduced during the revision stage as an architectural optimization inspired by the peer-review process, adaptively recalibrates channel-wise feature weights. It emphasizes the unique harmonic structures of piglet screams while suppressing redundant background interference. While the SE-1D-CNN represents the performance ceiling of our design, the Base-1D-CNN (without the SE-block) remains the benchmark for evaluating initial field deployment stability (Section 3.5). Each convolutional layer is followed by ReLU activation, MaxPooling1D ( P o o l S i z e = 2 ), and a Dropout layer (0.25) to ensure robustness and prevent overfitting. In the classification stage, the feature tensor—processed through multiple layers of convolution and pooling—is flattened into a one-dimensional vector and fed into a Dense Layer. Finally, the Softmax function maps the output to a normalized confidence probability distribution across four target categories: Distress, Interaction, Nursing, and Ambient.
Considering the SRAM constraints of the ESP32-S3, this study implemented a Post-Training Quantization (PTQ) workflow to map model weights from Float32 to Int8. Detailed comparisons of accuracy loss and inference latency for both Base-1D-CNN and SE-1D-CNN are provided in Section 3. As a baseline for performance comparison, a two-layer Stacked-LSTM model was also constructed. This benchmark maintains the same input dimensionality and training hyperparameters to evaluate whether the convolutional architecture achieves a superior trade-off between computational efficiency and accuracy for processing transient piglet distress screams.

2.4. Multi-Modal Closed-Loop Control Strategy

To implement edge-side real-time perception and closed-loop intervention for piglet crushing events, this study developed an event-driven Finite State Machine (FSM) control strategy. This strategy integrates acoustic perception (via 1D-CNN) with kinematic posture estimation (via IMU). As illustrated in Figure 6, the strategy partitions the sow’s crushing behavior recognition and subsequent rescue process into five logically interlocked operational phases, establishing a comprehensive closed-loop that spans from low-level physical perception to edge-side algorithmic decision-making and remote mechanical intervention.

2.4.1. Motion-Gated Sensing Logic for High-Risk Postural Transitions

The proposed “Motion-Gating” mechanism aims to minimize the power consumption associated with redundant sampling at edge nodes through physical trigger logic. Its core theoretical foundation lies in the precise capture of physical signatures during high-risk posture transitions, such as “standing-to-lying” or vigorous rolling behaviors. For physical feature extraction, this study utilizes the Signal Vector Magnitude ( S V M ) to characterize the overall movement intensity of the sow’s trunk. By fusing tri-axial acceleration data, the S V M objectively represents trunk displacement while remaining invariant to sensor installation angle deviations [35]. The system performs real-time acquisition of instantaneous tri-axial acceleration ( a x , a y , a z ) , with the calculation defined as follows:
S V M = a x 2 + a y 2 + a z 2
The system identifies center-of-gravity (CG) displacement events by calculating the absolute deviation between the S V M and the gravitational baseline ( 1   g 9.8 m / s 2 ). Building upon observations by Thompson et al. regarding acceleration profiles during sow posture transitions, the decision threshold T h m o t i o n was systematically calibrated through a sensitivity analysis involving a range of 0.15 g to 0.35 g. Experimental results showed that while a 0.15 g threshold ensured high sensitivity, it triggered a 32.8% increase in redundant system wake-ups caused by the sow’s respiratory patterns or nursing tremors, thereby significantly reducing battery longevity. Conversely, a 0.35 g threshold exhibited a risk of failing to capture slow-onset postural transitions. Thus, 0.25 g was selected as the optimal equilibrium between detection sensitivity and power efficiency. When the deviation satisfies Equation (2), the system immediately identifies a high-risk movement and triggers a hardware interrupt to wake the main controller for the acoustic inference phase:
| S V M 1   g | > T h m o t i o n
However, as noted by Thompson et al., extremely slow posture transitions caused by farrowing fatigue often result in missed detections because the signal variance remains below the prescribed threshold [35]. To address this limitation, this study parallelly incorporates a posture compensation mechanism based on angular variations. Utilizing the MPU6050, the system resolves the pitch and roll angles of the sow’s back in real-time. By maintaining a sliding time window of 1.0 s, the system monitors the magnitude of change in the posture angle ( θ ). If any posture angle within the window satisfies Equation (3), the system classifies the event as a high-risk posture transition and instantaneously activates the monitoring sequence, even if the instantaneous acceleration deviation does not reach the T h m o t i o n threshold:
| θ t θ t 1.0 s | > T h a n g l e
The posture variation threshold ( T h a n g l e ) was also systematically calibrated through a sensitivity analysis involving a range of 20–40°. Thresholds of 20–25° were frequently mis-triggered by the sow’s normal postural micro-adjustments. While 35° or 40° thresholds could identify the posture change, they introduced a dangerous response lag. Since the system requires a 2.0   s audio sampling window for inference, a late wake-up (e.g., at 40°) would delay the intervention until after critical injury might occur. Therefore, 30° was established to ensure the system is fully ‘awake and monitoring’ before the peak risk, providing necessary lead time for the intervention. This is consistent with previous ethological observations of sow postural transitions [35]. This fusion logic, which combines dynamic impact capture with static posture monitoring, ensures robust coverage of standing and lying behaviors across varying movement velocities. This perception-driven activation strategy significantly compresses power consumption and successfully fulfills the maintenance-free requirement for full-cycle monitoring throughout the 28-day lactation period.

2.4.2. Event-Driven Control Logic and Intervention Phases

Based on the aforementioned kinematic perception model, the system achieves hierarchical rescue through the logical transitions of five stages (see Figure 6):
  • Phase 1: Sentry Mode and Motion Gating
To address the high power consumption bottleneck of battery-powered devices under all-weather monitoring, the system remains in a “Deep Sleep” state by default, deactivating power-intensive audio acquisition and neural network modules while maintaining the MPU6050 sensor at ultra-low power. To ensure robust coverage of posture transition behaviors across varying velocities, the system introduces a dual-path parallel wake-up mechanism that monitors whether the instantaneous acceleration deviation | S V M 1   g | exceeds T h m o t i o n ( 0.25   g ), and whether the back inclination variation | Δ θ | within a 1.0 s sliding window exceeds T h a n g l e (30°). Even in low-acceleration scenarios such as slow rising or lying down, the system identifies a high-risk posture transition as long as the angular change reaches the threshold; once either trigger condition is met, the IMU instantaneously wakes the ESP32-S3 main controller via a hardware interrupt pin to initiate a 30 s “monitoring window.” This “Wake-on-Motion” (WOM) strategy ensures that the system operates only during periods of sow activity or posture transition, effectively reducing idle current consumption to the micro-ampere level and fulfilling the maintenance-free requirement for the entire 28-day lactation period.
  • Phase 2: Tactile Warning Stage
Upon activation, the system initiates real-time audio stream analysis. To mitigate false positives, the algorithm implements a rigorous counting threshold: a potential risk is confirmed, and the miniature vibration motor is activated (sustained for 3 s), only if the cumulative number of identified piglets screams within the monitoring window is ≥3. This phase aims to prompt the sow to adjust her posture through tactile feedback (flexible intervention), attempting to resolve early-stage crushing without causing generalized disturbance in the farrowing house. If the scream count fails to meet the threshold (e.g., only 1–2 instances of sporadic noise), the system automatically aborts the sequence and transitions back to the Phase 1 Deep Sleep state to prevent erroneous triggering.
  • Phase 3: Forceful Rescue Intervention
If the tactile warning in Phase 2 proves ineffective and piglet screams continue to be detected (or if 2 screams are detected directly under high-risk conditions), the system determines that the crushing behavior has escalated, subsequently entering the forceful rescue stage. At this point, the edge node transmits microsecond-level commands to the local actuator via the ESP-NOW protocol, triggering relay closure to activate a high-power fan for forced-air stimulation. The combination of airflow-induced strong airflow and physical noise creates a stronger deterrent, forcing the sow to stand up due to discomfort, thereby resolving the crushing event.
  • Phase 4: Intelligent Closed-loop Feedback
Following fan activation, the system enters the intelligent closed-loop monitoring phase to continuously track the sow’s postural changes. Leveraging the kinematic characteristic where the Pitch angle returns toward the zero-baseline when the sow stands, the system will immediately issue a shutdown command ([FAN_OFF]) to terminate fan operation once the IMU confirms a “Posture Safe” status. If no postural recovery is detected, the fan will be forced to stop after a 30 s safety timeout and trigger a remote alarm to prevent the sow from experiencing overstress.
  • Phase 5: High-Alert Mechanism
To address the risk of “secondary injury” caused by the sow lying down again immediately after a rescue, this study designed a High-Alert Mechanism. Within 30 s following the conclusion of a rescue sequence, the system sets a “High Alert Flag.” If motion triggers and piglet screams are re-detected during this window, the algorithm utilizes the “Fast Bypass Mechanism” (indicated by the red dashed line in Figure 6), skipping the Phase 2 tactile warning and directly triggering Phase 3 fan intervention. This mechanism endows the system with a rapid response capability for recurrent crushing behaviors, significantly reducing the mortality risk for piglets.

2.5. Performance Evaluation Metrics

To objectively evaluate the effectiveness and operational efficiency of the proposed 1D-CNN algorithm on the resource-constrained ESP32-S3 edge terminal, this study established an evaluation framework comprising two dimensions: Classification Accuracy and Edge-side Performance.

2.5.1. Classification Performance Metrics

The model’s ability to identify the four categories of acoustic events (Distress, Interaction, Nursing, Ambient) in the test set is quantified using statistical measures derived from the Confusion Matrix. For any target category, the following variables are defined:
  • TP (True Positive): Samples correctly predicted as the target category.
  • FP (False Positive): Samples of other categories incorrectly predicted as the target category.
  • FN (False Negative): Samples of the target category incorrectly predicted as other categories.
  • TN (True Negative): Samples of other categories correctly excluded.
Based on these statistics, four core metrics are employed:
  • Accuracy:
Measures the overall classification correctness across the entire test set.
Accuracy = N c o r r e c t N t o t a l × 100 %
where N c o r r e c t is the total number of correctly classified samples and N t o t a l is the total number of samples in the test set.
2.
Precision:
Measures the proportion of correctly predicted positive samples among all samples predicted as the “target category.” In the anti-crushing system, high precision corresponds to a lower False Alarm Rate (FAR), effectively preventing unnecessary stress to the sow caused by erroneous activation of fans or vibration motors.
Precision = T P T P + F P × 100 %
3.
Recall:
Measures the proportion of actual “target category” samples successfully detected by the model. For lethal crushing events, recall is the most critical safety indicator. A low recall implies the system may miss a piglet’s distress signals, directly leading to crushing fatalities.
Recall = T P T P + F N × 100 %
4.
F1-Score:
The harmonic mean of precision and recall, used to evaluate the comprehensive performance under imbalanced sample distributions, reflecting the model’s ability to balance precision and recall.
F 1 - Score = 2 × Precision × Recall Precision + Recall

2.5.2. Edge Deployment Efficiency Metrics

Given that the system operates on an embedded platform (ESP32-S3) with strictly limited computational resources and power budgets, the computational overhead and resource footprint are critical for assessing engineering feasibility:
  • Inference Latency:
The average time required for a calculation from the input of the feature tensor to the output of classification probabilities (unit: ms). To meet the real-time requirements described in Section 2.4, the inference latency must be significantly lower than the sampling interval to ensure timely intervention.
2.
Flash Usage:
The non-volatile storage space occupied by model weights and compiled program code (unit: KB).
3.
Peak RAM Usage:
The maximum dynamic memory allocation (Tensor Arena Size) during model inference (unit: KB). This metric determines whether the model can coexist with other system tasks (e.g., WiFi stack, sensor drivers) within the limited SRAM without triggering out-of-memory errors.

3. Results and Discussion

3.1. Acoustic Feature Analysis

In deep-learning-based audio classification tasks, the quality of feature extraction directly determines the upper bound of the model’s generalization capability and the stability of the decision boundary. To intuitively evaluate the representation capability of MFCC for piglet distress signals, this study conducted a visual feature mapping analysis of a typical scream sample across different dimensions ( F { 8 , 13 , 32 } ).
As shown in Figure 7, the MFCC feature mappings across different dimensions exhibit significant variations in time-frequency resolution, intuitively reflecting the trade-off between acoustic feature abundance and computational complexity. Under the low-dimensional feature configuration ( F = 8 ), although the computational load is minimized, the spectral resolution is limited. This results in blurred primary formant contours—which represent vocal tract resonance characteristics—making them lack sufficient identifiability amidst the complex background noise of the pig farm. In contrast, visual analysis of the 13-dimensional feature vector ( F = 13 ) reveals its ability to clearly delineate the unique harmonic structure of piglet scream signals. The extracted low-order cepstral envelope completely covers the core frequency-domain energy distribution of the alarm sounds, demonstrating robust feature representation capability. While further increasing to high-dimensional features ( F = 32 ) captures finer details, it also introduces irrelevant background interference, such as high-frequency mechanical vibrations, due to increased sensitivity to minor frequency fluctuations. More importantly, constrained by the extremely limited SRAM resources of the edge-side ESP32-S3, excessively high feature dimensions lead to an explosion in the number of neurons in the neural network’s input layer, resulting in significant diminishing marginal returns. The visual comparative experiments confirm that in the piglet crushing detection scenario, the 13-dimensional feature space effectively suppresses redundant interference while ensuring precise characterization of the target signal. This not only physically validates the hypotheses regarding piglet vocalization mechanisms discussed in Section 2.1 but also provides a direct engineering basis for parameter optimization between performance and power consumption in the subsequent lightweight model architecture.

3.2. Classification Accuracy and Model Robustness

To comprehensively balance classification performance, computational overhead, and deployment potential in resource-constrained environments, this study established a test matrix comprising 18 sets of comparative experiments. The experiments encompass three feature dimensions ( F { 8 , 13 , 32 } ), three network architectures (Base-1D-CNN, SE-1D-CNN, and Stacked-LSTM), and two numerical precision modes (Float32 full-precision vs. Int8 quantization). All evaluation metrics were generated based on an independent test set to ensure the impartiality and generalization value of the results.
The comparative results in Table 2 reveal that while the Stacked-LSTM demonstrates the highest absolute accuracy (up to 99.72%), the lightweight 1D-CNN architectures provide a more viable trade-off for resource-constrained edge devices. Specifically, the Base-1D-CNN achieved a classification accuracy of 95.56% ( F = 13 , Int8), which was identified as the optimal version for our actual field deployment due to its proven operational stability. Although the optimized SE-1D-CNN further improved the accuracy to 96.97%, it should be noted that this variant was developed during the revision stage as an architectural optimization inspired by the peer-review process; while it exhibits enhanced performance in experimental evaluations, the Base-1D-CNN remains the primary version utilized for the recorded field trials to maintain the spatiotemporal consistency and integrity of the initial deployment data. Consequently, given the excessive inference latency of the LSTM architecture (detailed in Section 3.3), the Base-1D-CNN was selected for the current field deployment to provide a more reliable balance between classification performance and real-time operational efficiency.
An in-depth analysis of the target Base-1D-CNN model l indicates that the feature dimension has a significant nonlinear impact on classification performance. Increasing the MFCC dimension from 8 to 13 improved the accuracy by 2.6% (from 92.95% to 95.56%), which strongly suggests a “resolution blind spot” in ultra-low-dimensional features due to the loss of critical spectral envelope information. However, as the dimension further expands to 32, the marginal gain in accuracy diminishes significantly, with an increase of less than 0.2%. This phenomenon reveals that the 13-dimensional feature space already encapsulates sufficient core acoustic fingerprints to support high-precision decision-making. Continually increasing the dimension fails to yield a qualitative performance leap; instead, it results in a 2.5-fold increase in input tensor volume, significantly inflating SRAM occupancy at the edge. Consequently, F = 13 was determined as the optimal feature parameter for system deployment.
Furthermore, the quantization experiments reveal that the model exhibits exceptional robustness to numerical precision compression, with the Int8 quantization process causing almost no performance degradation. Taking the Base-1D-CNN ( F = 13 ) model utilized in our field trials as an example, the accuracy of its Int8 version remains identical to the Float32 full-precision version at 95.56%. Even for the F = 32 configuration, which showed slight fluctuations, the accuracy drop induced by quantization was only 0.28%. These results confirm that the designed lightweight network architecture is highly compatible with the 8-bit hardware acceleration units of the ESP32-S3. Without sacrificing recognition capability, the system successfully compressed the model storage footprint to 25% of its original size. This establishes a solid foundation for edge deployment with ultra-low resource consumption.
To intuitively evaluate the practical usability of the model, Figure 8 presents the confusion matrix of the Base-1D-CNN ( F = 13 , Int8) on the test set. The distribution of values along the diagonal elements indicates that the model maintains a high classification fidelity for the most critical category, “Distress” screams (92.5%), demonstrating its keen sensitivity in capturing danger signals. Although a small number of misclassifications occur between “Nursing” and “Interaction” sounds, these errors are entirely acceptable in a real-world production environment. Since both are non-critical categories, their identification results lead to the same non-intervention strategy, thus avoiding unnecessary system triggers. In summary, the model achieves an ideal balance between recognition robustness and computational efficiency, effectively meets the dual requirements of real-time early warning and edge autonomy for the anti-crushing system.

3.3. Edge Model Deployment Performance

While the Stacked-LSTM model demonstrates excellent performance in pure classification accuracy, its real-time responsiveness and computational overhead on resource-constrained embedded terminals (ESP32-S3) are the core metrics that determine the overall feasibility of the solution. In this study, all comparative models were deployed onto actual hardware platforms, and the measured performance metrics are summarized in Table 3.
Analysis of the time decomposition data in Table 3 reveals that the total system latency primarily consists of two components: DSP feature extraction and model inference. DSP processing accounts for the vast majority of the total time (approximately 70–98%); for instance, at F = 13 , a fixed overhead of 135 ms constitutes an irreducible physical baseline. During the model inference stage, the Base-1D-CNN demonstrates remarkable computational efficiency. At F = 13 , inference takes only 2 ms (extending to 4 ms for the SE-1D-CNN variant), consuming negligible CPU time slices. In contrast, an LSTM with the same configuration requires 57 ms—approximately 28.5 times longer than the Base-1D-CNN. This significant discrepancy arises because 1D-CNN operators are highly compatible with the parallel acceleration provided by the ESP32-S3’s Xtensa® vector instruction set. Conversely, the serial recurrent structure of LSTM keeps the CPU in a state of prolonged high load, which not only increases power consumption but also risks preempting operational resources from the Wi-Fi protocol stack or DMA buffers, potentially leading to system instability or crashes. Final evaluations show that the total latency for the selected Base-1D-CNN ( F = 13 ) is 137 ms. In practical application scenarios, shorter processing latency facilitates a tighter response loop from sound recognition to hardware rescue (e.g., activating fans or vibration modules). Although the highest-precision LSTM ( F = 32 ) has a total latency of 350 ms, its superior recognition rate comes at the cost of increased intervention delay for the actuators. Given the time-sensitivity requirements of piglet crushing events, the 1D-CNN solution achieves a more rational balance between algorithmic performance and real-time capability.
Regarding memory resources, the peak RAM occupancy for Base-1D-CNN ( F = 13 , Int8) is only 5.1 KB, significantly lower than the 11.9 KB required by LSTM ( F = 32 ). This low memory consumption leaves a larger safety margin for audio input buffers (DMA buffers) and network communication stacks, thereby markedly improving the long-term operational stability of the system. From a comprehensive decision-making perspective, while the LSTM architecture excels in absolute accuracy, its actual inference overhead makes the Base-1D-CNN ( F = 13 , Int8) the optimal choice for an “accuracy-efficiency” balance. Its 95.56% accuracy, combined with the backend logic, is sufficient for practical application needs; the ultra-low latency of 137 ms ensures an immediate response, and the 2 ms inference time minimizes power consumption and CPU load. Therefore, this study ultimately identifies Base-1D-CNN ( F = 13 , Int8) as the optimal solution for edge-side deployment, while the SE-1D-CNN provides a performance-enhanced path for future iterations.

3.4. Energy Efficiency Evaluation and Remote Monitoring

3.4.1. Edge Node Energy Efficiency Model and Battery Life Analysis

To evaluate the maintenance cycle of the system in practical livestock scenarios, this study established an energy consumption model based on the “Motion-Gating” mechanism. The system’s operational states are categorized into Deep Sleep Mode ( I s l e e p 0.5   mA ) and Active Mode ( I a c t i v e 120   mA ).
Assuming a daily trigger frequency ( N t r i g g e r ) of 50 times for a sow in a farrowing crate, with each active window ( T a c t i v e ) fixed at 30 s, the theoretical endurance ( D e n d u r a n c e ) of the system using a lithium polymer battery with a nominal capacity of 3000 mAh—can be calculated as follows:
E d a i l y = I s l e e p 24 N t r i g g e r T a c t i v e 3600 + I a c t i v e N t r i g g e r T a c t i v e 3600  
D e n d u r a n c e = C b a t t e r y η E d a i l y
In this model, the term N t r i g g e r T a c t i v e / 3600 represents the total daily duration in Active Mode (in hours), while the remainder of the 24 h cycle is spent in Deep Sleep Mode. Here, η = 0.85 serves as the battery discharge efficiency coefficient, accounting for energy loss during voltage conversion and self-discharge. Based on the measured parameters, the calculated E d a i l y is approximately 61.8 mAh, yielding a theoretical endurance ( D e n d u r a n c e ) of 41.2 days. Even under extreme scenarios where the daily trigger frequency increases to 150 times, the calculated battery life remains above 32 days, which still sufficiently covers the standard 28-day lactation period. This fulfills the “single deployment, full-cycle coverage” maintenance-free requirement, significantly reducing the labor intensity for farm staff and ensuring the continuity of piglet protection.
For piglet crushing rescue, real-time performance is the core operational metric. Beyond the 137 ms model inference time verified in Section 3.3, the system-level latency also encompasses sensor acquisition, ESP-NOW wireless transmission, and actuator response times. Field measurements indicate that in a typical farrowing house environment, the average ESP-NOW transmission delay is only 12 ms. Combined with approximately 20 ms for sensor sampling and 10 ms for actuator mechanical response, the total end-to-end system response time is approximately 179 ms. This result is significantly lower than the one-minute “golden rescue window” widely recognized in the literature [22], providing an ample safety margin for intervention. This fully demonstrates the significant advantages of the “Edge-Fog” collaborative architecture in ensuring highly time-sensitive interventions: by offloading decision-making to the edge and executing local wireless commands, the system circumvents the high latency associated with cloud-based processing.

3.4.2. Multi-Terminal Collaborative Monitoring and Human–Machine Collaborative Intervention

To mitigate the inherent risks of physical failure in edge-side automated interventions, this study developed a multi-terminal visual monitoring platform. This platform implements a hierarchical management model characterized as “automated rescue as primary, manual intervention as auxiliary.” As shown in Figure 9a, the PC-side console is specifically optimized for duty room scenarios. Utilizing a stable, long-connection data link, it allows staff to maintain panoramic supervision of all sows from a comfortable office environment, eliminating the need for prolonged exposure to farrowing houses filled with high ammonia concentrations and excessive noise. Testing indicates that when the edge node detects a crushing event, the “Safety Status” indicator on the dashboard undergoes a state transition and synchronizes the confidence score within 200 ms. Simultaneously, the console triggers a high-decibel acoustic alarm. This dual-feedback mechanism—integrating audiovisual cues—ensures that duty personnel maintain high situational awareness and can perform immediate video verification even when not looking directly at the screen.
For night patrols or mobile scenarios, a mobile terminal was developed, as illustrated in Figure 9b. This terminal is not merely a status display but a critical component of the system’s fault-tolerance mechanism. During simulated experiments, if the system determines that automated interventions (vibration or fans) have failed to resolve the crushing event—for instance, if the alarm persists beyond a predefined threshold—the mobile terminal immediately issues a push notification accompanied by persistent vibrations and alert tones. This mechanism completes the “Device-to-Human” information loop. It ensures that in extreme cases where automated rescue fails, stockmen can swiftly reach the site based on the alarm’s timestamp and location data. This configuration constitutes a “double insurance” system for maximizing piglet survival rates. During the long-term field trials spanning three production cycles, the ‘Edge-to-Cloud’ communication link maintained exceptional stability, with a recorded packet loss rate of less than 0.1% for remote data synchronization.

3.5. General Discussion

The proposed TinyML-based multi-modal monitoring system achieves a balanced trade-off between recognition accuracy, real-time responsiveness, and hardware cost. To verify its long-term reliability and the effectiveness of the real-time logic, field tests were conducted across three complete production cycles in commercial farrowing houses. While the hardware demonstrated consistent stability, a representative 28-day lactation period involving ten randomly selected sows was analyzed in depth to quantify the algorithm’s efficacy. Experimental records showed that the multi-modal fusion logic identified 98 critical intervention events associated with potential crushing risks. Consistent with the biological characteristic that piglet crushing mortality is primarily concentrated within the first 72 h post-farrowing, the recorded events were predominantly concentrated in the early lactation stage. Analysis of the hierarchical rescue performance revealed that 71 of these events (approximately 72.4%) were successfully resolved through tactile warnings in Phase 2, prompting autonomous postural adjustments by the sows. In the remaining 27 instances where the sow’s response was delayed, the forceful fan intervention in Phase 3 successfully achieved critical rescue. Within this monitored cohort, no recorded piglet fatalities related to crushing occurred in the target pens, supporting the practical feasibility of the hierarchical rescue strategy. This ‘soft-to-forceful’ strategy demonstrated its effectiveness during the trials while minimizing stress on the sows, addressing limitations in prior single-modality or single-intervention research [22].
Specifically, this hierarchical intervention strategy was designed with a prioritize-welfare approach. The Phase 2 tactile vibration provides a non-nociceptive alert, utilizing the high sensitivity of the ear area to prompt postural adjustment without inducing pain or significant stress. The Phase 3 airflow serves as a localized physical prompt, which behavioral studies suggest is an effective rescue mechanism that is significantly less invasive than constant manual interference or traditional electric prods. This ensures piglet safety while maintaining a low-stress environment for the sow, strictly adhering to the institutional ethical guidelines (Approval No. SXAU-EAW-2022P.GT.0070080141).
Beyond the specific field trial environment, the system’s generalizability is supported by its modular architecture. While sensing thresholds for the IMU may require minor recalibration based on the specific body dimensions and movement intensities of different sow breeds (e.g., Landrace vs. Large White), the core dual-verification logic remains robust across various barn layouts. In diverse farming settings, microphone sensitivity and wireless gateway placement can be adjusted to account for different background noise profiles and spatial reverberations, ensuring consistent performance across varying climates and intensive management systems.
From a technical standpoint, the “Motion-Gating” mechanism introduced in this study essentially constructs a physical-level pre-filter. Many existing non-contact monitoring solutions rely on a single modality; for instance, the audio-only scheme proposed by Chen et al. [22] is highly susceptible to false positives triggered by environmental noise. In contrast, the IMU provides a robust constraint based on the sow’s postural stasis. By applying a 0.25 g SVM threshold and a 30° tilt change criterion, the system filters out non-relevant acoustic events. This dual-verification logic effectively addresses the challenge of “cross-talk” from adjacent pens in intensive farming environments.
The technical performance of the system directly translates into biological advantages. The 179 ms system latency is critical for intervening within the narrow physiological window before piglet injury occurs. Furthermore, the 28-day battery endurance ensures seamless monitoring throughout the lactation cycle without the need for human interference, which is essential for maintaining a low-stress environment for the sow and reducing labor costs in intensive farming.
Finally, from a commercial and operational perspective, the proposed system demonstrates significant cost-effectiveness and technical superiority, as summarized in Table 4. Compared to vision-based solutions [11,12] with single-node costs exceeding 100 USD, the ESP32-S3-based edge node in this study is strictly controlled within 20 USD. Beyond the initial hardware savings, the system offers a rapid Return on Investment (ROI); as shown in the comparative analysis, the estimated payback period is less than one single lactation cycle. Furthermore, by performing TinyML inference locally and transmitting only abstracted metadata, the system ensures high data privacy and operational stability in offline environments. This hierarchical model maximizes piglet survival while prioritizing animal welfare, providing a scalable and robust engineering tool for sustainable swine production within the PLF framework.
Despite the promising results, this study should be interpreted as a robust proof-of-concept (POC) validation within a controlled field environment. The current trial size (ten sows) provides sufficient data to verify the technical feasibility of the ‘motion-gated’ logic; however, further large-scale operational validation across more diverse housing systems and larger animal populations is required to confirm its long-term commercial robustness.

4. Conclusions

To address the industrial challenges of high piglet crushing mortality and the lack of low-power, continuous monitoring tools in intensive farming, this study developed and validated a multi-modal edge monitoring system based on the TinyML paradigm. By integrating 1D-CNN acoustic inference with IMU-based kinematic posture estimation within a hierarchical Edge-Fog-Cloud collaborative architecture, real-time closed-loop intervention was successfully implemented on an ultra-low-power platform. The main conclusions are as follows:
  • Optimal Efficiency and Determinism: The proposed Int8-quantized 1D-CNN model (5.1 KB) achieved 95.56% accuracy with only 2 ms inference latency on the ESP32-S3. Compared to LSTM, the 1D-CNN significantly reduces computational overhead while ensuring the inference determinism required for real-time rescue.
  • Robust Multi-modal Fusion: The “Motion-Gating” mechanism effectively filters ambient noise and cross-talk from adjacent pens by using postural transitions as a trigger for acoustic detection. Field tests confirmed this logic ensures high specificity and overcomes the limitations of single-modal monitoring.
  • End-to-End Autonomy and Endurance: The system maintains an end-to-end response latency within 179 ms, ensuring intervention well within the 60 s “golden rescue window.” Furthermore, the motion-triggering design ensures the battery life covers the entire 28-day lactation cycle, achieving a maintenance-free “single-deployment” design.
  • Preliminary Field Validation of the Hierarchical Strategy: Field trials spanning three lactation cycles demonstrated that the system was able to effectively intercept critical crushing risks within the test environment. In the analyzed 28-day period involving ten sows, no fatalities were recorded within this monitored cohort, supporting the potential feasibility of the synergy between autonomous interventions and remote oversight. While further large-scale validation is required, this human–machine collaboration model shows potential as a scalable tool for enhancing piglet survival. Furthermore, this hierarchical sensing logic provides a practical reference for developing other low-power, multi-modal monitoring solutions in resource-constrained agricultural environments.

Author Contributions

Conceptualization, Z.L.; methodology, H.L. (Hao Liu); software, H.L. (Hao Liu); validation, G.H.; formal analysis, H.L. (Hao Liu); investigation, H.L. (Hao Liu), H.L. (Haopu Li), Y.C. and R.C.; resources, G.H.; data curation, H.L. (Haopu Li) and Y.C.; writing—original draft preparation, H.L. (Hao Liu); writing—review and editing, Z.L.; visualization, H.L. (Hao Liu); supervision, Z.L.; project administration, Z.L.; funding acquisition, Z.L. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the Research Project Supported by the Shanxi Scholarship Council of China (grant number: 2023-092) and the key R&D program of Shanxi Province (grant number: 202302010101002).

Institutional Review Board Statement

This animal study protocol was approved by the Animal Ethics Committee of Shanxi Agricultural University (approval number: [SXAU-EAW-2022P.GT.0070080141]; approval date: 1 December 2022).

Data Availability Statement

The data presented in this study are available on request from the corresponding author due to privacy and commercial confidentiality.

Acknowledgments

We thank the staff of Deshenggou Village, Guxian Town, Qinxian County, Shanxi Province, and the local pig farms for their help with the data collection process. We also thank the experts who participated in data collection, labelling, and the model evaluation process.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Nuntapaitoon, M.; Tummaruk, P. Piglet Preweaning Mortality in a Commercial Swine Herd in Thailand. Trop. Anim. Health Prod. 2015, 47, 1539–1546. [Google Scholar] [CrossRef]
  2. Nuntapaitoon, M.; Tummaruk, P. Factors Influencing Piglet Pre-Weaning Mortality in 47 Commercial Swine Herds in Thailand. Trop. Anim. Health Prod. 2018, 50, 129–135. [Google Scholar] [CrossRef] [PubMed]
  3. Fraser, D. Behavioural Perspectives on Piglet Survival. J. Reprod. Fertil. Suppl. 1990, 40, 355–370. [Google Scholar] [CrossRef]
  4. Liu, T. New Insights into Factors Affecting Piglet Crushing and Anti-Crushing Techniques. Livest. Sci. 2022, 265, 105080. [Google Scholar] [CrossRef]
  5. Weary, D.M.; Pajor, E.A.; Fraser, D.; Honkanen, A.-M. Sow Body Movements That Crush Piglets: A Comparison between Two Types of Farrowing Accommodation. Appl. Anim. Behav. Sci. 1996, 49, 149–158. [Google Scholar] [CrossRef]
  6. Valros, A.; Rundgren, M.; Špinka, M.; Saloniemi, H.; Algers, B. Sow Activity Level, Frequency of Standing-to-Lying Posture Changes and Anti-Crushing Behaviour—Within Sow-Repeatability and Interactions with Nursing Behaviour and Piglet Performance. Appl. Anim. Behav. Sci. 2003, 83, 29–40. [Google Scholar] [CrossRef]
  7. Andersen, I.L.; Berg, S.; Bøe, K.E. Crushing of Piglets by the Mother Sow (Sus Scrofa)—Purely Accidental or a Poor Mother? Appl. Anim. Behav. Sci. 2005, 93, 229–243. [Google Scholar] [CrossRef]
  8. Friend, T.; O’Connor, L.; Knabe, D.; Dellmeier, G. Preliminary Trials of a Sound-Activated Device to Reduce Crushing of Piglets by Sows. Appl. Anim. Behav. Sci. 1989, 24, 23–29. [Google Scholar] [CrossRef]
  9. Cravero, A.; Sepúlveda, S.; Gutiérrez, F.; Muñoz, L. From Precision Agriculture to Intelligent Agricultural Ecosystems: A Systematic Review of Machine Learning and Big Data Applications. Agronomy 2026, 16, 516. [Google Scholar] [CrossRef]
  10. Botero-Valencia, J.; García-Pineda, V.; Valencia-Arias, A.; Valencia, J.; Reyes-Vera, E.; Mejia-Herrera, M.; Hernández-García, R. Machine Learning in Sustainable Agriculture: Systematic Review and Research Perspectives. Agriculture 2025, 15, 377. [Google Scholar] [CrossRef]
  11. Thongsrimoung, K.; Kusakunniran, W.; Wisetpaitoon, K.; Thongkanchorn, K.; Yano, T.; Thanapongtharm, W.; Boonyo, K. Sow Posture Detection for Determining Piglet Crushing through a Camera System. PeerJ Comput. Sci. 2025, 11, e3400. [Google Scholar] [CrossRef]
  12. Wei, J.; Tang, Y.; Chen, J.; Wang, K.; Li, P.; Shen, M.; Liu, L. SPMF-YOLO-Tracker: A Method for Quantifying Individual Activity Levels and Assessing Health in Newborn Piglets. Agriculture 2025, 15, 2087. [Google Scholar] [CrossRef]
  13. Chen, J.; Liu, L.; Li, P.; Yao, W.; Shen, M.; Liu, L. Resting Posture Recognition Method for Suckling Piglets Based on Piglet Posture Recognition (PPR)–You Only Look Once. Agriculture 2025, 15, 230. [Google Scholar] [CrossRef]
  14. Chapel, N.; Lucas, J.; Radcliffe, S.; Stewart, K.; Lay, D. Comparison of Vocalization Patterns in Piglets Which Were Crushed to Those Which Underwent Human Restraint. Animals 2018, 8, 138. [Google Scholar] [CrossRef] [PubMed]
  15. Illmann, G.; Hammerschmidt, K.; Špinka, M.; Tallet, C. Calling by Domestic Piglets during Simulated Crushing and Isolation: A Signal of Need? PLoS ONE 2013, 8, e83529. [Google Scholar] [CrossRef]
  16. Appleby, M.C.; Weary, D.M.; Taylor, A.A.; Illmann, G. Vocal Communication in Pigs: Who Are Nursing Piglets Screaming At? Ethology 1999, 105, 881–892. [Google Scholar] [CrossRef]
  17. Moura, D.J.; Silva, W.T.; Naas, I.A.; Tolón, Y.A.; Lima, K.A.O.; Vale, M.M. Real Time Computer Stress Monitoring of Piglets Using Vocalization Analysis. Comput. Electron. Agric. 2008, 64, 11–18. [Google Scholar] [CrossRef]
  18. Jahns, G. Call Recognition to Identify Cow Conditions—A Call-Recogniser Translating Calls to Text. Comput. Electron. Agric. 2008, 62, 54–58. [Google Scholar] [CrossRef]
  19. Vinayagam, P.; Kanagamalliga, S.; Mahalakshmi, B.; Pradisha, P. Acoustic Deep Learning Models for Early Detection of Distress Calls in Farm Animals. In Proceedings of the 2025 10th International Conference on Smart Structures and Systems (ICSSS), Chennai, India, 12 December 2025; IEEE: Chennai, India, 2025; pp. 1–6. [Google Scholar]
  20. Pann, V.; Kwon, K.-S.; Kim, B.; Jang, D.-H.; Kim, J.; Kim, J.-B. Robustness of CNN-Based Model Assessment for Pig Vocalization Classification across Diverse Acoustic Environments. Comput. Electron. Agric. 2026, 240, 111181. [Google Scholar] [CrossRef]
  21. Chen, W.-E.; Chen, L.-X.; Chiu, Y.-C. An Intelligent Detection and Notification (iDN) System for Handling Piglet Crushing Based on Machine Learning. In Cognitive Cities; Shen, J., Chang, Y.-C., Su, Y.-S., Ogata, H., Eds.; Communications in Computer and Information Science; Springer: Singapore, 2020; Volume 1227, pp. 475–484. ISBN 978-981-15-6112-2. [Google Scholar]
  22. Chen, W.-E.; Lin, Y.-B.; Chen, L.-X. PigTalk: An AI-Based IoT Platform for Piglet Crushing Mitigation. IEEE Trans. Ind. Informat. 2021, 17, 4345–4355. [Google Scholar] [CrossRef]
  23. Reza, M.N.; Do, M.-G.; Seo, J.-B.; Song, M.; Chung, S.-O.; Kim, G. Sound Based Approaches for Pig Diseases and Crush Symptoms Monitoring in Pig Farms: A Review. Precis. Agric. Sci. Technol. 2022, 4, 35–49. [Google Scholar] [CrossRef]
  24. Reza, M.N.; Ali, M.R.; Haque, M.A.; Jin, H.; Kyoung, H.; Choi, Y.K.; Kim, G.; Chung, S.-O. A Review of Sound-Based Pig Monitoring for Enhanced Precision Production. J. Anim. Sci. Technol. 2025, 67, 277–302. [Google Scholar] [CrossRef]
  25. Kong, Q.; Cao, Y.; Iqbal, T.; Wang, Y.; Wang, W.; Plumbley, M.D. PANNs: Large-Scale Pretrained Audio Neural Networks for Audio Pattern Recognition. IEEE/ACM Trans. Audio Speech Lang. Process. 2020, 28, 2880–2894. [Google Scholar] [CrossRef]
  26. Wang, R.-F.; Su, W.-H. The Application of Deep Learning in the Whole Potato Production Chain: A Comprehensive Review. Agriculture 2024, 14, 1225. [Google Scholar] [CrossRef]
  27. Wang, R.-F.; Qu, H.-R.; Su, W.-H. From Sensors to Insights: Technological Trends in Image-Based High-Throughput Plant Phenotyping. Smart Agric. Technol. 2025, 12, 101257. [Google Scholar] [CrossRef]
  28. Mihigo, I.N.; Zennaro, M.; Uwitonze, A.; Rwigema, J.; Rovai, M. On-Device IoT-Based Predictive Maintenance Analytics Model: Comparing TinyLSTM and TinyModel from Edge Impulse. Sensors 2022, 22, 5174. [Google Scholar] [CrossRef]
  29. Gookyi, D.A.N.; Wulnye, F.A.; Arthur, E.A.E.; Ahiadormey, R.K.; Agyemang, J.O.; Agyekum, K.O.-B.O.; Gyaang, R. TinyML for Smart Agriculture: Comparative Analysis of TinyML Platforms and Practical Deployment for Maize Leaf Disease Identification. Smart Agric. Technol. 2024, 8, 100490. [Google Scholar] [CrossRef]
  30. Miller, T.; Mikiciuk, G.; Durlik, I.; Mikiciuk, M.; Łobodzińska, A.; Śnieg, M. The IoT and AI in Agriculture: The Time Is Now—A Systematic Review of Smart Sensing Technologies. Sensors 2025, 25, 3583. [Google Scholar] [CrossRef]
  31. Michielon, A.; Litta, P.; Bonelli, F.; Don, G.; Farisè, S.; Giannuzzi, D.; Milanesi, M.; Pietrucci, D.; Vezzoli, A.; Cecchinato, A.; et al. Mind the Step: An Artificial Intelligence-Based Monitoring Platform for Animal Welfare. Sensors 2024, 24, 8042. [Google Scholar] [CrossRef] [PubMed]
  32. Manteuffel, C.; Tuchscherer, A.; Schmidt, M.; Hoffmann, G.; Schön, P.C. Using Air-Blow and Floor Vibration to Trigger Posture Changes in Gestating and Lactating Sows. Comput. Electron. Agric. 2014, 104, 105–110. [Google Scholar] [CrossRef]
  33. Düpjan, S.; Schön, P.-C.; Puppe, B.; Tuchscherer, A.; Manteuffel, G. Differential Vocal Responses to Physical and Mental Stressors in Domestic Pigs (Sus Scrofa). Appl. Anim. Behav. Sci. 2008, 114, 105–115. [Google Scholar] [CrossRef]
  34. Kittle, O.J.; Knauer, M.T.; Almond, G.W.; Stamenos, A.; Kushner, L.; Weisenhorn, S.; Leonard, S.M. Effects of Indoor Temperature, Relative Humidity, and Carbon Dioxide Conditions on Wean-to-Finish Swine Survivability. Agriculture 2025, 15, 2050. [Google Scholar] [CrossRef]
  35. Thompson, R.; Matheson, S.M.; Plötz, T.; Edwards, S.A.; Kyriazakis, I. Porcine Lie Detectors: Automatic Quantification of Posture State and Transitions in Sows Using Inertial Sensors. Comput. Electron. Agric. 2016, 127, 521–530. [Google Scholar] [CrossRef] [PubMed]
Figure 1. Experimental environment and spatial layout of the system components. (a) Overview of the standardized commercial farrowing house. (b) Detailed deployment in the farrowing crate: featuring the data collection units (HD cameras at 1.5 m and high-sensitivity microphones at 1.0 m for behavioral labeling) and the intervention system components (transmitter node worn by the sow and the intervention fan located at the front).
Figure 1. Experimental environment and spatial layout of the system components. (a) Overview of the standardized commercial farrowing house. (b) Detailed deployment in the farrowing crate: featuring the data collection units (HD cameras at 1.5 m and high-sensitivity microphones at 1.0 m for behavioral labeling) and the intervention system components (transmitter node worn by the sow and the intervention fan located at the front).
Agriculture 16 00753 g001
Figure 2. Comparison of Log-Mel spectrograms.
Figure 2. Comparison of Log-Mel spectrograms.
Agriculture 16 00753 g002
Figure 3. The three-tier Edge-Fog-Cloud system architecture.
Figure 3. The three-tier Edge-Fog-Cloud system architecture.
Agriculture 16 00753 g003
Figure 4. Photographs of the hardware prototype and industrial wiring architecture. (a) Transmitter Node: A wearable module integrating an ESP32-S3 MCU, a digital MEMS microphone (INMP441), an MPU6050 IMU, and a vibration motor for soft intervention. (b) Receiver Node (Fog Gateway): Standardized industrial wiring implementation featuring a four-channel relay module to drive multiple intervention fans (Fan 1–4), an integrated DHT11 sensor for ambient temperature and humidity monitoring, and dedicated AC 220 V/DC 5 V power interfaces.
Figure 4. Photographs of the hardware prototype and industrial wiring architecture. (a) Transmitter Node: A wearable module integrating an ESP32-S3 MCU, a digital MEMS microphone (INMP441), an MPU6050 IMU, and a vibration motor for soft intervention. (b) Receiver Node (Fog Gateway): Standardized industrial wiring implementation featuring a four-channel relay module to drive multiple intervention fans (Fan 1–4), an integrated DHT11 sensor for ambient temperature and humidity monitoring, and dedicated AC 220 V/DC 5 V power interfaces.
Agriculture 16 00753 g004
Figure 5. Architecture of the proposed lightweight SE-1D-CNN model with integrated attention mechanism.
Figure 5. Architecture of the proposed lightweight SE-1D-CNN model with integrated attention mechanism.
Agriculture 16 00753 g005
Figure 6. The operational workflow of the multimodal monitoring algorithm. Note: Δ S V M denotes S V M 1   g as defined in Section 2.4.1; Δ θ represents the orientation change within a 1.0 s window. The dotted arrows represent wireless command signal transmissions or state transition triggers; question marks (?) denote the conditional queries within decision blocks.
Figure 6. The operational workflow of the multimodal monitoring algorithm. Note: Δ S V M denotes S V M 1   g as defined in Section 2.4.1; Δ θ represents the orientation change within a 1.0 s window. The dotted arrows represent wireless command signal transmissions or state transition triggers; question marks (?) denote the conditional queries within decision blocks.
Agriculture 16 00753 g006
Figure 7. Visualization of MFCC features at different dimensions ( F { 8 , 13 , 32 } ) for a typical distress call sample.
Figure 7. Visualization of MFCC features at different dimensions ( F { 8 , 13 , 32 } ) for a typical distress call sample.
Agriculture 16 00753 g007
Figure 8. Confusion matrix of the final deployed model (1D-CNN, MFCC = 13, Int8) on the test set.
Figure 8. Confusion matrix of the final deployed model (1D-CNN, MFCC = 13, Int8) on the test set.
Agriculture 16 00753 g008
Figure 9. Real-time remote monitoring interface. (a) PC Dashboard (b) Mobile Dashboard.
Figure 9. Real-time remote monitoring interface. (a) PC Dashboard (b) Mobile Dashboard.
Agriculture 16 00753 g009
Table 1. Distribution of the augmented piglet distress acoustic dataset.
Table 1. Distribution of the augmented piglet distress acoustic dataset.
CategoryDescriptionRaw SamplesTraining SetTest SetTotal
DistressAcute pain screams
(Field + Web)
40813063261632
InteractionSqueals during fighting/playing44614273571784
NursingRhythmic grunting of sows50316104022012
AmbientFan, machinery, and background noise42613633411704
Total-1783570614267132
Table 2. Comprehensive Performance Comparison of Different Model Architectures, Feature Dimensions, and Quantization Modes.
Table 2. Comprehensive Performance Comparison of Different Model Architectures, Feature Dimensions, and Quantization Modes.
FeatureModelQuantizationAccuracyPrecisionRecallF1
8Base-1D-CNNINT892.95%92.97%92.95%92.93%
8Base-1D-CNNFLOAT3292.88%92.91%92.88%92.85%
8SE-1D-CNNINT896.12%96.10%96.12%96.10%
8SE-1D-CNNFLOAT3296.12%96.11%96.12%96.09%
8LSTMINT898.45%98.45%98.45%98.44%
8LSTMFLOAT3298.45%98.46%98.45%98.45%
13Base-1D-CNNINT895.56%95.54%95.56%95.54%
13Base-1D-CNNFLOAT3295.56%95.53%95.56%95.54%
13SE-1D-CNNINT896.97%96.99%96.97%96.97%
13SE-1D-CNNFLOAT3297.04%97.06%97.04%97.04%
13LSTMINT898.38%98.39%98.38%98.38%
13LSTMFLOAT3298.38%98.40%98.38%98.38%
32Base-1D-CNNINT895.77%95.80%95.77%95.77%
32Base-1D-CNNFLOAT3296.05%96.08%96.05%96.05%
32SE-1D-CNNINT896.62%96.68%96.62%96.63%
32SE-1D-CNNFLOAT3297.04%97.10%97.04%97.05%
32LSTMINT899.72%99.72%99.72%99.72%
32LSTMFLOAT3299.65%99.65%99.65%99.65%
Table 3. Performance comparison of different model architectures on the edge gateway.
Table 3. Performance comparison of different model architectures on the edge gateway.
ModelMFCCQuant.Test Acc.Peak RAMDSP TimeInference TimeTotal Latency
Base-1D-CNN8Int892.95%4.1 KB124 ms2 ms126 ms
Base-1D-CNN13Int895.56%5.1 KB135 ms2 ms137 ms
Base-1D-CNN32Int895.77%9.0 KB181 ms3 ms184 ms
SE-1D-CNN8Int896.12%5.1 KB124 ms4 ms128 ms
SE-1D-CNN13Int896.97%6.1 KB135 ms4 ms139 ms
SE-1D-CNN32Int896.62%10.0 KB181 ms5 ms186 ms
LSTM8Int898.45%8.5 KB124 ms55 ms179 ms
LSTM13Int898.38%8.5 KB135 ms57 ms192 ms
LSTM32Int899.72%11.9 KB181 ms169 ms350 ms
Table 4. Comparative analysis of system architecture, performance, and economic benefits.
Table 4. Comparative analysis of system architecture, performance, and economic benefits.
FeatureProposed System (TinyML Edge)Vision-Based (Cloud/Server)Audio-Only (Cloud/Server)
Inference ModeEdge-based (Local)Cloud or Local ServerCloud or Local Server
Hardware Cost<$20 (Low-power node)>$100 (GPU/Camera/Gateway)~$40 (Mic/Processing PC)
Connectivity
Requirement
Minimal (Metadata only)High bandwidth (Raw video)Medium bandwidth
(Raw audio)
Latency & StabilityReal-time; Offline-capableNetwork-dependentNetwork-dependent
Privacy & SecurityHigh (Raw data on node)Low (Raw video streaming)Low (Raw audio streaming)
Main Technical LimitIMU threshold calibrationOcclusion & light sensitivityHigh false alarms (Noise)
Payback Period<1 Lactation cycle3–5 Lactation cyclesUncertain (false alarms)
Economic BenefitExtremely HighModerateLow
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Liu, H.; Li, H.; Cao, Y.; Cao, R.; Hu, G.; Liu, Z. A Low-Power Piglet Crushing Detection System Based on Multi-Modal Fusion. Agriculture 2026, 16, 753. https://doi.org/10.3390/agriculture16070753

AMA Style

Liu H, Li H, Cao Y, Cao R, Hu G, Liu Z. A Low-Power Piglet Crushing Detection System Based on Multi-Modal Fusion. Agriculture. 2026; 16(7):753. https://doi.org/10.3390/agriculture16070753

Chicago/Turabian Style

Liu, Hao, Haopu Li, Yue Cao, Riliang Cao, Guangying Hu, and Zhenyu Liu. 2026. "A Low-Power Piglet Crushing Detection System Based on Multi-Modal Fusion" Agriculture 16, no. 7: 753. https://doi.org/10.3390/agriculture16070753

APA Style

Liu, H., Li, H., Cao, Y., Cao, R., Hu, G., & Liu, Z. (2026). A Low-Power Piglet Crushing Detection System Based on Multi-Modal Fusion. Agriculture, 16(7), 753. https://doi.org/10.3390/agriculture16070753

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