Sunday, 4 October 2026

AI Automated Irrigation System using Crop Prediction

Absolutely . I can structure this as a complete final-year/academic IoT project documentation for an:

AI-Powered Automated Irrigation System Using Crop Prediction

ESP32 + Sensors + AI Agent + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard

The system can automatically monitor soil and environmental conditions, predict the crop/irrigation requirement, control a water pump through an ESP32, log data to Google Sheets/ThingSpeak, and use an AI Agent through n8n to generate intelligent alerts and recommendations.

I can provide the full project in the following structure:

1. Project Architecture

                  ┌─────────────────────────┐
                  │       FARM / FIELD      │
                  │                         │
                  │ Soil Moisture Sensor    │
                  │ Temperature Sensor      │
                  │ Humidity Sensor         │
                  │ Rain Sensor             │
                  │ Water Level Sensor      │
                  └───────────┬─────────────┘
                              │
                              ▼
                    ┌──────────────────┐
                    │      ESP32       │
                    │                  │
                    │ Sensor Reading   │
                    │ Decision Logic   │
                    │ Wi-Fi            │
                    └────────┬─────────┘
                             │
                 ┌───────────┼───────────────┐
                 │           │               │
                 ▼           ▼               ▼
          ┌──────────┐ ┌───────────┐ ┌─────────────┐
          │ Water    │ │ ThingSpeak│ │    n8n      │
          │ Pump     │ │ Dashboard │ │ Automation  │
          └──────────┘ └───────────┘ └──────┬──────┘
                                            │
                             ┌──────────────┼──────────────┐
                             ▼              ▼              ▼
                       ┌──────────┐  ┌───────────┐  ┌──────────┐
                       │ AI Agent │  │  Google   │  │ Telegram │
                       │          │  │  Sheets   │  │ Alerts   │
                       └────┬─────┘  └───────────┘  └────┬─────┘
                            │                            │
                            ▼                            ▼
                     Crop/Irrigation              Text / Voice
                       Analysis                     Notification

2. Main Objective

The objective is to develop an intelligent automated irrigation system that determines when irrigation is required by combining:

  • Soil moisture

  • Temperature

  • Relative humidity

  • Rain detection

  • Water-tank level

  • Crop information

  • Crop growth stage

  • AI-based prediction

  • Historical irrigation data

Instead of continuously running the pump, the ESP32 and automation system determine whether irrigation is actually required.

Basic principle

Sensor Data
     ↓
ESP32
     ↓
Internet
     ↓
n8n Workflow
     ↓
AI Agent
     ↓
Analyze Crop + Environment
     ↓
Irrigation Decision
     ↓
ESP32
     ↓
Pump ON/OFF
     ↓
Cloud Logging
     ↓
Telegram Alert

3. Proposed Features

Hardware

  • ESP32 development board

  • Capacitive soil-moisture sensor

  • DHT22/DHT11 temperature-humidity sensor

  • Rain sensor

  • Water-level sensor

  • Relay module

  • DC water pump

  • External pump power supply

  • Optional flow sensor

  • Optional LCD/OLED

  • Wi-Fi connection

Software

  • Arduino IDE

  • ESP32 Arduino framework

  • n8n

  • Telegram Bot

  • Google Sheets

  • ThingSpeak

  • AI/LLM API

  • Optional web dashboard


4. Overall System Flow

                    START
                      │
                      ▼
              ESP32 initializes
                      │
                      ▼
                Connect Wi-Fi
                      │
                      ▼
             Read all sensors
                      │
                      ▼
       ┌───────────────────────────┐
       │ Soil moisture sufficiently │
       │ high?                      │
       └─────────────┬─────────────┘
                     │
               YES   │   NO
                │    │
                ▼    ▼
             Pump   Check
             OFF    weather/
                    rain/tank
                     │
                     ▼
              Send data to n8n
                     │
                     ▼
                AI Agent
                     │
          ┌──────────┴──────────┐
          │                     │
      Irrigation              No
       required             irrigation
          │                     │
          ▼                     ▼
       Pump ON                Pump OFF
          │                     │
          └──────────┬──────────┘
                     ▼
               Record data
                     │
              ┌──────┴──────┐
              ▼             ▼
        Google Sheets   ThingSpeak
              │
              ▼
          Telegram
              │
              ▼
       Voice/Text Alert
              │
              ▼
           Repeat

5. Hardware Block Diagram

                     ┌───────────────┐
                     │     ESP32     │
                     │               │
                     │ GPIO / ADC    │
                     │ Wi-Fi         │
                     └───────┬───────┘
                             │
       ┌─────────────────────┼──────────────────────┐
       │                     │                      │
       ▼                     ▼                      ▼
┌────────────┐       ┌──────────────┐       ┌─────────────┐
│ Soil       │       │ DHT11/DHT22  │       │ Rain Sensor │
│ Moisture   │       │ Temp/Humidity │       │             │
└────────────┘       └──────────────┘       └─────────────┘
       │
       │
       ▼
┌───────────────┐
│ Water Level   │
│ Sensor        │
└───────────────┘

                     ESP32
                       │
                       ▼
                 ┌──────────┐
                 │  Relay   │
                 └────┬─────┘
                      │
                      ▼
                 ┌──────────┐
                 │   Pump   │
                 └────┬─────┘
                      │
                      ▼
                    FIELD

6. Example Electrical Schematic

A typical low-voltage prototype can be wired approximately as follows:

                 ESP32
          ┌──────────────────┐
          │                  │
          │ 3.3V ─────────────── Sensor VCC
          │ GND  ─────────────── Sensor GND
          │                  │
          │ GPIO34 ◄──────────── Soil Moisture AO
          │ GPIO4  ◄──────────── DHT DATA
          │ GPIO35 ◄──────────── Rain Sensor
          │ GPIO32 ◄──────────── Water Level
          │                  │
          │ GPIO26 ───────────── Relay IN
          │                  │
          └──────────────────┘
                       │
                       ▼
                  ┌─────────┐
                  │ RELAY   │
                  │ MODULE  │
                  └────┬────┘
                       │
                       ▼
              ┌────────────────┐
              │ External       │
              │ Pump Supply    │
              └───────┬────────┘
                      │
                      ▼
                   DC PUMP

Important: The pump should normally have its own correctly rated power supply. Do not power a pump directly from an ESP32 GPIO pin. For mains-powered pumps, use an appropriately rated isolated switching arrangement and have the mains portion installed/tested by a qualified person.


7. Suggested GPIO Assignment

Component ESP32 Pin
Soil moisture analog output GPIO 34
DHT22 data GPIO 4
Rain sensor GPIO 35
Water-level sensor GPIO 32
Relay GPIO 26
Optional flow sensor GPIO 27
OLED SDA GPIO 21
OLED SCL GPIO 22

GPIO assignments can be changed depending on the ESP32 board and sensor modules used.


8. How the AI Component Works

The AI should not blindly control the pump.

Instead, the ESP32 collects measurements and sends a structured data packet.

Example:

{
  "soil_moisture": 31,
  "temperature": 34.2,
  "humidity": 48,
  "rain_detected": false,
  "water_level": 72,
  "crop": "Tomato",
  "growth_stage": "Flowering"
}

n8n receives this information.

The AI Agent analyzes the data:

Soil moisture = 31%
Temperature = 34.2°C
Humidity = 48%
Rain = No
Tank = 72%
Crop = Tomato
Stage = Flowering

It could return a structured decision such as:

{
  "irrigation_required": true,
  "duration_minutes": 8,
  "priority": "high",
  "reason": "Low soil moisture and high temperature",
  "alert_required": true
}

The n8n workflow can then validate this response before sending a pump command.


9. Crop Prediction Module

The crop-prediction component can operate at two levels.

Level 1 — Crop selection

The user supplies or selects:

Crop:
Tomato

or the AI predicts a likely crop from available agricultural/environmental information.

Level 2 — Crop-specific irrigation prediction

Different crops have different water requirements.

For example:

Crop
  ↓
Growth Stage
  ↓
Soil Moisture
  ↓
Temperature
  ↓
Humidity
  ↓
Rain Forecast/Detection
  ↓
Historical Irrigation
  ↓
AI Prediction
  ↓
Recommended Irrigation

For an academic project, I recommend making crop type + growth stage explicit inputs rather than claiming that an LLM itself is a scientifically validated crop classifier.


10. n8n Automation Architecture

The n8n workflow can be designed as:

                    ESP32 HTTP Request
                           │
                           ▼
                    ┌─────────────┐
                    │ Webhook     │
                    └──────┬──────┘
                           │
                           ▼
                    ┌─────────────┐
                    │ Validate    │
                    │ Sensor Data │
                    └──────┬──────┘
                           │
                           ▼
                    ┌─────────────┐
                    │ Google      │
                    │ Sheets Log  │
                    └──────┬──────┘
                           │
                           ▼
                    ┌─────────────┐
                    │ AI Agent    │
                    └──────┬──────┘
                           │
                           ▼
                    ┌─────────────┐
                    │ Parse AI    │
                    │ Decision    │
                    └──────┬──────┘
                           │
                           ▼
                  ┌──────────────────┐
                  │ Safety Validation│
                  └────────┬─────────┘
                           │
                  ┌────────┴────────┐
                  │                 │
                YES                 NO
                  │                 │
                  ▼                 ▼
             ESP32 Pump          Pump OFF
               Command               │
                  │                  │
                  └────────┬─────────┘
                           ▼
                    ┌─────────────┐
                    │ ThingSpeak  │
                    │ Update      │
                    └──────┬──────┘
                           │
                           ▼
                    ┌─────────────┐
                    │ Telegram    │
                    │ Notification│
                    └─────────────┘

11. n8n Nodes

A practical workflow can contain:

  1. Webhook

  2. Set/Edit Fields

  3. IF – Validate Sensor Values

  4. Google Sheets – Append Row

  5. AI Agent

  6. Structured Output Parser

  7. IF – Irrigation Required

  8. HTTP Request – ESP32

  9. ThingSpeak HTTP Request

  10. Telegram

  11. Google Sheets – Update Result

  12. Error/Alert branch


12. AI Agent Prompt

The AI Agent should receive structured sensor data rather than an unstructured paragraph.

Example system instruction:

You are an agricultural irrigation decision assistant.

Analyze the supplied crop, growth stage, soil moisture,
temperature, humidity, rainfall status, water level and
historical irrigation information.

Your job is to recommend whether irrigation is required.

Never recommend irrigation when:
1. The water tank is critically low.
2. Rain is currently detected.
3. Sensor values are invalid.
4. The system reports a hardware fault.

Return ONLY valid JSON using this schema:

{
  "irrigation_required": true,
  "duration_minutes": 5,
  "priority": "low",
  "reason": "string",
  "alert_required": true
}

Do not invent sensor values.
Do not directly claim that irrigation is scientifically optimal.
Treat your answer as a recommendation subject to safety validation.

This is an important architectural improvement: the AI makes a recommendation, while deterministic safety logic has the final authority over the pump.


13. ESP32 → n8n Data

The ESP32 can send an HTTP POST request:

POST /webhook/irrigation
Content-Type: application/json

with:

{
  "device_id": "ESP32_FIELD_01",
  "soil_moisture": 28,
  "temperature": 33.5,
  "humidity": 51,
  "rain": false,
  "water_level": 78,
  "crop": "Tomato",
  "growth_stage": "Flowering"
}

14. ESP32 Arduino Code

Below is a starter implementation for the ESP32.

#include <WiFi.h>
#include <HTTPClient.h>
#include <DHT.h>

#define DHTPIN 4
#define DHTTYPE DHT22

#define SOIL_PIN 34
#define RAIN_PIN 35
#define WATER_LEVEL_PIN 32

#define RELAY_PIN 26

const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASSWORD = "YOUR_PASSWORD";

const char* N8N_URL =
  "https://YOUR-N8N-DOMAIN/webhook/irrigation";

DHT dht(DHTPIN, DHTTYPE);

void setup() {

  Serial.begin(115200);

  pinMode(RELAY_PIN, OUTPUT);

  // Pump OFF initially
  digitalWrite(RELAY_PIN, LOW);

  dht.begin();

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

  Serial.print("Connecting to WiFi");

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println();
  Serial.println("WiFi connected");
}

void loop() {

  int soilRaw = analogRead(SOIL_PIN);
  int rainRaw = analogRead(RAIN_PIN);
  int waterRaw = analogRead(WATER_LEVEL_PIN);

  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("DHT sensor error");
    delay(5000);
    return;
  }

  // These values must be calibrated for the actual sensors.
  int soilMoisture =
      map(soilRaw, 4095, 1500, 0, 100);

  soilMoisture = constrain(soilMoisture, 0, 100);

  int waterLevel =
      map(waterRaw, 1000, 3000, 0, 100);

  waterLevel = constrain(waterLevel, 0, 100);

  bool rainDetected = rainRaw < 1500;

  Serial.println("------ SENSOR DATA ------");

  Serial.print("Soil: ");
  Serial.println(soilMoisture);

  Serial.print("Temperature: ");
  Serial.println(temperature);

  Serial.print("Humidity: ");
  Serial.println(humidity);

  Serial.print("Rain: ");
  Serial.println(rainDetected);

  Serial.print("Water Level: ");
  Serial.println(waterLevel);

  if (WiFi.status() == WL_CONNECTED) {

    HTTPClient http;

    http.begin(N8N_URL);

    http.addHeader(
      "Content-Type",
      "application/json"
    );

    String json = "{";

    json += "\"device_id\":\"ESP32_FIELD_01\",";
    json += "\"soil_moisture\":" +
            String(soilMoisture) + ",";
    json += "\"temperature\":" +
            String(temperature) + ",";
    json += "\"humidity\":" +
            String(humidity) + ",";
    json += "\"rain\":" +
            String(rainDetected ? "true" : "false") + ",";
    json += "\"water_level\":" +
            String(waterLevel) + ",";
    json += "\"crop\":\"Tomato\",";
    json += "\"growth_stage\":\"Flowering\"";

    json += "}";

    Serial.println(json);

    int responseCode =
      http.POST(json);

    Serial.print("HTTP Response: ");
    Serial.println(responseCode);

    String response =
      http.getString();

    Serial.println(response);

    http.end();
  }

  delay(60000);
}

15. Important Sensor Calibration

Do not assume the map() values above represent your actual sensors.

For the soil sensor, record:

Completely dry soil → ADC value
Wet soil             → ADC value

For example:

Dry = 3500
Wet = 1500

Then calibrate:

int moisture = map(
    soilRaw,
    3500,
    1500,
    0,
    100
);

The exact values depend on the sensor, soil and ESP32 ADC configuration.


16. Pump-Control Safety

A better architecture is:

                 AI Recommendation
                        │
                        ▼
               ┌─────────────────┐
               │ Safety Rules    │
               └────────┬────────┘
                        │
       ┌────────────────┼────────────────┐
       │                │                │
       ▼                ▼                ▼
 Tank OK?          Rain absent?     Sensor valid?
       │                │                │
       └────────────────┼────────────────┘
                        ▼
                 ALL CONDITIONS OK
                        │
                        ▼
                    Pump ON

Never allow an LLM response such as:

{"irrigation_required":true}

to directly energize the pump without validation.


17. Telegram Alert System

When irrigation starts:

🌱 IRRIGATION ALERT

Crop: Tomato
Growth Stage: Flowering

Soil Moisture: 28%
Temperature: 33.5°C
Humidity: 51%

Rain: No
Water Level: 78%

AI Recommendation:
Irrigation Required

Pump:
ON

Duration:
5 minutes

When irrigation finishes:

✅ IRRIGATION COMPLETED

Crop: Tomato

Pump Runtime: 5 minutes

System Status:
NORMAL

Data has been recorded in
Google Sheets and ThingSpeak.

18. Telegram Voice Alert

For a voice notification, the conceptual n8n flow is:

AI Decision
    ↓
Generate Alert Text
    ↓
Text-to-Speech Service
    ↓
Audio File
    ↓
Telegram Bot
    ↓
Send Voice/Audio Message

Example spoken message:

"Irrigation alert. Soil moisture is low for the tomato crop. The system recommends five minutes of irrigation."

This makes the project particularly useful for a farmer who may not continuously monitor a dashboard.


19. Google Sheets Database

Create columns such as:

Timestamp Device Crop Stage Soil Temp Humidity Rain Water AI Decision Pump Duration
2026-10-04 10:00 ESP32-01 Tomato Flowering 28 33.5 51 No 78 Irrigate ON 5
2026-10-04 11:00 ESP32-01 Tomato Flowering 46 32.1 55 No 73 No irrigation OFF 0

This gives you a historical dataset for later analysis and model development.


20. ThingSpeak Dashboard

ThingSpeak can be used for numerical visualization.

Possible channels:

Field 1 → Soil Moisture
Field 2 → Temperature
Field 3 → Humidity
Field 4 → Water Level
Field 5 → Rain Status
Field 6 → Pump Status
Field 7 → Irrigation Duration

Dashboard:

┌──────────────────────────────────────────┐
│       SMART IRRIGATION DASHBOARD         │
├──────────────────────────────────────────┤
│ Soil Moisture       ███████░░░  28%       │
│ Temperature                     33.5°C    │
│ Humidity                        51%       │
│ Water Tank                     78%        │
│ Rain                            NO        │
│ Pump                            ON        │
├──────────────────────────────────────────┤
│ Crop: Tomato                              │
│ Stage: Flowering                          │
│ AI: Irrigation Recommended                │
└──────────────────────────────────────────┘

21. Webpage / IoT Dashboard

You can also create a custom webpage:

              SMART FARM AI
        ─────────────────────────

        🌱 Crop: TOMATO
        🌿 Stage: FLOWERING

        Soil Moisture
        ███████░░░░ 28%

        Temperature
        33.5 °C

        Humidity
        51 %

        Tank Level
        78 %

        Rain
        ❌ NO

        Pump
        🟢 ON

        AI Recommendation
        ─────────────────
        Irrigation required

        Duration: 5 minutes

        ┌────────────────────────┐
        │ VIEW HISTORICAL DATA   │
        └────────────────────────┘

22. Complete Communication Architecture

                         INTERNET
                            │
             ┌──────────────┼──────────────┐
             │              │              │
             ▼              ▼              ▼
          ThingSpeak       n8n          Web UI
                            │
                 ┌──────────┼───────────┐
                 │          │           │
                 ▼          ▼           ▼
             AI Agent   Google Sheets Telegram
                 │                      │
                 │                      ▼
                 │                 Voice Alert
                 │
                 ▼
             Decision
                 │
                 ▼
              ESP32
                 │
                 ▼
               Relay
                 │
                 ▼
               Pump

23. Agentic IoT Concept

The project becomes more than simple IoT when the AI Agent can:

OBSERVE
   ↓
Sensor data
   ↓
ANALYZE
   ↓
AI Agent
   ↓
REASON
   ↓
Determine irrigation recommendation
   ↓
ACT
   ↓
ESP32 / Pump
   ↓
OBSERVE AGAIN
   ↓
Verify result
   ↓
LOG
   ↓
