Thursday, 1 October 2026

AI Vehicle Speed Monitoring & Number Plate Recognition System

Yes. I can structure this as a complete final-year/engineering project documentation package covering the ESP32 hardware, AI vehicle detection/speed estimation, number-plate recognition, IoT dashboard, n8n automation, Telegram voice alerts, Google Sheets logging, ThingSpeak, and the AI-agent workflow.

I’d recommend the architecture below as the baseline:

                    ┌───────────────────────────┐
                    │       ROAD / VEHICLE      │
                    │                           │
                    │  Vehicle → Camera/Sensors │
                    └─────────────┬─────────────┘
                                  │
                                  ▼
                    ┌───────────────────────────┐
                    │          ESP32             │
                    │                           │
                    │ • Sensor acquisition      │
                    │ • Vehicle trigger          │
                    │ • Time measurement         │
                    │ • Speed calculation        │
                    │ • Wi-Fi / MQTT / HTTP      │
                    └─────────────┬─────────────┘
                                  │
                         Wi-Fi / HTTP / MQTT
                                  │
                                  ▼
                    ┌───────────────────────────┐
                    │       n8n WORKFLOW         │
                    │                           │
                    │ Webhook → Validate        │
                    │        → AI Agent          │
                    │        → Database/Sheets   │
                    │        → Alert Decision    │
                    └───────┬─────────┬─────────┘
                            │         │
                ┌───────────┘         └─────────────┐
                ▼                                   ▼
       ┌─────────────────┐                 ┌─────────────────┐
       │   AI / OCR      │                 │  Google Sheets  │
       │                 │                 │                 │
       │ Vehicle detect  │                 │ Date/time       │
       │ Plate detection │                 │ Plate number    │
       │ OCR             │                 │ Speed           │
       │ Classification  │                 │ Location/status │
       └────────┬────────┘                 └─────────────────┘
                │
                ▼
       ┌─────────────────┐
       │ AI Agent        │
       │                 │
       │ Analyze event   │
       │ Decide severity │
       │ Generate alert │
       └────────┬────────┘
                │
        ┌───────┴─────────┐
        ▼                 ▼
┌───────────────┐  ┌────────────────┐
│ Telegram      │  │ ThingSpeak /   │
│ Voice Alert   │  │ IoT Dashboard  │
│ + Message     │  │                │
└───────────────┘  └────────────────┘

1. Proposed project title

AI-Powered Vehicle Speed Monitoring and Automatic Number Plate Recognition System Using ESP32, IoT, n8n Automation and Telegram Voice Alerts

Short title

AI Vehicle Speed Monitoring & Number Plate Recognition Using ESP32 + n8n


2. Project objective

The system is designed to automatically:

  1. Detect a moving vehicle.

  2. Measure/estimate its speed.

  3. Capture the vehicle image.

  4. Detect the vehicle's number plate.

  5. Extract the registration number using OCR.

  6. Determine whether the vehicle exceeds a configurable speed limit.

  7. Send the event to an IoT/cloud backend.

  8. Use an AI agent to analyze the event.

  9. Store the event in Google Sheets.

  10. Update an IoT dashboard such as ThingSpeak.

  11. Send Telegram notifications.

  12. Generate a Telegram voice alert for important violations.

  13. Provide a web dashboard for monitoring.

  14. Maintain a historical record of detected vehicles and violations.


3. Important architecture decision

There are actually two different jobs in this project:

ESP32

The ESP32 is excellent for:

  • Sensor interfacing

  • Vehicle-trigger detection

  • Timestamping

  • Speed calculation

  • Wi-Fi communication

  • Sending sensor data

  • Controlling LEDs/buzzers

  • Receiving commands

AI computer/cloud service

Number-plate recognition and sophisticated computer vision are generally better performed by:

  • Raspberry Pi

  • Laptop/PC

  • NVIDIA Jetson

  • Cloud server

  • Python/OpenCV service

Rather than trying to perform full ANPR/OCR directly on a basic ESP32.

A practical architecture is therefore:

                 CAMERA
                    │
                    ▼
             ┌─────────────┐
             │ ESP32-CAM / │
             │ IP Camera   │
             └──────┬──────┘
                    │
                    ▼
          ┌───────────────────┐
          │ AI Vision Server  │
          │                   │
          │ YOLO/OpenCV       │
          │ Plate detection   │
          │ OCR               │
          └────────┬──────────┘
                   │
                   │ JSON
                   ▼
             ┌─────────────┐
             │    n8n      │
             └──────┬──────┘
                    │
       ┌────────────┼─────────────┐
       ▼            ▼             ▼
   AI Agent    Google Sheets   ThingSpeak
       │
       ▼
   Telegram
       │
       ▼
 Telegram Voice

This separation makes the project much easier to implement and demonstrate.


4. Hardware components

A typical prototype can use:

Component Purpose
ESP32 DevKit Main IoT controller
ESP32-CAM Camera/video capture
IR sensor 1 Vehicle detection
IR sensor 2 Vehicle detection
Ultrasonic sensor Optional distance measurement
GPS module Optional location
OLED/LCD Local display
Buzzer Local violation alert
Red LED Overspeed indication
Green LED Normal vehicle indication
Wi-Fi router/hotspot Internet connection
5 V power supply ESP32/camera power
Raspberry Pi/PC AI processing
Camera Vehicle/plate image acquisition

5. Speed measurement principle

One simple approach uses two sensors.

                 VEHICLE DIRECTION
                       →

       Sensor A                         Sensor B
          │                                │
          ▼                                ▼
──────────┼────────────────────────────────┼──────── ROAD
          │<---------- distance D -------->│

          T1                               T2

When the vehicle crosses Sensor A:

T1 = timestamp at Sensor A

When it crosses Sensor B:

T2 = timestamp at Sensor B

The elapsed time is:

Δt=T2−T1\Delta t = T_2-T_1

If the distance between sensors is DD:

v=DΔtv = \frac{D}{\Delta t}

For km/h:

vkm/h=DΔt×3.6v_{km/h} = \frac{D}{\Delta t} \times 3.6

where:

  • DD = distance in metres

  • Δt\Delta t = seconds

  • vv = metres/second

Example

Suppose:

Distance = 5 m
Time = 0.40 s

Then:

v=5/0.40=12.5m/sv = 5/0.40 = 12.5 m/s

and:

12.5×3.6=45km/h12.5 \times 3.6 = 45 km/h

The ESP32 can therefore calculate approximately 45 km/h.


6. Speed-monitoring flow

             START
               │
               ▼
       Initialize ESP32
               │
               ▼
          Connect Wi-Fi
               │
               ▼
       Monitor Sensor A
               │
        Vehicle detected?
          ┌────┴────┐
          │ No      │ Yes
          │         ▼
          │       Record T1
          │         │
          │         ▼
          │    Monitor Sensor B
          │         │
          │    Vehicle detected?
          │      ┌──┴──┐
          │      │ No  │
          │      │     │
          │      │ Yes ▼
          │      │   Record T2
          │      │      │
          │      │      ▼
          │      │ Calculate speed
          │      │      │
          │      │      ▼
          │      │ Compare limit
          │      │      │
          │      │ ┌────┴────┐
          │      │ │ Normal  │ Overspeed
          │      │ ▼         ▼
          │      │ Log       Alert
          │      │           │
          └──────┴───────────┘
                       │
                       ▼
                 Send cloud data
                       │
                       ▼
                     LOOP

7. ESP32 wiring

A simple sensor configuration:

                 ESP32
          ┌─────────────────┐
          │                 │
Sensor A ─┤ GPIO 27        │
Sensor B ─┤ GPIO 26        │
          │                 │
Buzzer  ──┤ GPIO 25        │
Red LED ──┤ GPIO 33        │
Green LED ┤ GPIO 32        │
          │                 │
OLED SDA ─┤ GPIO 21        │
OLED SCL ─┤ GPIO 22        │
          │                 │
          │ Wi-Fi           │
          └─────────────────┘

Basic circuit

                +3.3V
                  │
             ┌────┴────┐
             │ Sensor A│
             └────┬────┘
                  │ OUT
                  │
                  ▼
               GPIO27


                +3.3V
                  │
             ┌────┴────┐
             │ Sensor B│
             └────┬────┘
                  │ OUT
                  │
                  ▼
               GPIO26


ESP32 GPIO25 ───────► 220Ω ───► LED/Buzzer
ESP32 GND ──────────────────────► GND

Important: sensor output voltage must be compatible with the ESP32's 3.3 V GPIO. Use level shifting where necessary.


8. ESP32 software

Arduino IDE can be used for the ESP32 firmware.

Required libraries

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

Example ESP32 firmware

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

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

const char* N8N_WEBHOOK =
    "http://YOUR_N8N_SERVER/webhook/vehicle-event";

