Smart livestock farming aims to improve the productivity of livestock through the provision of optimal housing, and it is developed using various sensors and actuators. Ventilation systems play a crucial role in smart livestock farming, including disease prevention and the processing of pollutants (ammonia and hydrogen sulfide) that are severely detrimental to livestock growth. Malfunctions in animal housing ventilation systems lead to mass mortality events. To address such issues, this study reports the design and implementation for a smart detection system for malfunctions in the ventilation devices installed in animal housing. This system is based on recurrent neural networks (RNNs) and implements the ontology method, considering sensor and controller data as the standard. A semantic sensor network ontology founded on a knowledge base was used to detect malfunctions, and stimulus-sensor-observation patterns were used to determine a sensor network within the smart barn. System activation and RNN model tests were used to test the malfunction detection system, and the error between actual data and predicted values was found to be 0.06889. These findings provide insight into the development of autonomous detection systems for device malfunctions and are essential for the development of smart livestock farming technologies.