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.
- 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.
- π· 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.
- π¬ 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.
- Responsive Design: Seamlessly adapts to both desktop and mobile devices.
- β‘ Firebase Integration: Robust real-time database ensuring rapid and seamless data synchronization.
- ESP32 or ESP8266 microcontroller board
- Capacitive Soil Moisture Sensor v1.2
- Jumper wires and Breadboard
- Power supply (USB or battery bank)
| Sensor Pin | ESP32 Connection |
|---|---|
VCC |
3.3V |
GND |
GND |
AOUT |
GPIO34 (ESP32) or A0 (ESP8266) |
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
- Node.js (v16 or higher)
- Python (v3.10 or higher)
- A Firebase account for real-time data
- A Google Gemini API Key for AI features
- Arduino IDE (if flashing the IoT firmware)
git clone https://github.com/Umesh-369/AgriSense.git
cd AgriSense/backend
npm install- Create a Firebase project and enable the Realtime Database.
- Go to Project Settings β Service Accounts and generate a new private key.
- Save the file as
backend/serviceAccountKey.json. - Copy the environment variables example and update your database URL:
cp .env.example .envFIREBASE_DATABASE_URL=https://your-project-id.firebaseio.comnpm startNote: Without Firebase configuration, the app runs in Demo Mode with simulated data.
Open in browser:
- π Home: http://localhost:3000
- π Dashboard: http://localhost:3000/dashboard
This server powers both the Crop Disease Detector and the AgriBot Chatbot.
cd AgriSense/backend_python
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS/Linux
pip install -r requirements.txtCreate a .env file inside backend_python/ with your key:
GEMINI_API_KEY=your_gemini_api_key_hereYou can get a free API key from Google AI Studio.
python server.pyThe AI server will be available at http://localhost:8000.
Open the AI-powered pages:
- π¬ Disease Detector: Open
frontend/disease_detector.htmlin your browser - π€ AgriBot Chatbot: Open
frontend/chatbot.htmlin your browser
| 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 |
| 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 |
- Upload a clear photo of a plant leaf via the
disease_detector.htmlpage. - The image is sent to the Python FastAPI
/analyzeendpoint. - Gemini 2.5 Flash analyzes the image as an expert plant pathologist.
- 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 recommendationconfidenceβ The AI's confidence in the diagnosis
- Ask any agriculture-related question via the
chatbot.htmlpage. - The message is sent to the Python FastAPI
/api/chatendpoint. - Gemini 2.5 Flash responds with Google Search grounding enabled for real-time accuracy.
- Responses are always structured as:
[OVERVIEW]β A single summary sentence[KEY FINDINGS]β 3β5 concise bullet points with bolded key terms
- Optional Text-to-Speech reads the response aloud via the browser's Web Speech API.
- Open
iot/esp32_moisture_sensor.inoin your Arduino IDE. - Install the Firebase ESP Client library by Mobizt via the Library Manager.
- 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"
- Flash the code to your ESP32/ESP8266 board.
Use the included data simulator to generate realistic mock readings:
cd iot
node data_simulator.js| 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 |
Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.
This project is MIT licensed.



