Skip to content

Umesh-369/AgriSense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 AgriSense β€” Smart Agriculture Platform

License: MIT Node.js Python Firebase Gemini AI Three.js

A full-stack smart agriculture platform combining IoT soil monitoring, AI-powered crop disease detection, and an intelligent agricultural chatbot β€” all in one unified system.

Project Banner


🌟 Key Features

πŸ“‘ IoT Soil Monitoring

  • Real-time Monitoring: Live soil moisture readings continuously synced from IoT sensors via Firebase.
  • πŸ“Š Beautiful Dashboard: Animated circular gauges, live updating line charts, and dynamic status indicators.
  • πŸ”” Smart Alerts: Instant notifications triggered when moisture drops to critical levels.
  • 🎨 3D Interactive UI: Stunning Three.js animations and GSAP scroll effects for an immersive experience.

πŸ”¬ Crop Disease Detection

  • πŸ“· AI Image Analysis: Upload a photo of any plant leaf and get an instant disease diagnosis powered by Gemini 2.5 Flash.
  • 🩺 Detailed Diagnosis: Identifies the disease name, estimates severity (0–100%), and provides a practical cure/recommendation.
  • βœ… Confidence Scoring: Each result includes an AI confidence score for transparency.
  • πŸ›‘οΈ Non-Crop Guard: Automatically rejects non-plant images with a helpful error message.

πŸ€– AgriBot Chatbot

  • πŸ’¬ Agricultural Expert AI: Ask any farming or crop-related question and receive structured, expert-level answers.
  • 🌐 Google Search Grounding: Responses are enriched with real-time web data for up-to-date agricultural advice.
  • πŸ”Š Text-to-Speech: Built-in browser TTS reads out responses for hands-free use in the field.
  • πŸ“– Structured Responses: Answers are always formatted with an [OVERVIEW] and [KEY FINDINGS] section for clarity.

πŸ“± General

  • Responsive Design: Seamlessly adapts to both desktop and mobile devices.
  • ⚑ Firebase Integration: Robust real-time database ensuring rapid and seamless data synchronization.

πŸ“· IoT Hardware Sensor

IoT Soil Moisture Sensor deployed in the field

Capacitive Soil Moisture Sensor (ESP32-based) deployed in a crop field

πŸ”§ Components Needed

  • ESP32 or ESP8266 microcontroller board
  • Capacitive Soil Moisture Sensor v1.2
  • Jumper wires and Breadboard
  • Power supply (USB or battery bank)

πŸ”Œ Wiring Diagram

Sensor Pin ESP32 Connection
VCC 3.3V
GND GND
AOUT GPIO34 (ESP32) or A0 (ESP8266)

πŸ“Έ Interface Preview

🏠 Home Page β€” 3D Interactive Landing

AgriSense Home Page

πŸ“Š Real-Time Dashboard

AgriSense Dashboard

πŸ“ Project Structure

AgriSense/
β”œβ”€β”€ assets/                        # Images and media assets for this README
β”‚
β”œβ”€β”€ backend/                       # Node.js REST API & Firebase integration
β”‚   β”œβ”€β”€ routes/                    # Express endpoints (moisture.js)
β”‚   β”œβ”€β”€ utils/                     # Moisture logic & thresholds
β”‚   └── server.js                  # Main entry point
β”‚
β”œβ”€β”€ backend_python/                # Python FastAPI server (AI features)
β”‚   β”œβ”€β”€ server.py                  # AgriBot chat & disease detection API
β”‚   β”œβ”€β”€ requirements.txt           # Python dependencies
β”‚   └── .env                       # Gemini API key configuration
β”‚
β”œβ”€β”€ frontend/                      # Client-side web application
β”‚   β”œβ”€β”€ index.html                 # Landing page with 3D elements
β”‚   β”œβ”€β”€ dashboard.html             # Live soil analytics dashboard
β”‚   β”œβ”€β”€ disease_detector.html      # πŸ”¬ AI crop disease detection page
β”‚   β”œβ”€β”€ chatbot.html               # πŸ€– AgriBot agricultural chatbot page
β”‚   β”œβ”€β”€ css/                       # Styling & themes
β”‚   └── js/                        # Three.js, GSAP, and Chart.js logic
β”‚
β”œβ”€β”€ iot/                           # Microcontroller code & testing tools
β”‚   β”œβ”€β”€ esp32_moisture_sensor.ino  # Arduino firmware
β”‚   └── data_simulator.js          # Mock data generator (for testing)
β”‚
└── docs/                          # Additional documentation

πŸš€ Quick Start Guide