#define SENSOR_A 27
#define SENSOR_B 26

#define RED_LED 33
#define GREEN_LED 32
#define BUZZER 25

const float SENSOR_DISTANCE = 5.0;
const float SPEED_LIMIT = 40.0;

volatile bool sensorATriggered = false;
volatile bool sensorBTriggered = false;

unsigned long timeA = 0;
unsigned long timeB = 0;

void IRAM_ATTR sensorA_ISR()
{
    sensorATriggered = true;
}

void IRAM_ATTR sensorB_ISR()
{
    sensorBTriggered = true;
}

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

    pinMode(SENSOR_A, INPUT);
    pinMode(SENSOR_B, INPUT);

    pinMode(RED_LED, OUTPUT);
    pinMode(GREEN_LED, OUTPUT);
    pinMode(BUZZER, OUTPUT);

    digitalWrite(GREEN_LED, LOW);
    digitalWrite(RED_LED, LOW);
    digitalWrite(BUZZER, LOW);

    attachInterrupt(
        digitalPinToInterrupt(SENSOR_A),
        sensorA_ISR,
        RISING
    );

    attachInterrupt(
        digitalPinToInterrupt(SENSOR_B),
        sensorB_ISR,
        RISING
    );

    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 loop()
{
    if (sensorATriggered)
    {
        sensorATriggered = false;

        timeA = millis();

        Serial.println("Vehicle detected at Sensor A");

        waitForSensorB();
    }

    delay(10);
}

void waitForSensorB()
{
    unsigned long start = millis();

    while (!sensorBTriggered &&
           millis() - start < 5000)
    {
        delay(1);
    }

    if (sensorBTriggered)
    {
        sensorBTriggered = false;

        timeB = millis();

        float elapsed =
            (timeB - timeA) / 1000.0;

        if (elapsed > 0)
        {
            float speedMS =
                SENSOR_DISTANCE / elapsed;

            float speedKMPH =
                speedMS * 3.6;

            Serial.print("Speed: ");
            Serial.print(speedKMPH);
            Serial.println(" km/h");

            processVehicle(speedKMPH);
        }
    }
}

void processVehicle(float speed)
{
    bool overspeed = speed > SPEED_LIMIT;

    if (overspeed)
    {
        digitalWrite(RED_LED, HIGH);
        digitalWrite(GREEN_LED, LOW);

        tone(BUZZER, 2000, 500);
    }
    else
    {
        digitalWrite(RED_LED, LOW);
        digitalWrite(GREEN_LED, HIGH);
    }

    sendToN8N(speed, overspeed);
}

void sendToN8N(float speed, bool overspeed)
{
    if (WiFi.status() != WL_CONNECTED)
        return;

    HTTPClient http;

    http.begin(N8N_WEBHOOK);

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

    String json = "{";

    json += "\"device_id\":\"ESP32_SPEED_01\",";
    json += "\"speed\":" + String(speed, 2) + ",";
    json += "\"speed_limit\":" +
            String(SPEED_LIMIT, 2) + ",";
    json += "\"overspeed\":" +
            String(overspeed ? "true" : "false") +
            ",";

    json += "\"timestamp\":" +
            String(millis());

    json += "}";

    int response =
        http.POST(json);

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

    http.end();
}

This is the basic speed-monitoring firmware. In the complete version, the ESP32 can additionally send camera information, GPS coordinates, device health, sensor confidence, and an event ID.


9. AI number-plate recognition

The AI portion can follow this pipeline:

Camera
  │
  ▼
Vehicle Detection
  │
  ▼
Vehicle Crop
  │
  ▼
Number Plate Detection
  │
  ▼
Plate Crop
  │
  ▼
Image Preprocessing
  │
  ├── Resize
  ├── Grayscale
  ├── Noise reduction
  ├── Contrast enhancement
  └── Thresholding
  │
  ▼
OCR
  │
  ▼
Plate Number
  │
  ▼
Confidence Check
  │
  ▼
Send JSON to n8n

A Python computer-vision service can perform this portion.


10. Example AI/OCR Python service

Conceptually:

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/analyze", methods=["POST"])
def analyze():

    # 1. Receive image
    image = request.files["image"]

    # 2. Run vehicle detector
    # vehicle_results = vehicle_model(image)

    # 3. Detect number plate
    # plate_results = plate_model(vehicle_crop)

    # 4. OCR
    # plate_text = ocr_engine(plate_crop)

    # 5. Return result

    result = {
        "vehicle_detected": True,
        "plate_number": "TS09AB1234",
        "plate_confidence": 0.94,
        "vehicle_type": "car"
    }

    return jsonify(result)


if __name__ == "__main__":
    app.run(
        host="0.0.0.0",
        port=5000
    )

For an actual implementation, the placeholder detector/OCR calls would be replaced with the selected computer-vision models.


11. n8n automation architecture

The n8n workflow is the central automation layer.

             ESP32
               │
               ▼
         ┌────────────┐
         │ Webhook    │
         └─────┬──────┘
               │
               ▼
       ┌────────────────┐
       │ Validate JSON  │
       └───────┬────────┘
               │
               ▼
       ┌────────────────┐
       │ AI Vision/OCR  │
       └───────┬────────┘
               │
               ▼
       ┌────────────────┐
       │ AI Agent       │
       └───────┬────────┘
               │
         ┌─────┴─────┐
         ▼           ▼
      Normal      Overspeed
         │           │
         ▼           ▼
 Google Sheets   Telegram
         │           │
         ▼           ▼
 ThingSpeak     Voice Alert
         │
         ▼
    Web Dashboard

12. Example JSON exchanged with n8n

The ESP32 can send:

{
  "device_id": "ESP32_SPEED_01",
  "event_id": "EVT-20261001-001",
  "speed": 67.4,
  "speed_limit": 40,
  "overspeed": true,
  "sensor_distance": 5,
  "timestamp": "2026-10-01T22:30:10+05:30"
}

After AI processing:

{
  "device_id": "ESP32_SPEED_01",
  "event_id": "EVT-20261001-001",
  "speed": 67.4,
  "speed_limit": 40,
  "overspeed": true,

  "vehicle": {
    "type": "car",
    "color": "white"
  },

  "number_plate": {
    "text": "TS09AB1234",
    "confidence": 0.94
  },

  "location": {
    "latitude": 17.3850,
    "longitude": 78.4867
  }
}

13. n8n workflow nodes

A complete workflow could contain:

[Webhook]
    ↓
[Set / Normalize Data]
    ↓
[HTTP Request - AI Vision]
    ↓
[Merge ESP32 + AI Result]
    ↓
[AI Agent]
    ↓
[IF - Overspeed?]
   ↙       ↘
 NO         YES
 │           │
 ▼           ▼
Sheets     Telegram
 │           │
 ▼           ▼
ThingSpeak  Telegram Voice
 │
 ▼
Dashboard

Node 1 — Webhook

Receives the ESP32 request.

Example:

POST /webhook/vehicle-event

14. AI Agent logic

The AI agent should not directly control safety-critical hardware based solely on an LLM response.

Instead, deterministic logic should establish the actual violation:

IF speed > speed_limit
    overspeed = TRUE
ELSE
    overspeed = FALSE

The AI agent can then provide:

  • Event interpretation

  • Natural-language summary

  • Alert wording

  • Classification assistance

  • Anomaly explanation

  • Operator-facing summary

Example:

System:
You are a vehicle monitoring assistant.

Input:
Speed = 67.4 km/h
Limit = 40 km/h
Plate = TS09AB1234
Confidence = 94%

Task:
Generate a concise monitoring alert.
Do not change the measured speed.
Do not invent missing information.

Possible output:

Vehicle monitoring alert:
A vehicle identified as TS09AB1234 was detected
at 67.4 km/h against the configured 40 km/h limit.
Plate recognition confidence: 94%.

15. Telegram notification

The n8n workflow can send:

🚨 VEHICLE SPEED ALERT

Plate: TS09AB1234
Speed: 67.4 km/h
Limit: 40 km/h
Vehicle: Car
Confidence: 94%

Event: EVT-20261001-001
Device: ESP32_SPEED_01

16. Telegram voice-alert architecture

              n8n
               │
               ▼
         AI-generated text
               │
               ▼
             TTS
          Text-to-Speech
               │
               ▼
        Audio file / voice
               │
               ▼
           Telegram Bot
               │
               ▼
          Mobile phone
               │
               ▼
          🔊 Voice alert

The voice message could say:

“Speed alert. Vehicle TS09AB1234 was detected at 67.4 kilometres per hour. The configured speed limit is 40 kilometres per hour.”


17. Google Sheets database

A spreadsheet can contain:

Timestamp Event ID Device Plate Speed Limit Vehicle Confidence Status
2026-10-01 22:30 EVT001 ESP32-01 TS09AB1234 67.4 40 Car 94% Overspeed
2026-10-01 22:32 EVT002 ESP32-01 TS08XY5678 35.2 40 Bike 91% Normal

This provides a simple historical database for demonstrations.


18. ThingSpeak architecture

The ESP32/n8n system can publish fields such as:

Field 1 = Vehicle speed
Field 2 = Speed limit
Field 3 = Overspeed status
Field 4 = Vehicle count
Field 5 = Plate confidence
Field 6 = Device status

Dashboard:

┌──────────────────────────────────────────────┐
│        AI VEHICLE MONITORING DASHBOARD       │
├──────────────────────────────────────────────┤
│                                              │
│ Current Speed       67.4 km/h                │
│ Speed Limit         40 km/h                  │
│ Status              ⚠ OVERSPEED              │
│                                              │
│ Vehicles Today     128                       │
│ Violations          17                       │
│                                              │
│ Speed Graph                                   │
│      ╭──╮                                    │
│ ─────╯  ╰──╮────╮────                        │
│             ╰────╯                            │
│                                              │
└──────────────────────────────────────────────┘

19. Web dashboard

A separate webpage can display the latest event.

Example architecture

ESP32
  │
  ▼
n8n
  │
  ├──────────────► Google Sheets
  │
  ├──────────────► ThingSpeak
  │
  └──────────────► Web API
                         │
                         ▼
                  ┌─────────────┐
                  │ Web Page    │
                  │             │
                  │ Speed       │
                  │ Plate       │
                  │ Status      │
                  │ Timestamp   │
                  └─────────────┘

Example frontend:

<!DOCTYPE html>
<html>
<head>
    <title>AI Vehicle Monitoring</title>

    <style>
        body {
            font-family: Arial;
            background: #101820;
            color: white;
            margin: 0;
            padding: 30px;
        }

        .dashboard {
            max-width: 1000px;
            margin: auto;
        }

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

        .card {
            background: #1d2935;
            padding: 25px;
            border-radius: 15px;
        }

        .value {
            font-size: 32px;
            font-weight: bold;
            margin-top: 10px;
        }

        .danger {
            color: #ff5252;
        }

        .normal {
            color: #4caf50;
        }
    </style>
</head>

<body>

<div class="dashboard">

    <h1>🚗 AI Vehicle Monitoring</h1>

    <div class="cards">

        <div class="card">
            <div>Current Speed</div>
            <div id="speed"
                 class="value">
                -- km/h
            </div>
        </div>

        <div class="card">
            <div>Number Plate</div>
            <div id="plate"
                 class="value">
                -------
            </div>
        </div>

        <div class="card">
            <div>Status</div>
            <div id="status"
                 class="value">
                Waiting
            </div>
        </div>

        <div class="card">
            <div>Confidence</div>
            <div id="confidence"
                 class="value">
                -- %
            </div>
        </div>

    </div>

</div>

<script>

async function updateDashboard() {

    /*
       Replace this URL with your API endpoint.
    */

    const response =
        await fetch("/api/latest-event");

    const data =
        await response.json();

    document.getElementById("speed")
        .textContent =
        data.speed + " km/h";

    document.getElementById("plate")
        .textContent =
        data.plate;

    document.getElementById("confidence")
        .textContent =
        data.confidence + "%";

    const status =
        document.getElementById("status");

    status.textContent =
        data.overspeed
            ? "OVERSPEED"
            : "NORMAL";

    status.className =
        data.overspeed
            ? "value danger"
            : "value normal";
}

setInterval(updateDashboard, 5000);

updateDashboard();

</script>

</body>
</html>

20. Complete system flow

                         VEHICLE
                            │
                            ▼
                    ┌───────────────┐
                    │ Sensor A      │
                    └───────┬───────┘
                            │ T1
                            ▼
                    ┌───────────────┐
                    │ Sensor B      │
                    └───────┬───────┘
                            │ T2
                            ▼
                    ┌───────────────┐
                    │ ESP32         │
                    │               │
                    │ Speed = D/Δt  │
                    └───────┬───────┘
                            │
                            │ Wi-Fi
                            ▼
                    ┌───────────────┐
                    │ n8n Webhook   │
                    └───────┬───────┘
                            │
                 ┌──────────┴──────────┐
                 │                     │
                 ▼                     ▼
          ┌─────────────┐       ┌──────────────┐
          │ AI Vision   │       │ Sensor Data  │
          │              │       │              │
          │ Plate OCR   │       │ Speed        │
          └──────┬──────┘       └──────┬───────┘
                 │                     │
                 └──────────┬──────────┘
                            ▼
                     ┌─────────────┐
                     │ AI Agent    │
                     └──────┬──────┘
                            │
                 ┌──────────┼───────────┐
                 │          │           │
                 ▼          ▼           ▼
            Google       ThingSpeak  Telegram
            Sheets          │           │
                 │           │           ▼
                 │           │       Voice Alert
                 │           │
                 └─────┬─────┘
                       ▼
                 Web Dashboard

21. Communication protocol

The recommended protocol is HTTP/REST for the first prototype.

ESP32 → n8n

POST /webhook/vehicle-event
Content-Type: application/json

JSON

{
    "device_id": "ESP32_01",
    "speed": 67.4,
    "limit": 40,
    "timestamp": "2026-10-01T22:30:10+05:30"
}

n8n then handles the rest.

For a larger deployment, MQTT can be introduced:

ESP32
  │
  │ MQTT
  ▼
MQTT Broker
  │
  ▼
n8n

22. Event/state machine

A useful engineering design is to make the ESP32 operate as a state machine.

       ┌────────────┐
       │    IDLE    │
       └─────┬──────┘
             │
       Sensor A
             ▼
       ┌────────────┐
       │ VEHICLE_1  │
       └─────┬──────┘
             │
       Sensor B
             ▼
       ┌────────────┐
       │ CALCULATE  │
       └─────┬──────┘
             │
             ▼
       ┌────────────┐
       │ TRANSMIT   │
       └─────┬──────┘
             │
             ▼
       ┌────────────┐
       │    IDLE    │
       └────────────┘

This is more reliable than putting everything inside a single loop().


23. Data flow diagram — Level 0

                  ┌───────────┐
                  │  Vehicle  │
                  └─────┬─────┘
                        │
                        ▼
              ┌──────────────────┐
              │ Vehicle Monitoring│
              │     System        │
              └────────┬─────────┘
                       │
       ┌───────────────┼────────────────┐
       ▼               ▼                ▼
    Speed           Plate             Image
    Data            Number            Data
       │               │                │
       └───────────────┼────────────────┘
                       ▼
                 Cloud / n8n
                       │
           ┌───────────┼───────────┐
           ▼           ▼           ▼
       Database     Dashboard    Alerts

24. Data flow diagram — Level 1

Vehicle
   │
   ▼
[1.0 Vehicle Detection]
   │
   ├──► Sensor timestamp
   │
   ▼
[2.0 Speed Calculation]
   │
   ▼
[3.0 Camera Capture]
   │
   ▼
[4.0 AI Vehicle Detection]
   │
   ▼
[5.0 Number Plate Detection]
   │
   ▼
[6.0 OCR]
   │
   ▼
[7.0 n8n Automation]
   │
   ├──► [Google Sheets]
   │
   ├──► [ThingSpeak]
   │
   ├──► [Web Dashboard]
   │
   └──► [Telegram]
                 │
                 ▼
             Voice Alert

25. Database/event structure

A more professional system should assign each vehicle event a unique ID.

EVT-YYYYMMDD-HHMMSS-DEVICE

Example:

EVT-20261001-223010-ESP01

Recommended event fields:

{
    "event_id": "",
    "device_id": "",
    "timestamp": "",
    "speed": 0,
    "speed_limit": 0,
    "overspeed": false,
    "plate_number": "",
    "plate_confidence": 0,
    "vehicle_type": "",
    "image_url": "",
    "latitude": null,
    "longitude": null,
    "processing_status": "",
    "alert_status": ""
}

26. Reliability features

For a serious prototype, add:

  • Sensor debounce

  • Duplicate-event prevention

  • Camera confidence threshold

  • OCR confidence threshold

  • Wi-Fi reconnect

  • n8n retry

  • Local event buffering

  • Timestamp synchronization using NTP

  • Watchdog timer

  • Unique event IDs

  • API authentication

  • HTTPS where practical

  • Input validation

  • Error logging


27. Offline operation

The ESP32 should not lose the measurement simply because Wi-Fi temporarily disappears.

             Vehicle
                │
                ▼
             ESP32
                │
          Calculate speed
                │
                ▼
        ┌───────────────┐
        │ Wi-Fi available│
        └───────┬───────┘
             YES│   │NO
                │   │
                ▼   ▼
              Send  Store
              cloud locally
                    │
                    ▼
               Reconnect
                    │
                    ▼
               Upload queue

A small local queue can store events until connectivity returns.


28. AI agent responsibilities

The AI agent can be used for agentic automation, rather than making the basic speed calculation dependent on an LLM.

For example:

                 ┌──────────────┐
                 │ Vehicle Event│
                 └──────┬───────┘
                        ▼
                 ┌──────────────┐
                 │ Rule Engine  │
                 │ speed > limit│
                 └──────┬───────┘
                        ▼
                 ┌──────────────┐
                 │ AI Agent     │
                 └──────┬───────┘
                        │
          ┌─────────────┼─────────────┐
          ▼             ▼             ▼
       Summarize     Choose tool   Generate
       event         action         message

The AI agent can call tools such as:

Tool 1: get_vehicle_event
Tool 2: write_google_sheet
Tool 3: update_dashboard
Tool 4: send_telegram
Tool 5: send_voice_alert
Tool 6: get_device_status

29. Example agent decision

Input:

{
    "speed": 72,
    "limit": 40,
    "plate": "TS09AB1234",
    "confidence": 0.96
}

Deterministic rule:

72 > 40

Therefore:

OVERSPEED = TRUE

Agent task:

1. Record event.
2. Create alert.
3. Send Telegram notification.
4. Generate voice notification.
5. Update dashboard.

This creates the agentic IoT aspect of the project.


30. Security architecture

Don't expose the ESP32 directly to the public internet.

Prefer:

ESP32
  │
  ▼
Router/firewall
  │
  ▼
HTTPS
  │
  ▼
n8n
  │
  ├── authentication
  ├── validation
  └── rate limiting

Use:

  • Webhook authentication

  • HTTPS

  • API keys/tokens

  • Secrets stored in n8n credentials

  • No passwords embedded in public GitHub repositories

  • Restricted Google/Telegram credentials

  • Input validation


31. Project modules

For your report, divide the project into these modules:

Module 1 — Vehicle Detection

Detect vehicle arrival using IR/ultrasonic sensors.

Module 2 — Speed Measurement

Calculate vehicle speed from two detection points.

Module 3 — Image Acquisition

Capture the vehicle image.

Module 4 — AI Vehicle Detection

Identify the vehicle within the image.

Module 5 — Number Plate Detection

Locate the registration plate.

Module 6 — OCR

Convert the plate image into text.

Module 7 — ESP32 IoT Communication

Send measurements to the cloud.

Module 8 — n8n Automation

Process and route events.

Module 9 — AI Agent

Analyze events and orchestrate actions.

Module 10 — Google Sheets

Store event history.

Module 11 — ThingSpeak

Display IoT measurements.

Module 12 — Telegram

Send real-time notifications and voice alerts.

Module 13 — Web Dashboard

Display current and historical system status.


32. Testing plan

Test Input Expected result
Sensor A Vehicle crosses T1 recorded
Sensor B Vehicle crosses T2 recorded
Speed Known speed Approx. calculated speed
Normal vehicle Below limit Normal status
Fast vehicle Above limit Overspeed status
Camera Vehicle image Image captured
Plate Valid plate OCR text generated
Low OCR confidence Poor image Review/uncertain status
Wi-Fi Connected Event uploaded
Wi-Fi Disconnected Event buffered
n8n Valid JSON Workflow executed
Google Sheets Event Row created
ThingSpeak Event Dashboard updated
Telegram Violation Message sent
Voice Violation Voice alert generated

33. Demonstration setup

For a college/project demonstration, don't test at actual road traffic speeds.

Build a miniature test track:

              MINI ROAD

       Sensor A              Sensor B
          │                     │
          ▼                     ▼
══════════╪═════════════════════╪══════════
          │<------ 2 m -------->│

             🚗 Toy vehicle
                  →

              Camera
                 │
                 ▼
           Raspberry Pi/PC
                 │
                 ▼
                n8n
                 │
       ┌─────────┼─────────┐
       ▼         ▼         ▼
    Sheets    Telegram  Dashboard

This is safer and gives you repeatable measurements.


34. Suggested project folder structure

AI-Vehicle-Monitoring/
│
├── README.md
│
├── firmware/
│   └── esp32_speed_monitor/
│       └── esp32_speed_monitor.ino
│
├── ai/
│   ├── app.py
│   ├── detector.py
│   ├── plate_detector.py
│   ├── ocr.py
│   └── requirements.txt
│
├── n8n/
│   ├── vehicle_monitoring.json
│   └── README.md
│
├── dashboard/
│   ├── index.html
│   ├── style.css
│   └── app.js
│
├── docs/
│   ├── architecture.md
│   ├── hardware.md
│   ├── software.md
│   ├── testing.md
│   └── report.md
│
└── images/
    ├── schematic.png
    ├── flowchart.png
    └── dashboard.png

35. Final project architecture

                         ┌────────────────────┐
                         │      VEHICLE       │
                         └─────────┬──────────┘
                                   │
                    ┌──────────────┴──────────────┐
                    │                             │
                    ▼                             ▼
             ┌────────────┐                ┌─────────────┐
             │ IR Sensor A│                │   Camera    │
             └─────┬──────┘                └──────┬──────┘
                   │                              │
                   ▼                              │
             ┌────────────┐                        │
             │ IR Sensor B│                        │
             └─────┬──────┘                        │
                   │                               │
                   ▼                               ▼
             ┌────────────────┐          ┌─────────────────┐
             │     ESP32      │          │ AI Vision Server │
             │                │          │                 │
             │ Speed          │          │ YOLO/OpenCV     │
             │ Wi-Fi          │          │ Plate detection │
             │ IoT            │          │ OCR             │
             └────────┬───────┘          └────────┬────────┘
                      │                           │
                      └────────────┬──────────────┘
                                   │
                                   ▼
                          ┌────────────────┐
                          │      n8n       │
                          │ Automation     │
                          └───────┬────────┘
                                  │
                         ┌────────┴────────┐
                         │                 │
                         ▼                 ▼
                  ┌────────────┐    ┌─────────────┐
                  │ AI Agent   │    │ Rule Engine │
                  └─────┬──────┘    └──────┬──────┘
                        │                  │
             ┌──────────┼──────────┬───────┤
             │          │          │       │
             ▼          ▼          ▼       ▼
        Google       ThingSpeak  Web    Telegram
        Sheets                   App       │
                                           ▼
                                     Voice Alert

36. Recommended final deliverables

For a complete project submission, the documentation should contain:

  1. Abstract

  2. Introduction

  3. Problem statement

  4. Existing system

  5. Proposed system

  6. Objectives

  7. Scope

  8. System requirements

  9. Hardware requirements

  10. Software requirements

  11. System architecture

  12. Block diagram

  13. Circuit schematic

  14. ESP32 pin configuration

  15. Speed-measurement mathematics

  16. AI/ANPR architecture

  17. OCR workflow

  18. n8n workflow

  19. AI-agent architecture

  20. Telegram integration

  21. Google Sheets integration

  22. ThingSpeak integration

  23. Web dashboard

  24. Complete ESP32 code

  25. AI/Python code

  26. n8n workflow JSON

  27. Dashboard source code

  28. Database/event schema

  29. Flowcharts

  30. Data-flow diagrams

  31. Sequence diagrams

  32. Test cases

  33. Results

  34. Limitations

  35. Security considerations

  36. Future enhancements

  37. Conclusion

  38. References

  39. Viva questions and answers

One important engineering point: for a working system, I would not make the LLM itself responsible for determining whether a vehicle is speeding. The measured speed and configured threshold should be deterministic; the AI agent should handle interpretation, orchestration, and notifications. That makes the system much more reliable and easier to defend during a project viva.

If you want this as a full project report, the next useful step is to build the complete package in sequence: (1) detailed circuit schematic → (2) exact ESP32/ESP32-CAM code → (3) Python ANPR/OCR code → (4) importable n8n workflow → (5) Telegram voice workflow → (6) Google Sheets/ThingSpeak configuration → (7) complete web dashboard → (8) final 30–50 page project documentation and viva questions.

full project report

detailed circuit schematic

exact ESP32/ESP32-CAM code

Python ANPR/OCR code

importable n8n workflow

Telegram voice workflow

Google Sheets/ThingSpeak configuration

complete web dashboard

final 30–50 page project documentation and viva questions

 

Absolutely . Below is a complete project-submission documentation structure you can use as the master report. It is written around the project:

AI-Powered Vehicle Speed Monitoring & Automatic Number Plate Recognition System Using ESP32, AI, IoT, n8n Automation, Telegram Voice Alerts, Google Sheets and ThingSpeak


