Next Article in Journal
A Robust Lightweight Vision Transformer for Classification of Crop Diseases
Previous Article in Journal
Ear Back Surface Temperature of Pigs as an Indicator of Comfort: Spatial Variability and Its Thermal Implications
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

An IoT-Based System for Measuring Diurnal Gas Emissions of Laying Hens in Smart Poultry Farms

by
Sejal Bhattad
1,
Ahmed Abdelmoamen Ahmed
1,*,
Ahmed A. A. Abdel-Wareth
2,3 and
Jayant Lohakare
2
1
Department of Computer Science, Prairie View A&M University, Prairie View, TX 77446, USA
2
Poultry Center, Cooperative Agricultural Research Center, Prairie View A&M University, Prairie View, TX 77446, USA
3
Department of Animal and Poultry Production, Faculty of Agriculture, South Valley University, Qena 83523, Egypt
*
Author to whom correspondence should be addressed.
AgriEngineering 2025, 7(8), 267; https://doi.org/10.3390/agriengineering7080267
Submission received: 19 July 2025 / Revised: 10 August 2025 / Accepted: 14 August 2025 / Published: 21 August 2025

Abstract

It is critical to provide proper environmental conditions in poultry houses to maintain birds’ health, boost productivity, and improve the overall economic viability of the poultry industry. Among the myriad of environmental elements, indoor air quality has been a determining factor that directly affects poultry well-being. Elevated concentrations of harmful gases—in particular Carbon Dioxide ( C O 2 ), Methane ( C H 4 ), and Ammonia ( N H 3 )—decomposition products of poultry litter, feed wastage, and biological processes have draconian effects on bird health, feed efficiency, the growth rate, reproduction efficiency, and mortality rate. Despite their importance, traditional air quality monitoring systems are often operated manually, labor intensive, and cannot detect sudden environmental changes due to the lack of real-time sensing. To overcome these limitations, this paper presents an interdisciplinary approach combining cloud computing, Artificial Intelligence (AI), and Internet of Things (IoT) technologies to measure real-time poultry gas concentrations. Real-time sensor feeds are transmitted to a cloud-based platform, which stores, displays, and processes the data. Furthermore, a machine learning (ML) model was trained using historical sensory data to predict the next-day gas emission levels. A web-based platform has been developed to enable convenient user interaction and display the gas sensory readings on an interactive dashboard. Also, the developed system triggers automatic alerts when gas levels cross safe environmental thresholds. Experimental results of C O 2 concentrations showed a significant diurnal trend, peaking in the afternoon, followed by the evening, and reaching their lowest levels in the morning. In particular, C O 2 concentrations peaked at approximately 570 ppm during the afternoon, a value that was significantly elevated (p < 0.001) compared to those recorded in the evening (~560 ppm) and morning (~555 ppm). This finding indicates a distinct diurnal pattern in C O 2 accumulation, with peak concentrations occurring during the warmer afternoon hours.

1. Introduction

In response to the increasing demand for poultry production, ensuring optimal environmental conditions within poultry housing systems is essential. Such conditions are fundamental to safeguarding avian health, enhancing production efficiency, and promoting the overall economic sustainability of poultry enterprises [1,2]. Air quality in poultry farms, in the form of the concentration of gases such as Carbon Dioxide ( C O 2 ), Methane ( C H 4 ), and Ammonia ( N H 3 ), is one of the most critical factors that affect chickens’ health and meat and egg production. Long-term exposure to these gases can lead to respiratory ailments, stunted growth, and reduced productivity by 30% [3]. Also, extended exposure to these gases can cause severe respiratory issues among farm workers and birds [4].
Traditional methods of gas sensing using manual sampling or handheld detectors are manpower- and time-consuming, with the disadvantage of missing the real-time variation in gas concentration [5,6], and they also are not well-suited to modern large-scale farming systems. Manual systems are time-demanding, intermittent, subject to human error, and unable to identify acute peaks in gas concentration or log real-time fluctuations [7]. Furthermore, most poultry farms are located in rural or remote areas and lack access to sophisticated environmental monitoring technologies, further exacerbating the issue of prompt detection and alleviating poor air quality conditions [8].
With the recent advances in Internet of Things (IoT) [9] and machine learning (ML) [10,11] technologies, real-time monitoring of gas concentration is becoming visible at a relatively low cost, especially in economically disadvantaged poultry farms in rural areas [12]. This paper presents the implementation of an IoT-based real-time air quality monitoring system, particularly tailored for poultry farm settings. The developed system utilizes a Raspberry Pi Single-Board Computer (SBC) integrated with several low-cost calibrated gas sensors strategically placed to measure the concentration of toxic gases at preset intervals in perpetuity. The collected data is processed locally by the Raspberry Pi and transmitted securely to a cloud-based platform via the RESTful Application Programming Interface (API), enabling centralized storage, real-time visualization, and historical analysis [13].
A web-based Graphical User Interface (GUI) application was developed to provide users with a dynamic and welcoming dashboard to utilize the system conveniently. System users can view real-time gas levels through animated color-coded gauges and historical trends categorized by time intervals, and can download custom CSV reports. The GUI also supports in-depth analysis through gas-specific views that allow the granular filtering and analysis of sensor readings across selected time intervals (e.g., daytime, nighttime). Also, gas levels crossing safe thresholds trigger automatic alerts. Live monitoring, cloud analytics, and machine learning-based forecasting are integrated into the developed system, offering an end-to-end solution for managing poultry air quality.
We trained an ML prediction model using historical sensory feeds to foretell gas concentration levels in the next 24 h, giving poultry farm operators an early warning device to anticipate and act against adverse air quality events. The predictive model aids in informed decision-making by enabling farm managers to undertake preventive measures against factors such as settings on ventilation systems or modifications to farm management strategies before their occurrence. The ML model archived acceptable prediction results, enabling the operators to ventilate and avoid gas buildup preemptively.
The rest of the paper is organized as follows: Section 2 presents related work. Section 3 presents the design and prototype implementation of the system. Section 4 experimentally evaluates the system in terms of performance and accuracy. Finally, Section 5 summarizes the results of this work.

2. Background and Related Work

The intensive poultry production in enclosed housing systems contributes significantly to the emission of various gases, including C O 2 , C H 4 , and N H 3 . These gases not only affect the health and welfare of the birds and farm workers but also pose broader environmental concerns related to air quality and greenhouse gas emissions [3,14,15]. Among these, C O 2 is mainly generated through bird respiration that has a safe limit of less than 1000 ppm, N H 3 results from the microbial degradation of uric acid in manure with a safe limit emission of 25 ppm, and C H 4 originates from the anaerobic fermentation of organic matter in litter and feces with a safe limit of 50 ppm [16,17]. Previous studies have documented that gas emissions in poultry houses are not constant throughout the day but follow distinct diurnal patterns influenced by factors such as ventilation rates, temperature fluctuations, bird activity, and manure conditions [4,18]. Recent investigations have emphasized the temporal variability of gas concentrations within layer facilities.
Kilic and Yaslioglu [19] observed that both C O 2 and N H 3 concentrations were significantly higher during the daytime compared to nighttime, correlating with bird metabolic activity and reduced ventilation efficiency during peak heat periods. Similarly, Liu et al. [20] reported that ammonia emissions varied across production systems and time of day, with cage systems generally exhibiting higher levels due to manure accumulation and ventilation patterns. These findings highlight the importance of monitoring gas concentrations over time rather than relying on single-point measurements, as diurnal fluctuations can substantially influence both short- and long-term air quality assessments. However, traditional manual sampling methods often lack the sensitivity and frequency needed to capture such fine-scale temporal changes.
Several works utilized Raspberry Pi boards integrated with DHT22 temperature and humidity sensors and MQ-series gas sensors (e.g., MQ-2, MQ-135) for basic gas monitoring. A few of these systems were interfaced with cloud platforms like the AWS IoT Core or Blynk and had limited remote monitoring functionality [7]. While there were enhancements, most systems did not have predictive forecasting models, and most interfaces were technical or rudimentary and not amenable to farm workers who needed actionable, easy-to-use dashboards.
ML models such as Support Vector Regression (SVR) [21] and Long Short-Term Memory (LSTM) neural networks [22] have been extensively studied in predictive analytics to forecast urban air pollution levels and environmental parameters [8]. Their application in poultry farm environments—with their specific gas emission profiles, microclimate conditions, and operational constraints—is, nevertheless, limited in the literature [4,20,23]. Most present-day research targets large industrial poultry compounds. It overlooks the need to serve small- and medium-sized poultry farms that comprise most of the world’s poultry business [1].
To address these research gaps, this paper employs advanced IoT-based gas sensors to monitor gas concentrations in real time continuously. These IoT sensors enabled high-resolution, automated data collection at multiple time points (i.e., morning, afternoon, and evening), thereby enhancing the precision and consistency of measurements under partially controlled environmental conditions. The objective of the present study is to investigate the diurnal dynamics of gaseous emissions using Lohmann LSL Lite laying hens over a 3-week period. By integrating IoT technology into poultry research, this study aims to provide accurate insights into emission profiles and inform better ventilation and environmental management strategies in modern layer production systems.

3. Design and Implementation

Figure 1 shows the developed distributed system comprised of IoT sensors (i.e., MQ-135 sensors) connected to edge computing devices (i.e., Raspberry Pi 4 micro-controller) and centralized servers in the cloud. The figure shows that the four-layer architecture provides an end-to-end, modular, and scalable system that seamlessly integrates real-time data acquisition, cloud connectivity, threshold-based alert generation, predictive analytics, and ease of visualization, thereby facilitating proactive farm management.
In Layer 1, the Raspberry Pi uses real-time gaseous emissions (i.e., C O 2 , C H 4 , and N H 3 ) from the MQ-135 sensors deployed in the poultry farm and communicates them to a cloud-based platform (i.e., ThingSpeak), which is an open-source IoT analytics platform, via RESTful APIs powered by JSON formatting, enabling centralized storage, real-time visualization, and historical analysis. As shown in Layer 2, ThingSpeak streams log gas concentration feeds, displays dynamic graphs, and provides dashboards for system users. We used the Flask Python framework, version 3.1.1, to retrieve the logged gas readings from ThingSpeak and train our ML models.
Layer 3 (i.e., ML layer) pre-processes the collected data from ThingSpeak using NumPy and Scikit-learn Python libraries. A Long Short-Term Memory (LSTM) model is trained using historical gas concentration values to predict near-future trends, focusing on gas level predictions for the next day. This forecasting capability enables the early detection of possible environmental threats and allows for preventive measures within the poultry farm.
We built a GUI for real-time interaction and monitoring (see Layer 4). The web-based application is developed using the Flask framework, HTML, JS, and Jinja engine. The GUI displays real-time sensor readings, graphs of historical data, and ML-based predicted next-day gaseous emissions in a structured visual display. It gives farm operators a user-friendly, easy-to-use interface that places all relevant information on one platform.

3.1. Experimental Design and Setup

The experiment was conducted over a continuous three-week period in May 2025, a time selected to ensure stable ambient environmental conditions in Prairie View, Texas, which minimized external fluctuations that could influence gas emissions. The study was conducted at the Poultry Center, Cooperative Agricultural Research Center (CARC), Prairie View A&M University (PVAMU), Prairie View, Texas, USA, in a dedicated research facility equipped to simulate commercial layer housing in a controlled and replicable manner. At the start of the experiment, 120 Lohmann LSL Lite laying hens, 30 weeks of age, were randomly assigned to 12 identical wooden layer pens (10 birds/pen).
All birds were housed under uniform environmental conditions, and standard management practices were followed throughout the study. The hens were housed under semi-open wooden pens with natural ventilation, allowing for consistent airflow and exposure to ambient light. The temperature during the experimental period was maintained between 21–24 °C, and relative humidity ranged from 55–65%. A 16-h light:8-h dark photoperiod was maintained. Each pen was equipped with fresh wood shaving bedding, which was regularly cleaned to reduce ammonia buildup. Birds had ad libitum access to water and feed, and all pens followed identical routines for feeding, cleaning, and monitoring to ensure consistency across replicates.
All pens were maintained under similar environmental and management conditions, including standardized feed and water routines, daily cleaning of wood shaving bedding, and regular health checks. While small fluctuations in ambient temperature and humidity naturally occurred, their range was minimal and consistent across all pens. These minor deviations were considered normal and did not affect the data integrity meaningfully, as the experimental design ensured replication and controlled measurements. Measurements were taken under consistent housing and management conditions across all 12 pens, located in a semi-open poultry facility with a lateral orientation and natural ventilation. Ventilation was provided via sidewall openings in an east–west airflow direction, which allowed for passive air movement across all pens. While slight environmental variations existed due to natural airflow, the housing layout and measurement schedule (fixed daily time points) were designed to minimize temporal and spatial variability, thereby ensuring the reliable comparative analysis of gas emissions.
Figure 2 shows the experiment setup of the developed system at PVAMU. A single gas sensing unit, comprising an MQ-135 gas sensor, ADS1115 analog-to-digital converter, and Raspberry Pi SBC, was rotated systematically among the 12 pens at each designated time point (6:00 a.m., 2:00 p.m., and 10:00 p.m.) for 21 days, resulting in 756 total data points per gas type (12 pens × 3 time points × 21 days). The sensor was consistently placed at bird head-height (approximately 0.5 m above the floor) and positioned centrally within each pen, away from feeders and drinkers, to obtain representative air samples and minimize measurement bias. Only one sensing unit was used throughout the study, with calibration checks conducted regularly.
The experimental design followed a completely randomized design (CRD), and the focus was placed on monitoring gaseous emissions over time. The CRD was used because gas concentration was measured at the pen level, not on individual birds, and treatments (time of day) were not repeated on the same unit but were independently observed across multiple replicates. Given that the study objective was to assess temporal variation under uniform housing conditions, a CRD was deemed appropriate. However, we recognize the merit of repeated measures designs as a potential enhancement for future longitudinal studies.
Gas measurements were recorded three times daily (i.e., morning, afternoon, and evening) across all pens to assess the temporal dynamics of gas production under consistent housing and feeding conditions. Statistical analysis was planned to compare gas emissions across these three time points per day over the course of the 3-week trial. Gaseous emissions, specifically C O 2 , C H 4 , and N H 3 , were measured and recorded using a Raspberry Pi SBC, an ADS1115 analog-to-digital converter (ADC) module, and an MQ-135 gas sensor, connected using jumper wires and a breadboard setup—see Figure 3. The MQ-135 sensor was calibrated to detect and quantify levels of C O 2 , C H 4 , and N H 3 .
Over three consecutive weeks, gas concentrations were recorded daily (morning at 6:00 a.m., afternoon at 2:00 p.m., and evening at 10:00 p.m.), aligned with observed patterns in poultry metabolic activity and ventilation conditions. This schedule was selected to observe peak bird activity periods (i.e., morning/evening), track midday heating effects (i.e., afternoon), and ensure uniformity across all measurement days. Each log was triggered by automated time-based scripts running on the Raspberry Pi, synchronized with the ThingSpeak platform to ensure timestamped, structured, and consistent data capture. These data were used to evaluate daily and temporal fluctuations in gas emissions and to statistically compare emissions across different time points within and across days.

3.2. Data Acquisition and Storage

The sensory data collection process is initiated by configuring the MQ-135 sensors for measuring the C O 2 , C H 4 , and N H 3 gas concentrations, which are connected to the Raspberry Pi via GPIO and I 2 C communication interfaces. Each sensor is calibrated to achieve accuracy, and the Raspberry Pi is configured to poll sensor data at regular intervals (typically every 60 s). This setup the enables around-the-clock recording of real-time gas concentration levels from the poultry house.
Calibrating the MQ-135 gas sensor for measuring gas emissions in poultry farms (e.g., C O 2 , C H 4 , N H 3 , etc.) is crucial for accurate and reliable readings. We first preheat the MQ-135 sensor for a 24–48 h burn-in time to stabilize the sensor. We then placed it in outdoor clean air. Using the following formula, we calculated the sensor resistance, R s , in the poultry house environment.
R s = V c c V o u t V o u t × R L
where V c c is the supply voltage to the MQ-135 sensor circuit, V o u t is the analog voltage output from the sensor, and R L is the load resistor (typically 10 kΩ).
We then calculated the sensor resistance in clean outdoor air condition, R θ , using the following formula.
R θ = R s γ
where γ is the ratio for clean air measured to be approximately 3.6 at the Poultry Center, PVAMU.
To improve the accuracy and reliability of gas concentration measurements using the MQ-135 sensor in poultry farms, the system performs pre-processing steps, including noise filtering, outlier removal, and converting analog signals to readable parts per million (ppm) measurements. Given that the sensor output is analog and highly sensitive to environmental noise, we implemented various strategies to help reduce false or erratic readings. We used the Moving Average Filter (MAF) to smooth out the short-term fluctuations and keep computation lightweight, especially for the Raspberry Pi devices. We also utilized the Exponential Moving Average (EMA) technique to give more weight to the most recent sensor values. The median filter removes extreme outliers, collects samples, sorts them, and picks the middle value. We used the Interquartile Range (IQR) statistical dispersion measure for outlier removal, a robust mechanism for adjusting skewed data, storing a sample sensor data window, and sorting it. The I Q R metric is calculated using this formula.
I Q R = Q 3 Q 1 ; L = Q 1 1.5 × I Q R ; U = Q 3 + 1.5 × I Q R
where Q 1 is the first quartile representing the 25th percentile of our sensory dataset, Q 3 is the third quartile representing the 75th percentile of our sensory dataset, and L and U are the lower and upper outlier bounds, receptively. In other words, any value outside this range (LU) is considered an outlier.
The cleaned data is time-stamped and formatted into a JSON string. The data packets are transmitted to the ThingSpeak cloud platform via RESTful API calls, where they are stored for real-time access and historical analytics, as shown in Figure 4 and Figure 5. This organized data stream sustains the operation of the Flask-based web dashboard, which pulls and plots the sensor data for monitoring, alerting, and predictive forecasting. This orchestrated communication mechanism guarantees that the system will be operated with high reliability, minimal latency, and constant accuracy, accomplishing the primary requirements of real-time poultry air quality monitoring. At the same time, the backend also compares each reading of the gases with pre-defined safety levels (e.g., C O 2 > 1000 ppm) in real-time, which preserves the bird’s health and performance [7]. If the reading is above its threshold, the system flags the alert dynamically and provides a visual notification on the dashboard to alert the user in real-time.
We used the following formula to convert the analog voltage of the MQ-135 sensor to gas concentration, p p m .
p p m = a ( V o u t V i n V o u t ) b
where V o u t is the sensor’s analog output voltage, V i n is the input voltage (typically 5V), and a and b are sensor-specific calibration constants derived experimentally.

