Thursday, 24 September 2026

AI Plant Disease Detection Robot using ESP32CAM

AI Plant Disease Detection Robot Using ESP32-CAM + IoT + AI Agent + n8n

Below is a complete project architecture you can use as a final-year engineering/college project, prototype, or research demonstrator. It combines:

  • ESP32-CAM for plant-image capture

  • AI-based plant disease detection

  • A mobile/PC IoT webpage

  • ESP32 sensor/actuator control

  • n8n automation

  • AI Agent for interpreting detections

  • Telegram notifications and voice alerts

  • Google Sheets logging

  • ThingSpeak cloud dashboard

  • Optional automatic irrigation

  • Web/API communication between the robot and cloud

Important design choice: ESP32-CAM is excellent for capturing and transmitting images, but running a modern image-classification model directly on the ESP32-CAM is constrained by memory and processing power. A practical architecture sends the image to an AI inference service and lets the ESP32 handle sensing, movement, camera capture, and actuators.


1. Project Title

AI-Powered Plant Disease Detection Robot Using ESP32-CAM with Agentic IoT, n8n Automation, Telegram Voice Alerts, Google Sheets and ThingSpeak

Short title

AI Plant Doctor Robot – ESP32-CAM + AI + IoT + n8n


2. Project Abstract

The proposed system is an autonomous IoT-enabled agricultural robot capable of monitoring plants, capturing plant images, detecting possible diseases using artificial intelligence, recording environmental parameters, and notifying the farmer through Telegram.

An ESP32-CAM provides image acquisition while sensors measure parameters such as soil moisture, temperature, humidity, and light intensity. When the robot identifies a plant or receives a scheduled inspection command, it captures an image and sends it to an AI inference server.

The AI model classifies the plant condition , for example:

  • Healthy

  • Leaf spot

  • Powdery mildew

  • Rust

  • Bacterial infection

  • Other classes included in the trained dataset

The resulting diagnosis and confidence are passed to an n8n automation workflow. n8n acts as the orchestration layer between the robot, AI service, database/cloud services, Telegram, and the AI Agent.

The workflow can:

  1. Receive plant data.

  2. Analyze the AI result.

  3. Decide whether an alert is necessary.

  4. Store the observation in Google Sheets.

  5. Send measurements to ThingSpeak.

  6. Send a Telegram message.

  7. Generate a voice notification.

  8. Send commands back to the robot.

  9. Trigger irrigation when predefined conditions are satisfied.

This produces an agentic IoT system, where the AI Agent can interpret sensor and disease information and select appropriate actions from predefined tools.


3. Overall System Architecture

                         ┌───────────────────────────┐
                         │       PLANT / FIELD       │
                         │                           │
                         │  Leaves                  │
                         │  Soil                    │
                         │  Environment             │
                         └─────────────┬─────────────┘
                                       │
                    ┌──────────────────┴──────────────────┐
                    │                                     │
                    ▼                                     ▼
          ┌───────────────────┐                 ┌─────────────────┐
          │    ESP32-CAM      │                 │ Sensors         │
          │                   │                 │                 │
          │ OV2640 Camera     │                 │ Soil Moisture   │
          │ Wi-Fi             │                 │ DHT22/BME280    │
          │ Image Capture     │                 │ LDR             │
          └─────────┬─────────┘                 └────────┬────────┘
                    │                                    │
                    └────────────────┬───────────────────┘
                                     │ Wi-Fi
                                     ▼
                         ┌──────────────────────┐
                         │   n8n / API Server   │
                         │                      │
                         │ Webhook              │
                         │ Automation            │
                         │ AI Agent              │
                         │ Decision Logic        │
                         └──────────┬───────────┘
                                    │
                  ┌─────────────────┼─────────────────┐
                  │                 │                 │
                  ▼                 ▼                 ▼
          ┌─────────────┐   ┌──────────────┐   ┌─────────────┐
          │ AI Vision   │   │ Google       │   │ ThingSpeak  │
          │ Model       │   │ Sheets       │   │ Dashboard   │
          │             │   │              │   │             │
          │ Image →     │   │ Historical   │   │ Graphs      │
          │ Disease     │   │ records      │   │ Monitoring  │
          └──────┬──────┘   └──────────────┘   └─────────────┘
                 │
                 ▼
          ┌─────────────────┐
          │   AI Agent      │
          │                 │
          │ Analyze result  │
          │ + sensor data   │
          │ + thresholds    │
          │                 │
          │ Select action   │
          └────────┬────────┘
                   │
                   ▼
             ┌──────────────┐
             │ n8n Router    │
             └──────┬───────┘
                    │
          ┌─────────┼─────────┐
          │         │         │
          ▼         ▼         ▼
      Telegram   Voice     ESP32
      Message    Alert     Command
          │                   │
          ▼                   ▼
       Farmer             Pump / Robot

4. Major Hardware Components

4.1 Controller

ESP32-CAM

Recommended because it provides:

  • Wi-Fi

  • Camera interface

  • GPIO

  • Compact size

  • Low cost

  • Image capture

  • HTTP communication

A common development board is the AI-Thinker ESP32-CAM with OV2640 camera.


4.2 Sensors

You can use:

Sensor Purpose
Soil moisture Determine irrigation requirement
DHT22 Temperature + humidity
BME280 Higher-quality temperature/humidity/pressure
LDR Light measurement
Ultrasonic Obstacle detection
IR sensor Line/plant detection
MQ sensor Optional environmental monitoring

For a student prototype, I recommend:

ESP32-CAM + capacitive soil-moisture sensor + DHT22/BME280 + ultrasonic sensor.


5. Actuators

Possible actuators include:

  • Water pump

  • Relay/MOSFET

  • DC motors

  • Motor driver

  • Servo motor

  • LED

  • Buzzer

The robot could therefore perform:

Move
 ↓
Find plant
 ↓
Stop
 ↓
Capture image
 ↓
Analyze plant
 ↓
Check soil
 ↓
AI decision
 ↓
Irrigate if appropriate
 ↓
Record result
 ↓
Notify farmer

6. Recommended Robot Structure

A simple two-wheel robot:

              FRONT
        ┌────────────────┐
        │   ESP32-CAM    │
        │      📷        │
        └────────────────┘

       ┌─────────────────────┐
       │                     │
       │      Battery        │
       │                     │
       │ ESP32 + Electronics │
       │                     │
       └─────────────────────┘

        O                   O
      Motor               Motor

              BACK

For a stationary plant-monitoring prototype, you can eliminate the motors entirely and mount the ESP32-CAM on a fixed stand.


7. ESP32-CAM Hardware Block Diagram

                 ┌─────────────────┐
                 │    ESP32-CAM    │
                 │                 │
                 │     ESP32       │
                 │                 │
                 │    OV2640       │
                 └───────┬─────────┘
                         │
          ┌──────────────┼──────────────┐
          │              │              │
          ▼              ▼              ▼
      Wi-Fi          Sensors         Actuators
          │              │              │
          │              │              │
          ▼              ▼              ▼
        n8n         Soil/DHT/etc.    Relay/Pump

8. Example Schematic

Because ESP32-CAM GPIO availability depends on the exact board and camera configuration, verify the pinout of your specific board before wiring.

A possible sensor architecture is:

                  ESP32-CAM
              ┌───────────────┐
              │               │
              │ GPIO ---------┼──── DHT22 DATA
              │               │
              │ GPIO ---------┼──── Soil Sensor
              │               │
              │ GPIO ---------┼──── Relay IN
              │               │
              │ GND ----------┼──── GND
              │ 5V/3.3V ------┼──── Sensor supply*
              │               │
              └───────────────┘

* Use the voltage specified by each sensor/module. Do not assume every sensor accepts 3.3 V.

Pump circuit

Do not power a water pump directly from an ESP32 GPIO.

Use:

ESP32 GPIO
    │
    ▼
MOSFET / Relay
    │
    ▼
External Pump Supply
    │
    ▼
   Pump

For a DC pump, a MOSFET driver and flyback diode are generally preferable to directly switching the pump from a GPIO.


9. Power Architecture

A practical system can use:

                 Battery
                    │
          ┌─────────┴──────────┐
          │                    │
          ▼                    ▼
     5V/USB regulator      Motor/Pump supply
          │                    │
          ▼                    ▼
      ESP32-CAM              Pump
          │
          ├── Sensors
          │
          └── Logic

Keep noisy loads such as motors and pumps electrically separated from sensitive logic as much as practical.


10. Software Architecture

ESP32 Firmware
      │
      │ HTTP / MQTT
      ▼
n8n Webhook
      │
      ├──── AI Vision
      │
      ├──── AI Agent
      │
      ├──── Google Sheets
      │
      ├──── ThingSpeak
      │
      └──── Telegram
                 │
                 ▼
             Farmer

11. AI Disease Detection

The central AI pipeline is:

Camera Image
     │
     ▼
Preprocessing
     │
     ├── Resize
     ├── Normalize
     └── Crop/segment leaf
     │
     ▼
AI Model
     │
     ▼
Classification
     │
     ├── Healthy
     ├── Disease A
     ├── Disease B
     └── Disease C
     │
     ▼
Confidence
     │
     ▼
Decision Layer

12. AI Model Options

There are several approaches.

Option A — Cloud/Server AI

ESP32-CAM sends the image to a server.

ESP32-CAM
    ↓
HTTP
    ↓
Python/FastAPI
    ↓
AI Model
    ↓
JSON

This is usually the easiest architecture for a prototype.


Option B — Edge AI

A smaller TensorFlow Lite / TensorFlow Lite Micro model can potentially run on suitable ESP32 hardware.

Architecture:

Camera
  ↓
Image preprocessing
  ↓
TinyML model
  ↓
Disease class

This reduces cloud dependence but requires considerably more attention to model size, image preprocessing, RAM, flash and inference time.


13. Recommended AI Response Format

Have the AI server return structured JSON.

{
  "plant": "tomato",
  "condition": "early_blight",
  "confidence": 0.91,
  "severity": "moderate",
  "recommendation": "Inspect affected leaves and monitor progression",
  "image_id": "IMG_001245",
  "timestamp": "2026-09-24T13:30:00Z"
}

This is much easier for n8n to process than unstructured text.


14. AI Agent Architecture

The AI Agent should not directly control arbitrary hardware.

Instead, expose controlled tools.

                   ┌─────────────────┐
                   │     AI Agent    │
                   └────────┬────────┘
                            │
             ┌──────────────┼─────────────┐
             │              │             │
             ▼              ▼             ▼
        get_sensor()   get_diagnosis()  send_alert()
             │              │             │
             └──────────────┼─────────────┘
                            │
                            ▼
                      decision JSON

For example:

{
  "action": "ALERT_AND_LOG",
  "irrigation": false,
  "message": "Possible tomato leaf disease detected",
  "priority": "medium"
}

15. Important Safety Rule for Irrigation

Do not allow the LLM alone to decide whether to operate a physical pump.

Use deterministic rules around the agent.

For example:

IF soil_moisture < 30%
AND pump_runtime < maximum_allowed_runtime
AND water_tank_level > minimum
AND irrigation_allowed = true

THEN pump ON

The AI Agent can provide interpretation, but hardware safety conditions should remain deterministic.


16. n8n Automation Architecture

The n8n workflow could look like:

                ┌──────────────┐
                │ Webhook      │
                │ ESP32        │
                └──────┬───────┘
                       │
                       ▼
               ┌───────────────┐
               │ Validate Data │
               └───────┬───────┘
                       │
                       ▼
              ┌──────────────────┐
              │ Image available? │
              └───────┬──────────┘
                      YES
                       │
                       ▼
              ┌─────────────────┐
              │ AI Vision API   │
              └────────┬────────┘
                       │
                       ▼
              ┌─────────────────┐
              │ AI Agent        │
              └────────┬────────┘
                       │
              ┌────────┼───────────┐
              │        │           │
              ▼        ▼           ▼
          Google     ThingSpeak  Telegram
          Sheets                 Alert
              │                    │
              │                    ▼
              │                 TTS/Voice
              │                    │
              └────────┬───────────┘
                       │
                       ▼
                ESP32 Command

17. n8n Workflow Nodes

A practical workflow:

1. Webhook
      ↓
2. Set / Code
      ↓
3. HTTP Request – AI Vision
      ↓
4. AI Agent
      ↓
5. Structured Output Parser
      ↓
6. IF – disease detected?
      ├── No → Google Sheets → ThingSpeak
      │
      └── Yes
            ↓
         Google Sheets
            ↓
         Telegram
            ↓
         Voice generation
            ↓
         Telegram Voice
            ↓
         ESP32 command

18. ESP32 → n8n API

The ESP32 can send:

POST /webhook/plant-monitor
Content-Type: application/json

Example:

{
  "device_id": "ESP32_PLANT_01",
  "temperature": 28.4,
  "humidity": 67.2,
  "soil_moisture": 34,
  "light": 720,
  "battery": 87,
  "image_url": "https://example.com/image.jpg"
}

19. ESP32-CAM Basic HTTP Code

Below is a starting framework rather than a complete board-specific production firmware.

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

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

const char* N8N_URL =
    "https://YOUR_N8N_HOST/webhook/plant-monitor";

void connectWiFi()
{
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

    Serial.print("Connecting");

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

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

void sendSensorData()
{
    if (WiFi.status() != WL_CONNECTED)
        return;

    HTTPClient http;

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

    String json = "{";
    json += "\"device_id\":\"ESP32_PLANT_01\",";
    json += "\"temperature\":28.4,";
    json += "\"humidity\":67.2,";
    json += "\"soil_moisture\":34";
    json += "}";

    int responseCode = http.POST(json);

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

    if (responseCode > 0)
    {
        Serial.println(http.getString());
    }

    http.end();
}

void setup()
{
    Serial.begin(115200);

    connectWiFi();
}

void loop()
{
    sendSensorData();

    delay(60000);
}

20. Adding Camera Capture

The ESP32-CAM camera initialization typically follows the ESP32 camera library structure.

Conceptually:

#include "esp_camera.h"

Then configure the camera pins for your specific ESP32-CAM board.

camera_config_t config;

config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 12;
config.fb_count = 1;

Then:

esp_err_t err = esp_camera_init(&config);

if (err != ESP_OK)
{
    Serial.println("Camera initialization failed");
}

Capture:

camera_fb_t *fb = esp_camera_fb_get();

if (!fb)
{
    Serial.println("Camera capture failed");
    return;
}

Serial.print("Image size: ");
Serial.println(fb->len);

esp_camera_fb_return(fb);

21. Better Image Transmission Architecture

Instead of embedding a large JPEG in JSON:

ESP32-CAM
    │
    ├── capture JPEG
    │
    ▼
Image storage/API
    │
    ▼
Image URL
    │
    ▼
n8n
    │
    ▼
AI Vision

The metadata can then contain:

{
  "image_url": "https://server/images/plant_001.jpg"
}

This simplifies n8n processing.


22. AI Vision Server

A Python FastAPI server is one possible implementation.

Install:

pip install fastapi uvicorn python-multipart pillow

Example:

from fastapi import FastAPI, UploadFile, File

app = FastAPI()

@app.post("/predict")
async def predict(file: UploadFile = File(...)):

    image_data = await file.read()

    # Load image
    # Preprocess image
    # Run trained model

    result = {
        "plant": "tomato",
        "condition": "healthy",
        "confidence": 0.94,
        "severity": "none"
    }

    return result

Run:

uvicorn main:app --host 0.0.0.0 --port 8000

Your actual model inference code would be inserted where indicated.


23. Example AI Classification Code Structure

from PIL import Image
import io

def preprocess(image_bytes):

    image = Image.open(io.BytesIO(image_bytes))

    image = image.convert("RGB")

    image = image.resize((224, 224))

    return image

Then:

def predict(image):

    # model.predict(...)
    #
    # Example only

    classes = [
        "healthy",
        "early_blight",
        "late_blight",
        "leaf_spot"
    ]

    probabilities = model.predict(image)

    index = probabilities.argmax()

    return {
        "condition": classes[index],
        "confidence": float(probabilities[index])
    }

24. AI Training Pipeline

If you train your own model:

Plant Images
     │
     ▼
Dataset
     │
     ▼
Labeling
     │
     ▼
Train / Validation / Test
     │
     ▼
Augmentation
     │
     ▼
CNN / MobileNet / EfficientNet
     │
     ▼
Evaluation
     │
     ▼
Export Model
     │
     ▼
Inference API

25. Dataset Structure

For example:

dataset/
│
├── train/
│   ├── healthy/
│   ├── early_blight/
│   ├── late_blight/
│   └── leaf_spot/
│
├── validation/
│   ├── healthy/
│   ├── early_blight/
│   ├── late_blight/
│   └── leaf_spot/
│
└── test/
    ├── healthy/
    ├── early_blight/
    ├── late_blight/
    └── leaf_spot/

26. Training Considerations

The model should be evaluated using:

  • Accuracy

  • Precision

  • Recall

  • F1 score

  • Confusion matrix

For agricultural deployment, test images should represent the actual camera conditions rather than relying exclusively on clean laboratory images.

For example:

Training image:
      Perfect lighting
          ↓
       Model

Real robot:
Sun + shadow + dust + background + leaf angle
          ↓
       Model

This domain difference can significantly affect performance.


27. AI Confidence Threshold

Do not treat every prediction as a definite diagnosis.

Example:

Confidence >= 0.85
        ↓
Possible high-confidence classification

0.60 – 0.85
        ↓
Needs monitoring / additional image

< 0.60
        ↓
Unknown / request another image

These are example thresholds and should be calibrated using your validation data.


28. AI Agent Prompt

A useful system prompt could be:

You are an agricultural IoT monitoring assistant.

You receive:
- plant identification
- AI image classification
- confidence
- soil moisture
- temperature
- humidity
- light level
- previous observations

Your responsibilities are:

1. Interpret the supplied observations.
2. Do not claim certainty when model confidence is low.
3. Recommend inspection when the result is uncertain.
4. Generate a concise farmer-friendly explanation.
5. Return structured JSON.
6. Never directly bypass hardware safety rules.
7. Irrigation commands must obey the deterministic safety constraints supplied by the system.

29. AI Agent Output

Example:

{
  "status": "ATTENTION",
  "plant": "tomato",
  "condition": "possible_early_blight",
  "confidence": 0.91,
  "severity": "moderate",
  "action": "inspect",
  "irrigation": false,
  "notify_farmer": true,
  "message": "Possible early blight detected on tomato foliage. Inspect affected leaves."
}

30. Google Sheets Structure

Create columns:

Timestamp Device Plant Disease Confidence Temperature Humidity Soil Action
2026-09-24 ESP32-01 Tomato Healthy 0.94 28.4 67 42 Monitor
2026-09-24 ESP32-01 Tomato Early blight 0.91 29.1 69 36 Inspect

This gives you a historical database.


31. ThingSpeak

ThingSpeak can be used for numerical IoT telemetry.

Example channel fields:

Field 1 = Temperature
Field 2 = Humidity
Field 3 = Soil Moisture
Field 4 = Light
Field 5 = Disease Confidence
Field 6 = Disease Code
Field 7 = Battery

The architecture becomes:

ESP32
  │
  ▼
n8n
  │
  ▼
ThingSpeak
  │
  ▼
Charts

32. Telegram Notification

Example notification:

🌱 PLANT MONITOR ALERT

Device: ESP32_PLANT_01

Plant: Tomato
Condition: Possible early blight
Confidence: 91%

Temperature: 28.4 °C
Humidity: 67%
Soil moisture: 36%

Action:
Inspect affected leaves.

Time:
24 Sep 2026, 13:30

33. Telegram Voice Alert

For a voice alert:

AI Agent
    ↓
Text
    ↓
Text-to-Speech
    ↓
Audio file
    ↓
n8n
    ↓
Telegram
    ↓
Farmer's phone

Example spoken message:

"Attention. Possible tomato leaf disease has been detected. Please inspect the affected plant."

The voice should clearly indicate that this is an AI-assisted detection, not necessarily a confirmed plant pathology diagnosis.


34. n8n Telegram Workflow

AI Agent
    │
    ▼
IF notify_farmer == true
    │
    ▼
Create notification text
    │
    ├───────────────┐
    │               │
    ▼               ▼
Telegram Text    Text-to-Speech
                    │
                    ▼
               Audio file
                    │
                    ▼
              Telegram Voice

35. Telegram Command → Robot

You can also make the system bidirectional.

Farmer
   │
   │ Telegram
   ▼
n8n
   │
   ▼
AI Agent
   │
   ▼
Command validation
   │
   ▼
ESP32

Example commands:

/status
/photo
/soil
/temperature
/inspect
/pump
/stop

36. Example Command Architecture

Telegram: /photo
       │
       ▼
      n8n
       │
       ▼
HTTP request
       │
       ▼
ESP32-CAM
       │
       ▼
Capture image
       │
       ▼
Upload
       │
       ▼
AI analysis
       │
       ▼
Telegram result

37. IoT Webpage

A simple web dashboard could contain:

┌───────────────────────────────────────────────┐
│         🌱 AI PLANT MONITOR                  │
├───────────────────────────────────────────────┤
│                                               │
│  Camera                                      │
│  ┌──────────────────────┐                    │
│  │                      │                    │
│  │       PLANT          │                    │
│  │       IMAGE          │                    │
│  │                      │                    │
│  └──────────────────────┘                    │
│                                               │
│  Plant: Tomato                                │
│  Condition: Possible Leaf Disease             │
│  Confidence: 91%                              │
│                                               │
│  Temperature     28.4 °C                     │
│  Humidity        67 %                        │
│  Soil            36 %                        │
│                                               │
│  [ TAKE PHOTO ]  [ INSPECT ]                 │
│                                               │
│  Pump: OFF                                    │
│  Robot: ONLINE                                │
└───────────────────────────────────────────────┘

38. Simple HTML Dashboard

<!DOCTYPE html>
<html>
<head>
    <title>AI Plant Monitor</title>

    <style>
        body {
            font-family: Arial;
            background: #eef7ee;
            margin: 0;
            padding: 20px;
        }

        .container {
            max-width: 900px;
            margin: auto;
        }

        .card {
            background: white;
            padding: 20px;
            margin: 15px 0;
            border-radius: 12px;
            box-shadow: 0 2px 10px #bbb;
        }

        .value {
            font-size: 28px;
            color: #198754;
        }

        button {
            padding: 12px 20px;
            margin: 5px;
            cursor: pointer;
        }
    </style>
</head>

<body>

<div class="container">

<h1>🌱 AI Plant Monitor</h1>

<div class="card">

<h2>Plant Diagnosis</h2>

<p>
Condition:
<span id="condition">Waiting...</span>
</p>

<p>
Confidence:
<span id="confidence">--</span>
</p>

</div>

<div class="card">

<h2>Environment</h2>

<p>
Temperature:
<span class="value" id="temperature">--</span>
°C
</p>

<p>
Humidity:
<span class="value" id="humidity">--</span>
%
</p>

<p>
Soil:
<span class="value" id="soil">--</span>
%
</p>

</div>

<div class="card">

<button onclick="takePhoto()">
Take Photo
</button>

<button onclick="inspectPlant()">
Inspect Plant
</button>

<button onclick="stopRobot()">
STOP
</button>

</div>

</div>

<script>

async function takePhoto() {

    await fetch("/api/photo", {
        method: "POST"
    });

    alert("Photo requested");
}

async function inspectPlant() {

    await fetch("/api/inspect", {
        method: "POST"
    });

    alert("Inspection requested");
}

async function stopRobot() {

    await fetch("/api/stop", {
        method: "POST"
    });

    alert("Robot stopped");
}

</script>

</body>
</html>

39. Complete Communication Flow

                  USER
                   │
             Web Dashboard
                   │
                   ▼
              ┌─────────┐
              │   n8n   │
              └────┬────┘
                   │
         ┌─────────┴─────────┐
         │                   │
         ▼                   ▼
      ESP32-CAM          AI Service
         │                   │
         │ image             │
         └──────────┬────────┘
                    ▼
                AI Result
                    │
                    ▼
                AI Agent
                    │
          ┌─────────┼──────────┐
          │         │          │
          ▼         ▼          ▼
       Sheets   ThingSpeak  Telegram
                               │
                               ▼
                          Voice Alert

40. Complete Robot Operating Sequence

Step 1 — Start

ESP32 boots.

BOOT
 ↓
Initialize sensors
 ↓
Initialize camera
 ↓
Connect Wi-Fi
 ↓
Register device

Step 2 — Monitoring

Read sensors
 ↓
Check robot status
 ↓
Wait for inspection

Step 3 — Inspection

Inspection request
 ↓
Stop motors
 ↓
Position camera
 ↓
Capture image

Step 4 — AI

Image
 ↓
AI inference
 ↓
Disease + confidence

Step 5 — Decision

AI result
     +
Sensor data
     ↓
Decision engine

Step 6 — Cloud

Save
 ↓
Google Sheets
 ↓
ThingSpeak

Step 7 — Notification

Disease detected
 ↓
Telegram text
 ↓
Telegram voice

Step 8 — Robot action

Decision
 ↓
Safety checks
 ↓
Pump/movement/action

41. Complete Data Flow Diagram

                     ┌───────────────┐
                     │    PLANT      │
                     └───────┬───────┘
                             │
                             ▼
                     ┌───────────────┐
                     │ ESP32-CAM     │
                     │ Camera        │
                     └───────┬───────┘
                             │
                             │ Image
                             ▼
                     ┌───────────────┐
                     │ AI Vision     │
                     │ Model         │
                     └───────┬───────┘
                             │
                       Prediction
                             │
                             ▼
                     ┌───────────────┐
                     │ n8n           │
                     │ Orchestrator  │
                     └───────┬───────┘
                             │
                             ▼
                     ┌───────────────┐
                     │ AI Agent      │
                     └───────┬───────┘
                             │
               ┌─────────────┼──────────────┐
               │             │              │
               ▼             ▼              ▼
          Google Sheets  ThingSpeak     Telegram
               │                            │
               │                            ▼
               │                         Voice
               │
               ▼
           Historical
             Data

42. Complete Control Flow

                 START
                   │
                   ▼
             Initialize ESP32
                   │
                   ▼
              Connect Wi-Fi
                   │
                   ▼
              Read Sensors
                   │
                   ▼
          Inspection Required?
              /           \
            NO             YES
            │               │
            │               ▼
            │         Capture Image
            │               │
            │               ▼
            │          Send to AI
            │               │
            │               ▼
            │         Disease Result
            │               │
            │               ▼
            │          AI Agent
            │               │
            │        ┌──────┴───────┐
            │        │              │
            │        ▼              ▼
            │      Normal        Attention
            │        │              │
            │        │              ▼
            │        │        Telegram Alert
            │        │              │
            │        │              ▼
            │        │        Voice Alert
            │        │
            └────────┴───────┐
                             ▼
                        Log Data
                             │
                             ▼
                         LOOP

43. Recommended Project Directory

AI_Plant_Robot/
│
├── firmware/
│   ├── esp32_camera/
│   │   ├── main.ino
│   │   ├── camera.cpp
│   │   ├── camera.h
│   │   ├── sensors.cpp
│   │   └── sensors.h
│   │
│   └── robot_controller/
│
├── ai_server/
│   ├── main.py
│   ├── model.py
│   ├── preprocessing.py
│   ├── requirements.txt
│   └── models/
│
├── web/
│   ├── index.html
│   ├── style.css
│   └── app.js
│
├── n8n/
│   └── plant_monitor_workflow.json
│
├── dataset/
│   ├── train/
│   ├── validation/
│   └── test/
│
├── documentation/
│   ├── architecture.md
│   ├── installation.md
│   ├── testing.md
│   └── final_report.md
│
└── README.md

44. Database/Logging Schema

Recommended fields:

id
timestamp
device_id
plant_id
plant_type
image_url
predicted_disease
confidence
temperature
humidity
soil_moisture
light
battery
robot_status
pump_status
agent_action
notification_sent

45. Example Complete Record

{
  "timestamp": "2026-09-24T13:40:00+05:30",
  "device_id": "ESP32_PLANT_01",
  "plant_id": "TOMATO_007",
  "plant_type": "tomato",
  "predicted_disease": "possible_early_blight",
  "confidence": 0.91,
  "temperature": 28.4,
  "humidity": 67.2,
  "soil_moisture": 36,
  "light": 720,
  "battery": 87,
  "robot_status": "ONLINE",
  "pump_status": "OFF",
  "agent_action": "INSPECT",
  "notification_sent": true
}

46. Security

Do not put sensitive credentials directly into publicly shared firmware.

Avoid:

const char* BOT_TOKEN = "...";
const char* API_KEY = "...";

for a project that will be published publicly.

Instead:

ESP32
  │
  │ authenticated request
  ▼
n8n
  │
  ├── Telegram credentials
  ├── Google credentials
  ├── AI API credentials
  └── ThingSpeak credentials

n8n can act as the credential-protected backend.

Use:

  • HTTPS

  • webhook authentication

  • API keys/tokens

  • secret management

  • device authentication

  • rate limiting


47. Error Handling

The system should handle:

Camera failure

Capture failed
 ↓
Retry
 ↓
If repeated failure
 ↓
Telegram "Camera offline"

Wi -Fi failure

Wi-Fi lost
 ↓
Retry connection
 ↓
Store essential local data
 ↓
Upload when connection returns

AI failure

AI API unavailable
 ↓
Do not claim disease
 ↓
Log "AI unavailable"
 ↓
Notify operator if necessary

Low confidence

confidence < threshold
 ↓
"Uncertain"
 ↓
Request another image

48. Example n8n Logic

Conceptually:

const confidence = Number($json.confidence || 0);

let status;

if (confidence >= 0.85) {
    status = "HIGH_CONFIDENCE";
}
else if (confidence >= 0.60) {
    status = "REVIEW";
}
else {
    status = "UNCERTAIN";
}

return [{
    json: {
        ...$json,
        status
    }
}];

49. Example Decision Logic

const disease = $json.condition;
const confidence = Number($json.confidence);
const soil = Number($json.soil_moisture);

let notify = false;
let irrigation = false;

if (confidence >= 0.85 &&
    disease !== "healthy") {

    notify = true;
}

if (soil < 30) {
    irrigation = true;
}

return [{
    json: {
        disease,
        confidence,
        notify,
        irrigation
    }
}];

In a real deployment, irrigation should additionally be protected by hardware-side limits and explicit safety conditions.


50. Robot Safety State Machine

              ┌─────────────┐
              │    IDLE     │
              └──────┬──────┘
                     │
                  Inspect
                     │
                     ▼
              ┌─────────────┐
              │  CAPTURE    │
              └──────┬──────┘
                     │
                     ▼
              ┌─────────────┐
              │  ANALYZE    │
              └──────┬──────┘
                     │
          ┌──────────┴──────────┐
          ▼                     ▼
      NORMAL                  ALERT
          │                     │
          │                     ▼
          │              ┌────────────┐
          │              │ NOTIFY     │
          │              └─────┬──────┘
          │                    │
          └──────────┬─────────┘
                     ▼
                   IDLE

51. Suggested Final-Year Project Modules

Divide the project into these modules:

Module 1 — Robot

  • ESP32-CAM

  • Motors

  • Motor driver

  • Battery

  • Chassis

Module 2 — Sensors

  • Soil moisture

  • Temperature

  • Humidity

  • Light

Module 3 — Computer Vision

  • Camera

  • Dataset

  • AI model

  • Classification API

Module 4 — IoT

  • Wi-Fi

  • REST API

  • n8n

  • ThingSpeak

Module 5 — AI Agent

  • AI reasoning

  • Structured outputs

  • Tool calls

  • Decision orchestration

Module 6 — Notification

  • Telegram

  • Text notification

  • Voice notification

Module 7 — Cloud Logging

  • Google Sheets

  • ThingSpeak

  • Historical observations

Module 8 — Web Dashboard

  • Plant image

  • Diagnosis

  • Sensors

  • Robot status

  • Controls


52. Project Demonstration Scenario

For a college demonstration, prepare three plants/images:

Plant 1
Healthy
 ↓
AI → Healthy
 ↓
No disease alert
 ↓
Google Sheets

Plant 2
Disease image
 ↓
AI → Possible disease
 ↓
n8n
 ↓
Telegram text
 ↓
Telegram voice
 ↓
Google Sheets

Plant 3
Dry soil
 ↓
Soil < threshold
 ↓
Safety checks
 ↓
Pump ON
 ↓
Soil becomes wet
 ↓
Pump OFF
 ↓
Log event

This demonstrates the complete chain.


53. Example Telegram Conversation

FARMER:
 /status

BOT:
🌱 Plant Monitor

Robot: ONLINE
Temperature: 28.4°C
Humidity: 67%
Soil: 36%
Battery: 87%

Latest diagnosis:
Possible early blight
Confidence: 91%

Then:

FARMER:
 /photo

Bot:

📷 New image captured.

Analyzing plant...

Then:

BOT:
🌱 AI Analysis Complete

Plant: Tomato
Result: Possible early blight
Confidence: 91%

Recommendation:
Inspect the affected leaves.

A record has been added to the monitoring log.

54. Agentic IoT Concept

The project becomes more than a simple IoT sensor because the system has multiple tools:

                  AI AGENT
                     │
       ┌─────────────┼─────────────┐
       │             │             │
       ▼             ▼             ▼
 Get Sensor      Analyze Image   Get History
       │             │             │
       └─────────────┼─────────────┘
                     │
                     ▼
                 Decision
                     │
       ┌─────────────┼──────────────┐
       ▼             ▼              ▼
    Log Data      Notify         Robot Action

The important engineering principle is that the agent should operate within well-defined tools and safety constraints, rather than having unrestricted control of the robot.


55. Full System in One Diagram

                         🌱 PLANT
                            │
                            ▼
                    ┌───────────────┐
                    │  ESP32-CAM    │
                    │               │
                    │ 📷 Camera     │
                    │ 🌡 Sensors    │
                    │ 💧 Soil       │
                    └───────┬───────┘
                            │
                         Wi-Fi
                            │
                            ▼
                    ┌───────────────┐
                    │     n8n       │
                    │ Automation    │
                    └───────┬───────┘
                            │
              ┌─────────────┼──────────────┐
              │             │              │
              ▼             ▼              ▼
        ┌──────────┐  ┌───────────┐  ┌────────────┐
        │ AI Vision│  │ Sensors   │  │ Dashboard  │
        │          │  │           │  │            │
        │ Disease  │  │ Temp      │  │ Web        │
        │ Model    │  │ Humidity  │  │ Interface  │
        └────┬─────┘  │ Soil      │  └────────────┘
             │        └─────┬─────┘
             │              │
             └──────┬───────┘
                    ▼
             ┌──────────────┐
             │   AI AGENT   │
             │              │
             │ Reasoning    │
             │ Decision     │
             └──────┬───────┘
                    │
       ┌────────────┼─────────────┐
       │            │             │
       ▼            ▼             ▼
 Google Sheets  ThingSpeak    Telegram
       │                          │
       │                          ├── Text
       │                          │
       │                          └── Voice
       │
       ▼
 Historical Data

                    AI Agent
                       │
                       ▼
               Safety Controller
                       │
                ┌──────┴──────┐
                ▼             ▼
              Pump          Robot

56. Development Roadmap

Build it in this order rather than attempting everything simultaneously.

Phase 1 — ESP32

Get:

ESP32-CAM
 ↓
Camera
 ↓
Wi-Fi
 ↓
Web page

working first.

Phase 2 — Sensors

Add:

DHT/BME
+
Soil sensor
+
Light sensor

and display values.

Phase 3 — Backend

Build:

ESP32
 ↓
n8n Webhook

and verify JSON communication.

Phase 4 — AI

Build:

Image
 ↓
AI server
 ↓
JSON diagnosis

Phase 5 — Automation

Connect:

AI
 ↓
n8n
 ↓
Google Sheets

Phase 6 — ThingSpeak

Add telemetry.

Phase 7 — Telegram

Add text alerts.

Phase 8 — Voice

Add TTS + Telegram voice messages.

Phase 9 — AI Agent

Add structured reasoning/tool calls.

Phase 10 — Robot

Add motors/pump and enforce hardware safety.


57. Testing Plan

Test Expected result
ESP32 boot Successful startup
Camera Image captured
Wi-Fi Connected
Sensor Correct values
n8n webhook JSON received
AI server Prediction returned
Low confidence Marked uncertain
Disease Alert generated
Google Sheets Row inserted
ThingSpeak Telemetry uploaded
Telegram Message received
Voice Audio received
Pump Operates only under permitted conditions
Wi-Fi failure Recovery attempted
AI failure No false diagnosis

58. Evaluation Metrics

For the AI:

Accuracy
Precision
Recall
F1 Score
Confusion Matrix
Inference Time

For IoT:

Sensor accuracy
Communication latency
Packet success rate
System uptime

For automation:

Workflow execution time
Notification latency
API failure rate
Recovery success rate

For robotics:

Navigation accuracy
Obstacle detection
Battery life
Pump response
Camera positioning accuracy

59. Expected Output

The final prototype should be capable of:

                 AI PLANT ROBOT
                       │
          ┌────────────┼────────────┐
          │            │            │
       SENSE         SEE          ACT
          │            │            │
          ▼            ▼            ▼
       Sensors      Camera       Pump/Motor
          │            │            │
          └────────────┼────────────┘
                       ▼
                      AI
                       │
                       ▼
                     n8n
                       │
       ┌───────────────┼──────────────┐
       ▼               ▼              ▼
   Dashboard       Google Sheets   Telegram
                                       │
                                       ▼
                                    Voice

60. Suggested Project Report Chapters

For your final documentation/report, use:

Chapter 1 — Introduction

  • Agriculture automation

  • Plant disease problem

  • IoT

  • AI

  • Project motivation

Chapter 2 — Literature Survey

  • Plant disease detection

  • Computer vision

  • ESP32

  • IoT agriculture

  • AI agents

  • Workflow automation

Chapter 3 — Proposed System

  • Objectives

  • Architecture

  • System requirements

  • Functional requirements

Chapter 4 — Hardware Design

  • ESP32-CAM

  • Sensors

  • Motor driver

  • Pump

  • Power supply

  • Circuit diagrams

Chapter 5 — Software Design

  • ESP32 firmware

  • API

  • n8n

  • AI server

  • AI Agent

  • Telegram

  • Web dashboard

Chapter 6 — AI Model

  • Dataset

  • Preprocessing

  • Training

  • Validation

  • Testing

  • Confusion matrix

Chapter 7 — IoT Automation

  • n8n workflow

  • Google Sheets

  • ThingSpeak

  • Telegram

  • Voice alerts

Chapter 8 — Implementation

  • Hardware assembly

  • Firmware

  • AI integration

  • Cloud integration

Chapter 9 — Results

  • AI performance

  • Sensor performance

  • Notification latency

  • Robot performance

Chapter 10 — Limitations

  • Lighting

  • Camera quality

  • Model generalization

  • Network dependence

  • False positives/negatives

Chapter 11 — Future Scope

  • Multi-camera robot

  • Edge AI

  • Autonomous navigation

  • More crops

  • Disease severity estimation

  • Drone integration

  • Larger agricultural deployment

Chapter 12 — Conclusion


61. Final Project Concept

The complete project can be summarized as:

              ┌───────────────────────────┐
              │       AI PLANT ROBOT      │
              └─────────────┬─────────────┘
                            │
            ┌───────────────┼────────────────┐
            │               │                │
            ▼               ▼                ▼
          SENSE             SEE             MOVE
            │               │                │
      DHT/BME/Soil      ESP32-CAM          Motors
            │               │
            └───────────────┘
                    │
                    ▼
                 Wi-Fi
                    │
                    ▼
              ┌───────────┐
              │    n8n    │
              └─────┬─────┘
                    │
             ┌──────┴──────┐
             ▼             ▼
          AI Vision     Sensor Data
             │             │
             └──────┬──────┘
                    ▼
                 AI Agent
                    │
             ┌──────┼───────┐
             ▼      ▼       ▼
           LOG    ALERT    ACT
             │      │       │
             ▼      ▼       ▼
          Sheets Telegram Pump
                   │
                   ▼
              Voice Alert

             + ThingSpeak
             + Web Dashboard

This gives you a coherent ESP32-CAM + AI vision + agentic IoT + n8n + Telegram + Google Sheets + ThingSpeak project rather than treating those technologies as separate features.

If you implement it for a real agricultural application, keep the AI output framed as screening/decision support unless the model has been appropriately validated for the specific crops, diseases, camera conditions, and deployment environment.

 

No comments:

Post a Comment