Notify farmer

This creates an observe → reason → act → verify loop.


24. Example Agent Conversation

Farmer

Farmer:
How is the field?

AI Agent

AI:
The tomato field currently has 28% soil moisture.
The temperature is 33.5°C and no rain is detected.

The water tank is 78% full.

I recommend irrigation for approximately
5 minutes, subject to the system safety checks.

Farmer

Farmer:
Start irrigation.

Agent

AI:
The request was received.

Safety conditions:
✓ Tank level sufficient
✓ No rain detected
✓ Sensors responding

Irrigation can be started.

System

ESP32
   ↓
Relay ON
   ↓
Pump ON

Agent

AI:
Irrigation completed.

Pump runtime: 5 minutes.

The event has been recorded.

25. Manual Telegram Control

You can optionally implement commands:

/start
/status
/soil
/pump_on
/pump_off
/irrigation
/history
/ai

Example:

Farmer → /status

Bot →
🌱 Field Status

Soil: 31%
Temperature: 32.8°C
Humidity: 54%
Tank: 76%
Rain: No
Pump: OFF

AI:
Irrigation may be required soon.

For safety, manual /pump_on should still pass through maximum-runtime and sensor/tank checks.


26. n8n Workflow Logic

Pseudo-code:

RECEIVE SENSOR DATA

IF soil moisture < crop threshold
    AND rain = false
    AND water level > minimum
    AND sensor values valid

        SEND DATA TO AI

        AI → irrigation_required?

        IF YES
            duration = AI duration

            LIMIT duration to safe maximum

            SEND COMMAND TO ESP32

            LOG EVENT

            SEND TELEGRAM ALERT

        ELSE
            LOG "No irrigation"

ELSE
    Pump OFF
    LOG reason

27. Fault Detection

The system should also identify:

Sensor failure
Wi-Fi failure
Low tank level
Unexpected pump state
Invalid AI response
Unexpected soil readings
Rain detected
ESP32 offline

Example:

🚨 SYSTEM FAULT

Soil moisture sensor returned
an invalid reading.

Pump operation has been disabled.

Please inspect the sensor.

28. Recommended Database/Data Model

A complete record can contain:

{
  "timestamp": "...",
  "device_id": "ESP32_FIELD_01",
  "crop": "Tomato",
  "growth_stage": "Flowering",
  "soil_moisture": 28,
  "temperature": 33.5,
  "humidity": 51,
  "rain": false,
  "water_level": 78,
  "ai_recommendation": "irrigate",
  "irrigation_duration": 5,
  "pump_status": "ON",
  "system_status": "NORMAL"
}

29. Project Development Phases

Phase 1 — Hardware

ESP32
 ↓
Soil Sensor
 ↓
DHT Sensor
 ↓
Rain Sensor
 ↓
Relay
 ↓
Pump

First prove that local sensing and pump control work.

Phase 2 — Internet

ESP32
 ↓
Wi-Fi
 ↓
HTTP
 ↓
n8n

Phase 3 — Cloud

ESP32
 ↓
n8n
 ├── Google Sheets
 └── ThingSpeak

Phase 4 — AI

n8n
 ↓
AI Agent
 ↓
Structured decision

Phase 5 — Telegram

n8n
 ↓
Telegram
 ├── Text
 └── Voice

Phase 6 — Automation

Sensor
 ↓
AI
 ↓
Safety
 ↓
Pump
 ↓
Verification
 ↓
Notification

30. Testing Plan

Test Input Expected Result
Dry soil Low moisture Irrigation recommendation
Wet soil High moisture Pump remains OFF
Rain Rain detected Pump OFF
Low tank Tank below limit Pump OFF + alert
Normal temperature Normal conditions Normal operation
Sensor failure Invalid reading Pump disabled
Wi-Fi failure Network unavailable Local safe state
Telegram Alert event Notification delivered
Google Sheets Sensor event Row created
ThingSpeak Sensor event Fields updated
AI failure Invalid AI output Safe fallback
Manual OFF Telegram command Pump stops

31. Expected Results

The completed system should:

  • Monitor field conditions continuously.

  • Measure soil moisture automatically.

  • Monitor temperature and humidity.

  • Detect rain.

  • Monitor available water.

  • Identify the selected crop and growth stage.

  • Generate an AI-assisted irrigation recommendation.

  • Apply deterministic safety rules.

  • Control the pump automatically.

  • Store historical data.

  • Display cloud graphs.

  • Send Telegram notifications.

  • Generate optional voice alerts.

  • Allow remote monitoring.

  • Provide a foundation for future predictive irrigation models.


32. Advantages

Traditional irrigation

Farmer
  ↓
Manual observation
  ↓
Manual pump
  ↓
Water consumption

Proposed system

Sensors
  ↓
ESP32
  ↓
Cloud
  ↓
AI Agent
  ↓
Safety validation
  ↓
Automatic irrigation
  ↓
Cloud logging
  ↓
Telegram alert

Advantages include:

  • Reduced unnecessary irrigation

  • Remote monitoring

  • Automated operation

  • Historical data collection

  • Crop-aware recommendations

  • Early fault notification

  • Voice-based alerts

  • Expandability to multiple fields


33. Limitations

For an academically honest project report, include these:

  1. AI recommendations depend on the quality of sensor data.

  2. Soil-moisture sensors require calibration.

  3. A generic AI model is not automatically an agronomically validated irrigation model.

  4. Internet connectivity may fail.

  5. Crop-water requirements vary by soil, climate and growth stage.

  6. The prototype should be validated against real agricultural measurements before being used for production irrigation.

  7. Pump control requires appropriate electrical and mechanical safety measures.


34. Future Enhancements

The project can later be upgraded with:

Weather API
     ↓
Rain Forecast
     ↓
AI Agent

and:

Historical Data
      ↓
Machine Learning Model
      ↓
Crop Water Requirement
      ↓
Prediction

Other upgrades:

  • Multiple ESP32 field nodes

  • Solar power

  • LoRa/LoRaWAN

  • Flow-rate monitoring

  • Fertilizer automation

  • Disease detection using camera

  • Leaf-image analysis

  • Weather prediction

  • Digital twin

  • Mobile application

  • Multi-crop support

  • Reinforcement-learning irrigation optimization


35. Final System Diagram

                         ┌──────────────────┐
                         │       FARM       │
                         │                  │
                         │ Soil Sensor      │
                         │ Temp/Humidity    │
                         │ Rain Sensor      │
                         │ Water Level      │
                         └────────┬─────────┘
                                  │
                                  ▼
                         ┌──────────────────┐
                         │      ESP32       │
                         │                  │
                         │ Sensor Processing│
                         │ Wi-Fi            │
                         │ Pump Interface   │
                         └───────┬──────────┘
                                 │
                         Internet / HTTP
                                 │
                                 ▼
                         ┌──────────────────┐
                         │       n8n        │
                         │ Automation       │
                         └────────┬─────────┘
                                  │
                     ┌────────────┼────────────┐
                     │            │            │
                     ▼            ▼            ▼
              ┌───────────┐ ┌──────────┐ ┌───────────┐
              │ AI Agent  │ │ Google   │ │ ThingSpeak│
              │           │ │ Sheets   │ │ Dashboard │
              └─────┬─────┘ └──────────┘ └───────────┘
                    │
                    ▼
             ┌───────────────┐
             │ Safety Rules  │
             └───────┬───────┘
                     │
             ┌───────┴────────┐
             │                │
             ▼                ▼
        Irrigation          No Water
         Required            Needed
             │                │
             ▼                ▼
          ESP32             ESP32
             │                │
             ▼                ▼
          Relay             OFF
             │
             ▼
           PUMP
             │
             ▼
           FIELD

                    n8n
                     │
                     ▼
                ┌──────────┐
                │ Telegram │
                └────┬─────┘
                     │
              ┌──────┴──────┐
              ▼             ▼
             Text          Voice
             Alert         Alert

36. Recommended Project Title

For a college/project report, I would use:

“AI-Powered Automated Irrigation System Using Crop Prediction and Agentic IoT with ESP32, n8n Automation, Telegram Voice Alerts, Google Sheets and ThingSpeak Cloud Monitoring”

Short title

“AI-Based Smart Irrigation System Using ESP32 and n8n”

Core technologies

ESP32
+
IoT Sensors
+
Wi-Fi
+
n8n
+
AI Agent
+
Telegram
+
Google Sheets
+
ThingSpeak
=
Agentic Smart Irrigation System

If you want this as a complete project report, the next logical version is to turn this into a chapter-by-chapter document containing Abstract, Introduction, Literature Survey, Problem Statement, Objectives, Proposed Methodology, complete circuit/schematic, component specifications, ESP32 source code, n8n workflow configuration, AI prompt, Telegram bot setup, Google Sheets setup, ThingSpeak setup, database format, flowcharts, UML/use-case diagram, sequence diagram, testing tables, results, advantages, limitations, future scope, conclusion, and viva questions/answers.

 

Project Summary

AI-Powered Automated Irrigation System Using Crop Prediction is a smart agriculture project that combines ESP32, IoT sensors, AI Agent, n8n automation, Telegram alerts, Google Sheets, and ThingSpeak to automate irrigation.

Core workflow

Soil/Weather Sensors
        ↓
      ESP32
        ↓
     Wi-Fi
        ↓
      n8n
        ↓
    AI Agent
        ↓
Safety Validation
        ↓
   Pump ON/OFF
        ↓
Google Sheets + ThingSpeak
        ↓
Telegram Text/Voice Alert

Main functions

  • Measures soil moisture, temperature, humidity, rain and water level.

  • Uses crop type and growth stage to make irrigation recommendations.

  • ESP32 communicates with the n8n automation server.

  • n8n sends sensor information to an AI Agent.

  • AI recommends whether irrigation is required and suggests a duration.

  • Deterministic safety rules verify the AI recommendation before the pump operates.

  • Relay controls the irrigation pump.

  • Data is stored in Google Sheets for historical analysis.

  • ThingSpeak provides cloud-based graphs and monitoring.

  • Telegram sends real-time text and optional voice alerts.

  • The system can support remote status checking and manual commands.

  • Historical data can later be used to develop a dedicated machine-learning crop/irrigation prediction model.

Key architecture

┌──────────────┐
│ Farm Sensors │
└──────┬───────┘
       ↓
┌──────────────┐
│    ESP32     │
└──────┬───────┘
       ↓
┌──────────────┐
│     n8n      │
└──────┬───────┘
       ↓
┌──────────────┐
│   AI Agent   │
└──────┬───────┘
       ↓
┌──────────────┐
│ Safety Logic │
└──────┬───────┘
       ↓
┌──────────────┐
│ Pump / Relay │
└──────────────┘

       n8n
        ├── Google Sheets
        ├── ThingSpeak
        └── Telegram
              ├── Text
              └── Voice

Main components

Hardware: ESP32, capacitive soil-moisture sensor, DHT22/DHT11, rain sensor, water-level sensor, relay, water pump and suitable power supply.

Software: Arduino IDE, ESP32 firmware, n8n, AI/LLM API, Telegram Bot, Google Sheets and ThingSpeak.

Important design principle

The AI should recommend irrigation, not directly control the pump. Sensor validation, tank-level checks, rain detection, maximum pump runtime and other safety rules should be enforced independently before the ESP32 activates the pump.

Final concept:

Sense → Analyze → Predict → Validate → Irrigate → Log → Notify → Verify

This makes the project an Agentic IoT smart irrigation system rather than simply an automatic moisture-based pump controller.

 

No comments:

Post a Comment