GJ_Poultry is an open-source IoT-based poultry monitoring system designed to track and visualize key environmental parameters in a chicken coop.
It integrates low-cost sensors (temperature, humidity, gas, and camera modules) with a microcontroller and web app to continuously collect and analyze data.
By maintaining optimal coop conditions, the system helps:
- Reduce mortality and growth delays
- Improve feed efficiency
- Enable data-driven farm management
The project aligns with precision livestock farming principles β leveraging IoT, control systems, and physics-based modeling to enhance animal welfare and productivity.
| Component | Description | Function |
|---|---|---|
| ESP8266/NodeMCU | 32-bit Wi-Fi-enabled microcontroller | Main controller; collects and transmits data |
| DHT22 | Digital Temperature & Humidity Sensor | Measures ambient conditions |
| MQ-135 | Gas Sensor | Detects NHβ, COβ, and air pollutants |
| DS18B20 | Waterproof Temperature Probe | Measures localized/ground temperature |
| ESP32-CAM | Optional Camera Module | Captures coop visuals |
| Buzzer/LEDs | Output indicators | Alerts for abnormal conditions |
| Power Supply (5 V) | β | Feeds system components |
Typical wiring setup: DHT22 β Digital pin 3 MQ135 β A0 DS18B20 β Digital pin 2 Buzzer β Digital pin 4 Wi-Fi β ESP8266 built-in
The firmware is written in Arduino (C/C++).
- Install Arduino IDE and libraries:
Adafruit DHTOneWireDallasTemperature
- Configure pins & Wi-Fi credentials in
GJ_Poultry.ino. - Upload code to ESP8266 or ESP32 board.
- Monitor serial output (baud rate:
115200).
#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define DHTPIN 3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature ds18(&oneWire);
const int MQ135_PIN = A0;
void setup() {
Serial.begin(115200);
dht.begin();
ds18.begin();
}
void loop() {
float humidity = dht.readHumidity();
float temp1 = dht.readTemperature();
ds18.requestTemperatures();
float temp2 = ds18.getTempCByIndex(0);
int mqRaw = analogRead(MQ135_PIN);
float co2ppm = (mqRaw - 33.0) * (1000.0 / (4095.0 - 33.0));
Serial.printf("Temp1=%.2fC Temp2=%.2fC Humidity=%.1f%% CO2=%.1fppm\n",
temp1, temp2, humidity, co2ppm);
delay(5000);
}Web Dashboard Options:
- Blynk IoT App
- Add widgets for gauges and plots.
- Link virtual pins to ESP8266. -View real-time updates on mobile.
Run locally:
$ pip install -r requirements.txt
$ python server.py
# or
$ npm install && npm start
Visit: http://localhost:5000
-Real-time sensor charts -Alerts for threshold breaches -CSV data export
Dashboard with adjustable time ranges
Collected data are stored in /src/data.csv as:
timestamp,temperature_C,humidity_%,co2_ppm
2025-11-01 06:00:00,24.2,45.7,350
2025-11-01 06:05:00,24.5,46.0,355
2025-11-01 06:10:00,24.3,45.5,348
Data Fields
Column Unit Description
timestamp ISO time Reading time
temperature_C Β°C DHT22 / DS18B20 temperature
humidity_% %RH Ambient humidity
co2_ppm ppm MQ-135 gas reading- Time-Series Graphs: Temperature, humidity, and gas concentration over time.
- Threshold Bands: Safe/unsafe zones highlighted on charts.
- Historical Comparison: Weekly or daily parameter trends.
- KPI Overlay: Mortality, productivity, and feed efficiency vs. environment.
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('data.csv', parse_dates=['timestamp'])
plt.plot(data['timestamp'], data['temperature_C'], label='Temp (Β°C)')
plt.plot(data['timestamp'], data['humidity_%'], label='Humidity (%)')
plt.xlabel('Time'); plt.ylabel('Value')
plt.legend(); plt.show()| Metric | Formula | Description |
|---|---|---|
| Environmental Compliance | % of time within safe range | Stability indicator |
| COβ/NHβ Levels | Average and peak ppm | Air quality indicator |
| Mortality Rate (CMR) | CMR = (D / N) Γ 100% |
Health performance |
| Egg Production Rate (EPR) | EPR = E / C |
Productivity |
| Sensor Uptime | Logged readings / total attempts | Data integrity |
| Energy Efficiency | Energy / Airflow | HVAC efficiency |
π― Target:
Maintain >95% uptime, COβ < 1000 ppm, and temperature between 18β24 Β°C for optimal flock health.
This system contributes to smart poultry research by:
- Demonstrating IoT integration with real-time environmental feedback
- Applying open-source, low-cost hardware for small farms
- Supporting data analytics for mortality reduction and performance optimization
Supporting Studies:
- Syafar et al. β IoT-based poultry coop monitoring with DHT22 and MQ-135
- Phiri et al. β Arduino-ZigBee-GSM smart farming model
- Liu et al., 2024 β Integrated environmental & performance dashboards for smart poultry houses
Maintaining coop temperature uses the convective heat transfer equation:
Q = m_dot * c_p * ΞT
Where:
m_dot = mass flow rate of air (kg/s)
c_p = specific heat capacity of air (kJ/kgΒ·K)
ΞT = temperature difference (Β°C)
π¨ Gas Law Relation For MQ-135 readings, gas concentration depends on the ideal gas law:
p * V = n * R * T
Where:
p = pressure (Pa)
V = volume (mΒ³)
n = number of moles
R = universal gas constant (8.314 J/molΒ·K)
T = temperature (K)
π§ Humidity Sensing The DHT22 measures relative humidity (RH) using a capacitive sensor:
C = Ξ΅ * A / d
Where:
C = capacitance (F)
Ξ΅ = permittivity of the dielectric
A = area of the capacitor plates
d = distance between plates
π‘οΈ Comfort Index (Enthalpy Approximation)
h = 1.006*T + RH * (2501 + 1.86*T)
Where:
T = temperature in Β°C
RH = relative humidity (fraction)
h = enthalpy (kJ/kg)
π Production Equations
Copy code
# Mortality Rate
CMR = (D / N) * 100 # D = number of deaths, N = initial population
# Egg Production Rate
EPR = E / C # E = eggs produced, C = number of chickensData Flow:
Arduino β CSV β Web App β Visualization
Sensors β ESP8266 via GPIO/ADC
Data β Logged as data.csv
Web App β Displays charts (real-time & historical)
Analysis β Performed using Python/Pandas
- Improved environmental control via sensor feedback
- Enhanced animal welfare
- Scalable and reproducible open-source design
- Potential to reduce mortality by 10β15% through environmental optimization
- Syafar et al. β IoT-based poultry coop monitoring with DHT22 and MQ-135
- Phiri et al. β Arduino-ZigBee-GSM smart farming model
- Liu et al., 2024 β Integrated environmental & performance dashboards for smart poultry houses
- Integrate PID-based temperature control (using fans/heaters)
- Add cloud synchronization (Firebase/MQTT)
- Implement predictive analytics using Machine Learning models
This project is released under the MIT License.
Feel free to use, modify, and extend it for research and educational purposes.