A comprehensive IoT-powered agriculture monitoring and plant health prediction system. This project integrates ESP32-based hardware sensors, a Python Flask web server, and a modern web interface to provide real-time environmental data and AI-driven plant disease classification.
- Overview
- Features
- Hardware Components
- Software Components
- Installation & Setup
- Usage
- Directory Structure
- API Endpoints
- License
- Mobile App Availability
This project enables smart agriculture by:
- Collecting real-time data (temperature, humidity, soil moisture, NPK values) from the field using ESP32 microcontrollers and sensors.
- Sending this data to a Flask-based backend for visualization and further processing.
- Providing a web interface for live monitoring and plant disease prediction using deep learning (ResNet-50).
- Real-Time Sensor Data: View live temperature, humidity, soil moisture, and NPK (Nitrogen, Phosphorus, Potassium) values from the field.
- AI Plant Disease Detection: Upload plant images for instant health classification (Healthy, Potassium/Nitrogen deficiencies, etc.) using a ResNet-50 model.
- Remote Hardware Control: Toggle field devices (e.g., LEDs/lights) via the web interface.
- SocketIO Live Updates: Instant frontend updates when new sensor data arrives.
- ESP32 Integration: Ready-to-flash Arduino code for ESP32 boards to connect sensors and communicate with the server.
- ESP32 Boards: For WiFi connectivity and sensor interfacing.
- Sensors:
- DHT11/DHT22 (Temperature & Humidity)
- NPK Soil Sensor (for Nitrogen, Phosphorus, Potassium)
- Relay/LED Modules: For remote control demonstration.
- Flask Web Server: Handles API requests, serves the frontend, and manages SocketIO events.
- PyTorch/Transformers: For running the ResNet-50 plant disease classifier.
- Frontend: HTML/CSS/JS (with SocketIO) for real-time dashboard and image upload.
- ESP32 Arduino Code: For sensor reading and WiFi communication (see
hardware/folder).
git clone https://github.com/R3tr0gh057/Agri-project
cd Agri-projectYou can use the provided script or manually install:
# Using the script (Linux)
bash install_packages.sh
# Or manually
pip install -r requirements.txt- Use the code in
hardware/esp-32/,hardware/npk-code/, andhardware/light-code/for respective ESP32 modules. - Install required Arduino libraries (see
hardware/esp-32/lib-requirements.txt).
# Using the helper script (Linux)
bash run_server.sh
# Or manually
python server.py- Open your browser and go to: http://localhost:5000
- For remote access, use the ngrok tunnel provided by
run_server.sh.
- Live Dashboard: View real-time sensor data as it updates.
- Image Prediction: Upload plant images for instant health/disease classification.
- Test Prediction Locally:
python Test/image.py
- Hardware Control: Use the web interface to toggle LEDs/lights connected to ESP32.
Agri-project/
├── hardware/
│ ├── esp-32/ # ESP32 main board code & requirements
│ ├── light-code/ # ESP32 code for light/relay control
│ └── npk-code/ # ESP32 code for NPK sensor
├── lib/ # Python utility and model code
├── static/ # Frontend JS and CSS
├── templates/ # HTML templates
├── Test/ # Image prediction test scripts
├── server.py # Main Flask server
├── requirements.txt # Python dependencies
├── install_packages.sh # Setup script
├── run_server.sh # Server + ngrok launcher
└── README.md # This file
GET /— Main dashboard pagePOST /predict— Accepts base64-encoded plant images, returns class & descriptionPOST /update-data— ESP32 posts sensor data (JSON)GET /fetch-data— Returns latest sensor data (JSON)GET /toggleLED— Toggles field LED/relay via ESP32
This project is licensed under the MIT License. See LICENSE for details.
A companion mobile app is available and works seamlessly with this system once the server and hardware are set up and running. Contact the project maintainer for access or more details.