3.3. GUI

The web-based dashboard enables farm operators to interact with the system and track real-time and historical sensory data using any internet-enabled device (see Figure 6). It was developed on top of the Flask web framework, which makes the dashboard responsive, lightweight, and completely integrated with the ThingSpeak cloud platform. Our system periodically fetches the latest gas concentration values by making GET calls on ThingSpeak’s REST API. The parsed data is passed on to the dashboard using Flask’s Jinja2 template engine, and the sensory data is dynamically rendered in real time.
The dashboard offers several functionalities to farm operators, including live gauges that show the real-time gas concentrations through color-coded animation gauges for defining safe, caution, and danger zones, data export in CSV format, gas-specific analysis pages that allow users to do time-of-day filtering (i.e., morning, afternoon, evening), and date-range selections. The dashboard uses the LSTM model to predict the next-day gas volumes using historical patterns. Predicted values are shown in the form of bar charts on the dashboard.

3.4. ML Model

The ML-based prediction module utilizes historical gas sensory data stored and accessed in ThingSpeak to train an LSTM neural network. The model can predict gas concentration values with a high temporal resolution for the next 24 h period. This allows farm operators to be prepared for deteriorating air quality conditions in advance and act ahead, for instance, by modifying ventilation or changing waste management routines. The ML model was trained and installed in the Flask engine, which retrieves the historical data at regular intervals, processes it, and feeds it through the LSTM model.
The LSTM model was trained using historical gas concentration data recorded in May 2025 and collected from a Raspberry Pi 4 device installed in the experimental poultry facility at Prairie View A&M University. The dataset contained continuous time-stamped readings for three gases— C O 2 , C H 4 , and N H 3 —recorded at roughly 1 min intervals. This resulted in a total of 1440 records per gas over the measurement period. The dataset was split as follows: Training (80%), 1152 records; Validation (10%), 144 records; and Testing (10%), 144 records. This approach ensured a balanced temporal distribution while preserving chronological order to prevent data leakage in time-series prediction.
The LSTM model was implemented using the Scikit-learn and Keras-TensorFlow libraries, with the following configuration: (1) input features are time-stamped C O 2 , C H 4 , and N H 3 concentrations; (2) the target is the next-day prediction for each gas type; (3) the architecture is one LSTM layer with 64 units, followed by a dense output layer; (4) the activation function is the ReLU for hidden layers, linear for output; (6) the loss function is Mean Squared Error (MSE); (7) the Optimizer (Adam); (8) the number of training epochs is 100; and (9) the batch size is 16. This configuration was determined after basic tuning using the validation dataset. Due to the relatively small dataset size, deeper architectures were avoided to prevent overfitting.
As shown in Figure 7, the predicted values are displayed as a grouped bar chart on the web dashboard and are available for CSV download. This smooth integration guarantees that users get real-time monitoring features and future-oriented information, making the system more useful as a decision-support tool in intelligent poultry farming settings. The figure shows the hourly prediction of gas concentrations for the next day from the LSTM model. The bar chart enables a time-based daily assessment of air quality trends. The line graph compares the actual and predicted values over time for the C O 2 , C H 4 , and N H 3 gas emissions. The lines’ proximity indicates the ML model’s high prediction accuracy.
Figure 8 shows the model’s performance in the training and validation phases. As shown in the figure, the Mean Squared Error (MSE) loss for training and validation sets across epochs proves the model’s convergence and elimination of overfitting. The MSE is calculated using this formula.
M S E = 1 n i = 1 n ( y i y ^ i ) 2
where y i is the ground truth value and y ^ i is the predicted value.
To predict the next day’s gas concentration, a regression model was used, which is mathematically represented as follows:
y ^ = w 0 + w 1 x 1 + w 2 x 2 + + w n x n
where y ^ is the predicted gas concentration value in ppm, x i is the i t h historical gas reading (i.e., feature vector), and w i is the i t h weight value learned during the training process.

4. Evaluation and Result Analysis

We evaluated our system experimentally regarding performance and accuracy, in addition to conducting statistical analysis.

4.1. Performance and Prediction Accuracy

System responsiveness and latency are the key performance parameters for real-time monitoring systems. The Raspberry Pi SBC, connected with the calibrated gas sensors, could read and transmit sensor data to ThingSpeak in a very short latency. Real-time transmission was achieved with an average delay of less than 5 s from reading the sensor to data visibility on the dashboard online. The Flask-based web application periodically sends requests to ThingSpeak’s API within a range of 15–30 s, giving real-time indications of the gas concentration level on the GUI.
The ML predictive model was evaluated using standard performance metrics to determine its ability to predict near-future gas concentrations. The trained model, utilizing hourly resampled historical data, performed well on unseen data and demonstrated good generalization capability. Evaluation metrics of interest include Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and R 2 . As shown in Figure 9, the model generated an average MAE of 3.47 ppm, an RMSE of 4.12 ppm, and an R 2 of 16.98 ppm on the C O 2 , C H 4 , and N H 3 gases, respectively. The coefficient of determination R 2 score is calculated mathematically as follows:
R 2 = 1 i = 1 n ( y i y ^ i ) 2 i = 1 n ( y i y ¯ ) 2
where y ¯ is the mean of the ground truth (actual) values.
Figure 10 compares the actual and predicted values over time for the C O 2 , C H 4 , and N H 3 gaseous emissions. The lines’ proximity indicates the ML model’s high prediction accuracy. These results indicate a negligible prediction error range, confirming the model’s validity in predicting environmental conditions in the short term for poultry farms. The forecasting system enables intelligence-based decision-making by allowing farm operators to act proactively before an increase in dangerous gas levels, contributing to proactive and intelligence-based environmental management.

4.2. Statistical Analysis

Sensor data were collected and analyzed to compare gas emissions across different times of day (morning, afternoon, and evening). Statistical analysis was performed using the General Linear Model (GLM) procedure in SAS software (version 9.2; SAS Institute Inc., Cary, NC, USA) based on a one-way analysis of variance (ANOVA) under a completely randomized design. Time of day was considered as a fixed effect. When significant differences were observed ( p < 0.05 ), treatment means were separated using Duncan’s Multiple Range Test. Data are presented as means ± standard error of the mean (SEM). All graphical representations were generated using GraphPad Prism software (version 9; GraphPad Software, La Jolla, CA, USA).

4.2.1. Carbon Dioxide Emissions

The concentration of C O 2 in the laying hens at 30 weeks of age differed significantly across the three time points measured in the facility during the day ( p < 0.001 ; see Figure 11a). The highest C O 2 levels were recorded in the afternoon, followed by the evening, while the lowest concentrations occurred in the morning. Specifically, C O 2 levels reached approximately 570 ppm in the afternoon, which was significantly higher ( p < 0.001 ) than the levels observed in the evening (~560 ppm) and morning (~555 ppm). These findings indicate a distinct diurnal pattern in C O 2 accumulation, with peak concentrations occurring during the warmer afternoon hours.

4.2.2. Methane Emissions

C H 4 concentrations showed significant diurnal variation throughout the day p < 0.001 ; see Figure 11b). The highest C H 4 levels were recorded in the morning (~18 ppm), followed by the evening (~17.5 ppm), while the lowest values were observed in the afternoon (~17 ppm). Statistically, C H 4 levels in the morning were significantly higher than in both the afternoon and evening, and evening levels were also significantly greater than those in the afternoon. These findings suggest that methane emissions peaked during the early hours and declined slightly during the warmer afternoon period before rising again in the evening.

4.2.3. Ammonia Emissions

N H 3 concentrations also varied significantly across the day ( p < 0.001 ; see Figure 11c). The highest N H 3 levels were observed in the morning and evening, both of which were significantly higher than the levels recorded in the afternoon. Specifically, N H 3 concentrations in the morning and evening averaged around 21 ppm, while afternoon values were slightly lower at approximately 20 ppm. Despite the relatively small numerical differences, the statistical variation suggests that ammonia levels were subject to subtle but significant diurnal fluctuations, with a slight dip during the afternoon period.

4.3. Discussion

In the current study, significant diurnal fluctuations were observed in all gases measured (p < 0.001). C O 2 concentrations peaked in the afternoon, followed by evening and morning periods, reflecting increased metabolic activity or ventilation during warmer hours. Ammonia levels were highest in the morning and evening, with a slight decrease in the afternoon, indicating subtle shifts in microbial activity or ventilation dynamics. Methane emissions exhibited a similar pattern, peaking in the morning, declining in the afternoon, and rising again in the evening. These findings highlight the importance of the time of day in evaluating gaseous emissions from poultry housing and suggest potential windows for targeted mitigation strategies to reduce environmental impact.
C O 2 concentrations showed a significant diurnal trend, peaking in the afternoon, followed by the evening, and reaching their lowest levels in the morning. These observations are consistent with those reported by Huang and Guo [4], who examined gas emissions from commercial broiler and layer barns and found a similar increase in C O 2 levels during the daytime, especially in the afternoon. This trend is typically attributed to increased bird activity and ambient temperature, which raise the metabolic rate and, subsequently, the respiratory C O 2 output. Additionally, Kilic and Yaslioglu [19] documented elevated C O 2 levels during warmer periods of the day in Turkish layer houses, further confirming the correlation between environmental conditions and gas accumulation.
A possible explanation for the peak C O 2 concentrations in the afternoon is the reduced ventilation efficiency during the hottest hours of the day. Poultry houses often experience altered ventilation cycles to limit heat stress on birds during peak heat periods, which inadvertently slows the removal of metabolically produced C O 2 [5]. C O 2 can also be produced due to the breakdown of the organic matter and manure in the floor pens, due to the microbial decomposition and combustion of fuels that are used, like propane or natural gas, in heaters to maintain heat in the houses for birds.
Ni et al. [18] highlighted that ventilation management significantly influences gas accumulation, particularly in manure-belt systems. If air exchange rates are not adequately adjusted during high metabolic periods, C O 2 may build up quickly, especially when combined with limited diffusion due to stagnant air layers and higher stocking densities [3,15,17,24]. Furthermore, higher ambient temperatures in the afternoon can increase the birds’ respiration rates due to thermal stress. As birds pant to regulate their body temperature, they exhale more C O 2 , further contributing to elevated indoor concentrations. This biological response, combined with suboptimal ventilation during the hottest periods, creates a compounding effect, leading to the afternoon peak. By evening, although ambient temperatures may decline, residual C O 2 may remain trapped in the house due to inertia in air exchange and the accumulation from the prior period of increased production [3,14,15]. These findings suggest that optimizing ventilation rates based on bird activity and temperature fluctuations could help mitigate C O 2 buildup and improve air quality in poultry houses.
N H 3 levels in the current study followed a distinct diurnal pattern, with the highest concentrations occurring in the morning and evening, and significantly lower values observed in the afternoon. This pattern is consistent with the findings of Liu et al. [20], who reported that ammonia emissions in North China layer systems were influenced by both the ventilation pattern and time of day. Their findings showed that morning and late-day emissions were elevated, likely due to manure accumulation and reduced ventilation rates. Similarly, Ni et al. [18] emphasized that N H 3 emissions are highly dependent on-air exchange rates, manure characteristics, and the degree of microbial degradation occurring on the manure surface.
The elevated N H 3 levels observed in the morning could be attributed to overnight accumulation when ventilation is generally minimized to conserve heat or energy. During this time, ammonia generated from the microbial decomposition of uric acid in manure volatilizes and builds up within the enclosed space. Kilic and Yaslioglu [19] also observed that morning ammonia levels often reflect the residual concentration from the night when gas dispersion was limited. As temperatures rise and ventilation increases in the afternoon, ammonia concentrations typically drop due to the enhanced gas exchange and drying of the litter surface, which reduces microbial activity and ammonia release [15,16]. In the evening, as ventilation slows again and manure begins to rehydrate slightly due to moisture cycling and reduced airflow, ammonia emissions increase. The presence of moisture is a key factor in ammonia volatilization, as the hydrolysis of uric acid is enhanced under moist conditions. Ni et al. [18] confirmed that increased humidity and temperature synergistically elevate N H 3 release from manure. Therefore, the evening spike in N H 3 observed in the present study likely reflects a combination of declining ventilation efficiency and the reactivation of microbial processes. These patterns highlight the importance of maintaining consistent ventilation strategies, especially during transitional times such as dawn and dusk, to minimize ammonia accumulation and ensure better air quality for both birds and workers.
C H 4 emissions in this study followed a clear diurnal rhythm, with the highest levels detected in the morning, followed by the evening, and the lowest values observed in the afternoon. This pattern is in agreement with the findings of Huang and Guo [4], who reported similar C H 4 fluctuations in commercial broiler and layer barns. Methane in poultry houses is primarily produced via the anaerobic microbial fermentation of organic matter in manure. The observed increase in C H 4 during the early hours of the day may be explained by the accumulation of emissions overnight, when microbial activity continues but ventilation is reduced or inactive, allowing methane to concentrate within the housing environment [3,14,15]. In the afternoon, methane levels dropped significantly, which could be due to both improved ventilation and the drying effect of elevated ambient temperatures. According to Ni et al. [18], higher airflow rates reduce anaerobic zones on the manure surface and disperse built-up gases more efficiently. Additionally, the heat and air movement may lead to the crusting or drying of the manure, which impairs the anaerobic conditions necessary for methanogenic microbial populations to thrive. This natural inhibition of methanogenesis during the warmer and more ventilated parts of the day leads to a measurable reduction in C H 4 emissions.
Evening concentrations of methane rose again, though not as high as the morning peak. This secondary increase may be associated with the transition to cooler temperatures and a corresponding decrease in ventilation rates. As airflow slows and manure surface moisture returns via condensation or humidity cycling, anaerobic microenvironments can re-establish, permitting renewed methane production [16,17]. This finding is consistent with that of Liu et al. [20], who noted that even minor changes in manure moisture and air movement could significantly influence microbial gas emissions. Overall, the observed diurnal patterns of C H 4 suggest that effective manure management and stable ventilation control are crucial in minimizing methane accumulation and its environmental impact.

5. Conclusions

This paper presented an end-to-end architecture—from sensor-level data acquisition to web-based visualization and prediction—offering a low-cost, scalable, and intelligent environmental monitoring system. The developed system allows poultry farmers to maintain ideal air conditions, reduce bird health hazards, and increase productivity through data-driven decision-making. The system accurately measures crucial gas concentrations, of C O 2 , C H 4 , and N H 3 , utilizing a Raspberry Pi SBC and MQ-135 gas sensors. Real-time data transfer to the ThingSpeak cloud-based platform and visualization using an interactive, design-oriented web dashboard keeps farm operators informed continuously about prevailing air quality trends.
This study demonstrated clear diurnal variations in gaseous emissions from laying hens housed under standardized conditions. Carbon dioxide concentrations peaked during the afternoon, likely due to higher metabolic rates and ambient temperatures, while ammonia and methane emissions were highest in the morning and evening, reflecting complex interactions between bird activity, microbial processes, and ventilation patterns. The significant temporal fluctuations observed for all gases emphasize the need to consider the time of day when monitoring emissions to obtain accurate and representative data. Understanding these patterns is crucial for developing effective environmental management practices in poultry production. Based on the observed diurnal emission trends, it is recommended that poultry housing ventilation and environmental control systems be optimized to target peak emission periods, particularly during the afternoon for C O 2 and during the morning and evening for N H 3 and C H 4 .
To analyze emission patterns, we applied one-way ANOVA using the GLM procedure in SAS with time of day as a fixed effect. Significant differences (p < 0.05) were detected and separated using Duncan’s test. Results are presented as means ± SEM. We also trained a regression model for next-day gas prediction. Model performance was evaluated using MSE, RMSE, and MAE, with strong results (e.g., MSE = 35.2, R2 = 0.87), indicating high accuracy without overfitting.
Future research should explore mitigation strategies such as enhanced ventilation timing, dietary adjustments, and manure management tailored to these critical periods to reduce gaseous emissions and improve air quality. Further data processing on the network edge and communication protocol optimization are needed to support wide-scale deployment across several poultry farms with multi-barn management features and load-balanced cloud infrastructure using multi-node deployments and employing seasonal studies. We also plan to integrate more sophisticated ML models, such as Gated Recurrent Unit (GRU) networks, SVR, and ARIMA models, to improve accuracy in forecasting gas concentration and detecting anomalies or sensor failure. Cross-validation to assess the ML model’s generalizability and the sensitivity testing of input feature variations on output accuracy are some other directions we will investigate in the future. We are currently working on utilizing automated sensor diagnostic features to detect sensor degradation or failure online, with the provision of data integrity and facilitated proactive maintenance. Finally, we plan to expand the sensor array to include the detection of other such important gases like Hydrogen Sulfide ( H 2 S ), Carbon Monoxide (CO), and Volatile Organic Compounds (VOCs) to achieve an even more holistic view of poultry barn air.

Author Contributions

Conceptualization, S.B. and A.A.A.; methodology, S.B.; formal analysis, S.B., A.A.A.A.-W., and J.L.; investigation, S.B., A.A.A., and A.A.A.A.-W.; resources, A.A.A. and J.L.; data curation, A.A.A.A.-W. and A.A.A.; writing—original draft preparation, S.B., A.A.A., and A.A.A.A.-W.; writing—review and editing, A.A.A. and A.A.A.A.-W.; visualization, A.A.A.; supervision, A.A.A. and A.A.A.A.-W.; project administration, J.L.; funding acquisition, A.A.A. All authors have read and agreed to the published version of the manuscript.

Funding

The National Science Foundation (NSF) partly supported this research work under grants #2011330, 2200377, and 2302469. Also, funding received from the USDA-NIFA-Evans Allen grant with Accession Number #7004964 and other USDA-NIFA grants (#2023-38821-39977, #2023-51300-40853) to Lohakare is gratefully acknowledged.

Institutional Review Board Statement

All experimental procedures were conducted in compliance with the Animal Welfare Act (AWA) and Animal Welfare Regulations (AWRs) as stipulated by the United States Department of Agriculture (USDA), as well as the Guide for the Care and Use of Laboratory Animals. Approval was obtained from the Institutional Animal Care and Use Committee (IACUC) of PVAMU under protocol number AUP# 2023-055 for layer studies.

Informed Consent Statement

Not applicable.

Data Availability Statement

The raw data supporting the conclusions of this article will be made available by the authors on request.

Conflicts of Interest

The authors declare no conflicts of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

References

  1. Bist, R.B.; Subedi, S.; Chai, L.; Yang, X. Ammonia emissions, impacts, and mitigation strategies for poultry production: A critical review. J. Environ. Manag. 2023, 328, 116919. [Google Scholar] [CrossRef]
  2. Ahmed, M.M.; Hassanien, E.E.; Hassanien, A.E. A smart IoT-based monitoring system in poultry farms using chicken behavioural analysis. Internet Things 2024, 25, 101010. [Google Scholar] [CrossRef]
  3. Xin, H.; Gates, R.; Green, A.; Mitloehner, F.; Moore, P.; Wathes, C. Environmental impacts and sustainability of egg production systems1. Poult. Sci. 2011, 90, 263–277. [Google Scholar] [CrossRef]
  4. Huang, D.; Guo, H. Diurnal and seasonal variations of greenhouse gas emissions from a commercial broiler barn and cage-layer barn in the Canadian Prairies. Environ. Pollut. 2019, 248, 726–735. [Google Scholar] [CrossRef]
  5. Shahab, H.; Iqbal, M.; Sohaib, A.; Ullah Khan, F.; Waqas, M. IoT-based agriculture management techniques for sustainable farming: A comprehensive review. Comput. Electron. Agric. 2024, 220, 108851. [Google Scholar] [CrossRef]
  6. Abdelmoamen, A. A Modular Approach to Programming Multi-Modal Sensing Applications. In Proceedings of the IEEE International Conference on Cognitive Computing, San Francisco, CA, USA, 2–7 July 2018; ICCC ’18. pp. 91–98. [Google Scholar]
  7. Narayana, T.L.; Venkatesh, C.; Kiran, A.; J, C.B.; Kumar, A.; Khan, S.B.; Almusharraf, A.; Quasim, M.T. Advances in real time smart monitoring of environmental parameters using IoT and sensors. Heliyon 2024, 10, e28195. [Google Scholar] [CrossRef]
  8. Caselles Nuñez, J.G.; Contreras Negrette, O.A.; de Jesús Beleño Sáenz, K.; Díaz Sáenz, C.G. Design and Implementation of an Indoor and Outdoor Air Quality Measurement Device for the Detection and Monitoring of Gases with Hazardous Health Effects. Eng. Proc. 2025, 83, 3013. [Google Scholar] [CrossRef]
  9. Ahmed, A.A.; Omari, S.A.; Awal, R.; Fares, A.; Chouikha, M. A Distributed System for Supporting Smart Irrigation using IoT Technology. Eng. Rep. 2020, 3, 1–13. [Google Scholar] [CrossRef]
  10. Symeonaki, E.; Maraveas, C.; Arvanitis, K.G. Recent Advances in Digital Twins for Agriculture 5.0: Applications and Open Issues in Livestock Production Systems. Appl. Sci. 2024, 14, 686. [Google Scholar] [CrossRef]
  11. Inadagbo, O.; Makowski, G.; Ahmed, A.A.; Daigle, C. On Developing a Machine Learning-Based Approach for the Automatic Characterization of Behavioral Phenotypes for Dairy Cows Relevant to Thermotolerance. AgriEngineering 2024, 6, 2656–2677. [Google Scholar] [CrossRef]
  12. Singh, K.; Yadav, M.; Barak, D.; Bansal, S.; Moreira, F. Machine-Learning-Based Frameworks for Reliable and Sustainable Crop Forecasting. Sustainability 2025, 17, 4711. [Google Scholar] [CrossRef]
  13. Ahmed, A.A.; Reddy, G.H. A Mobile-Based System for Detecting Plant Leaf Diseases Using Deep Learning. AgriEngineering 2021, 3, 478–493. [Google Scholar] [CrossRef]
  14. Lin, X.J.; Cortus, E.; Zhang, R.; Jiang, S.; Heber, A. Ammonia, hydrogen sulfide, carbon dioxide and particulate matter emissions from California high-rise layer houses. Atmos. Environ. 2012, 46, 81–91. [Google Scholar] [CrossRef]
  15. Liang, Y.; Xin, H.; Wheeler, E.; Gates, R.; Li, H.; Zajaczkowski, J.; Topper, P.; Casey, K.; Behrends, B.; Burnham, D.; et al. Ammonia emissions from U.S. Laying hen houses in Iowa and Pennsylvania. Trans. Asae. Am. Soc. Agric. Eng. 2005, 48, 1927–1941. [Google Scholar] [CrossRef]
  16. Backes, A.M.; Aulinger, A.; Bieser, J.; Matthias, V.; Quante, M. Ammonia emissions in Europe, part II: How ammonia emission abatement strategies affect secondary aerosols. Atmos. Environ. 2016, 126, 153–161. [Google Scholar] [CrossRef]
  17. Zhu, Z.; Dong, H.; Zhou, Z.; Xin, H.; Chen, Y. Ammonia and Greenhouse Gases Concentrations and Emissions of a Naturally Ventilated Laying Hen House in Northeast China. Trans. ASABE 2011, 54, 1085–1091. [Google Scholar] [CrossRef]
  18. Ni, J.Q.; Diehl, C.A.; Chai, L.; Chen, Y.; Heber, A.J.; Lim, T.T.; Bogan, B.W. Factors and characteristics of ammonia, hydrogen sulfide, carbon dioxide, and particulate matter emissions from two manure-belt layer hen houses. Atmos. Environ. 2017, 156, 113–124. [Google Scholar] [CrossRef]
  19. Kilic Ilker, Y.E. Ammonia and Carbon Dioxide Concentrations in a Layer House. Asian-Australas. J. Anim. Sci. 2014, 27, 1211–1218. [Google Scholar] [CrossRef] [PubMed]
  20. Liu, Y.; Zhang, G.; Rong, L.; Li, Z.; Wang, S.; Wang, C. Concentrations and Emissions of Ammonia from Different Laying Hen Production Systems of Conventional Cage, Aviary and Natural Mating Colony Cage in North China Plain. Appl. Sci. 2020, 10, 6820. [Google Scholar] [CrossRef]
  21. Comito, C.; Pizzuti, C. Artificial intelligence for forecasting and diagnosing COVID-19 pandemic: A focused review. Artif. Intell. Med. 2022, 128, 102286. [Google Scholar] [CrossRef]
  22. Sun, Y.; Liu, J. AQI Prediction Based on CEEMDAN-ARMA-LSTM. Sustainability 2022, 14, 12182. [Google Scholar] [CrossRef]
  23. Seo, H.J.; Seo, I.H.; Oh, B.W. Managemental Impacts on Particulate Matter Emission in Tunnel-Ventilated Broiler Houses. Agriculture 2024, 14, 204. [Google Scholar] [CrossRef]
  24. Yamaji, K.; Ohara, T.; Akimoto, H. Regional-specific emission inventory for NH3, N2O, and CH4 via animal farming in South, Southeast, and East Asia. Atmos. Environ. 2004, 38, 7111–7121. [Google Scholar] [CrossRef]
Figure 1. System architecture.
Figure 1. System architecture.
Agriengineering 07 00267 g001
Figure 2. Experiment Setup at the Poultry Center in Prairie View A&M University. (a) Physical IoT Sensing Unit. (b) Wireless WiFi Adapter. (c) Screen Monitor attached to the Sensing Unit. (d) Snapshot of the pen that hosts the laying hens.
Figure 2. Experiment Setup at the Poultry Center in Prairie View A&M University. (a) Physical IoT Sensing Unit. (b) Wireless WiFi Adapter. (c) Screen Monitor attached to the Sensing Unit. (d) Snapshot of the pen that hosts the laying hens.
Agriengineering 07 00267 g002
Figure 3. The Hardware Design of the IoT-based System for measuring Diurnal Gas Emissions in the poultry farm. (a) Snapshot of the touchscreen monitor attached to the Sensing Unit (i.e., Raspberry PI, MQ-135 sensor, ADC Analog-to-Digital Converter Module, and Jumper Wires). (b) Snapshot of the laptop connected to the sensing unit and monitor. (c) Snapshot of the sensing unit showing detailed connections. (d) Snapshot of the GUI displayed on the laptop.
Figure 3. The Hardware Design of the IoT-based System for measuring Diurnal Gas Emissions in the poultry farm. (a) Snapshot of the touchscreen monitor attached to the Sensing Unit (i.e., Raspberry PI, MQ-135 sensor, ADC Analog-to-Digital Converter Module, and Jumper Wires). (b) Snapshot of the laptop connected to the sensing unit and monitor. (c) Snapshot of the sensing unit showing detailed connections. (d) Snapshot of the GUI displayed on the laptop.
Agriengineering 07 00267 g003
Figure 4. A screenshot of the ThingSpeak dashboard showing the real-time sensor stream of the C O 2 , C H 4 , and N H 3 gas concentrations.
Figure 4. A screenshot of the ThingSpeak dashboard showing the real-time sensor stream of the C O 2 , C H 4 , and N H 3 gas concentrations.
Agriengineering 07 00267 g004
Figure 5. A screenshot of the C O 2 gas levels page at ThingSpeak.
Figure 5. A screenshot of the C O 2 gas levels page at ThingSpeak.
Agriengineering 07 00267 g005
Figure 6. A screenshot of the web-based GUI dashboard.
Figure 6. A screenshot of the web-based GUI dashboard.
Agriengineering 07 00267 g006
Figure 7. The next-day prediction of gas emissions using the ML model.
Figure 7. The next-day prediction of gas emissions using the ML model.
Agriengineering 07 00267 g007
Figure 8. The training and validation loss of the ML model.
Figure 8. The training and validation loss of the ML model.
Agriengineering 07 00267 g008
Figure 9. The evaluation metrics ( M A E , R M S E and R 2 scores) for gas estimation prediction.
Figure 9. The evaluation metrics ( M A E , R M S E and R 2 scores) for gas estimation prediction.
Agriengineering 07 00267 g009
Figure 10. The actual vs. predicted gas emission levels.
Figure 10. The actual vs. predicted gas emission levels.
Agriengineering 07 00267 g010
Figure 11. Concentrations of gas emissions measured at three time points during the day. Statistical significance is indicated by p < 0.001 with different letters (a,b,c).
Figure 11. Concentrations of gas emissions measured at three time points during the day. Statistical significance is indicated by p < 0.001 with different letters (a,b,c).
Agriengineering 07 00267 g011
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

Bhattad, S.; Ahmed, A.A.; Abdel-Wareth, A.A.A.; Lohakare, J. An IoT-Based System for Measuring Diurnal Gas Emissions of Laying Hens in Smart Poultry Farms. AgriEngineering 2025, 7, 267. https://doi.org/10.3390/agriengineering7080267

AMA Style

Bhattad S, Ahmed AA, Abdel-Wareth AAA, Lohakare J. An IoT-Based System for Measuring Diurnal Gas Emissions of Laying Hens in Smart Poultry Farms. AgriEngineering. 2025; 7(8):267. https://doi.org/10.3390/agriengineering7080267

Chicago/Turabian Style

Bhattad, Sejal, Ahmed Abdelmoamen Ahmed, Ahmed A. A. Abdel-Wareth, and Jayant Lohakare. 2025. "An IoT-Based System for Measuring Diurnal Gas Emissions of Laying Hens in Smart Poultry Farms" AgriEngineering 7, no. 8: 267. https://doi.org/10.3390/agriengineering7080267

APA Style

Bhattad, S., Ahmed, A. A., Abdel-Wareth, A. A. A., & Lohakare, J. (2025). An IoT-Based System for Measuring Diurnal Gas Emissions of Laying Hens in Smart Poultry Farms. AgriEngineering, 7(8), 267. https://doi.org/10.3390/agriengineering7080267

Article Metrics

Back to TopTop