IoT-Based Poultry Farm Monitoring System Using ESP8266 and KiwisIoT
by ananthi rk in Circuits > Sensors
11 Views, 0 Favorites, 0 Comments
IoT-Based Poultry Farm Monitoring System Using ESP8266 and KiwisIoT
- Poultry farming is an important part of modern agriculture. Maintaining suitable environmental conditions inside a poultry farm is essential for bird comfort, farm management, and day-to-day monitoring.
- Temperature, humidity, lighting, movement, and air conditions are important parameters to observe. Checking these conditions manually can be time-consuming, especially when continuous monitoring is required.
- This project presents an IoT-Based Poultry Farm Monitoring System using a NodeMCU ESP8266, four sensors, and the KiwisIoT platform.
- The system collects temperature and humidity readings using a DHT11 sensor, detects movement using a PIR sensor, reads the output of an MQ-2 gas and smoke sensor, and identifies bright or dark conditions using an LDR module.
- The ESP8266 connects to Wi-Fi and transmits sensor data to a KiwisIoT dashboard. Users can view the incoming readings through a connected device without needing to read every sensor directly.
- This project demonstrates how IoT technology can be used to build a basic remote environmental monitoring system for poultry farms.
Supplies
Hardware Components
- NodeMCU ESP8266 development board
- DHT11 temperature and humidity sensor
- HC-SR501 PIR motion sensor
- MQ-2 gas and smoke sensor module
- LDR light sensor module with digital output
- Jumper wires
- USB cable
- Suitable power supply
- Computer or laptop
- Wi-Fi connection
Software Requirements
- Arduino IDE
- ESP8266 board package
- DHT sensor library
- Adafruit Unified Sensor library, if required
- KiwisIoT Arduino library
- KiwisIoT account
- Web browser for dashboard access
Circuit Connections
Connect the sensors to the NodeMCU ESP8266 according to the following pin mapping.
DHT11
PIR Motion Sensor
MQ-2 Gas Sensor
LDR Digital Module
Connect all sensor grounds to a common GND.
Important electrical safety: MQ-2 modules may require 5V and may produce an analog output that exceeds the ESP8266 analog input limit. Verify the exact NodeMCU board's A0 range and the module's output voltage before connecting them. Use a suitable voltage divider or signal-conditioning circuit where required. Never apply an unsafe voltage to an ESP8266 input.
Arduino IDE Installation
Step 1: Install Arduino IDE
Download and install Arduino IDE on your computer.
Step 2: Install the ESP8266 Board Package
Open Arduino IDE and navigate to Boards Manager. Search for the ESP8266 platform and install it if it is not already installed.
Step 3: Select the Board
Connect the NodeMCU through USB.
Select the appropriate NodeMCU ESP8266 board and the COM port corresponding to your device.
Step 4: Install Sensor Libraries
Open Library Manager and install the DHT sensor library. Install Adafruit Unified Sensor if the selected DHT library requires it.
Step 5: Install the KiwisIoT Library
Install the appropriate KiwisIoT library and use the example supplied with that version to confirm its connection and data-sending functions.
Step 6: Configure the Program
Enter the Wi-Fi credentials and the actual KiwisIoT dashboard topic ID in the Arduino program.
Check that the pin definitions match the physical circuit.
Step 7: Compile and Upload
Click Verify to compile the code. If there are no errors, click Upload to flash the program to the NodeMCU.
Open Serial Monitor and select 115200 baud to observe the output.
KiwisIoT Platform Setup
KiwisIoT provides a dashboard interface for organizing panels, adding widgets, connecting hardware, and monitoring incoming sensor data.
Official links:
- Getting Started: https://www.kiwisiot.in/get-started
- Tutorials: https://www.kiwisiot.in/tutorial
- Help Center: https://www.kiwisiot.in/help-center
Step 1: Create an Account
Open the KiwisIoT website in your browser. https://www.kiwisiot.in/login
Create an account if you do not already have one. Complete any verification step required by the platform and sign in.
Step 2: Open My Panels
After signing in, navigate to the My Panels section.
Panels are workspaces where sensor widgets can be organized and connected to the relevant data source.
Step 3: Create a New Panel
Choose the option to create a panel or dashboard.
Enter the panel name: Poultry Farm Monitoring Dashboard
Step 4: Obtain the Panel Topic ID
- Open the created panel and locate its topic ID or connection information.
- The project code uses a topic in this general format:
- dash_XXXXXXXXXXXXX
- Copy the actual topic ID shown by your panel and replace the placeholder in the Arduino code.
- Do not use the sample topic as your real connection ID.
Step 5: Add Widgets
- Add the widgets supported by your KiwisIoT dashboard. Suggested widget types include gauges, numeric displays, charts, and status displays.
- Choose widgets according to the type of data being sent.
Step 6: Configure Data Sources
For each widget, choose the relevant panel or device data source. Set the appropriate channel or field mapping if the dashboard asks for it.
Save the configuration.
Step 7: Connect the ESP8266
- Configure the ESP8266 program with the same topic ID.
- The device must connect through the KiwisIoT library and protocol supported by the installed setup. Confirm that the platform receives the data before changing the widget layout.
Step 8: Verify the Dashboard
- Power on the device and wait for sensor readings to arrive.
- Compare the values displayed on the dashboard with those printed in the Arduino Serial Monitor.
- If the device sends readings but the dashboard remains empty, check the topic ID, connection status, widget data source, and channel mapping.
Dashboard Data Mapping
The Arduino program uses the following channel mapping.
The example readings are illustrative, not measured values from a particular poultry farm.
Recommended Widget Configuration
Temperature: Use a numeric value widget or gauge. Display the unit as °C.
Humidity: Use a numeric value widget or gauge. Display the unit as %.
Motion Status: Use a status or text widget that supports the values sent by the program.
Gas Sensor: Use a numeric widget or gauge to show the raw sensor reading. Do not label the raw reading as ppm unless a calibrated measurement system provides that unit.
Light Status: Use a status or text widget that displays Bright or Dark.
The exact widget names and data configuration fields may vary with the current platform interface.
Arduino Code
How the Arduino Program Works
The program performs the following operations.
Initialization
The ESP8266 starts Serial communication, initializes the DHT11 sensor, configures the PIR and LDR pins, and initializes the KiwisIoT library.
Sensor Reading
At each scheduled update, the program reads temperature, humidity, motion status, gas sensor output, and light status.
Data Validation
The DHT11 values are checked to ensure the reading is valid before sending the temperature and humidity.
Status Conversion
The PIR digital value is converted to a readable status:
- HIGH becomes Detected.
- LOW becomes No Detection.
The LDR digital value is converted to Bright or Dark according to the assumed module logic.
Data Transmission
The program sends each reading using the corresponding channel ID and KiwisIoT library method.
Repeated Updates
The program uses a five-second interval to schedule sensor readings and updates. This is the intended sampling interval; actual dashboard arrival times can vary with network and platform latency.
Testing Procedure
Test 1: Temperature Monitoring
- Place the DHT11 in the test environment and power on the NodeMCU.
- Observe the temperature value in the Serial Monitor. Confirm that the dashboard displays the corresponding value.
Test 2: Humidity Monitoring
Check the relative humidity reading and compare it with the dashboard display.
Test 3: Motion Detection
- Move within the PIR sensor's detection area.
- Confirm that the program displays Detected when movement is detected and No Detection when its output returns LOW.
- Allow sufficient time for PIR initialization after power-up.
Test 4: Gas Sensor Reading
- Allow the MQ-2 module to warm up according to its specifications.
- Observe the raw reading under normal conditions and compare it with the value received by the dashboard.
- Do not deliberately release hazardous gas or smoke for testing. This project is not a certified gas-safety detector.
Test 5: Light Detection
- Expose the LDR module to bright light and then cover it.
- Check whether the status changes between Bright and Dark. If the labels are reversed, update the program to match the module's actual output.
Test 6: IoT Dashboard
- Keep the ESP8266 connected to Wi-Fi.
- Confirm that all five channel values appear in their respective dashboard widgets. Check the Serial Monitor and dashboard side by side if a value is missing.
13. Sample Output
Example Serial Monitor output:
The values shown above are examples. Actual readings depend on the environment, sensor calibration, module behavior, and installation.
Dashboard
Dashboard Interpretation
The dashboard helps the user observe five categories of information.
- Temperature provides a reading of the surrounding air temperature.
- Humidity indicates the relative moisture level in the air.
- Motion Status indicates whether the PIR sensor currently reports movement.
- Gas Sensor Value displays the MQ-2 raw analog reading.
- Light Status indicates whether the LDR module classifies the surroundings as bright or dark.
GitHub Repository
The complete source code for this KiwisIoT project is available on GitHub. You can access the code, review the sensor connections, and modify it according to your project requirements.
GitHub Source Code: https://github.com/Kiwistron/KiwisIoT-Projects
Troubleshooting
Problem: Dashboard Values Are Missing
Check the Wi-Fi connection, topic ID, library configuration, and widget data source. Confirm that the device is transmitting readings using the method supported by the installed KiwisIoT library.
Problem: Temperature or Humidity Shows an Error
Check the DHT11 wiring, DATA pin, library installation, and sensor type definition.
Problem: Motion Is Always Detected
Allow the PIR sensor to initialize. Check the OUT pin, power supply, sensitivity, and delay settings.
Problem: Bright and Dark Are Reversed
Test the LDR module and reverse the label mapping if its digital output behaves differently from the program's assumption.
Problem: MQ-2 Reading Is Unstable
Check the sensor supply, warm-up period, grounding, and analog input voltage. Do not treat raw readings as calibrated gas concentrations.
Problem: Arduino Code Does Not Compile
Verify the ESP8266 board selection and library installation. If a KiwisIoT function differs from the code, compare it with the example supplied by the installed library version.
Applications
- Poultry farm environmental monitoring
- Temperature and humidity observation
- Motion monitoring
- Gas and smoke sensor observation
- Light condition monitoring
- Smart agriculture prototypes
- Educational IoT projects
- Embedded systems experimentation
Conclusion
- The ESP8266 Poultry Farm IoT Monitoring System demonstrates how multiple sensors can be combined with a Wi-Fi-enabled microcontroller and the KiwisIoT platform.
- The system monitors temperature, humidity, motion, gas-sensor output, and light status, then presents the readings through an IoT dashboard.
- This project provides a foundation for learning connected sensor systems and developing more advanced agricultural monitoring solutions.