1. Abstract

The proposed project presents an intelligent IoT-based vehicle monitoring system capable of detecting vehicles, measuring their speed, recognizing vehicle number plates, storing vehicle-event information, and generating real-time notifications. The system combines an ESP32 microcontroller with vehicle detection sensors, camera-based artificial intelligence, automatic number plate recognition (ANPR), optical character recognition (OCR), n8n workflow automation, an AI agent, Google Sheets, ThingSpeak, and Telegram.

The ESP32 measures vehicle speed using two sensing points separated by a known distance. The time taken by a vehicle to travel between the two points is measured, and the vehicle speed is calculated using the distance/time relationship. A camera captures vehicle images, which are processed by an AI vision system to identify the vehicle and locate its number plate. OCR is then used to extract the registration number.

The resulting data is transferred to an n8n automation workflow. n8n combines sensor measurements with AI results and applies deterministic rules to determine whether the vehicle exceeds the configured speed limit. An AI agent can then generate an event summary and orchestrate actions such as logging the event, updating dashboards, and sending notifications.

Vehicle events are stored in Google Sheets and IoT parameters can be visualized through ThingSpeak. Telegram is used for real-time text and voice notifications. A web dashboard provides an interface for viewing vehicle speed, number plate information, violation status, confidence values, and historical information.

The project demonstrates the integration of embedded systems, artificial intelligence, computer vision, IoT, cloud services, workflow automation, and conversational/agentic AI into a single intelligent transportation-monitoring prototype.


2. Introduction

Rapid growth in road traffic has increased the need for automated traffic-monitoring technologies. Conventional speed monitoring often requires dedicated equipment and manual observation. Similarly, manual identification of vehicle registration numbers is time-consuming and difficult to scale.

Artificial intelligence and IoT technologies provide an opportunity to automate these operations.

The proposed system combines:

  • ESP32 embedded technology

  • Vehicle detection sensors

  • Camera-based computer vision

  • Automatic number plate recognition

  • OCR

  • IoT communication

  • n8n automation

  • AI-agent orchestration

  • Google Sheets

  • ThingSpeak

  • Telegram notifications

  • Web-based visualization

The ESP32 acts as the edge controller responsible for sensor acquisition, timing, speed calculation, and communication. AI processing is performed by a more capable computer or server because full image recognition and OCR are computationally demanding for a conventional ESP32.

The system is designed primarily as an educational/prototype platform demonstrating how embedded systems and AI services can work together.


3. Problem Statement

Traditional vehicle monitoring systems can have several limitations:

  • Manual speed monitoring requires human supervision.

  • Manual number-plate recording is slow.

  • Vehicle information may not be available immediately.

  • Separate systems may be required for speed measurement, image recognition, storage, and notification.

  • Historical information may be difficult to organize.

  • Real-time notification may not be available.

  • IoT dashboards and automation are often separate from the sensing system.

The project addresses these problems by integrating vehicle sensing, speed measurement, AI-based plate recognition, cloud logging, automation, dashboards, and notifications into a unified architecture.


4. Existing System

A conventional vehicle monitoring arrangement may contain:

Vehicle
   │
   ▼
Speed Sensor
   │
   ▼
Display

For ANPR:

Vehicle
   │
   ▼
Camera
   │
   ▼
Human Operator
   │
   ▼
Manual Plate Recording

Such systems may require separate components for:

  • Speed measurement

  • Image capture

  • Number plate recognition

  • Data storage

  • Alert generation

  • Visualization

The proposed system integrates these functions through an IoT and automation architecture.


5. Proposed System

The proposed system consists of five major layers.

┌──────────────────────────────────────────┐
│             VEHICLE LAYER                │
│ Vehicle + Number Plate + Motion          │
└────────────────────┬─────────────────────┘
                     │
┌────────────────────▼─────────────────────┐
│             EDGE LAYER                   │
│ ESP32 + Sensors + Camera Interface       │
└────────────────────┬─────────────────────┘
                     │
┌────────────────────▼─────────────────────┐
│             AI LAYER                     │
│ Vehicle Detection + Plate Detection +   │
│ OCR                                      │
└────────────────────┬─────────────────────┘
                     │
┌────────────────────▼─────────────────────┐
│        AUTOMATION / AGENT LAYER          │
│ n8n + Rules + AI Agent                   │
└────────────────────┬─────────────────────┘
                     │
┌────────────────────▼─────────────────────┐
│           APPLICATION LAYER              │
│ Google Sheets + ThingSpeak + Web +       │
│ Telegram Voice Alerts                    │
└──────────────────────────────────────────┘

6. Objectives

The main objectives are:

  1. Detect vehicles automatically.

  2. Measure vehicle speed.

  3. Calculate speed using two detection points.

  4. Capture vehicle images.

  5. Detect vehicle number plates.

  6. Extract registration numbers using OCR.

  7. Determine whether the configured speed limit is exceeded.

  8. Send vehicle information to n8n.

  9. Automate event processing.

  10. Store records in Google Sheets.

  11. Visualize IoT parameters.

  12. Send Telegram notifications.

  13. Generate Telegram voice alerts.

  14. Provide a web dashboard.

  15. Demonstrate agentic AI integration with IoT.


7. Scope

The project scope includes:

Hardware

  • ESP32

  • Sensors

  • Camera

  • LEDs

  • Buzzer

  • Optional GPS

  • Optional display

Software

  • Arduino IDE

  • ESP32 firmware

  • Python AI service

  • Computer vision

  • OCR

  • n8n

  • Google Sheets

  • ThingSpeak

  • Telegram Bot

  • Web dashboard

AI

  • Vehicle detection

  • Number plate detection

  • OCR

  • Event summarization

  • Automation assistance

The system is intended as a prototype and educational demonstration rather than a certified enforcement system.


8. System Requirements

Functional requirements

The system shall:

  • Detect a vehicle.

  • Record detection timestamps.

  • Calculate vehicle speed.

  • Compare speed with a configured limit.

  • Capture/process vehicle images.

  • Detect number plates.

  • Extract plate text.

  • Store events.

  • Generate alerts.

  • Display current information.

Non-functional requirements

The system should provide:

  • Reasonable measurement accuracy

  • Reliable communication

  • Fault recovery

  • Data validation

  • Secure credentials

  • Low response time

  • Expandability

  • Maintainability


9. Hardware Requirements

Component Purpose
ESP32 DevKit Main controller
ESP32-CAM/camera Image acquisition
IR Sensor A First vehicle detection
IR Sensor B Second vehicle detection
OLED Local information display
Buzzer Local alarm
Red LED Overspeed indication
Green LED Normal indication
GPS Optional location
Wi-Fi router Internet connectivity
5 V supply Power

10. Software Requirements

Software Purpose
Arduino IDE ESP32 development
C/C++ ESP32 programming
Python AI backend
OpenCV Image processing
OCR engine Plate text extraction
n8n Workflow automation
Google Sheets Event database
ThingSpeak IoT visualization
Telegram Bot Notification
HTML/CSS/JavaScript Dashboard

11. System Architecture

                     ┌──────────────┐
                     │   VEHICLE    │
                     └──────┬───────┘
                            │
              ┌─────────────┴────────────┐
              │                          │
              ▼                          ▼
        ┌──────────┐               ┌──────────┐
        │ Sensor A │               │ Camera   │
        └────┬─────┘               └────┬─────┘
             │                          │
             ▼                          ▼
        ┌──────────┐               ┌──────────┐
        │ Sensor B │               │ AI/OCR   │
        └────┬─────┘               └────┬─────┘
             │                          │
             ▼                          │
        ┌──────────┐                    │
        │  ESP32   │────────────────────┘
        └────┬─────┘
             │
             ▼
        ┌──────────┐
        │   n8n    │
        └────┬─────┘
             │
      ┌──────┼─────────┐
      ▼      ▼         ▼
    Sheets ThingSpeak Telegram
                         │
                         ▼
                    Voice Alert

             n8n
              │
              ▼
        Web Dashboard

12. Block Diagram

 ┌──────────────┐
 │ Vehicle      │
 └──────┬───────┘
        │
        ▼
 ┌─────────────────┐
 │ Vehicle Sensors │
 └────────┬────────┘
          │
          ▼
 ┌─────────────────┐
 │ ESP32 Controller│
 │                 │
 │ Timing          │
 │ Speed           │
 │ Wi-Fi           │
 └────────┬────────┘
          │
          │ HTTP/JSON
          ▼
 ┌─────────────────┐
 │      n8n        │
 └────────┬────────┘
          │
    ┌─────┴─────┐
    ▼           ▼
 AI Vision   Rule Engine
    │           │
    └─────┬─────┘
          ▼
      AI Agent
          │
 ┌────────┼─────────┬──────────┐
 ▼        ▼         ▼          ▼
