G
YouTube TikTok Games
Skip to content
TheTechTigerPublic

About

AI-Powered Smart Irrigation for Precision Farming. ESP32 + Flask + Ollama (DeepSeek) + WhatsApp integration for real-time farm monitoring and automated irrigation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

AgroSense 🌱

AI-Powered Smart Irrigation for Precision Farming

AgroSense is an end-to-end smart farming system that combines ESP32-based IoT hardware with an AI-driven Flask web application. It enables farmers to monitor soil conditions, control irrigation remotely, and get intelligent recommendations through a dashboard or WhatsApp.

Architecture

ESP32 Sensor Node β†’ Flask Backend β†’ SQLite DB
                        ↕
                   Ollama LLM (DeepSeek)
                        ↕
         Web Dashboard  |  WhatsApp (wacli)

See Website/flow.md for the full system architecture diagram.

Features

  • Real-time Monitoring β€” Soil moisture, temperature, humidity, water tank level, battery status via ESP32 heartbeat
  • Irrigation Control β€” Manual, periodic (scheduled), moisture-threshold-triggered, and rain-delay rules
  • AI Auto-Irrigation β€” Ollama-powered rule generation based on sensor history, weather forecast, and crop details
  • KrishiMitra Chatbot β€” Context-aware farming assistant with SSE streaming β€” knows your farm, sensors, and active rules
  • WhatsApp Integration β€” Farmers can check stats and schedule irrigation via WhatsApp messages processed by AI
  • Weather Integration β€” 5-day OpenWeatherMap forecast for informed irrigation decisions
  • User Dashboard β€” Login/register, profile management, live charts, notification center

Tech Stack

Layer Technology
Backend Flask (Python)
Database SQLite
Frontend Jinja2 + Bootstrap 5 (NiceAdmin theme) + ApexCharts / Chart.js
Hardware ESP32 (Arduino framework, PlatformIO)
AI / LLM Ollama running DeepSeek model locally
Weather OpenWeatherMap API
WhatsApp Go-based CLI tool (wacli)

Project Structure

β”œβ”€β”€ Website/                    # Flask web application
β”‚   β”œβ”€β”€ app.py                  # Main application routes
β”‚   β”œβ”€β”€ database.py             # SQLite helper functions
β”‚   β”œβ”€β”€ whatsapp_Service.py     # WhatsApp polling + AI service
β”‚   β”œβ”€β”€ AgroSenseDB.db.sql      # Database schema + seed data
β”‚   β”œβ”€β”€ templates/              # Jinja2 HTML templates
β”‚   β”œβ”€β”€ assets/                 # CSS, JS, images, vendor libs
β”‚   └── flow.md                 # Architecture diagram
β”‚
β”œβ”€β”€ AgroSenseHardwareSketch/    # ESP32 firmware (PlatformIO)
β”‚   β”œβ”€β”€ platformio.ini
β”‚   └── src/                    # Arduino source files
β”‚
β”œβ”€β”€ requirements.txt
└── README.md

Getting Started

Prerequisites

  • Python 3 + Flask
  • Ollama with a DeepSeek model (e.g. deepseek-v3.2:cloud)
  • PlatformIO (for ESP32 firmware)
  • OpenWeatherMap API key (optional, for weather features)
  • WhatsApp account + wacli binary (optional, for WhatsApp integration)

Backend Setup

cd Website
pip install -r ../requirements.txt
# Set environment variables:
#   OWM_API_KEY=your_openweathermap_key
#   SECRET_KEY=your_flask_secret_key
#   WHATSAPP_TO=... (optional, for WhatsApp)
#   WHATSAPP_CHAT_ID=... (optional)
flask run --debug -h 0.0.0.0 -p 82

The database is auto-created from AgroSenseDB.db.sql on first run.

ESP32 Firmware

cd AgroSenseHardwareSketch
platformio run --target upload

Environment Variables

Variable Description Required
OWM_API_KEY OpenWeatherMap API key No (weather features)
SECRET_KEY Flask session secret No (has default)
WHATSAPP_TO Target WhatsApp number No (WhatsApp features)
WHATSAPP_CHAT_ID WhatsApp group/contact ID No (WhatsApp features)
ESP_ID Default ESP MAC address No

Database Schema

6 tables: userDetails, espDetails, esp_logs, farmDetails, irrigation_rules, notifications, chats

See Website/AgroSenseDB.db.sql for the full schema and seed data.

Irrigation Rule Types

  1. Periodic β€” Schedule by day-of-week + time window
  2. Moisture-Triggered β€” Start/stop based on soil moisture thresholds
  3. Rain Delay β€” Suppress irrigation when rain is forecast
  4. AI Auto-Generated β€” DeepSeek generates 2–4 optimized rules from farm + sensor + weather context

License

MIT

About

AI-Powered Smart Irrigation for Precision Farming. ESP32 + Flask + Ollama (DeepSeek) + WhatsApp integration for real-time farm monitoring and automated irrigation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages