MQTT-Based Architecture for Real-Time Data Collection and Anomaly Detection in Smart Livestock Housing
- PMID: 41374561
- PMCID: PMC12694545
- DOI: 10.3390/s25237186
MQTT-Based Architecture for Real-Time Data Collection and Anomaly Detection in Smart Livestock Housing
Abstract
This study designed a message queuing telemetry transport (MQTT)-based communication framework to acquire environmental data with stable, low-latency response (soft real-time capability) and detect anomalies in smart livestock housing. We validated the performance of the proposed framework using actual sensor data. It comprises environmental sensor nodes, a Mosquitto MQTT broker, and a GRU-based anomaly detection model, with data transmission via a WiFi-based network. Comparing quality of service (QoS) levels, the QoS 1 configuration demonstrated the most stable performance, with an average latency of ~150 ms, a data collection rate ≥ 99%, and a packet loss rate ≤ 0.5%. In the sensor node expansion experiment, responsiveness (≤200 ms) persisted for 10-15 nodes, whereas latency increased to 238.7 ms for 20 or more nodes. The GRU model proved suitable for low-latency analysis, achieving 97.5% accuracy, an F1-score of 0.972, and 18.5 ms/sample inference latency. In the integrated experiment, we recorded an average end-to-end latency of 185.4 ms, a data retention rate of 98.9%, processing throughput of 5.39 samples/s, and system uptime of 99.6%. These findings demonstrate that combining QoS 1-based lightweight MQTT communication with the GRU model ensures stable system response and low-latency operation (soft real-time capability) in monitoring livestock housing environments, achieving an average end-to-end latency of 185.4 ms.
Keywords: GRU; MQTT; QoS; anomaly detection; low-latency monitoring; smart livestock housing.
Conflict of interest statement
The authors declare no conflicts of interest.
Figures
References
-
- FAO . The Future of Livestock in Sustainable Food Systems. Food and Agriculture Organization of the United Nations; Rome, Italy: 2021. [(accessed on 11 August 2025)]. Available online: https://www.fao.org/documents/card/en/c/cb7004en.
-
- European Commission . Safeguarding Food Security and Reinforcing the Resilience of Food Systems; COM(2022) 133 final. European Commission; Brussels, Belgium: 2022. [(accessed on 18 August 2025)]. Available online: https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=celex:52022DC0133.
-
- United States Department of Agriculture (USDA) Precision Agriculture. USDA National Institute of Food and Agriculture; Washington, DC, USA: 2025. [(accessed on 18 August 2025)]. Available online: https://www.nifa.usda.gov/grants/programs/precision-geospatial-sensor-te....
-
- St-Pierre N.R., Cobanov B., Schnitkey G. Economic Losses from Heat Stress by US Livestock Industries. J. Dairy Sci. 2003;86:E52–E77. doi: 10.3168/jds.S0022-0302(03)74040-5. - DOI
-
- Huynh T.T.T., Aarnink A.J.A., Gerrits W.J.J., Heetkamp M.J.H., Canh T.T., Spoolder H.A.M., Kemp B., Verstegen M.W.A. Thermal behaviour of growing pigs in response to high temperature and humidity. Appl. Anim. Behav. Sci. 2005;91:1–16. doi: 10.1016/j.applanim.2004.10.020. - DOI
MeSH terms
LinkOut - more resources
Full Text Sources