Sheets ThingSpeak Telegram Dashboard
                   │
                   ▼
             Voice Notification

13. Circuit Schematic

A simplified circuit is:

                         ESP32
                ┌────────────────────┐
                │                    │
Sensor A OUT ───┤ GPIO 27            │
Sensor B OUT ───┤ GPIO 26            │
                │                    │
Buzzer ─────────┤ GPIO 25            │
                │                    │
Red LED ────────┤ GPIO 33            │
Green LED ──────┤ GPIO 32            │
                │                    │
OLED SDA ───────┤ GPIO 21            │
OLED SCL ───────┤ GPIO 22            │
                │                    │
                │       Wi-Fi        │
                └────────────────────┘

Sensor A VCC ───────── 3.3V
Sensor B VCC ───────── 3.3V
OLED VCC ───────────── 3.3V

All grounds ────────── GND

LED connection

ESP32 GPIO
    │
   220Ω
    │
    ▼
   LED
    │
    ▼
   GND

The exact sensor wiring depends on the selected sensor module. Ensure that sensor outputs never exceed the ESP32 GPIO voltage specification.


14. ESP32 Pin Configuration

ESP32 GPIO Function
GPIO 27 Sensor A
GPIO 26 Sensor B
GPIO 25 Buzzer
GPIO 33 Red LED
GPIO 32 Green LED
GPIO 21 I²C SDA
GPIO 22 I²C SCL

The pins can be changed according to the actual ESP32 board and connected peripherals.


15. Speed Measurement Mathematics

Let:

D=distance between sensorsD = \text{distance between sensors}

and:

T1=time vehicle crosses Sensor AT_1 = \text{time vehicle crosses Sensor A}

T2=time vehicle crosses Sensor BT_2 = \text{time vehicle crosses Sensor B}

Then:

ΔT=T2−T1\Delta T=T_2-T_1

Speed in metres/second:

V=DΔTV=\frac{D}{\Delta T}

Speed in kilometres/hour:

Vkm/h=DΔT×3.6V_{km/h}= \frac{D}{\Delta T}\times3.6

Example

Given:

D = 5 m
T1 = 10.00 s
T2 = 10.50 s

Then:

ΔT=0.50s\Delta T=0.50s

V=5/0.5=10m/sV=5/0.5=10m/s

Therefore:

V=10×3.6=36km/hV=10\times3.6=36km/h

If:

Speed limit = 40 km/h

then:

Status = NORMAL

16. AI/ANPR Architecture

                Camera
                  │
                  ▼
          Image Acquisition
                  │
                  ▼
        ┌──────────────────┐
        │ Vehicle Detection│
        └────────┬─────────┘
                 │
                 ▼
           Vehicle Crop
                 │
                 ▼
       Number Plate Detector
                 │
                 ▼
             Plate Crop
                 │
                 ▼
          Image Processing
                 │
       ┌─────────┼─────────┐
       ▼         ▼         ▼
    Resize    Contrast   Denoise
       │         │         │
       └─────────┼─────────┘
                 ▼
                OCR
                 │
                 ▼
        Plate Text + Confidence

17. OCR Workflow

Camera Image
     │
     ▼
Plate Detection
     │
     ▼
Crop Plate
     │
     ▼
Resize
     │
     ▼
Grayscale
     │
     ▼
Noise Reduction
     │
     ▼
Thresholding
     │
     ▼
OCR
     │
     ▼
Text Cleaning
     │
     ▼
Confidence Check
     │
     ▼
Plate Number

For example:

Input:
[Image of vehicle]

Detected plate:
TS09AB1234

OCR confidence:
94%

Output:
{
    "plate": "TS09AB1234",
    "confidence": 0.94
}

18. n8n Workflow

The main n8n workflow can be:

[Webhook]
     │
     ▼
[Validate Input]
     │
     ▼
[Generate Event ID]
     │
     ▼
[AI Vision API]
     │
     ▼
[Merge Results]
     │
     ▼
[Calculate/Verify Status]
     │
     ▼
[AI Agent]
     │
     ▼
[Google Sheets]
     │
     ├───────────────► [ThingSpeak]
     │
     └──────┬────────► [Dashboard API]
            │
            ▼
       [IF Overspeed]
          /       \
       FALSE      TRUE
        │           │
        ▼           ▼
       End      [Telegram]
                     │
                     ▼
               [Text-to-Speech]
                     │
                     ▼
              [Telegram Voice]

19. AI-Agent Architecture

The AI agent should be treated as an orchestration component.

                Vehicle Event
                     │
                     ▼
              ┌─────────────┐
              │ Rule Engine │
              └──────┬──────┘
                     │
                     ▼
                ┌────────┐
                │AI Agent│
                └───┬────┘
                    │
       ┌────────────┼────────────┐
       ▼            ▼            ▼
   Summarize    Google Sheet   Telegram
       │
       ├─────────────► Dashboard
       │
       └─────────────► ThingSpeak

The rule engine should make the actual speed-limit determination.

For example:

IF measured_speed > configured_speed_limit
THEN violation = true
ELSE violation = false

The AI agent can then explain and orchestrate the resulting event.


20. Telegram Integration

Telegram communication:

n8n
 │
 ▼
Telegram Bot API
 │
 ├── Text message
 │
 └── Voice/audio message
       │
       ▼
   User's Telegram

Example message:

🚨 VEHICLE SPEED ALERT

Event ID: EVT001
Plate: TS09AB1234
Speed: 67.4 km/h
Limit: 40 km/h
Vehicle: Car
Confidence: 94%
Device: ESP32_01

21. Google Sheets Integration

Recommended columns:

A: Timestamp
B: Event ID
C: Device ID
D: Plate Number
E: Plate Confidence
F: Vehicle Type
G: Speed
H: Speed Limit
I: Status
J: Latitude
K: Longitude
L: Image URL
M: Alert Status

Example:

Timestamp Plate Speed Limit Status
22:30:10 TS09AB1234 67.4 40 Overspeed
22:31:14 TS08XY5678 35.2 40 Normal

22. ThingSpeak Integration

Example channel:

Field 1 → Speed
Field 2 → Speed Limit
Field 3 → Overspeed
Field 4 → Vehicle Count
Field 5 → OCR Confidence
Field 6 → Device Status

Dashboard:

┌─────────────────────────────┐
│ VEHICLE IoT DASHBOARD       │
├─────────────────────────────┤
│ Speed       67.4 km/h       │
│ Limit       40 km/h         │
│ Status      OVERSPEED       │
│ Vehicles    128             │
│                             │
│ Speed History               │
│ 70 ┤        ╭─╮             │
│ 60 ┤     ╭──╯ ╰╮            │
│ 50 ┤─────╯     ╰──          │
│ 40 ┤----------------        │
│                             │
└─────────────────────────────┘

23. Web Dashboard

The dashboard should display:

┌─────────────────────────────────────────┐
│       AI VEHICLE MONITORING SYSTEM      │
├─────────────────────────────────────────┤
│                                         │
│ CURRENT SPEED        NUMBER PLATE       │
│                                         │
│ 67.4 km/h             TS09AB1234        │
│                                         │
├─────────────────────────────────────────┤
│ STATUS               CONFIDENCE         │
│                                         │
│ ⚠ OVERSPEED           94%               │
│                                         │
├─────────────────────────────────────────┤
│ DEVICE: ESP32_01                        │
│ EVENT: EVT-001                          │
│ TIME: 22:30:10                          │
└─────────────────────────────────────────┘

24. Complete ESP32 Code

The basic firmware architecture is:

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

const char* SSID = "YOUR_WIFI";
const char* PASSWORD = "YOUR_PASSWORD";

const char* WEBHOOK =
    "http://YOUR_N8N_SERVER/webhook/vehicle-event";

const int SENSOR_A = 27;
const int SENSOR_B = 26;

const int RED_LED = 33;
const int GREEN_LED = 32;
const int BUZZER = 25;

const float SENSOR_DISTANCE = 5.0;
const float SPEED_LIMIT = 40.0;

volatile bool sensorA = false;
volatile bool sensorB = false;

unsigned long t1 = 0;
unsigned long t2 = 0;

void IRAM_ATTR triggerA()
{
    sensorA = true;
}

void IRAM_ATTR triggerB()
{
    sensorB = true;
}

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

    pinMode(SENSOR_A, INPUT);
    pinMode(SENSOR_B, INPUT);

    pinMode(RED_LED, OUTPUT);
    pinMode(GREEN_LED, OUTPUT);
    pinMode(BUZZER, OUTPUT);

    attachInterrupt(
        digitalPinToInterrupt(SENSOR_A),
        triggerA,
        RISING
    );

    attachInterrupt(
        digitalPinToInterrupt(SENSOR_B),
        triggerB,
        RISING
    );

    WiFi.begin(SSID, PASSWORD);

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

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

void loop()
{
    if (sensorA)
    {
        sensorA = false;

        t1 = millis();

        Serial.println(
            "Vehicle detected at Sensor A"
        );

        unsigned long start = millis();

        while (!sensorB &&
               millis() - start < 5000)
        {
            delay(1);
        }

        if (sensorB)
        {
            sensorB = false;

            t2 = millis();

            float dt =
                (t2 - t1) / 1000.0;

            if (dt > 0)
            {
                float speed =
                    (SENSOR_DISTANCE / dt) * 3.6;

                Serial.print("Speed = ");
                Serial.print(speed);
                Serial.println(" km/h");

                bool overspeed =
                    speed > SPEED_LIMIT;

                if (overspeed)
                {
                    digitalWrite(RED_LED, HIGH);
                    digitalWrite(GREEN_LED, LOW);
                    tone(BUZZER, 2000, 500);
                }
                else
                {
                    digitalWrite(RED_LED, LOW);
                    digitalWrite(GREEN_LED, HIGH);
                }

                sendEvent(
                    speed,
                    overspeed
                );
            }
        }
    }
}

void sendEvent(
    float speed,
    bool overspeed
)
{
    if (WiFi.status() != WL_CONNECTED)
        return;

    HTTPClient http;

    http.begin(WEBHOOK);

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

    String payload = "{";

    payload +=
        "\"device_id\":\"ESP32_01\",";

    payload +=
        "\"speed\":" +
        String(speed, 2) + ",";

    payload +=
        "\"speed_limit\":" +
        String(SPEED_LIMIT, 2) + ",";

    payload +=
        "\"overspeed\":" +
        String(overspeed ? "true" : "false");

    payload += "}";

    int code = http.POST(payload);

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

    http.end();
}

This is the core speed-monitoring firmware; the production version should add NTP time, retry handling, authentication, buffering, and event IDs.


25. AI/Python Code

A minimal Python API architecture:

from flask import Flask, request, jsonify

app = Flask(__name__)


@app.route("/analyze", methods=["POST"])
def analyze():

    image = request.files.get("image")

    if image is None:
        return jsonify({
            "error": "No image received"
        }), 400

    # ---------------------------------
    # Vehicle detection
    # ---------------------------------

    vehicle_detected = True

    # ---------------------------------
    # Number plate detection
    # ---------------------------------

    plate_detected = True

    # ---------------------------------
    # OCR
    # ---------------------------------

    plate_text = "TS09AB1234"
    confidence = 0.94

    return jsonify({
        "vehicle_detected":
            vehicle_detected,

        "plate_detected":
            plate_detected,

        "plate_number":
            plate_text,

        "confidence":
            confidence
    })


if __name__ == "__main__":

    app.run(
        host="0.0.0.0",
        port=5000
    )

For the final implementation, replace the placeholder values with the selected detection and OCR models.


26. n8n Workflow JSON

A simplified conceptual workflow can be represented as:

{
  "name": "AI Vehicle Monitoring",
  "nodes": [
    {
      "name": "Vehicle Webhook",
      "type": "n8n-nodes-base.webhook"
    },
    {
      "name": "Validate Data",
      "type": "n8n-nodes-base.code"
    },
    {
      "name": "AI Vision",
      "type": "n8n-nodes-base.httpRequest"
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent"
    },
    {
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets"
    },
    {
      "name": "ThingSpeak",
      "type": "n8n-nodes-base.httpRequest"
    },
    {
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram"
    }
  ]
}

For an actual importable n8n file, the node IDs, parameters, credentials, connections, webhook path, and API configuration must match the installed n8n version.


27. Dashboard Source Code

The frontend architecture is:

index.html
     │
     ├── CSS
     │
     └── JavaScript
             │
             ▼
        REST API
             │
             ▼
            n8n
             │
             ▼
       Latest event

Example JavaScript:

async function loadLatestEvent() {

    const response =
        await fetch("/api/latest-event");

    const event =
        await response.json();

    document.getElementById("speed")
        .textContent =
        event.speed + " km/h";

    document.getElementById("plate")
        .textContent =
        event.plate;

    document.getElementById("status")
        .textContent =
        event.overspeed
            ? "OVERSPEED"
            : "NORMAL";
}

setInterval(
    loadLatestEvent,
    5000
);

loadLatestEvent();

28. Database/Event Schema

Recommended event object:

{
    "event_id": "EVT001",
    "device_id": "ESP32_01",
    "timestamp": "2026-10-01T22:30:10+05:30",

    "speed": 67.4,
    "speed_limit": 40,
    "overspeed": true,

    "vehicle_type": "car",

    "plate_number": "TS09AB1234",
    "plate_confidence": 0.94,

    "latitude": null,
    "longitude": null,

    "image_url": "",

    "processing_status": "complete",
    "alert_status": "sent"
}

29. Flowchart

              START
                │
                ▼
        Initialize ESP32
                │
                ▼
          Connect Wi-Fi
                │
                ▼
       Monitor Sensor A
                │
        ┌───────┴───────┐
        │               │
       NO              YES
        │               │
        └───────┐       ▼
                │     Record T1
                │       │
                │       ▼
                │  Monitor Sensor B
                │       │
                │       ▼
                │     Record T2
                │       │
                │       ▼
                │ Calculate Speed
                │       │
                │       ▼
                │ Compare Limit
                │       │
                │       ▼
                │ Capture Image
                │       │
                │       ▼
                │ AI + OCR
                │       │
                │       ▼
                │      n8n
                │       │
                │       ▼
                │    AI Agent
                │       │
                │   ┌───┴────┐
                │   ▼        ▼
                │ Normal  Overspeed
                │   │        │
                │   ▼        ▼
                │ Log      Telegram
                │             │
                │             ▼
                │        Voice Alert
                │
                └───────────────► LOOP

30. Data-Flow Diagram

Level 0

Vehicle
   │
   ▼
Vehicle Monitoring System
   │
   ├──── Speed
   ├──── Image
   ├──── Plate
   │
   ▼
Cloud Automation
   │
   ├──── Google Sheets
   ├──── ThingSpeak
   ├──── Telegram
   └──── Web Dashboard

Level 1

Vehicle
   │
   ▼
[Vehicle Detection]
   │
   ▼
[Speed Measurement]
   │
   ├───────────────┐
   │               │
   ▼               ▼
[Camera]       [ESP32]
   │               │
   ▼               │
[AI Detection]     │
   │               │
   ▼               │
[OCR]              │
   │               │
   └───────┬───────┘
           ▼
        [n8n]
           │
      ┌────┼─────┐
      ▼    ▼     ▼
   Sheets IoT  Telegram

31. Sequence Diagram

Vehicle       ESP32       AI Server       n8n       Telegram
   │             │             │            │           │
   │─Detected───►│             │            │           │
   │             │             │            │           │
   │             │─Image──────►│            │           │
   │             │             │            │           │
   │             │─Speed───────────────────►│           │
   │             │             │            │           │
   │             │             │─Result────►│           │
   │             │             │            │           │
   │             │             │            │─Log──────►│
   │             │             │            │           │
   │             │             │            │─Alert────►│
   │             │             │            │           │
   │             │             │            │◄─Sent─────│

32. Test Cases

Test ID Test Expected result
TC01 Sensor A detection Timestamp recorded
TC02 Sensor B detection Second timestamp recorded
TC03 Speed calculation Correct speed generated
TC04 Below-limit vehicle Normal status
TC05 Above-limit vehicle Overspeed status
TC06 Camera capture Image received
TC07 Plate detection Plate region identified
TC08 OCR Plate text extracted
TC09 n8n webhook Event received
TC10 Google Sheets New row created
TC11 ThingSpeak Channel updated
TC12 Telegram Alert received
TC13 Voice Audio notification received
TC14 Dashboard Latest event displayed
TC15 Wi-Fi failure Event buffered/retried

33. Results

The results section should report measured experimental results, not assumed values.

For example:

Parameter Target Measured
Sensor distance 5 m 5.00 m
Test speed 20 km/h ___
Measured speed 20 km/h ___
Speed error — ___ %
Plate recognition confidence >90% ___ %
n8n processing time — ___ s
Telegram alert delay — ___ s

Speed error can be calculated as:

Error(%)=∣Vmeasured−Vreference∣Vreference×100Error(\%) = \frac{|V_{measured}-V_{reference}|} {V_{reference}} \times100


34. Limitations

The prototype has several limitations:

  1. Sensor alignment affects speed accuracy.

  2. IR sensors can be affected by environmental conditions.

  3. Camera quality affects plate recognition.

  4. Poor lighting can reduce OCR accuracy.

  5. Obstructed plates may not be recognized.

  6. OCR may confuse similar characters.

  7. Network failure can interrupt cloud communication.

  8. AI inference requires more computing power than a basic ESP32 can provide.

  9. The system is a prototype and should not automatically be treated as legally valid enforcement evidence.

  10. Camera placement and calibration significantly affect performance.


35. Security Considerations

Security should be included at every layer.

ESP32

  • Avoid hard-coding credentials in public repositories.

  • Use secure Wi-Fi.

  • Authenticate cloud requests.

n8n

  • Protect the n8n instance.

  • Use HTTPS.

  • Protect webhook endpoints.

  • Store credentials using the credential system.

  • Validate incoming JSON.

Google Sheets

  • Use restricted credentials.

  • Give only required permissions.

Telegram

  • Protect the bot token.

  • Do not publish the token.

Web dashboard

  • Authenticate administrative functions.

  • Validate API requests.

  • Avoid exposing private event information unnecessarily.


36. Future Enhancements

Possible future improvements include:

  • Multi-lane vehicle detection

  • Multiple cameras

  • Vehicle classification

  • Vehicle color detection

  • GPS-based mapping

  • Edge AI

  • MQTT

  • Database such as PostgreSQL

  • Mobile application

  • Driverless/automated traffic monitoring

  • Multi-device management

  • Historical analytics

  • Predictive traffic analysis

  • Anomaly detection

  • Camera health monitoring

  • Offline AI inference

  • Automatic model retraining

  • Improved OCR

  • Encrypted device communication

A more advanced architecture could become:

ESP32 Devices
     │
     ▼
MQTT Broker
     │
     ▼
Edge AI
     │
     ▼
n8n
     │
 ┌───┼─────────┐
 ▼   ▼         ▼
DB  AI Agent Dashboard
     │
 ┌───┼────────────┐
 ▼   ▼            ▼
SMS Telegram   Mobile App

37. Conclusion

The proposed AI-powered vehicle monitoring system demonstrates-control layer for vehicle detection, timing, speed calculation, and network communication. The AI processing layer performs vehicle and number-plate recognition and OCR. n8n provides the automation layer connecting the embedded system with cloud services. Google Sheets provides accessible event logging, while ThingSpeak can provide IoT visualization. Telegram provides real-time text and voice notifications, and the web dashboard coordinate appropriate software actions. Deterministic speed calculations and rule-based violation detection remain separate from generative AI, improving how embedded systems, artificial intelligence, computer vision, IoT, workflow automation, cloud services, and conversational interfaces can be integrated into one practical platform.

The ESP32 provides the edge-control layer for vehicle detection, timing, speed calculation, and network communication. The AI processing layer performs vehicle and number-plate recognition and OCR. n8n provides the automation layer connecting the embedded system with cloud services. Google Sheets provides accessible event logging, while ThingSpeak can provide IoT visualization. Telegram provides real-time text and voice notifications, and the web dashboard provides a centralized monitoring interface.

The architecture also demonstrates an agentic-IoT concept in which an AI agent can operate on structured sensor and AI results and coordinate appropriate software actions. Deterministic speed calculations and rule-based violation detection remain separate from generative AI, improving system predictability.

Overall, the project provides a strong demonstration platform for studying ESP32, IoT, AI, ANPR, OCR, n8n automation, cloud integration, dashboards, and agentic AI in a single engineering project.


38. References

Your final report should cite the actual documentation and papers used during implementation. Useful categories include:

  • ESP32 technical/reference documentation

  • Arduino-ESP32 documentation

  • OpenCV documentation

  • OCR engine documentation

  • n8n documentation

  • Telegram Bot API documentation

  • Google Sheets API documentation

  • ThingSpeak documentation

  • Research papers on ANPR

  • Research papers on vehicle detection

  • Research papers on speed estimation

  • AI/computer-vision publications

The exact references should correspond to the libraries, models, APIs, and hardware that you actually use in the final implementation.


39. Viva Questions and Answers

Q1. Why is ESP32 used?

Answer:
ESP32 provides Wi-Fi connectivity, GPIO interfaces, interrupt handling, sufficient processing capability for sensor acquisition, and low -cost embedded control.

Q2. Why are two sensors used?

Answer:
Two sensors provide two time references. With a known distance between them, vehicle speed can be calculated using distance divided by elapsed time.

Q3. What is the speed formula?

Answer:

V=DT2−T1V=\frac{D}{T_2-T_1}

and for km/h:

Vkm/h=DT2−T1×3.6V_{km/h}= \frac{D}{T_2-T_1}\times3.6

Q4. Why isn't all AI processing performed on ESP32?

Answer:
Full vehicle detection, plate detection, and OCR are computationally demanding. A dedicated computer, Raspberry Pi, Jetson, or server provides considerably more processing capability.

Q5. What is ANPR?

Answer:
ANPR stands for Automatic Number Plate Recognition. It automatically detects a vehicle registration plate and extracts the plate characters.

Q6. What is OCR?

Answer:
OCR stands for Optical Character Recognition. It converts characters present in an image into machine-readable text.

Q7. Why is n8n used?

Answer:
n8n connects the ESP32, AI service, databases, dashboards, and notification services through configurable workflows without requiring all integration logic to be implemented manually.

Q8. What is the role of the AI agent?

Answer:
The AI agent can interpret structured events, generate summaries, and orchestrate software tools such as logging and notifications. It should not replace deterministic safety-critical calculations.

Q9. Why use Google Sheets?

Answer:
Google Sheets provides an easily accessible cloud-based record of vehicle events and is convenient for prototype development and demonstrations.

Q10. What is ThingSpeak?

Answer:
ThingSpeak is an IoT-oriented platform that can receive sensor data and display it through channels and visualizations.

Q11. Why use Telegram?

Answer:
Telegram provides a convenient mechanism for delivering real-time text and voice notifications to an operator.

Q12. What happens if Wi-Fi fails?

Answer:
A robust implementation should temporarily buffer the event locally and transmit it after network connectivity is restored.

Q13. How can speed accuracy be improved?

Answer:
Accuracy can be improved through accurate sensor spacing, precise timestamping, sensor calibration, stable sensor mounting, filtering, and repeated experimental calibration.

Q14. What affects ANPR accuracy?

Answer:
Lighting, camera resolution, plate angle, motion blur, dirt or obstruction on the plate, image quality, and OCR/model performance can affect recognition.

Q15. Can this system be deployed directly for traffic enforcement?

Answer:
The prototype demonstrates the technical architecture, but real enforcement deployment would require appropriate calibration, validation, security, legal/regulatory compliance, evidence handling, and certification requirements.

Q16. What happens when OCR confidence is low?

Answer:
The system should mark the result as uncertain rather than inventing a plate number. It can request review or store the event with its confidence value.

Q17. What is the role of the web dashboard?

Answer:
It provides real-time visualization of speed, plate information, status, device information, and historical monitoring data.

Q18. What protocol can be used between ESP32 and n8n?

Answer:
HTTP/HTTPS with JSON is simple for the initial prototype. MQTT is another suitable choice, particularly when multiple IoT devices are involved.

Q19. What is an event ID?

Answer:
An event ID uniquely identifies one vehicle-detection event and allows information from sensors, AI, databases, dashboards, and notifications to be correlated.

Q20. What is the main advantage of the proposed architecture?

Answer:
The architecture separates edge sensing, AI processing, automation, storage, visualization, and notification into modular components, making the system easier to develop, test, expand, and maintain.


Recommended final project structure

For the actual submission, I would organize the report as:

CHAPTER 1   INTRODUCTION
CHAPTER 2   LITERATURE / EXISTING SYSTEM
CHAPTER 3   PROPOSED SYSTEM
CHAPTER 4   HARDWARE DESIGN
CHAPTER 5   SOFTWARE DESIGN
CHAPTER 6   AI / ANPR / OCR
CHAPTER 7   ESP32 IMPLEMENTATION
CHAPTER 8   n8n + AI AGENT AUTOMATION
CHAPTER 9   CLOUD / TELEGRAM / GOOGLE SHEETS / THINGSPEAK
CHAPTER 10  WEB DASHBOARD
CHAPTER 11  TESTING AND RESULTS
CHAPTER 12  SECURITY AND LIMITATIONS
CHAPTER 13  FUTURE ENHANCEMENTS
CHAPTER 14  CONCLUSION
             REFERENCES
             APPENDIX A – ESP32 CODE
             APPENDIX B – PYTHON CODE
             APPENDIX C – n8n WORKFLOW
             APPENDIX D – DASHBOARD CODE
             APPENDIX E – CIRCUIT DIAGRAM
             APPENDIX F – VIVA QUESTIONS

This gives you a coherent end-to-end project report rather than just a collection of code snippets.