Prerequisites


βš™οΈ Part 1: IoT Monitoring Backend (Node.js)

1. Clone & Install

git clone https://github.com/Umesh-369/AgriSense.git
cd AgriSense/backend
npm install

2. Configure Firebase

  1. Create a Firebase project and enable the Realtime Database.
  2. Go to Project Settings β†’ Service Accounts and generate a new private key.
  3. Save the file as backend/serviceAccountKey.json.
  4. Copy the environment variables example and update your database URL:
cp .env.example .env
FIREBASE_DATABASE_URL=https://your-project-id.firebaseio.com

3. Start the Node.js Server

npm start

Note: Without Firebase configuration, the app runs in Demo Mode with simulated data.

Open in browser:


πŸ€– Part 2: AI Features Backend (Python / FastAPI)

This server powers both the Crop Disease Detector and the AgriBot Chatbot.

1. Set Up Python Environment

cd AgriSense/backend_python
python -m venv .venv
.venv\Scripts\activate      # Windows
# source .venv/bin/activate # macOS/Linux
pip install -r requirements.txt

2. Configure Gemini API Key

Create a .env file inside backend_python/ with your key:

GEMINI_API_KEY=your_gemini_api_key_here

You can get a free API key from Google AI Studio.

3. Start the Python Server

python server.py

The AI server will be available at http://localhost:8000.

Open the AI-powered pages:

  • πŸ”¬ Disease Detector: Open frontend/disease_detector.html in your browser
  • πŸ€– AgriBot Chatbot: Open frontend/chatbot.html in your browser

πŸ“Š API Endpoints Reference

Node.js API (Port 3000)

Endpoint Method Description
/api/health GET Verifies server operational status
/api/moisture/current GET Fetches the latest moisture reading
/api/moisture/history GET Retrieves historical data (past 24h)
/api/moisture/status GET Calculates current status and alerts
/api/moisture/thresholds GET Returns threshold configuration data

Python FastAPI (Port 8000)

Endpoint Method Description
/api/health GET Verifies AgriBot server status
/api/chat POST Sends a message to the AgriBot chatbot
/analyze POST Uploads a crop image for disease analysis

πŸ”¬ Crop Disease Detector β€” How It Works

  1. Upload a clear photo of a plant leaf via the disease_detector.html page.
  2. The image is sent to the Python FastAPI /analyze endpoint.
  3. Gemini 2.5 Flash analyzes the image as an expert plant pathologist.
  4. The result is returned as a structured JSON with:
    • disease β€” The identified disease name (or "Healthy")
    • severity β€” A percentage score (0–100%)
    • cure β€” A concise, practical recommendation
    • confidence β€” The AI's confidence in the diagnosis

πŸ€– AgriBot Chatbot β€” How It Works

  1. Ask any agriculture-related question via the chatbot.html page.
  2. The message is sent to the Python FastAPI /api/chat endpoint.
  3. Gemini 2.5 Flash responds with Google Search grounding enabled for real-time accuracy.
  4. Responses are always structured as:
    • [OVERVIEW] β€” A single summary sentence
    • [KEY FINDINGS] β€” 3–5 concise bullet points with bolded key terms
  5. Optional Text-to-Speech reads the response aloud via the browser's Web Speech API.

πŸ’» IoT Hardware Setup Details

  1. Open iot/esp32_moisture_sensor.ino in your Arduino IDE.
  2. Install the Firebase ESP Client library by Mobizt via the Library Manager.
  3. Update credentials:
    #define WIFI_SSID      "your_wifi_name"
    #define WIFI_PASSWORD  "your_wifi_password"
    #define FIREBASE_HOST  "your-project.firebaseio.com"
    #define FIREBASE_AUTH  "your_firebase_secret"
  4. Flash the code to your ESP32/ESP8266 board.

πŸ§ͺ Testing Without Hardware

Use the included data simulator to generate realistic mock readings:

cd iot
node data_simulator.js

🎨 Technologies & Stack

Category Technologies Used
Frontend UI/UX HTML5, CSS3, JavaScript (ES6+), Glassmorphism
3D & Animation Three.js, GSAP (GreenSock)
Data Visualization Chart.js
IoT Backend & API Node.js, Express.js
AI Backend & API Python, FastAPI, Uvicorn
AI / LLM Google Gemini 2.5 Flash (google-genai SDK)
Database Firebase Realtime Database
IoT / Hardware C++ (Arduino), ESP32 / ESP8266

🀝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.

πŸ“„ License

This project is MIT licensed.


Designed & Developed with ❀️ for Smart Agriculture

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors