Thursday, 24 September 2026

AI Powered EV Bidirectional Charging System with Smart Grid

Yes . This can be designed as a complete AI-powered bidirectional EV charging + Smart Grid + IoT + ESP32 + n8n + Telegram + Google Sheets + ThingSpeak project.

I would structure the project as a modular system so that the power electronics, ESP32 control, cloud/IoT layer, automation, and AI agent are separated. That makes the prototype much safer to develop and easier to demonstrate.

1. Project title

AI-Powered Bidirectional EV Charging System with Smart Grid, ESP32, IoT Cloud, n8n Automation and AI Agent

Short description

The system is an IoT-enabled bidirectional EV charging prototype in which an ESP32 monitors electrical parameters and controls a bidirectional charger/inverter. The system can operate in:

  • G2V — Grid to Vehicle: charge the EV.

  • V2G — Vehicle to Grid: discharge energy from the EV toward the grid/load.

  • V2H — Vehicle to Home: use EV energy to supply a local load.

  • Smart charging: schedule charging according to grid conditions, electricity price, battery SOC, solar generation, etc.

  • AI-assisted operation: an AI agent analyzes system information and recommends/initiates permitted actions.

  • IoT monitoring: measurements are sent to a cloud dashboard.

  • n8n automation: events trigger workflows.

  • Telegram: alarms and voice notifications are delivered to the operator.

  • Google Sheets: operating data and events can be logged.

  • ThingSpeak: electrical/IoT data can be visualized.

  • Web dashboard: provides live status, controls, graphs and historical information.


2. Important architecture decision

For a student/research prototype, I strongly recommend not connecting an ESP32 directly to mains voltage or directly switching a high-power EV battery.

Instead use three layers:

                 ┌─────────────────────────────┐
                 │        USER / OPERATOR       │
                 │ Web Dashboard / Telegram     │
                 └──────────────┬──────────────┘
                                │
                                ▼
                 ┌─────────────────────────────┐
                 │      AI + AUTOMATION         │
                 │                              │
                 │ n8n + AI Agent + Rules       │
                 └──────────────┬──────────────┘
                                │
              ┌─────────────────┼──────────────────┐
              │                 │                  │
              ▼                 ▼                  ▼
        Google Sheets      ThingSpeak          Telegram
              │                 │                  │
              └─────────────────┼──────────────────┘
                                │
                                ▼
                 ┌─────────────────────────────┐
                 │           ESP32              │
                 │                             │
                 │ Sensors + Control + MQTT    │
                 └──────────────┬──────────────┘
                                │
                                ▼
                 ┌─────────────────────────────┐
                 │   Isolated Power Interface   │
                 │                             │
                 │ Contactors / Drivers /      │
                 │ Protection / Interlocks     │
                 └──────────────┬──────────────┘
                                │
                                ▼
                 ┌─────────────────────────────┐
                 │   BIDIRECTIONAL POWER STAGE │
                 │                             │
                 │ AC ↔ DC / DC ↔ Battery     │
                 └──────────────┬──────────────┘
                                │
                                ▼
                       ┌─────────────────┐
                       │ EV Battery /    │
                       │ Battery Emulator│
                       └─────────────────┘

For an initial prototype, the power stage can be represented by a low-voltage isolated DC/DC converter or laboratory power converter, while the ESP32/IoT/AI architecture is developed completely.


3. Overall system block diagram

                         SMART GRID
                             │
                             │ AC
                             ▼
                    ┌─────────────────┐
                    │ Grid Meter / CT │
                    │ Voltage Sensor  │
                    │ Current Sensor  │
                    └────────┬────────┘
                             │
                             ▼
                 ┌────────────────────────┐
                 │ BIDIRECTIONAL CHARGER  │
                 │                        │
                 │ AC/DC + DC/DC stage    │
                 └───────────┬────────────┘
                             │
                   DC        │
                             ▼
                  ┌────────────────────┐
                  │ EV Battery /       │
                  │ Battery Emulator   │
                  └────────────────────┘
                             ▲
                             │
                      SOC / Voltage /
                      Current / Temp
                             │
                             ▼
                     ┌──────────────┐
                     │    ESP32     │
                     │              │
                     │ ADC          │
                     │ GPIO         │
                     │ Wi-Fi        │
                     │ MQTT/HTTP    │
                     └──────┬───────┘
                            │
                     Internet/Wi-Fi
                            │
                            ▼
                  ┌─────────────────────┐
                  │      n8n SERVER     │
                  │                     │
                  │ Trigger             │
                  │ AI Agent             │
                  │ Rules                │
                  │ Database             │
                  │ Notifications        │
                  └───┬─────┬─────┬─────┘
                      │     │     │
            ┌─────────┘     │     └──────────┐
            ▼               ▼                ▼
       Telegram        Google Sheets     ThingSpeak
       Alerts          Data Logging      Dashboard
            │
            ▼
      Voice Notification

                         ▲
                         │
                  ┌──────┴───────┐
                  │ Web Dashboard│
                  │              │
                  │ SOC          │
                  │ Power        │
                  │ Voltage      │
                  │ Current      │
                  │ Mode         │
                  │ Alarms       │
                  └──────────────┘

4. Operating modes

Mode 1 — G2V

Grid supplies energy to the EV.

GRID
 │
 ▼
AC/DC
 │
 ▼
DC BUS
 │
 ▼
BATTERY

The ESP32 monitors:

  • Grid voltage

  • Grid current

  • Charging power

  • Battery voltage

  • Battery current

  • Battery temperature

  • SOC

  • Charging status


Mode 2 — V2G

The EV supplies energy back toward the grid.

BATTERY
   │
   ▼
DC/DC
   │
   ▼
DC/AC
   │
   ▼
GRID

The controller must ensure that the appropriate electrical protection, synchronization, isolation and certified grid-interconnection hardware are present.

For a prototype, this should initially be simulated or implemented using an approved bidirectional power converter, rather than constructing an uncertified grid-tied inverter.


Mode 3 — V2H

The EV supplies a local load.

             ┌───────────────┐
             │ EV BATTERY    │
             └───────┬───────┘
                     │
                     ▼
               BIDIRECTIONAL
                 CONVERTER
                     │
                     ▼
                 HOME LOAD

Example:

EV → inverter → AC load

5. AI agent concept

The AI agent should not have unrestricted control of the power electronics.

Instead:

                 AI AGENT
                    │
                    ▼
             ┌──────────────┐
             │ Decision     │
             │ / Reasoning  │
             └──────┬───────┘
                    │
                    ▼
              SAFETY RULES
                    │
          ┌─────────┴──────────┐
          │                    │
       ALLOWED              BLOCKED
          │                    │
          ▼                    ▼
      ESP32 command        Alarm / log

For example, the AI could receive:

{
  "soc": 78,
  "battery_voltage": 52.4,
  "battery_current": 8.2,
  "temperature": 31.5,
  "grid_power": 1200,
  "solar_power": 3500,
  "mode": "charging"
}

The AI might produce a structured recommendation:

{
  "recommended_mode": "V2H",
  "reason": "Solar generation is low and battery SOC is sufficient",
  "requested_power_w": 800
}

But the safety controller decides whether the command is actually permitted.


6. AI decision architecture

Use this hierarchy:

                    AI AGENT
                       │
                       ▼
               High-level decision
                       │
                       ▼
               POLICY ENGINE
                       │
                 ┌─────┴─────┐
                 │           │
              SAFE          UNSAFE
                 │           │
                 ▼           ▼
             COMMAND       REJECT
                 │           │
                 ▼           ▼
               ESP32       ALERT
                 │
                 ▼
           HARDWARE SAFETY
                 │
          ┌──────┴──────┐
          │             │
        ENABLE        TRIP
          │             │
          ▼             ▼
       POWER         CONTACTOR OFF

This is much better than allowing an LLM to directly control GPIO pins.


7. Hardware architecture

A practical prototype can contain:

Controller

  • ESP32 development board

  • Wi-Fi

  • MQTT or HTTP

  • OLED/LCD display, optional

  • status LEDs

  • buzzer

Sensors

Depending on the prototype:

  • Voltage sensor

  • Current sensor

  • Temperature sensor

  • Battery voltage measurement

  • Battery current measurement

  • SOC information from BMS

  • AC power meter

  • Grid frequency measurement

  • Solar generation measurement

Protection

Use appropriate hardware-rated protection such as:

  • Fuse

  • MCB

  • DC fuse

  • Contactor

  • Emergency-stop circuit

  • Overcurrent protection

  • Overvoltage protection

  • Undervoltage protection

  • Thermal protection

  • Isolation

  • Reverse-polarity protection

  • BMS protection

The exact protection components must be selected based on the actual voltage/current/power rating of the prototype.


8. ESP32 wiring concept

A simplified low-voltage prototype could look like:

                     ESP32
              ┌─────────────────┐
              │                 │
 Voltage ---->│ ADC             │
 Sensor       │                 │
              │                 │
 Current ---->│ ADC             │
 Sensor       │                 │
              │                 │
 Temp ------->│ GPIO/ADC        │
 Sensor       │                 │
              │                 │
 BMS -------->│ UART            │
              │                 │
              │ Wi-Fi           │────────── Internet
              │                 │
              │ GPIO            │
              └───────┬─────────┘
                      │
              ┌───────▼────────┐
              │ Isolated Driver│
              └───────┬────────┘
                      │
                      ▼
                  CONTACTOR
                      │
                      ▼
                 POWER STAGE

Do not connect mains voltage directly to an ESP32 ADC. Use suitably rated, isolated measurement equipment/modules .


9. Suggested ESP32 pin assignment

Example only:

Function ESP32
Battery voltage GPIO34 / ADC
Battery current GPIO35 / ADC
Temperature GPIO32
Emergency input GPIO27
Contactor enable GPIO26
Charger enable GPIO25
Status LED GPIO2
BMS UART RX GPIO16
BMS UART TX GPIO17
I2C SDA GPIO21
I2C SCL GPIO22

The actual pinout should be adapted to the particular ESP32 board and peripherals.


10. Software architecture

ESP32
 │
 ├── Sensor acquisition
 │
 ├── Filtering
 │
 ├── Local safety checks
 │
 ├── State machine
 │
 ├── Wi-Fi
 │
 ├── MQTT/HTTP
 │
 └── Command receiver
         │
         ▼
       n8n
         │
    ┌────┼──────────────┐
    │    │              │
    ▼    ▼              ▼
   AI   Database      Alerts
 Agent
    │
    ├──────────► Telegram
    │
    ├──────────► Google Sheets
    │
    └──────────► ThingSpeak

11. ESP32 state machine

A state machine makes the system much more reliable.

                 ┌────────────┐
                 │    INIT    │
                 └─────┬──────┘
                       ▼
                 ┌────────────┐
                 │ SELF CHECK │
                 └─────┬──────┘
                       │
                  PASS │
                       ▼
                 ┌────────────┐
                 │    IDLE    │
                 └─────┬──────┘
                       │
            ┌──────────┼───────────┐
            ▼          ▼           ▼
         CHARGE      V2H         V2G*
            │          │           │
            └──────────┼───────────┘
                       ▼
                 ┌────────────┐
                 │ MONITORING │
                 └─────┬──────┘
                       │
                Fault detected
                       ▼
                 ┌────────────┐
                 │    FAULT   │
                 └─────┬──────┘
                       │
                       ▼
                 SAFE SHUTDOWN

* V2G should only be enabled with an appropriate certified/isolated grid interface.


12. ESP32 example firmware

Below is a prototype-level firmware skeleton. It demonstrates the IoT/control architecture rather than providing a mains-connected charger controller.

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

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

const int VOLTAGE_PIN = 34;
const int CURRENT_PIN = 35;
const int TEMP_PIN    = 32;

const int CHARGER_ENABLE = 25;
const int CONTACTOR      = 26;
const int STATUS_LED     = 2;
const int ESTOP_PIN      = 27;

float batteryVoltage = 0.0;
float batteryCurrent = 0.0;
float temperature = 0.0;
float power = 0.0;

String operatingMode = "IDLE";

unsigned long lastUpload = 0;

void setup() {

  Serial.begin(115200);

  pinMode(CHARGER_ENABLE, OUTPUT);
  pinMode(CONTACTOR, OUTPUT);
  pinMode(STATUS_LED, OUTPUT);

  pinMode(ESTOP_PIN, INPUT_PULLUP);

  digitalWrite(CHARGER_ENABLE, LOW);
  digitalWrite(CONTACTOR, LOW);

  WiFi.begin(WIFI_SSID, WIFI_PASS);

  Serial.print("Connecting WiFi");

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

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

void readSensors() {

  int voltageRaw = analogRead(VOLTAGE_PIN);
  int currentRaw = analogRead(CURRENT_PIN);
  int tempRaw    = analogRead(TEMP_PIN);

  /*
     Replace these equations with calibration
     equations for your actual isolated sensors.
  */

  batteryVoltage = voltageRaw * 0.01;
  batteryCurrent = currentRaw * 0.01;
  temperature    = tempRaw * 0.1;

  power = batteryVoltage * batteryCurrent;
}

bool safetyCheck() {

  if (digitalRead(ESTOP_PIN) == LOW) {
    return false;
  }

  if (temperature > 50.0) {
    return false;
  }

  if (batteryVoltage > 60.0) {
    return false;
  }

  return true;
}

void emergencyShutdown() {

  digitalWrite(CHARGER_ENABLE, LOW);
  digitalWrite(CONTACTOR, LOW);

  operatingMode = "FAULT";

  Serial.println("EMERGENCY SHUTDOWN");
}

void setCharging(bool enable) {

  if (!safetyCheck()) {
    emergencyShutdown();
    return;
  }

  if (enable) {

    digitalWrite(CONTACTOR, HIGH);
    delay(100);

    digitalWrite(CHARGER_ENABLE, HIGH);

    operatingMode = "G2V";

  } else {

    digitalWrite(CHARGER_ENABLE, LOW);
    digitalWrite(CONTACTOR, LOW);

    operatingMode = "IDLE";
  }
}

void uploadData() {

  if (WiFi.status() != WL_CONNECTED)
    return;

  HTTPClient http;

  String url =
      "https://your-server.example/api/telemetry";

  http.begin(url);

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

  String payload = "{";
  payload += "\"voltage\":" +
             String(batteryVoltage, 2) + ",";
  payload += "\"current\":" +
             String(batteryCurrent, 2) + ",";
  payload += "\"power\":" +
             String(power, 2) + ",";
  payload += "\"temperature\":" +
             String(temperature, 2) + ",";
  payload += "\"mode\":\"" +
             operatingMode + "\"";
  payload += "}";

  int response =
      http.POST(payload);

  Serial.print("HTTP response: ");
  Serial.println(response);

  http.end();
}

void loop() {

  readSensors();

  if (!safetyCheck()) {
    emergencyShutdown();
  }

  if (millis() - lastUpload > 10000) {

    lastUpload = millis();

    uploadData();
  }

  delay(1000);
}

For a real system, sensor calibration, filtering, watchdog handling, communication authentication, command validation, fault handling and hardware interlocks need to be considerably more robust.


13. Recommended MQTT message structure

Instead of sending arbitrary strings, use structured JSON.

ESP32 → n8n

{
  "device_id": "EVSE_001",
  "timestamp": "2026-09-25T08:00:00",
  "mode": "G2V",
  "battery_voltage": 52.4,
  "battery_current": 8.2,
  "power": 429.68,
  "soc": 78,
  "temperature": 31.5,
  "grid_voltage": 230.2,
  "grid_current": 2.1,
  "grid_power": 483.4,
  "fault": false
}

n8n → ESP32

{
  "command": "SET_MODE",
  "mode": "G2V",
  "power_limit": 500,
  "request_id": "REQ_001"
}

14. n8n workflow

The central automation could be:

             ESP32
               │
               ▼
        ┌──────────────┐
        │ MQTT / HTTP  │
        │   Trigger    │
        └──────┬───────┘
               ▼
        ┌──────────────┐
        │ Parse JSON   │
        └──────┬───────┘
               ▼
        ┌──────────────┐
        │ Validate     │
        │ Data         │
        └──────┬───────┘
               ▼
        ┌──────────────┐
        │ Safety Rules │
        └──────┬───────┘
               │
       ┌───────┼─────────┐
       ▼       ▼         ▼
    Normal   Warning   Critical
       │       │         │
       ▼       ▼         ▼
    Sheets  Telegram   Telegram
       │       │         │
       ▼       ▼         ▼
 ThingSpeak  Voice     Voice
               │
               ▼
             AI Agent
               │
               ▼
         Recommendation
               │
               ▼
          Policy Check
               │
               ▼
             ESP32

15. n8n AI-agent workflow

A second workflow can handle intelligent decisions:

              Scheduler
                  │
                  ▼
          Read system status
                  │
                  ▼
        Read energy information
                  │
                  ▼
             AI Agent
                  │
       ┌──────────┼──────────┐
       ▼          ▼          ▼
    Charging    V2H        Idle
       │          │          │
       └──────────┼──────────┘
                  ▼
           Safety Validator
                  │
          ┌───────┴────────┐
          │                │
        VALID            INVALID
          │                │
          ▼                ▼
      ESP32 command      Telegram
          │
          ▼
      Confirmation
          │
          ▼
      Google Sheets

16. AI prompt architecture

Instead of asking an AI:

"Control the charger."

give it structured information and strict constraints.

Example system instruction:

You are an energy-management assistant.

Your role is to analyze EV charging system telemetry
and recommend an operating mode.

Allowed modes:
- IDLE
- G2V
- V2H

Never directly bypass safety limits.

Never request operation if:
- Emergency stop is active
- Battery temperature exceeds configured limit
- Battery voltage exceeds configured limit
- BMS reports a fault
- Communication status is invalid

Return JSON only:

{
  "mode": "...",
  "power_limit_w": 0,
  "reason": "...",
  "alert": false
}

For actual deployment, the permitted operating ranges should come from the battery/BMS and power-converter design rather than being invented by the AI.


17. Telegram notification system

Example event:

ESP32
  │
  │ High temperature
  ▼
n8n
  │
  ├── Log event
  │
  ├── AI analysis
  │
  └── Telegram
          │
          ▼
       Operator

Telegram text:

⚠️ EV ENERGY SYSTEM ALERT

Device: EVSE_001

Battery temperature: 51.2 °C
SOC: 74 %
Mode: G2V

Action:
Charging disabled.

Reason:
Temperature safety threshold exceeded.

For voice:

Sensor event
     │
     ▼
n8n
     │
     ▼
Text-to-Speech
     │
     ▼
Audio file
     │
     ▼
Telegram
     │
     ▼
Operator hears alert

18. Google Sheets logging

A spreadsheet can contain:

Timestamp Device Mode Voltage Current Power SOC Temperature Fault
08:00 EVSE001 G2V 52.4 8.2 429 78 31.5 No
08:01 EVSE001 G2V 52.5 8.1 425 79 31.7 No
08:02 EVSE001 IDLE 52.6 0 0 79 31.9 No

This provides an easy source for:

  • daily energy

  • charging sessions

  • faults

  • temperature history

  • SOC history

  • power consumption

  • operating hours


19. ThingSpeak architecture

ESP32
  │
  │ HTTP/MQTT
  ▼
ThingSpeak
  │
  ├── Field 1 → Voltage
  ├── Field 2 → Current
  ├── Field 3 → Power
  ├── Field 4 → SOC
  ├── Field 5 → Temperature
  ├── Field 6 → Grid Power
  ├── Field 7 → Mode
  └── Field 8 → Fault

Dashboard:

┌─────────────────────────────────────────┐
│          EV SMART ENERGY DASHBOARD      │
├─────────────────────────────────────────┤
│                                         │
│ SOC          78 %                       │
│ Battery      52.4 V                     │
│ Current       8.2 A                     │
│ Power       429 W                       │
│ Temperature 31.5 °C                     │
│                                         │
│ Mode: G2V                                │
│ Status: NORMAL                           │
│                                         │
│ Power Graph ────────────────             │
│ SOC Graph   ────────────────             │
│ Temp Graph  ────────────────             │
└─────────────────────────────────────────┘

20. Web dashboard

A separate web application can provide a more attractive interface.

Frontend

Possible stack:

HTML
CSS
JavaScript
Chart.js

or:

React
+
Chart.js

Dashboard

                  EV ENERGY MANAGER

 ┌────────────┐ ┌────────────┐ ┌────────────┐
 │ SOC        │ │ POWER      │ │ BATTERY    │
 │            │ │            │ │ TEMP       │
 │   78 %     │ │ 429 W      │ │ 31.5 °C    │
 └────────────┘ └────────────┘ └────────────┘

 ┌───────────────────────────────────────────┐
 │             OPERATING MODE               │
 │                                           │
 │  ● G2V      ○ V2H       ○ IDLE            │
 └───────────────────────────────────────────┘

 ┌───────────────────────────────────────────┐
 │ POWER HISTORY                             │
 │                                           │
 │       /\                                  │
 │      /  \        /\                       │
 │ ____/    \______/  \______                │
 │                                           │
 └───────────────────────────────────────────┘

 ┌───────────────────────────────────────────┐
 │ AI ENERGY ASSISTANT                      │
 │                                           │
 │ "Battery SOC is sufficient for local      │
 │  load support. V2H is permitted by        │
 │  current policy."                         │
 └───────────────────────────────────────────┘

21. Example dashboard HTML

A simple prototype frontend:

<!DOCTYPE html>
<html>
<head>
    <title>AI EV Energy Manager</title>

    <style>

        body {
            font-family: Arial;
            background: #101820;
            color: white;
            margin: 0;
        }

        header {
            background: #16232e;
            padding: 20px;
            text-align: center;
        }

        .dashboard {
            display: grid;
            grid-template-columns:
                repeat(auto-fit, minmax(200px, 1fr));

            gap: 20px;
            padding: 25px;
        }

        .card {
            background: #1c2d39;
            padding: 25px;
            border-radius: 15px;
            text-align: center;
        }

        .value {
            font-size: 35px;
            color: #00e676;
            font-weight: bold;
        }

        button {
            padding: 15px 25px;
            margin: 10px;
            border: none;
            border-radius: 10px;
            cursor: pointer;
        }

        .charge {
            background: #00c853;
        }

        .stop {
            background: #ff1744;
            color: white;
        }

    </style>
</head>

<body>

<header>
    <h1>AI EV Smart Energy Manager</h1>
</header>

<div class="dashboard">

    <div class="card">
        <h3>Battery SOC</h3>
        <div class="value" id="soc">78%</div>
    </div>

    <div class="card">
        <h3>Voltage</h3>
        <div class="value" id="voltage">52.4 V</div>
    </div>

    <div class="card">
        <h3>Current</h3>
        <div class="value" id="current">8.2 A</div>
    </div>

    <div class="card">
        <h3>Power</h3>
        <div class="value" id="power">429 W</div>
    </div>

    <div class="card">
        <h3>Temperature</h3>
        <div class="value" id="temperature">31.5 °C</div>
    </div>

</div>

<div style="text-align:center">

    <button class="charge"
            onclick="setMode('G2V')">
        CHARGE
    </button>

    <button onclick="setMode('V2H')">
        V2H
    </button>

    <button class="stop"
            onclick="setMode('IDLE')">
        STOP
    </button>

</div>

<script>

async function setMode(mode) {

    await fetch("/api/mode", {

        method: "POST",

        headers: {
            "Content-Type":
                "application/json"
        },

        body: JSON.stringify({
            mode: mode
        })

    });

}

async function updateDashboard() {

    const response =
        await fetch("/api/status");

    const data =
        await response.json();

    document.getElementById("soc")
        .innerText = data.soc + "%";

    document.getElementById("voltage")
        .innerText =
        data.voltage + " V";

    document.getElementById("current")
        .innerText =
        data.current + " A";

    document.getElementById("power")
        .innerText =
        data.power + " W";

    document.getElementById("temperature")
        .innerText =
        data.temperature + " °C";
}

setInterval(updateDashboard, 3000);

updateDashboard();

</script>

</body>
</html>

22. Complete data flow

The complete project can operate as follows:

                 ┌──────────────┐
                 │ EV BATTERY   │
                 └──────┬───────┘
                        │
                Electrical data
                        │
                        ▼
               ┌────────────────┐
               │     ESP32      │
               │                │
               │ V/I/T/SOC      │
               └───────┬────────┘
                       │
                 Wi-Fi/MQTT
                       │
                       ▼
               ┌────────────────┐
               │      n8n       │
               └───────┬────────┘
                       │
           ┌───────────┼────────────┐
           │           │            │
           ▼           ▼            ▼
        Google      ThingSpeak   Database
        Sheets
           │
           │
           ▼
       Analytics
           │
           ▼
       AI Agent
           │
           ▼
      Decision Engine
           │
       ┌───┴────┐
       │        │
       ▼        ▼
     SAFE     UNSAFE
       │        │
       ▼        ▼
     ESP32   Telegram
       │      Alert
       ▼
 Power Stage

23. Example AI conversation

Operator

What is the current EV status?

AI Agent

EVSE-001 status:

SOC: 78%
Battery voltage: 52.4 V
Battery current: 8.2 A
Power: 430 W
Temperature: 31.5 °C
Mode: G2V
Fault: None

The system is operating normally.

Operator

Why is charging slow?

AI

Current charging power is approximately 430 W.

Possible causes include:
- configured power limit
- available grid power
- charger operating state
- battery charging constraints

The current telemetry does not by itself identify
which condition is limiting power.

24. Example Telegram conversation

USER:
Status

BOT:
🔋 EV STATUS

SOC: 78%
Voltage: 52.4 V
Current: 8.2 A
Power: 429 W
Temperature: 31.5 °C

Mode: G2V
Fault: None

Then:

USER:
Stop charging

n8n:

Telegram
   │
   ▼
Parse command
   │
   ▼
Safety validation
   │
   ▼
ESP32 command
   │
   ▼
ESP32
   │
   ▼
Contactor/charger disabled
   │
   ▼
Confirmation

Telegram:

🛑 Charging stopped.

Device: EVSE-001
Mode: IDLE
Power: 0 W

25. Fault-management workflow

This is one of the most important parts.

Sensor
  │
  ▼
ESP32
  │
  ▼
Is value normal?
  │
 ┌┴──────────────┐
 │               │
YES              NO
 │               │
 ▼               ▼
Continue      Local shutdown
 │               │
 ▼               ▼
Cloud          Fault state
 │               │
                 ▼
             n8n alert
                 │
        ┌────────┼────────┐
        ▼        ▼        ▼
    Telegram   Sheets   Dashboard

Example faults:

OVERVOLTAGE
OVERCURRENT
OVERTEMPERATURE
UNDERVOLTAGE
BMS_FAULT
COMMUNICATION_LOSS
EMERGENCY_STOP
GRID_FAULT
CONTACTOR_FAULT
SENSOR_FAULT

26. Communication-loss protection

Suppose Wi-Fi disappears.

The system should not wait for an AI decision.

Instead:

Wi-Fi lost
   │
   ▼
ESP32 detects timeout
   │
   ▼
Local safety policy
   │
   ├── Continue in predefined safe state
   │
   └── OR shutdown

This is a key principle:

Cloud/AI failure must never become a hardware safety failure.


27. Suggested n8n workflows

I would divide the project into six workflows.

Workflow 1 — Telemetry

ESP32
 ↓
MQTT/HTTP
 ↓
Validate
 ↓
Database
 ↓
ThingSpeak
 ↓
Google Sheets

Workflow 2 — Fault alert

Telemetry
 ↓
IF fault = true
 ↓
Create alert
 ↓
Telegram
 ↓
Voice generation
 ↓
Telegram voice message

Workflow 3 — AI energy management

Schedule
 ↓
Get telemetry
 ↓
Get energy conditions
 ↓
AI Agent
 ↓
Safety policy
 ↓
ESP32

Workflow 4 — Telegram commands

Telegram
 ↓
Receive command
 ↓
Parse
 ↓
Validate
 ↓
ESP32
 ↓
Confirmation

Workflow 5 — Daily report

Cron
 ↓
Google Sheets
 ↓
Calculate:
Energy
Sessions
Faults
Peak power
 ↓
AI summary
 ↓
Telegram

Workflow 6 — Emergency notification

ESP32
 ↓
Critical fault
 ↓
n8n
 ↓
Immediate Telegram
 ↓
Voice alert
 ↓
Dashboard RED

28. Daily AI report example

The system could automatically send:

📊 DAILY EV ENERGY REPORT

Device: EVSE-001

Charging sessions: 4
Total charging energy: 3.8 kWh
V2H energy: 1.2 kWh
Peak power: 1.5 kW

Average battery temperature: 32.1 °C

Faults:
1 minor warning
0 critical faults

AI observation:
The system remained within the configured
operating limits during the reporting period.

29. Database structure

A simple database table could be:

CREATE TABLE telemetry (
    id INTEGER PRIMARY KEY,
    device_id VARCHAR(50),
    timestamp TIMESTAMP,
    mode VARCHAR(20),
    voltage FLOAT,
    current FLOAT,
    power FLOAT,
    soc FLOAT,
    temperature FLOAT,
    grid_voltage FLOAT,
    grid_power FLOAT,
    fault BOOLEAN
);

Fault table:

CREATE TABLE faults (
    id INTEGER PRIMARY KEY,
    device_id VARCHAR(50),
    timestamp TIMESTAMP,
    fault_code VARCHAR(50),
    severity VARCHAR(20),
    description TEXT,
    resolved BOOLEAN
);

30. Energy calculation

For sampled power data:

E=∫P(t) dtE = \int P(t)\,dt

For digital sampling:

E≈∑PiΔtE \approx \sum P_i \Delta t

For example, if:

Power = 500 W
Time = 2 hours

then:

E=500×2=1000WhE = 500 \times 2 = 1000Wh

or:

E=1kWhE = 1kWh

The software can accumulate this continuously.


31. Smart charging algorithm

A simple first-generation algorithm:

START
  │
  ▼
Read SOC
  │
  ▼
Read grid power
  │
  ▼
Read solar power
  │
  ▼
Read battery temperature
  │
  ▼
Check safety
  │
  ▼
SOC < target?
  │
 ┌┴───────────┐
YES           NO
 │             │
 ▼             ▼
Can charge?   IDLE
 │
 ▼
Calculate power limit
 │
 ▼
Charge

A more advanced version:

Solar surplus
      +
Grid condition
      +
Battery SOC
      +
Energy price
      +
User schedule
      +
Battery constraints
      │
      ▼
   AI Agent
      │
      ▼
 Optimization
      │
      ▼
Safety policy
      │
      ▼
Power command

32. Project development stages

Do not build everything simultaneously.

Stage 1 — ESP32

Build:

ESP32
 ↓
Temperature
 ↓
Voltage
 ↓
Current
 ↓
Serial monitor

Verify measurements.

Stage 2 — IoT

Add:

ESP32
 ↓
Wi-Fi
 ↓
HTTP/MQTT
 ↓
Cloud

Stage 3 — Dashboard

Add:

ESP32
 ↓
Server
 ↓
Web dashboard

Stage 4 — n8n

Add:

ESP32 → n8n → Google Sheets

Stage 5 — Telegram

Add:

ESP32
 ↓
n8n
 ↓
Telegram

Stage 6 — Voice

Add:

n8n
 ↓
TTS
 ↓
Telegram voice

Stage 7 — AI

Add:

Telemetry
 ↓
AI Agent
 ↓
Recommendation

Stage 8 — Control

Only after the above is stable:

AI
 ↓
Policy
 ↓
ESP32
 ↓
Low-voltage test load

Stage 9 — Bidirectional power

Finally integrate an appropriate power converter and battery/BMS system under suitable electrical protection and supervision.


33. Complete final architecture

                             ┌─────────────────┐
                             │      USER       │
                             └────────┬────────┘
                                      │
                     ┌────────────────┼───────────────┐
                     │                │               │
                     ▼                ▼               ▼
                 Web App          Telegram        Voice
                     │                │               │
                     └────────────────┼───────────────┘
                                      │
                                      ▼
                             ┌─────────────────┐
                             │      n8n        │
                             │                 │
                             │ Automation      │
                             │ AI Agent        │
                             │ Rules           │
                             │ Notifications   │
                             └────────┬────────┘
                                      │
                    ┌─────────────────┼──────────────────┐
                    │                 │                  │
                    ▼                 ▼                  ▼
              Google Sheets      ThingSpeak         Database
                    │                 │                  │
                    └─────────────────┼──────────────────┘
                                      │
                                      ▼
                             ┌─────────────────┐
                             │     ESP32       │
                             │                 │
                             │ Sensors         │
                             │ BMS             │
                             │ Wi-Fi           │
                             │ MQTT            │
                             │ State Machine   │
                             │ Safety Logic    │
                             └────────┬────────┘
                                      │
                                      ▼
                             ┌─────────────────┐
                             │ Isolation /     │
                             │ Protection      │
                             └────────┬────────┘
                                      │
                                      ▼
                             ┌─────────────────┐
                             │ Bidirectional   │
                             │ Power Converter │
                             └────────┬────────┘
                                      │
                    ┌─────────────────┴─────────────────┐
                    │                                   │
                    ▼                                   ▼
                 EV Battery                         Smart Grid
                    │                                   │
                    └───────────────┬───────────────────┘
                                    │
                                    ▼
                              Home / Load

34. Recommended project deliverables

For a final-year project / research project, your documentation can be divided into:

  1. Abstract

  2. Introduction

  3. Problem statement

  4. Existing system

  5. Proposed system

  6. Objectives

  7. System architecture

  8. Hardware requirements

  9. Software requirements

  10. ESP32 design

  11. Sensor interface

  12. BMS interface

  13. Bidirectional charging concept

  14. G2V operation

  15. V2G operation

  16. V2H operation

  17. Smart-grid integration

  18. IoT architecture

  19. MQTT/HTTP communication

  20. n8n workflow

  21. AI-agent architecture

  22. Telegram integration

  23. Voice-alert system

  24. Google Sheets integration

  25. ThingSpeak integration

  26. Web dashboard

  27. Database

  28. Safety architecture

  29. Fault handling

  30. Software flowcharts

  31. Hardware schematic

  32. ESP32 source code

  33. Web application source code

  34. n8n workflow

  35. Testing

  36. Results

  37. Performance analysis

  38. Limitations

  39. Future scope

  40. Conclusion

35. What the finished demonstration can look like

A particularly effective demonstration is:

              SOLAR / GRID
                   │
                   ▼
              EV CHARGER
                   │
                   ▼
                ESP32
                   │
          ┌────────┴────────┐
          │                 │
       Sensors            BMS
          │                 │
          └────────┬────────┘
                   ▼
                  n8n
                   │
       ┌───────────┼─────────────┐
       │           │             │
       ▼           ▼             ▼
      AI       Telegram       Sheets
       │           │
       │           ▼
       │       Voice alert
       │
       ▼
 Safety policy
       │
       ▼
    ESP32
       │
       ▼
   Power stage

Then demonstrate three scenarios:

Scenario A — Normal charging

SOC 40%
      ↓
AI/n8n detects charging requirement
      ↓
Safety checks
      ↓
G2V
      ↓
ESP32
      ↓
Charger

Scenario B — High temperature

Temperature rises
      ↓
ESP32 detects threshold
      ↓
Local protection
      ↓
Charging disabled
      ↓
n8n
      ↓
Telegram text + voice alert
      ↓
Google Sheets event

Scenario C — Smart V2H

EV SOC sufficiently high
       +
Home load request
       +
Safety conditions valid
       ↓
AI Agent recommendation
       ↓
Policy validation
       ↓
ESP32
       ↓
Approved bidirectional converter
       ↓
Home load

This architecture gives you a strong AI + IoT + embedded + automation + cloud + energy-management project while keeping the safety-critical power-control portion separate from the AI layer. For an actual grid-connected EV system, the power converter, isolation, BMS, protection, anti-islanding/grid synchronization and applicable electrical standards must be handled with appropriately rated hardware and qualified supervision; the ESP32 should not be treated as the sole safety controller.

 

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.