Sunday, 4 October 2026

AI Accident Alert & Vehicle Tracking using IoT Analytics

AI Accident Alert & Vehicle Tracking Using IoT, ESP32, n8n, AI Agent, Telegram, Google Sheets & ThingSpeak

Below is a complete reference implementation you can use as a final-year project, mini-project, prototype, GitHub project, or technical documentation.

The system combines:

  • ESP32

  • MPU6050 accelerometer/gyroscope

  • GPS module

  • optional buzzer/SOS button

  • Wi-Fi

  • n8n automation

  • AI Agent

  • Telegram bot

  • Telegram voice alerts

  • Google Sheets

  • ThingSpeak cloud dashboard

  • accident detection

  • vehicle tracking

  • event logging

  • AI-based accident analysis

The architecture deliberately keeps fast accident detection on the ESP32 and uses the cloud/AI layer for analysis, notification and logging. ESP32 supports Wi-Fi station mode for Internet connectivity, while ThingSpeak provides REST APIs for writing channel data. Espressif Systems+1


1. Project title

AI Accident Alert & Vehicle Tracking Using IoT Analytics

Alternative project titles

You can use any of these for your report:

Option 1

AI-Powered Accident Detection and Vehicle Tracking System Using ESP32, IoT Analytics and n8n Automation

Option 2

Agentic IoT Vehicle Safety System Using ESP32, AI Agent, n8n and Telegram Voice Alerts

Option 3

Smart Vehicle Accident Detection, GPS Tracking and AI Emergency Alert System

Option 4

AI-Powered ESP32 Vehicle Monitoring System with n8n, Telegram, Google Sheets and ThingSpeak


2. Abstract

Road accidents require rapid detection and communication because the driver or passengers may be unable to manually contact emergency contacts after a serious collision.

This project proposes an AI-powered IoT accident detection and vehicle tracking system based on an ESP32 microcontroller. The ESP32 continuously monitors vehicle motion using an MPU6050 accelerometer and gyroscope and obtains the vehicle's geographical position using a GPS receiver.

When an abnormal impact or accident-like motion is detected, the ESP32 generates an accident event containing acceleration, gyroscope, GPS coordinates, speed and device information. The event is transmitted through Wi-Fi to an n8n automation workflow.

n8n acts as the orchestration layer. It receives the IoT event, validates and enriches the data, sends the event to an AI Agent for interpretation, records the event in Google Sheets, updates ThingSpeak and generates an emergency notification.

The notification can be delivered to a predefined Telegram user or group as both a text message and a voice alert. Telegram's Bot API supports sending voice messages, while n8n provides built-in Telegram automation functionality. Telegram+1

The system therefore creates an integrated pipeline:

Physical vehicle → Sensors → ESP32 → Internet → n8n → AI Agent → Google Sheets + ThingSpeak + Telegram Voice Alert


3. Main objectives

The project has the following objectives:

  1. Detect possible vehicle accidents.

  2. Measure vehicle acceleration and angular motion.

  3. Determine the vehicle's GPS position.

  4. Track the vehicle remotely.

  5. Send sensor data to a cloud platform.

  6. Automatically analyze accident events using AI.

  7. Generate emergency Telegram notifications.

  8. Generate Telegram voice alerts.

  9. Maintain an accident/event history in Google Sheets.

  10. Visualize vehicle telemetry through ThingSpeak.

  11. Provide an extensible agentic IoT architecture.

  12. Reduce dependence on manual emergency reporting.


4. Overall system architecture

                         ┌───────────────────────┐
                         │      VEHICLE          │
                         │                       │
                         │  MPU6050              │
                         │  Accelerometer/Gyro   │
                         │                       │
                         │  GPS NEO-6M          │
                         │  Latitude/Longitude   │
                         │                       │
                         │  SOS Button           │
                         │  Buzzer/LED           │
                         └───────────┬───────────┘
                                     │
                                     ▼
                         ┌───────────────────────┐
                         │        ESP32           │
                         │                       │
                         │ Sensor acquisition    │
                         │ Accident detection    │
                         │ GPS processing        │
                         │ Event generation      │
                         └───────────┬───────────┘
                                     │
                                  Wi-Fi
                                     │
                                     ▼
                         ┌───────────────────────┐
                         │     n8n WEBHOOK       │
                         │                       │
                         │ Receive IoT JSON      │
                         │ Validate data         │
                         └───────────┬───────────┘
                                     │
                                     ▼
                         ┌───────────────────────┐
                         │      AI AGENT         │
                         │                       │
                         │ Accident assessment   │
                         │ Severity classification│
                         │ Response generation   │
                         └──────┬─────┬─────┬────┘
                                │     │     │
                   ┌────────────┘     │     └─────────────┐
                   ▼                  ▼                   ▼
          ┌────────────────┐ ┌───────────────┐ ┌──────────────────┐
          │ Google Sheets  │ │  ThingSpeak   │ │    Telegram      │
          │ Event database │ │ Cloud graphs  │ │ Text + Voice     │
          └────────────────┘ └───────────────┘ └──────────────────┘

5. Hardware requirements

Required components

Component Purpose
ESP32 DevKit Main IoT controller
MPU6050 Accelerometer + gyroscope
NEO-6M GPS Location and speed
Buzzer Local accident warning
Push button Manual SOS
LED Status indication
Breadboard Prototyping
Jumper wires Connections
5 V power source Vehicle/project power
USB cable Programming

Optional components

  • OLED display

  • vibration sensor

  • temperature sensor

  • current sensor

  • GSM/LTE module

  • SD card

  • camera

  • ESP32-CAM

  • relay

  • emergency cancellation button


6. Recommended hardware architecture

                       +----------------------+
                       |       VEHICLE        |
                       +----------------------+

             +----------------+
             |    MPU6050     |
             | Accel + Gyro   |
             +-------+--------+
                     |
                 I2C |
                     |
                     v
              +-------------+
              |    ESP32    |
              |             |
              | Wi-Fi       |
              | Processing  |
              +------+------+ 
                     |
          +----------+-----------+
          |                      |
       UART GPS               GPIO
          |                      |
          v                      v
   +-------------+        +-------------+
   |   NEO-6M    |        | SOS Button  |
   | GPS Module  |        +-------------+
   +-------------+
                     |
                     v
                  Buzzer

7. Schematic diagram

A simple prototype wiring can be arranged as follows.

MPU6050 → ESP32

MPU6050 ESP32
VCC 3.3 V
GND GND
SDA GPIO 21
SCL GPIO 22

GPS → ESP32

NEO-6M ESP32
VCC Appropriate module supply
GND GND
TX GPIO 16
RX GPIO 17

Use a proper voltage level arrangement for the particular GPS module you purchase.

Buzzer

ESP32 GPIO 25
      |
      +---- Buzzer
      |
     GND

For a higher-current buzzer, drive it through a transistor rather than directly from the ESP32 GPIO.

SOS button

GPIO 27
  |
  +-------- Push Button -------- GND

Configure the pin with INPUT_PULLUP.


8. Complete electrical block diagram

                  +-------------------+
                  |     5V INPUT      |
                  +---------+---------+
                            |
                     +------+------+
                     |   ESP32     |
                     |             |
                     | 3.3V        |
                     +--+----------+
                        |
             +----------+----------+
             |                     |
             v                     v
        +---------+           +---------+
        | MPU6050 |           |  GPS    |
        | I2C     |           | NEO-6M  |
        +---------+           +---------+
             |                     |
             |                     |
             +----------+----------+
                        |
                        v
                  Sensor Processing
                        |
                        v
                    Accident?
                    /       \
                  NO         YES
                  |           |
                  |           v
                  |      Create Event
                  |           |
                  +-----------+
                              |
                              v
                         Wi-Fi Upload
                              |
                              v
                          n8n Webhook

9. How accident detection works

The MPU6050 provides:

  • X acceleration

  • Y acceleration

  • Z acceleration

  • X angular velocity

  • Y angular velocity

  • Z angular velocity

Acceleration magnitude can be calculated as:

A=Ax2+Ay2+Az2A=\sqrt{A_x^2+A_y^2+A_z^2}

During stationary conditions, the acceleration magnitude is approximately close to:

1g≈9.81m/s21g \approx 9.81m/s^2

A collision can produce a sudden acceleration spike.

However, do not use a single acceleration threshold as a production accident detector.

A better prototype algorithm combines:

Acceleration spike
       +
Gyroscope spike
       +
Sudden change in motion
       +
Vehicle speed/GPS state
       +
Short confirmation window

Example:

Acceleration > threshold
          |
          v
   Possible impact
          |
          v
Check gyro
          |
          v
Check GPS speed
          |
          v
Calculate confidence
          |
          v
Accident confidence > 70% ?
       /             \
     NO               YES
     |                 |
 Normal event      ACCIDENT
                       |
                       v
                 Send emergency

10. Accident confidence calculation

For a prototype you can use:

Acceleration score = 40%
Gyroscope score    = 25%
Speed score        = 20%
Motion change      = 15%

Example:

acceleration = 85%
gyro         = 70%
speed        = 80%
motion       = 90%

confidence =
0.40(85) +
0.25(70) +
0.20(80) +
0.15(90)

confidence = 81.75%

The ESP32 can classify:

0–39%   → NORMAL
40–69%  → SUSPICIOUS
70–100% → POSSIBLE ACCIDENT

For a student prototype, these thresholds should be experimentally calibrated rather than presented as medically or automotive-certified thresholds.


11. GPS tracking

The GPS module supplies:

{
  "latitude": 17.3850,
  "longitude": 78.4867,
  "speed_kmph": 42.5
}

The coordinates can be converted into a map URL:

https://www.google.com/maps?q=17.3850,78.4867

Your Telegram alert can therefore contain:

🚨 POSSIBLE ACCIDENT

Vehicle: CAR-001

Location:
17.3850, 78.4867

Speed:
42.5 km/h

Map:
https://www.google.com/maps?q=17.3850,78.4867

In the actual implementation, n8n should construct the map URL dynamically.


12. ESP32-to-n8n communication

The ESP32 sends JSON.

Example:

{
  "device_id": "CAR-001",
  "event": "ACCIDENT",
  "timestamp": 1727979000,
  "accel_x": 3.21,
  "accel_y": 2.75,
  "accel_z": 16.42,
  "accel_magnitude": 17.01,
  "gyro_x": 12.4,
  "gyro_y": 9.8,
  "gyro_z": 21.3,
  "latitude": 17.385044,
  "longitude": 78.486671,
  "speed_kmph": 58.2,
  "accident_confidence": 86.4
}

13. n8n architecture

n8n is particularly suitable because it connects APIs, applications and AI workflows. n8n documents built-in Telegram functionality and AI capabilities. n8n Docs+1

The main workflow:

ESP32
  |
  | HTTP POST
  v
Webhook
  |
  v
Validate JSON
  |
  v
Normalize Data
  |
  +---------------------+
  |                     |
  v                     v
ThingSpeak          Google Sheets
  |
  v
AI Agent
  |
  v
Severity decision
  |
  +----------------------+
  |                      |
 NORMAL                ACCIDENT
  |                      |
  v                      v
Log only          Telegram text
                         |
                         v
                    Generate voice
                         |
                         v
                  Telegram voice
                         |
                         v
                  Send GPS location

14. n8n workflow nodes

Create the following nodes:

01 Webhook
       ↓
02 Code - Validate Payload
       ↓
03 IF - Accident?
       ↓
04 Google Sheets
       ↓
05 ThingSpeak HTTP Request
       ↓
06 AI Agent
       ↓
07 IF - Emergency?
       ↓
08 Telegram Text
       ↓
09 Text-to-Speech
       ↓
10 Telegram Voice
       ↓
11 Telegram Location

You can also split this into two workflows:

Workflow A — telemetry

ESP32
 ↓
Webhook
 ↓
Validation
 ↓
ThingSpeak
 ↓
Google Sheets

Workflow B — emergency

ESP32 Accident Event
 ↓
Webhook
 ↓
AI Agent
 ↓
Severity
 ↓
Telegram
 ↓
Voice
 ↓
Location

That architecture is easier to maintain.


15. n8n Webhook

Create:

Node: Webhook

Method:

POST

Example endpoint:

/webhook/vehicle-alert

ESP32 sends:

POST https://YOUR-N8N-DOMAIN/webhook/vehicle-alert
Content-Type: application/json

with the JSON payload.

Do not expose an unprotected production webhook. Use authentication, a secret token/signature, rate limiting and HTTPS. n8n itself provides security auditing functionality that can identify issues such as unprotected webhooks. n8n Docs


16. n8n validation node

Use a Code node after the webhook.

Example:

const d = $json.body ?? $json;

const required = [
  "device_id",
  "latitude",
  "longitude",
  "accident_confidence"
];

for (const field of required) {
  if (d[field] === undefined || d[field] === null) {
    throw new Error(`Missing field: ${field}`);
  }
}

return [{
  json: {
    device_id: String(d.device_id),
    event: d.event || "TELEMETRY",
    latitude: Number(d.latitude),
    longitude: Number(d.longitude),
    speed_kmph: Number(d.speed_kmph || 0),
    accel_x: Number(d.accel_x || 0),
    accel_y: Number(d.accel_y || 0),
    accel_z: Number(d.accel_z || 0),
    accel_magnitude: Number(d.accel_magnitude || 0),
    gyro_x: Number(d.gyro_x || 0),
    gyro_y: Number(d.gyro_y || 0),
    gyro_z: Number(d.gyro_z || 0),
    accident_confidence:
      Number(d.accident_confidence || 0),

    map_url:
      `https://www.google.com/maps?q=${Number(d.latitude)},${Number(d.longitude)}`,

    received_at: new Date().toISOString()
  }
}];

n8n's Code node is intended for data transformation and logic within workflows. n8n Docs


17. Google Sheets database

Create a spreadsheet called:

AI Vehicle Accident Monitoring

Create columns:

Column Description
Timestamp Event time
Device ID Vehicle ID
Event NORMAL/ACCIDENT
Latitude GPS latitude
Longitude GPS longitude
Speed km/h
Accel X X acceleration
Accel Y Y acceleration
Accel Z Z acceleration
Accel Magnitude Total acceleration
Gyro X X rotation
Gyro Y Y rotation
Gyro Z Z rotation
Confidence Accident confidence
Severity AI classification
AI Analysis Explanation
Notification Sent/Failed

n8n has a Google Sheets integration available for document/sheet operations. n8n Docs


18. ThingSpeak configuration

Create a ThingSpeak channel:

Channel name:
AI Vehicle Accident Monitoring

Suggested fields:

Field 1 = Acceleration
Field 2 = Gyroscope
Field 3 = Speed
Field 4 = Accident Confidence
Field 5 = Latitude
Field 6 = Longitude
Field 7 = Accident Status
Field 8 = Battery Voltage

ThingSpeak supports REST-based channel updates through api.thingspeak.com/update, including fields, latitude and longitude. MathWorks+1

Example:

https://api.thingspeak.com/update

Parameters:

api_key = YOUR_WRITE_API_KEY
field1 = 17.01
field2 = 21.3
field3 = 58.2
field4 = 86.4
field5 = 17.385044
field6 = 78.486671
field7 = 1

19. n8n ThingSpeak HTTP Request

Use:

Node: HTTP Request

Method:

POST

URL:

https://api.thingspeak.com/update.json

Body:

api_key={{ $env.THINGSPEAK_WRITE_KEY }}

field1={{ $json.accel_magnitude }}

field2={{ $json.gyro_z }}

field3={{ $json.speed_kmph }}

field4={{ $json.accident_confidence }}

field5={{ $json.latitude }}

field6={{ $json.longitude }}

field7={{ $json.event === "ACCIDENT" ? 1 : 0 }}

ThingSpeak returns an entry ID when the update succeeds and 0 on failure. MathWorks


20. AI Agent architecture

This is where the project becomes an Agentic IoT system instead of merely an IoT notification system.

The AI Agent receives:

Sensor data
+
GPS data
+
Vehicle state
+
Accident confidence

and determines:

Is this probably an accident?
What is the severity?
What action should be taken?
What message should be sent?

21. AI Agent prompt

Use a prompt similar to this:

You are an IoT Vehicle Safety AI Agent.

You receive telemetry from an ESP32 vehicle monitoring device.

Analyze:
- acceleration
- gyroscope
- speed
- GPS position
- accident confidence
- event type

Classify the event as one of:

NORMAL
SUSPICIOUS
ACCIDENT

If the event is an accident, classify severity:

LOW
MEDIUM
HIGH
CRITICAL

Rules:

1. Never claim that an accident is medically confirmed.
2. Treat sensor detection as a possible accident.
3. High acceleration combined with abnormal rotation increases accident likelihood.
4. A vehicle moving at significant speed before a large impact should increase severity.
5. If confidence is low, recommend monitoring rather than emergency escalation.
6. Always provide a concise emergency message.
7. Include GPS coordinates.
8. Include a Google Maps URL.

Return JSON only.

Expected output:

{
  "classification": "ACCIDENT",
  "severity": "HIGH",
  "confidence": 0.91,
  "reason": "Large acceleration spike combined with abnormal rotational motion.",
  "action": "SEND_EMERGENCY_ALERT",
  "telegram_message": "Possible high-severity vehicle accident detected.",
  "voice_message": "Emergency alert. A possible high-severity accident has been detected. Vehicle CAR-001 is located at the reported GPS position."
}

22. Important AI design principle

Do not allow the AI Agent to be the only accident detector.

Use:

ESP32 deterministic detection
             +
AI interpretation

rather than:

ESP32 → AI decides everything

Why?

Because Internet connectivity or AI response time could fail immediately after an accident.

The ESP32 should therefore detect the event locally and store/queue the event if necessary.


23. Agentic decision architecture

             SENSOR DATA
                  |
                  v
          +---------------+
          | ESP32 Rules   |
          +-------+-------+
                  |
                  v
          Possible Accident
                  |
                  v
             n8n Webhook
                  |
                  v
          +---------------+
          |   AI AGENT    |
          +-------+-------+
                  |
       +----------+----------+
       |          |          |
       v          v          v
    NORMAL     SUSPICIOUS   ACCIDENT
       |          |          |
       |          |          v
       |          |     Severity
       |          |          |
       |          |          v
       |          |     Take Action
       |          |          |
       +----------+----------+
                  |
                  v
          Automation Tools
          /       |       \
         /        |        \
        v         v         v
   Sheets     ThingSpeak Telegram

24. Telegram Bot

Create a Telegram bot using Telegram's official bot creation mechanism.

Obtain:

BOT_TOKEN

and determine the target:

CHAT_ID

Keep the token secret.

n8n provides a Telegram node with operations for sending messages, audio, locations and other Telegram content. n8n Docs


25. Telegram emergency message

Example:

🚨 VEHICLE ACCIDENT ALERT 🚨

Vehicle: CAR-001

Possible accident detected.

Severity: HIGH
Confidence: 91%

Speed: 58.2 km/h

Acceleration: 17.01 m/s²

Location:
17.385044, 78.486671

Open location:
https://www.google.com/maps?q=17.385044,78.486671

AI assessment:
Large acceleration spike combined with abnormal rotational motion.

Please check the vehicle immediately.

26. Telegram voice alert

The workflow should generate:

"Emergency alert. A possible high severity accident has been detected. Vehicle CAR-001 is currently at the reported GPS location. Please check the vehicle immediately."

Then convert the text to speech.

The resulting audio is passed to Telegram as a voice message.

Telegram's Bot API distinguishes voice messages from ordinary audio files and provides the sendVoice method for voice messages. Telegram


27. Voice workflow

AI Agent
   |
   v
voice_message
   |
   v
Text-to-Speech API
   |
   v
MP3/OGG audio
   |
   v
n8n Binary Data
   |
   v
Telegram Send Voice
   |
   v
Emergency recipient

Depending on the TTS service and Telegram integration version, you may use either a built-in n8n audio capability or an HTTP Request node to a TTS API.


28. Telegram location

After the text alert, send the GPS location.

Telegram
   |
   +-- Send Message
   |
   +-- Send Voice
   |
   +-- Send Location

Latitude:

{{ $json.latitude }}

Longitude:

{{ $json.longitude }}

This makes the alert much more useful than sending coordinates as plain text.


29. ESP32 firmware

Below is a prototype firmware implementation using:

  • ESP32

  • MPU6050

  • TinyGPS++

  • Wi-Fi

  • HTTPClient

  • JSON payload

  • local accident detection

The ESP32 Arduino Wi-Fi and HTTPClient libraries support connecting to an access point and making HTTP requests. Espressif Systems+1

Arduino libraries

Install:

Adafruit MPU6050
Adafruit Unified Sensor
TinyGPSPlus
ArduinoJson

30. ESP32 code

#include <WiFi.h>
#include <HTTPClient.h>
#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <TinyGPSPlus.h>
#include <ArduinoJson.h>

// =====================================================
// WIFI
// =====================================================

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

// n8n production webhook
const char* N8N_WEBHOOK =
    "https://YOUR-N8N-DOMAIN/webhook/vehicle-alert";

// =====================================================
// DEVICE
// =====================================================

const char* DEVICE_ID = "CAR-001";

// =====================================================
// GPS
// =====================================================

HardwareSerial GPSSerial(2);

#define GPS_RX 16
#define GPS_TX 17

TinyGPSPlus gps;

// =====================================================
// MPU6050
// =====================================================

Adafruit_MPU6050 mpu;

// =====================================================
// GPIO
// =====================================================

#define BUZZER_PIN 25
#define SOS_PIN    27
#define LED_PIN    2

// =====================================================
// TIMING
// =====================================================

unsigned long lastTelemetry = 0;

const unsigned long TELEMETRY_INTERVAL = 5000;

// =====================================================
// ACCIDENT PARAMETERS
// =====================================================

// Prototype values only.
// Calibrate using controlled experiments.

const float ACCEL_THRESHOLD = 18.0;
const float GYRO_THRESHOLD  = 15.0;
const float SPEED_THRESHOLD = 20.0;

// =====================================================
// WIFI
// =====================================================

void connectWiFi()
{
    Serial.print("Connecting to WiFi");

    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

    int attempts = 0;

    while (WiFi.status() != WL_CONNECTED &&
           attempts < 30)
    {
        delay(500);
        Serial.print(".");
        attempts++;
    }

    Serial.println();

    if (WiFi.status() == WL_CONNECTED)
    {
        Serial.println("WiFi connected");
        Serial.print("IP: ");
        Serial.println(WiFi.localIP());
    }
    else
    {
        Serial.println("WiFi connection failed");
    }
}

// =====================================================
// GPS UPDATE
// =====================================================

void updateGPS()
{
    while (GPSSerial.available())
    {
        gps.encode(GPSSerial.read());
    }
}

// =====================================================
// SEND EVENT TO N8N
// =====================================================

bool sendToN8N(
    String eventType,
    float ax,
    float ay,
    float az,
    float acceleration,
    float gx,
    float gy,
    float gz,
    float speed,
    float confidence
)
{
    if (WiFi.status() != WL_CONNECTED)
    {
        Serial.println("WiFi unavailable");
        return false;
    }

    HTTPClient http;

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

    float latitude = 0;
    float longitude = 0;

    if (gps.location.isValid())
    {
        latitude = gps.location.lat();
        longitude = gps.location.lng();
    }

    StaticJsonDocument<1024> doc;

    doc["device_id"] = DEVICE_ID;
    doc["event"] = eventType;

    doc["timestamp"] = millis();

    doc["accel_x"] = ax;
    doc["accel_y"] = ay;
    doc["accel_z"] = az;
    doc["accel_magnitude"] = acceleration;

    doc["gyro_x"] = gx;
    doc["gyro_y"] = gy;
    doc["gyro_z"] = gz;

    doc["speed_kmph"] = speed;

    doc["latitude"] = latitude;
    doc["longitude"] = longitude;

    doc["gps_valid"] = gps.location.isValid();

    doc["accident_confidence"] = confidence;

    String payload;

    serializeJson(doc, payload);

    Serial.println("Sending:");
    Serial.println(payload);

    int httpCode = http.POST(payload);

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

    http.end();

    return httpCode >= 200 &&
           httpCode < 300;
}

// =====================================================
// CALCULATE ACCELERATION
// =====================================================

float calculateAcceleration(
    sensors_event_t& accel
)
{
    return sqrt(
        accel.acceleration.x *
        accel.acceleration.x +

        accel.acceleration.y *
        accel.acceleration.y +

        accel.acceleration.z *
        accel.acceleration.z
    );
}

// =====================================================
// ACCIDENT CONFIDENCE
// =====================================================

float calculateConfidence(
    float acceleration,
    float gyro,
    float speed
)
{
    float score = 0;

    // Acceleration contribution
    if (acceleration > ACCEL_THRESHOLD)
        score += 40;

    // Gyroscope contribution
    if (gyro > GYRO_THRESHOLD)
        score += 30;

    // Speed contribution
    if (speed > SPEED_THRESHOLD)
        score += 20;

    // Combined condition
    if (acceleration > ACCEL_THRESHOLD &&
        gyro > GYRO_THRESHOLD)
    {
        score += 10;
    }

    if (score > 100)
        score = 100;

    return score;
}

// =====================================================
// BUZZER
// =====================================================

void accidentAlarm()
{
    digitalWrite(LED_PIN, HIGH);

    for (int i = 0; i < 5; i++)
    {
        digitalWrite(BUZZER_PIN, HIGH);
        delay(200);

        digitalWrite(BUZZER_PIN, LOW);
        delay(200);
    }

    digitalWrite(LED_PIN, LOW);
}

// =====================================================
// SETUP
// =====================================================

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

    pinMode(BUZZER_PIN, OUTPUT);
    pinMode(SOS_PIN, INPUT_PULLUP);
    pinMode(LED_PIN, OUTPUT);

    digitalWrite(BUZZER_PIN, LOW);
    digitalWrite(LED_PIN, LOW);

    Wire.begin(21, 22);

    // MPU6050
    if (!mpu.begin())
    {
        Serial.println(
            "MPU6050 not found!"
        );

        while (true)
        {
            delay(1000);
        }
    }

    Serial.println(
        "MPU6050 initialized"
    );

    mpu.setAccelerometerRange(
        MPU6050_RANGE_8_G
    );

    mpu.setGyroRange(
        MPU6050_RANGE_500_DEG
    );

    // GPS
    GPSSerial.begin(
        9600,
        SERIAL_8N1,
        GPS_RX,
        GPS_TX
    );

    connectWiFi();
}

// =====================================================
// LOOP
// =====================================================

void loop()
{
    updateGPS();

    // Manual SOS
    if (digitalRead(SOS_PIN) == LOW)
    {
        Serial.println("SOS BUTTON");

        accidentAlarm();

        sendToN8N(
            "MANUAL_SOS",
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            gps.speed.isValid()
                ? gps.speed.kmph()
                : 0,
            100
        );

        delay(3000);
    }

    if (millis() -
        lastTelemetry <
        TELEMETRY_INTERVAL)
    {
        return;
    }

    lastTelemetry = millis();

    sensors_event_t accel;
    sensors_event_t gyro;
    sensors_event_t temp;

    mpu.getEvent(
        &accel,
        &gyro,
        &temp
    );

    float acceleration =
        calculateAcceleration(accel);

    float gyroMagnitude =
        sqrt(
            gyro.gyro.x *
            gyro.gyro.x +

            gyro.gyro.y *
            gyro.gyro.y +

            gyro.gyro.z *
            gyro.gyro.z
        );

    float speed =
        gps.speed.isValid()
            ? gps.speed.kmph()
            : 0;

    float confidence =
        calculateConfidence(
            acceleration,
            gyroMagnitude,
            speed
        );

    String eventType =
        confidence >= 70
            ? "ACCIDENT"
            : "TELEMETRY";

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

    Serial.print("Acceleration: ");
    Serial.println(acceleration);

    Serial.print("Gyro: ");
    Serial.println(gyroMagnitude);

    Serial.print("Speed: ");
    Serial.println(speed);

    Serial.print("Confidence: ");
    Serial.println(confidence);

    Serial.print("Event: ");
    Serial.println(eventType);

    if (eventType == "ACCIDENT")
    {
        accidentAlarm();
    }

    sendToN8N(
        eventType,

        accel.acceleration.x,
        accel.acceleration.y,
        accel.acceleration.z,

        acceleration,

        gyro.gyro.x,
        gyro.gyro.y,
        gyro.gyro.z,

        speed,

        confidence
    );
}

31. Important improvement: don't send every event as an accident

A real implementation should have a state machine.

NORMAL
  |
  | impact detected
  v
POSSIBLE_IMPACT
  |
  | confirmation
  v
ACCIDENT_PENDING
  |
  | confirmed
  v
ACCIDENT
  |
  | alert sent
  v
ALERTED
  |
  | reset
  v
NORMAL

This prevents multiple Telegram alerts for the same accident.


32. Better accident algorithm

Use a sliding window.

For example:

Sample rate = 50 Hz

Maintain last 2 seconds:

100 sensor samples

Calculate:

maximum acceleration
maximum gyro
change in acceleration
change in orientation
vehicle speed

Then:

IF

maxAcceleration > threshold
AND
maxGyro > threshold

THEN

possible accident

After that:

Wait 1–3 seconds

IF movement remains abnormal
OR
second sensor condition confirms impact

THEN

ACCIDENT

This is significantly better than a single sensor reading.


33. n8n AI workflow in detail

Create the workflow:

┌──────────────┐
│   Webhook    │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│ Validate Payload │
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ Prepare Location │
└────────┬─────────┘
         │
         ├─────────────────┐
         │                 │
         ▼                 ▼
┌──────────────┐   ┌───────────────┐
│ Google Sheets│   │  ThingSpeak   │
└──────────────┘   └───────────────┘
         │
         ▼
┌─────────────────┐
│     AI Agent    │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│ Parse AI Result │
└────────┬────────┘
         │
         ▼
   ┌───────────────┐
   │ Severity?     │
   └──────┬────────┘
          │
       HIGH/CRITICAL
          │
          ▼
   ┌───────────────┐
   │ Telegram Text │
   └──────┬────────┘
          │
          ▼
   ┌───────────────┐
   │ Text to Speech│
   └──────┬────────┘
          │
          ▼
   ┌───────────────┐
   │Telegram Voice │
   └──────┬────────┘
          │
          ▼
   ┌───────────────┐
   │Telegram GPS   │
   │Location       │
   └───────────────┘

34. Google Sheets record

The n8n Google Sheets node should append something like:

2026-10-04 21:45:23
CAR-001
ACCIDENT
17.385044
78.486671
58.2
3.21
2.75
16.42
17.01
12.4
9.8
21.3
86.4
HIGH
Large acceleration + abnormal rotation
SENT

This gives you a permanent project log.


35. ThingSpeak dashboard

Configure charts for:

Chart 1

Acceleration vs Time

Chart 2

Vehicle Speed vs Time

Chart 3

Accident Confidence vs Time

Chart 4

Gyroscope vs Time

Map

Use:

Latitude
Longitude

ThingSpeak supports channel data visualization and map-related channel functionality through its APIs/platform. MathWorks+1


36. Complete data flow

                   VEHICLE
                      |
          +-----------+-----------+
          |                       |
          v                       v
      MPU6050                    GPS
          |                       |
          +-----------+-----------+
                      |
                      v
                   ESP32
                      |
             Accident Algorithm
                      |
          +-----------+-----------+
          |                       |
        NORMAL                 ACCIDENT
          |                       |
          +-----------+-----------+
                      |
                      v
                    Wi-Fi
                      |
                      v
                 n8n Webhook
                      |
                      v
                Data Validation
                      |
             +--------+--------+
             |                 |
             v                 v
        ThingSpeak       Google Sheets
             |                 |
             +--------+--------+
                      |
                      v
                   AI Agent
                      |
             +--------+---------+
             |        |         |
             v        v         v
           LOW     MEDIUM     HIGH
             |        |         |
             |        |         v
             |        |     Telegram
             |        |         |
             |        |     +---+---+
             |        |     |       |
             |        |     v       v
             |        |   Text    Voice
             |        |
             |        v
             |      Log
             |
             v
            Log

37. Telegram conversation example

Accident event

System → Telegram

🚨 VEHICLE ACCIDENT ALERT

System:

Vehicle: CAR-001
Status: Possible Accident
Severity: HIGH
Confidence: 91%
Speed: 58.2 km/h

System:

📍 Location: 17.385044, 78.486671

System:

🗺 Open vehicle location

System:

Sensor analysis indicates a large acceleration spike combined with abnormal rotational motion.

System → Voice

"Emergency alert. A possible high-severity accident has been detected. Vehicle CAR-001 is currently at the reported GPS location. Please check the vehicle immediately."


38. Manual SOS operation

The project should also have a manual emergency button.

Driver presses SOS
        |
        v
ESP32 detects button
        |
        v
Generate MANUAL_SOS event
        |
        v
n8n
        |
        v
AI Agent
        |
        v
Telegram
        |
        +---- Text
        |
        +---- Voice
        |
        +---- Location

This is useful even if no accident occurs.

For example:

Medical emergency
Vehicle breakdown
Threat/security problem
Driver assistance

39. Vehicle tracking mode

Apart from accident detection, send periodic telemetry.

For example:

Every 5 seconds:

GPS
Speed
Acceleration
Gyroscope
Battery

The system becomes:

Vehicle
   |
   v
ESP32
   |
   v
n8n
   |
   +---- ThingSpeak
   |
   +---- Google Sheets

ThingSpeak's REST API is designed for reading and writing channel data, so it is suitable for this telemetry layer. MathWorks


40. Recommended ThingSpeak fields

Use:

FIELD 1 → Acceleration
FIELD 2 → Gyroscope
FIELD 3 → Speed
FIELD 4 → Accident Confidence
FIELD 5 → Latitude
FIELD 6 → Longitude
FIELD 7 → Accident Flag
FIELD 8 → Battery

Example:

Field 1 = 17.01
Field 2 = 21.30
Field 3 = 58.20
Field 4 = 86.40
Field 5 = 17.385044
Field 6 = 78.486671
Field 7 = 1
Field 8 = 3.92

41. Security architecture

Do not hard-code all production secrets directly into firmware.

Avoid:

const char* API_KEY = "my-secret-key";

when the code will be published.

Instead use:

ESP32
   |
   | device authentication
   v
n8n
   |
   +-- Telegram credential
   +-- Google credential
   +-- ThingSpeak key
   +-- AI API credential
   +-- TTS credential

n8n credentials should be stored in n8n rather than exposed in the ESP32 payload.


42. Recommended authentication

Add an authentication header:

X-DEVICE-TOKEN: YOUR_DEVICE_SECRET

ESP32:

http.addHeader(
    "X-DEVICE-TOKEN",
    DEVICE_SECRET
);

n8n validation:

const token =
    $headers["x-device-token"];

if (token !== $env.DEVICE_SECRET) {
    throw new Error("Unauthorized device");
}

For production, consider stronger mechanisms such as signed requests, rotating credentials and HTTPS certificate validation.


43. Failure handling

The system should be designed around failures.

Case 1 — Wi-Fi unavailable

ESP32
 ↓
No Wi-Fi
 ↓
Store event locally
 ↓
Reconnect
 ↓
Upload later

Add EEPROM/NVS or SD storage for queued events.

Case 2 — n8n unavailable

ESP32
 ↓
HTTP failure
 ↓
Save event
 ↓
Retry

Case 3 — Telegram unavailable

n8n
 ↓
Telegram error
 ↓
Log failure
 ↓
Retry

Case 4 — GPS unavailable

Use:

"gps_valid": false

and send:

GPS unavailable
Last known location:
...

Case 5 — AI unavailable

The workflow should still send a deterministic alert:

ESP32 confidence > threshold
        |
        v
AI unavailable
        |
        v
Fallback emergency notification

This is extremely important.


44. AI fallback

Use an n8n IF node:

AI Agent
   |
   +---- success → AI decision
   |
   +---- error → deterministic decision

Fallback:

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

let severity = "LOW";

if (confidence >= 90) {
    severity = "CRITICAL";
}
else if (confidence >= 80) {
    severity = "HIGH";
}
else if (confidence >= 70) {
    severity = "MEDIUM";
}

return [{
    json: {
        ...$json,
        severity,
        ai_status: "FALLBACK"
    }
}];

45. State diagram

                 +---------+
                 | START   |
                 +----+----+
                      |
                      v
                 +---------+
                 | NORMAL  |
                 +----+----+
                      |
               Impact detected
                      |
                      v
             +----------------+
             | POSSIBLE IMPACT|
             +-------+--------+
                     |
              Confirm sensors
                     |
              +------+------+
              |             |
             NO            YES
              |             |
              v             v
           NORMAL        ACCIDENT
                            |
                            v
                      SEND EVENT
                            |
                            v
                       AI ANALYSIS
                            |
                  +---------+---------+
                  |                   |
                 LOW               HIGH
                  |                   |
                  v                   v
                 LOG              ALERT
                                      |
                         +------------+------------+
                         |            |             |
                         v            v             v
                       TEXT         VOICE         GPS
                         |            |             |
                         +------------+-------------+
                                      |
                                      v
                                   ALERTED
                                      |
                                      v
                                   RESET
                                      |
                                      v
                                   NORMAL

46. Software architecture

+-----------------------------------------------------+
|                    SOFTWARE                         |
+-----------------------------------------------------+
|                                                     |
| Arduino IDE                                         |
|      |                                              |
|      v                                              |
| ESP32 Firmware                                      |
|      |                                              |
|      +---- MPU6050 driver                           |
|      +---- GPS driver                               |
|      +---- Accident algorithm                       |
|      +---- Wi-Fi                                    |
|      +---- HTTP/JSON                                |
|                                                     |
+-----------------------------------------------------+

                    INTERNET
                       |
                       v

+-----------------------------------------------------+
|                     n8n                             |
+-----------------------------------------------------+
|                                                     |
| Webhook                                             |
|      |                                              |
| Validation                                          |
|      |                                              |
| Data transformation                                 |
|      |                                              |
| AI Agent                                            |
|      |                                              |
| +----+----------+-------------+                     |
| |               |             |                     |
| v               v             v                     |
| Sheets       ThingSpeak    Telegram                 |
|                                                     |
+-----------------------------------------------------+

47. AI Agent tools

A more advanced version can give the AI Agent tools such as:

Tool 1:
Get latest vehicle telemetry

Tool 2:
Get previous accident records

Tool 3:
Write incident to Google Sheets

Tool 4:
Send Telegram alert

Tool 5:
Send vehicle location

Tool 6:
Get ThingSpeak history

Then the AI Agent becomes:

                 AI AGENT
                    |
       +------------+-------------+
       |            |             |
       v            v             v
Telemetry       Incident       Notification
Tool            History Tool   Tool
       |            |             |
       +------------+-------------+
                    |
                    v
               Decision

n8n's AI tooling is designed to allow integrations and tools to participate in AI workflows. n8n Docs


48. Example AI reasoning

Input:

{
  "speed_kmph": 72,
  "accel_magnitude": 24.2,
  "gyro_z": 32.1,
  "accident_confidence": 94
}

AI response:

{
  "classification": "ACCIDENT",
  "severity": "CRITICAL",
  "confidence": 0.96,
  "reason": "High-speed vehicle combined with a large acceleration spike and extreme rotational movement.",
  "action": "SEND_EMERGENCY_ALERT"
}

The automation then executes:

Send Telegram
Send Voice
Send Location
Write Sheet
Update ThingSpeak

49. Project flowchart

             START
               |
               v
       Initialize ESP32
               |
               v
        Initialize MPU6050
               |
               v
         Initialize GPS
               |
               v
          Connect Wi-Fi
               |
               v
        Read sensor data
               |
               v
        Calculate motion
               |
               v
        Calculate speed
               |
               v
       Accident detected?
          /          \
        NO            YES
        |              |
        v              v
   Send telemetry   Activate buzzer
        |              |
        |              v
        |          Create event
        |              |
        +------+-------+
               |
               v
          Send to n8n
               |
               v
        AI Agent analysis
               |
               v
       Determine severity
               |
               v
      Log Google Sheets
               |
               v
       Update ThingSpeak
               |
               v
        Emergency alert?
          /          \
        NO            YES
        |              |
        v              v
      Finish      Telegram text
                       |
                       v
                  Voice message
                       |
                       v
                  GPS location
                       |
                       v
                     END

50. Complete technology stack

Layer Technology
Controller ESP32
Motion sensor MPU6050
Location NEO-6M GPS
Programming Arduino C++
Connectivity Wi-Fi
API protocol HTTP/JSON
Automation n8n
AI n8n AI Agent + LLM
Notification Telegram
Voice TTS
Database/logging Google Sheets
IoT dashboard ThingSpeak
Mapping Google Maps URL
Cloud workflow n8n
Visualization ThingSpeak

51. Required n8n credentials

You will need credentials for:

1. AI/LLM provider
2. Telegram Bot
3. Google Sheets
4. TTS provider
5. ThingSpeak API key

ThingSpeak uses channel-specific write API keys for channel updates. MathWorks


52. n8n environment variables

For a self-hosted deployment, conceptually maintain:

DEVICE_SECRET
THINGSPEAK_WRITE_KEY
TELEGRAM_CHAT_ID
N8N_WEBHOOK_URL

API credentials should preferably be stored in the credential manager rather than ordinary workflow fields.


53. Testing procedure

Do not begin by simulating a real road accident.

Use controlled tests.

Test 1 — Normal operation

Move the MPU6050 gently.

Expected:

EVENT = TELEMETRY
ACCIDENT = FALSE

Test 2 — GPS

Move the GPS outdoors.

Expected:

GPS valid = true

latitude ≠ 0
longitude ≠ 0

Test 3 — Manual SOS

Press the button.

Expected:

ESP32
 ↓
n8n
 ↓
Google Sheets
 ↓
Telegram text
 ↓
Telegram voice
 ↓
GPS location

Test 4 — Artificial impact

Perform a safe controlled sensor test.

Expected:

Acceleration spike
       +
Gyroscope spike
       ↓
Possible accident

Test 5 — Wi-Fi failure

Turn off Wi-Fi.

Expected:

ESP32 detects failure

and, if local queueing has been implemented:

Event stored

Test 6 — n8n failure

Stop n8n.

Expected:

HTTP request fails

and the ESP32 should not crash.


Test 7 — Telegram failure

Disable Telegram credentials temporarily.

Expected:

Incident remains in Google Sheets

and failure is logged.


54. Expected project output

When an accident is detected:

ESP32

ACCIDENT DETECTED
Confidence: 91%

n8n

Webhook received
Data validated
AI analysis completed
Severity = HIGH

Google Sheets

Incident record inserted

ThingSpeak

Telemetry updated

Telegram

🚨 VEHICLE ACCIDENT ALERT

followed by:

🔊 Voice alert

and:

📍 Vehicle location

55. Example complete incident record

{
  "device_id": "CAR-001",
  "event": "ACCIDENT",
  "timestamp": "2026-10-04T16:15:22Z",

  "sensor": {
    "accel_x": 3.21,
    "accel_y": 2.75,
    "accel_z": 16.42,
    "magnitude": 17.01,
    "gyro_x": 12.4,
    "gyro_y": 9.8,
    "gyro_z": 21.3
  },

  "vehicle": {
    "speed_kmph": 58.2
  },

  "gps": {
    "latitude": 17.385044,
    "longitude": 78.486671
  },

  "analysis": {
    "confidence": 0.91,
    "classification": "ACCIDENT",
    "severity": "HIGH"
  },

  "notifications": {
    "telegram_text": true,
    "telegram_voice": true,
    "location": true
  }
}

56. Advantages

Hardware advantages

  • Low-cost

  • Compact

  • Wi-Fi enabled

  • Easy to program

  • Expandable

Software advantages

  • n8n provides visual automation

  • AI adds contextual analysis

  • Google Sheets is easy to inspect

  • ThingSpeak provides visualization

  • Telegram provides instant notification

AI advantages

The AI can interpret several sensor values simultaneously instead of relying on one threshold.


57. Limitations

This is important for your project report.

The system is a prototype and not a certified automotive safety system.

Potential limitations include:

  • GPS may be unavailable indoors.

  • GPS location can have several meters of error.

  • Wi-Fi may not be available everywhere.

  • MPU6050 readings depend on mounting orientation.

  • Sensor thresholds require calibration.

  • False positives are possible.

  • False negatives are possible.

  • AI decisions can be imperfect.

  • Internet latency can delay cloud alerts.

  • Telegram requires Internet access.

  • The system should not replace certified vehicle safety equipment or emergency services.


58. Future enhancements

You can list these in your project presentation.

1. GSM/LTE

Add:

SIM7600 / LTE module

so alerts can work without Wi-Fi.

2. Camera

Add:

ESP32-CAM

or another camera to capture accident images.

3. Cloud database

Replace Google Sheets with:

PostgreSQL
Supabase
Firebase
MongoDB

4. Advanced ML model

Train an accident classifier using:

Acceleration
Gyroscope
Speed
Orientation
Time-series windows

5. Driver monitoring

Add:

Camera
Drowsiness detection
Face detection
Eye closure detection

6. OBD-II

Read:

Vehicle speed
RPM
Engine temperature
Diagnostic codes

7. Multi-vehicle fleet

Architecture:

CAR-001 ─┐
CAR-002 ─┤
CAR-003 ─┼──> n8n ──> AI Agent
CAR-004 ─┤
CAR-005 ─┘

8. Emergency-service integration

Future version could integrate authorized emergency-response APIs.


59. Multi-vehicle architecture

             VEHICLE 1
             ESP32 #001
                 |
                 |
             VEHICLE 2
             ESP32 #002
                 |
                 |
             VEHICLE 3
             ESP32 #003
                 |
                 |
                 v
          +--------------+
          |     n8n      |
          | Central IoT  |
          +------+-------+
                 |
        +--------+---------+
        |        |         |
        v        v         v
       AI     Database   Alerts
       |        |         |
       v        v         v
    Analysis  Sheets   Telegram
                         |
                         v
                     Operator

60. Suggested project folder structure

AI-Vehicle-IoT/
│
├── README.md
│
├── firmware/
│   └── esp32_vehicle_monitor/
│       └── esp32_vehicle_monitor.ino
│
├── n8n/
│   ├── telemetry-workflow.json
│   └── accident-workflow.json
│
├── docs/
│   ├── architecture.md
│   ├── hardware.md
│   ├── software.md
│   ├── testing.md
│   └── screenshots/
│
├── diagrams/
│   ├── block-diagram.png
│   ├── flowchart.png
│   ├── circuit.png
│   └── sequence-diagram.png
│
└── examples/
    └── accident-payload.json

61. Sequence diagram

ESP32          n8n          AI Agent       Sheets     ThingSpeak    Telegram
  |              |              |             |            |            |
  |---JSON------>|              |             |            |            |
  |              |              |             |            |            |
  |              |---validate-->|             |            |            |
  |              |              |             |            |            |
  |              |--------------------------->|            |            |
  |              |---------------------------------------->|            |
  |              |              |             |            |            |
  |              |---sensor data------------->|            |            |
  |              |              |             |            |            |
  |              |              |--analysis-->|            |            |
  |              |              |             |            |            |
  |              |<--decision---|             |            |            |
  |              |              |             |            |            |
  |              |--------------------------------------------------->|
  |              |              |             |            |            |
  |              |--------------------------------------------------->|
  |              |              |             |            |            |
  |              |              |             |            |<--voice----|
  |              |              |             |            |            |

62. One-line project explanation for viva

The system uses an ESP32 to detect abnormal vehicle motion and obtain GPS coordinates, sends the event to n8n through an HTTP webhook, uses an AI Agent to analyze accident severity, logs the incident in Google Sheets, visualizes telemetry on ThingSpeak, and automatically sends Telegram text, voice and location alerts.


63. 30-second presentation explanation

“Our project is an AI-powered IoT accident detection and vehicle tracking system. An ESP32 collects acceleration and gyroscope data from an MPU6050 and GPS information from a GPS module. When abnormal vehicle motion is detected, the ESP32 sends the event to an n8n webhook. n8n acts as the automation and agentic layer. An AI Agent analyzes the sensor data and determines the possible accident severity. The incident is stored in Google Sheets and telemetry is sent to ThingSpeak. For high-severity events, n8n automatically sends a Telegram emergency message, voice alert and GPS location to the configured recipient.”


64. Final system architecture

                     ┌───────────────────────┐
                     │       VEHICLE         │
                     │                       │
                     │  MPU6050              │
                     │  GPS                  │
                     │  SOS                  │
                     │  Buzzer               │
                     └──────────┬────────────┘
                                │
                                ▼
                     ┌───────────────────────┐
                     │        ESP32          │
                     │                       │
                     │ Sensor Processing     │
                     │ Accident Detection    │
                     │ GPS Processing        │
                     │ Wi-Fi Communication   │
                     └──────────┬────────────┘
                                │
                              HTTPS
                                │
                                ▼
                     ┌───────────────────────┐
                     │     n8n WEBHOOK       │
                     └──────────┬────────────┘
                                │
                                ▼
                     ┌───────────────────────┐
                     │ DATA VALIDATION       │
                     └──────────┬────────────┘
                                │
              ┌─────────────────┼──────────────────┐
              │                 │                  │
              ▼                 ▼                  ▼
        Google Sheets      ThingSpeak          AI Agent
              │                 │                  │
              │                 │                  ▼
              │                 │            Severity
              │                 │                  │
              │                 │          ┌───────┴───────┐
              │                 │          │               │
              │                 │        NORMAL        ACCIDENT
              │                 │          │               │
              │                 │          │               ▼
              │                 │          │        Telegram Text
              │                 │          │               │
              │                 │          │               ▼
              │                 │          │        Text-to-Speech
              │                 │          │               │
              │                 │          │               ▼
              │                 │          │        Telegram Voice
              │                 │          │               │
              │                 │          │               ▼
              │                 │          │        Telegram GPS
              │                 │          │
              └─────────────────┴──────────┴───────────────┘

65. Recommended implementation order

Build it in this order rather than trying everything simultaneously:

  1. ESP32 + MPU6050

    • Confirm acceleration and gyro readings.

  2. ESP32 + GPS

    • Confirm latitude, longitude and speed.

  3. ESP32 accident algorithm

    • Display confidence on Serial Monitor.

  4. ESP32 + Wi-Fi

    • Confirm Internet connectivity.

  5. n8n Webhook

    • Receive a manually generated JSON payload first.

  6. ESP32 → n8n

    • Send actual sensor data.

  7. Google Sheets

    • Log every event.

  8. ThingSpeak

    • Display sensor charts.

  9. Telegram

    • Send text alerts.

  10. AI Agent

    • Add classification and severity.

  11. TTS

    • Convert AI-generated emergency message to speech.

  12. Telegram Voice

    • Send the generated voice alert.

  13. GPS location

    • Send the vehicle's location.

  14. Failure/retry logic

    • Handle Wi-Fi, n8n, Telegram and GPS failures.

  15. Final enclosure

    • Mount the ESP32 and sensors securely in the vehicle.

This staged approach makes troubleshooting much easier.

Official references

  • ESP32 Arduino Wi-Fi documentation

  • ESP32 HTTPClient source/documentation

  • ThingSpeak Write Data API

  • ThingSpeak REST API reference

  • n8n documentation

  • n8n Telegram node documentation

  • Telegram Bot API

Important: For an academic prototype, this design is complete enough to implement and demonstrate. For a real vehicle/emergency deployment, the accident classifier, electrical design, enclosure, connectivity, cybersecurity and emergency escalation would need substantially more validation and safety engineering.

Project Summary

AI Accident Alert & Vehicle Tracking Using IoT Analytics is an IoT-based vehicle safety system that combines ESP32, MPU6050, GPS, n8n automation, AI Agent, Telegram, Google Sheets, and ThingSpeak.

Core workflow

MPU6050 + GPS
      ↓
    ESP32
      ↓
Accident Detection
      ↓
 Wi-Fi / HTTP
      ↓
   n8n Webhook
      ↓
    AI Agent
      ↓
 ┌────┼───────────────┐
 ↓    ↓               ↓
Sheets ThingSpeak   Telegram
                     ↓
               Text + Voice
                     ↓
                GPS Location

Main functions

  • ESP32 collects vehicle motion data.

  • MPU6050 measures acceleration and gyroscope movement.

  • GPS provides latitude, longitude and vehicle speed.

  • ESP32 calculates an accident confidence score.

  • n8n receives and processes the IoT event.

  • AI Agent classifies the event as Normal, Suspicious or Accident and estimates severity.

  • Google Sheets stores accident and telemetry records.

  • ThingSpeak provides cloud telemetry visualization.

  • Telegram sends emergency text notifications.

  • Text-to-Speech generates an emergency voice message.

  • Telegram Voice delivers the voice alert.

  • GPS coordinates are sent so the recipient can locate the vehicle.

  • A physical SOS button can manually trigger an emergency alert.

Key architecture principle

The ESP32 performs the initial accident detection locally, while the AI Agent performs higher-level analysis. This prevents the system from depending entirely on AI or Internet connectivity for the initial detection.

Main hardware

  • ESP32 DevKit

  • MPU6050

  • NEO-6M GPS

  • Buzzer

  • SOS push button

  • LED

  • Power supply

Main software

  • Arduino IDE / ESP32 Arduino framework

  • C++

  • n8n

  • AI/LLM

  • Telegram Bot API

  • Google Sheets

  • ThingSpeak

  • Text-to-Speech service

Example emergency event

🚨 POSSIBLE VEHICLE ACCIDENT

Vehicle: CAR-001
Severity: HIGH
Confidence: 91%
Speed: 58.2 km/h

Location:
17.385044, 78.486671

AI analysis:
Large acceleration spike combined
with abnormal rotational movement.

Voice alert: SENT
GPS location: SENT
Google Sheets: LOGGED
ThingSpeak: UPDATED

Project objective

The overall goal is to create an agentic IoT vehicle-monitoring platform that can automatically:

Sense → Detect → Analyze → Log → Decide → Notify → Track

It is suitable as a final-year engineering project, IoT project, AI project, ESP32 project, or n8n automation project, with further development required before any real-world safety-critical deployment.

 

AI Accident Alert & Vehicle Tracking — Mind Map

                           ┌──────────────────────────────┐
                           │ AI ACCIDENT ALERT &          │
                           │ VEHICLE TRACKING SYSTEM      │
                           └──────────────┬───────────────┘
                                          │
        ┌─────────────────────────────────┼─────────────────────────────────┐
        │                                 │                                 │
        ▼                                 ▼                                 ▼
 ┌───────────────┐                 ┌───────────────┐                 ┌───────────────┐
 │    HARDWARE   │                 │   ESP32 IoT   │                 │    CLOUD      │
 └───────┬───────┘                 └───────┬───────┘                 └───────┬───────┘
         │                                 │                                 │
   ┌─────┼─────┐                    ┌─────┼─────┐                    ┌──────┼──────┐
   │     │     │                    │     │     │                    │      │      │
   ▼     ▼     ▼                    ▼     ▼     ▼                    ▼      ▼      ▼
 MPU6050 GPS  SOS                 Wi-Fi  JSON  HTTP                 n8n  ThingSpeak Sheets
   │     │     │                    │     │     │                     │      │      │
   │     │     │                    └─────┴─────┘                     │      │      │
   │     │     │                          │                           │      │      │
   ▼     ▼     ▼                          ▼                           │      │      │
Accel  GPS  Button                  n8n Webhook                        │      │      │
Gyro   Speed Buzzer                       │                            │      │      │
                                         ▼                            │      │      │
                                  Data Validation                     │      │      │
                                         │                            │      │      │
                                         ▼                            │      │      │
                                    AI AGENT ◄────────────────────────┘      │      │
                                         │                                   │      │
                              ┌──────────┼──────────┐                        │      │
                              │          │          │                        │      │
                              ▼          ▼          ▼                        │      │
                           NORMAL   SUSPICIOUS  ACCIDENT                     │      │
                                                   │                         │      │
                                                   ▼                         │      │
                                             SEVERITY                        │      │
                                                   │                         │      │
                                    ┌──────────────┼──────────────┐          │      │
                                    │              │              │          │      │
                                    ▼              ▼              ▼          │      │
                                  LOW           HIGH          CRITICAL       │      │
                                    │              │              │          │      │
                                    └──────────────┼──────────────┘          │      │
                                                   │                         │      │
                                                   ▼                         │      │
                                             NOTIFICATION                    │      │
                                                   │                         │      │
                              ┌────────────────────┼─────────────────┐       │      │
                              │                    │                 │       │      │
                              ▼                    ▼                 ▼       │      │
                         Telegram Text      Telegram Voice      GPS Location│      │
                              │                    │                 │       │      │
                              └────────────────────┼─────────────────┘       │      │
                                                   │                         │      │
                                                   ▼                         │      │
                                             Emergency User                 │      │
                                                                             │      │
                                                                             └──────┘

Simplified Concept Map

AI VEHICLE SAFETY
│
├── 1. SENSING
│   ├── MPU6050
│   │   ├── Acceleration
│   │   └── Gyroscope
│   ├── GPS
│   │   ├── Latitude
│   │   ├── Longitude
│   │   └── Speed
│   └── SOS Button
│
├── 2. ESP32
│   ├── Sensor Reading
│   ├── Accident Algorithm
│   ├── Confidence Score
│   ├── Wi-Fi
│   └── JSON/HTTP
│
├── 3. ACCIDENT DETECTION
│   ├── Acceleration Spike
│   ├── Gyroscope Spike
│   ├── Speed
│   ├── Motion Change
│   └── Confidence
│
├── 4. n8n AUTOMATION
│   ├── Webhook
│   ├── Validation
│   ├── Data Processing
│   ├── AI Agent
│   └── Decision Logic
│
├── 5. AI AGENT
│   ├── Event Classification
│   │   ├── Normal
│   │   ├── Suspicious
│   │   └── Accident
│   ├── Severity
│   │   ├── Low
│   │   ├── Medium
│   │   ├── High
│   │   └── Critical
│   └── Recommended Action
│
├── 6. CLOUD
│   ├── Google Sheets
│   │   └── Incident Database
│   └── ThingSpeak
│       ├── Charts
│       ├── Telemetry
│       └── Location
│
├── 7. ALERT SYSTEM
│   └── Telegram
│       ├── Text Alert
│       ├── Voice Alert
│       └── GPS Location
│
├── 8. RELIABILITY
│   ├── Wi-Fi Failure
│   ├── n8n Failure
│   ├── Telegram Failure
│   ├── GPS Failure
│   ├── AI Failure
│   └── Retry / Local Storage
│
└── 9. FUTURE
    ├── GSM/LTE
    ├── Camera
    ├── OBD-II
    ├── Machine Learning
    ├── Driver Monitoring
    └── Multi-Vehicle Fleet

 

Saturday, 3 October 2026

SolarPulse AI: An IoT-Enabled Intelligent Framework for Real-Time Solar PV Performance Monitoring and Multi-Channel AI Alerting

SolarPulse AI: An IoT-Enabled Intelligent Framework for Real-Time Solar PV Performance Monitoring and Multi-Channel AI Alerting

Yes . I can structure this as a complete engineering/project document covering the SolarPulse AI architecture, ESP32 firmware , IoT webpage/dashboard, n8n workflow, AI agent, Telegram voice alerts, Google Sheets logging, ThingSpeak integration, circuit/schematic, data flow, and testing.

A good final project title would be :

SolarPulse AI

An IoT-Enabled Intelligent Framework for Real-Time Solar PV Performance Monitoring and Multi-Channel AI Alerting

1. Project concept

SolarPulse AI is an intelligent IoT-based solar photovoltaic monitoring system in which an ESP32 continuously measures the electrical and environmental parameters of a solar PV system and sends the data to cloud services.

The system combines:

  • ESP32 — sensor acquisition and local intelligence

  • Solar PV sensors — voltage, current, temperature and irradiance

  • IoT webpage/dashboard — real-time visualization

  • ThingSpeak — cloud IoT data storage/visualization

  • n8n — workflow automation

  • AI Agent — interprets abnormal operating conditions

  • Google Sheets — historical data/event logging

  • Telegram — instant text notifications

  • Telegram voice alerts — spoken warning notifications

  • Webhooks/API — communication between the different layers

The overall concept is:

                    ┌─────────────────────┐
                    │     SOLAR PV        │
                    │       PANEL         │
                    └──────────┬──────────┘
                               │
                 ┌─────────────┴─────────────┐
                 │       SENSOR LAYER        │
                 │                           │
                 │ Voltage │ Current         │
                 │ Temp.   │ Irradiance      │
                 └─────────────┬─────────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │       ESP32         │
                    │                     │
                    │ ADC + Sensors       │
                    │ Data Processing      │
                    │ Wi-Fi Communication  │
                    └──────────┬──────────┘
                               │
                         Wi-Fi / HTTP
                               │
              ┌────────────────┼────────────────┐
              │                │                │
              ▼                ▼                ▼
       ┌────────────┐   ┌─────────────┐  ┌──────────────┐
       │ ThingSpeak │   │ IoT Webpage │  │ n8n Webhook  │
       │ Cloud      │   │ Dashboard   │  │              │
       └────────────┘   └─────────────┘  └──────┬───────┘
                                                │
                                                ▼
                                      ┌──────────────────┐
                                      │    AI AGENT      │
                                      │                  │
                                      │ Analyze PV Data  │
                                      │ Detect Anomaly   │
                                      │ Generate Reason  │
                                      └────────┬─────────┘
                                               │
                              ┌────────────────┼─────────────────┐
                              │                │                 │
                              ▼                ▼                 ▼
                       ┌────────────┐   ┌────────────┐   ┌─────────────┐
                       │ Telegram   │   │ Voice      │   │ Google      │
                       │ Message    │   │ Alert      │   │ Sheets      │
                       └────────────┘   └────────────┘   └─────────────┘

2. Main objectives

The project has six primary objectives.

Objective 1 — Real-time monitoring

Measure PV parameters continuously:

  • PV voltage

  • PV current

  • PV power

  • panel temperature

  • ambient temperature

  • solar irradiance

  • energy generation

PV power is calculated as:

PPV=VPV×IPVP_{PV}=V_{PV}\times I_{PV}

where:

  • PPVP_{PV} = PV power in watts

  • VPVV_{PV} = PV voltage in volts

  • IPVI_{PV} = PV current in amperes

Energy can be estimated using:

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

For discrete measurements:

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


3. Proposed hardware

A practical prototype can use:

Component Function
ESP32 DevKit Main IoT controller
Solar panel PV energy source
Voltage sensor/divider PV voltage measurement
Current sensor PV current measurement
DS18B20 Panel/environment temperature
BH1750 / irradiance sensor Light measurement
OLED display Local status display
Wi-Fi Internet communication
5 V/USB supply ESP32 power
Resistors Voltage scaling/protection
Breadboard/PCB Prototype assembly
Optional relay Protection/control
Optional buzzer Local alarm

For an actual PV installation, the voltage/current sensing circuitry must be selected according to the maximum PV voltage and current. The ESP32 ADC must never be exposed directly to a voltage beyond its permitted input range.


4. Hardware block diagram

             SOLAR PANEL
                  │
        ┌─────────┴─────────┐
        │                   │
        ▼                   ▼
 Voltage Measurement    Current Measurement
        │                   │
        │                   │
        └─────────┬─────────┘
                  │
                  ▼
             ┌─────────┐
             │  ESP32  │
             │         │
             │ ADC     │
             │ GPIO    │
             │ I2C     │
             │ Wi-Fi   │
             └────┬────┘
                  │
       ┌──────────┼──────────┐
       │          │          │
       ▼          ▼          ▼
     OLED      Temp.       Wi-Fi
    Display    Sensor        │
                              ▼
                          Internet

5. Suggested ESP32 pin configuration

One possible prototype configuration:

ESP32
────────────────────────────
GPIO 34  → PV Voltage ADC
GPIO 35  → PV Current ADC
GPIO 21  → I2C SDA
GPIO 22  → I2C SCL
GPIO 4   → DS18B20
GPIO 2   → Status LED
GPIO 25  → Buzzer
3.3 V    → Sensors
GND      → Common GND

Example:

                 ESP32
          ┌────────────────┐
          │                │
PV Voltage ───────► GPIO34 │
PV Current ───────► GPIO35 │
          │                │
DS18B20 ──────────► GPIO4  │
          │                │
OLED SDA ─────────► GPIO21 │
OLED SCL ─────────► GPIO22 │
          │                │
Buzzer ◄────────── GPIO25  │
LED    ◄────────── GPIO2   │
          │                │
          └────────────────┘

6. Voltage measurement circuit

The ESP32 ADC cannot directly measure typical PV-panel voltages.

Therefore, a voltage divider is required.

             PV+
              │
             R1
              │
              ├────────────► ESP32 ADC
              │
             R2
              │
             GND

The ADC voltage is:

VADC=VPVR2R1+R2V_{ADC}=V_{PV}\frac{R_2}{R_1+R_2}

Therefore:

VPV=VADCR1+R2R2V_{PV}=V_{ADC}\frac{R_1+R_2}{R_2}

For example, the resistor values must be calculated from the maximum expected PV voltage, with suitable margin and appropriate resistor power ratings.

For a real installation, add suitable:

  • fuse/protection

  • filtering

  • overvoltage protection

  • isolation where required


7. Current measurement

A Hall-effect current sensor can be used.

Conceptually:

PV+ ───────► CURRENT SENSOR ───────► LOAD/CHARGE CONTROLLER
                    │
                    │ Analog output
                    ▼
                 ESP32 ADC

The firmware converts the sensor output into current according to the selected sensor's calibration equation.

For example:

I=Vsensor−VoffsetSensitivityI=\frac{V_{sensor}-V_{offset}}{Sensitivity}

The actual offset and sensitivity must come from the selected current sensor and be calibrated experimentally.


8. Temperature measurement

A DS18B20 can be attached to the rear of the solar panel.

Panel
──────────────────────
│                    │
│      PV CELLS      │
│                    │
──────────────────────
          │
          │ thermal contact
          ▼
      DS18B20
          │
          ▼
        ESP32

Temperature is important because PV output generally changes with cell temperature.

The AI layer can therefore compare:

Solar irradiance
       +
Panel temperature
       +
PV voltage
       +
PV current
       ↓
Expected PV behavior
       ↓
Actual PV behavior
       ↓
Anomaly detection

9. IoT data structure

The ESP32 can transmit a JSON payload such as:

{
  "device_id": "SOLARPULSE_001",
  "voltage": 18.72,
  "current": 2.84,
  "power": 53.16,
  "temperature": 42.6,
  "irradiance": 815,
  "energy": 1.284,
  "status": "NORMAL"
}

The important advantage of JSON is that the same payload can be consumed by:

  • n8n

  • web application

  • cloud APIs

  • database

  • AI agent


10. Complete software architecture

┌───────────────────────────────────────────────────────┐
│                    SOLARPULSE AI                      │
└───────────────────────────────────────────────────────┘

       HARDWARE
           │
           ▼
┌──────────────────────┐
│        ESP32         │
│                      │
│ Sensor acquisition   │
│ Filtering            │
│ Power calculation    │
│ Wi-Fi                │
└──────────┬───────────┘
           │
           │ JSON / HTTP
           ▼
┌──────────────────────┐
│    IoT Cloud Layer   │
│                      │
│ ThingSpeak           │
│ Web API              │
└──────────┬───────────┘
           │
           ├─────────────────┐
           │                 │
           ▼                 ▼
     ┌───────────┐    ┌─────────────┐
     │ Webpage   │    │     n8n     │
     │ Dashboard │    │ Automation  │
     └───────────┘    └──────┬──────┘
                             │
                             ▼
                       ┌────────────┐
                       │ AI Agent   │
                       └─────┬──────┘
                             │
                  ┌──────────┼──────────┐
                  ▼          ▼          ▼
             Telegram     Voice     Google Sheets
             Message      Alert       Logging

11. IoT webpage

The webpage is the user-facing monitoring interface.

A dashboard could contain:

╔══════════════════════════════════════════════════╗
║                 SOLARPULSE AI                    ║
║              Solar PV Dashboard                  ║
╠══════════════════════════════════════════════════╣
║                                                  ║
║  Voltage       Current        Power              ║
║  18.72 V       2.84 A         53.16 W            ║
║                                                  ║
║  Temperature   Irradiance     Energy             ║
║  42.6 °C       815 W/m²       1.284 kWh           ║
║                                                  ║
╠══════════════════════════════════════════════════╣
║              SYSTEM STATUS                      ║
║                                                  ║
║                 🟢 NORMAL                       ║
║                                                  ║
╠══════════════════════════════════════════════════╣
║                 PV POWER GRAPH                  ║
║                                                  ║
║       ╭──╮                                      ║
║   ╭───╯  ╰──╮                                   ║
║ ──╯         ╰────────                           ║
║                                                  ║
╠══════════════════════════════════════════════════╣
║ AI ANALYSIS                                     ║
║                                                  ║
║ "PV generation is operating within the expected ║
║ range for the measured irradiance."             ║
╚══════════════════════════════════════════════════╝

12. n8n automation architecture

n8n becomes the central orchestration layer.

                 ESP32
                   │
                   ▼
              HTTP Request
                   │
                   ▼
             ┌───────────┐
             │ Webhook   │
             └─────┬─────┘
                   │
                   ▼
             Parse JSON
                   │
                   ▼
          Validate Sensor Data
                   │
                   ▼
          Calculate/Check Rules
                   │
          ┌────────┴────────┐
          │                 │
       NORMAL             ABNORMAL
          │                 │
          ▼                 ▼
   Google Sheets        AI Agent
          │                 │
          │           ┌─────┴─────┐
          │           │           │
          │           ▼           ▼
          │        Diagnosis   Recommendation
          │           │
          │           ▼
          │       Telegram
          │           │
          │           ▼
          │      Voice Message
          │
          ▼
       Dashboard

13. n8n workflow nodes

A complete workflow can be organized as:

[Webhook]
    ↓
[Set / Normalize Data]
    ↓
[Function: Calculate Power]
    ↓
[IF: Sensor Valid?]
    ↓
[Store Data]
    ↓
[Rule Evaluation]
    ↓
[AI Agent]
    ↓
[Decision]
   / \
  /   \
Normal  Alert
 |       |
 ▼       ▼
Sheets  Telegram
         |
         ▼
     Text-to-Speech
         |
         ▼
   Telegram Voice

14. AI Agent responsibilities

The AI Agent should not simply say "high" or "low."

It should interpret several parameters together.

For example:

PV Voltage       = 17.1 V
PV Current       = 0.4 A
Irradiance       = 850 W/m²
Temperature      = 39 °C

The AI agent could determine that the current output is unusually low relative to the available irradiance and report a possible performance issue.

Potential anomaly categories:

  • low power

  • sudden power drop

  • abnormal voltage

  • abnormal current

  • overheating

  • sensor failure

  • communication failure

  • nighttime/low-light condition

  • prolonged underperformance

The AI should distinguish actual faults from expected environmental changes.

For example:

Irradiance = 50 W/m²
Power      = 2 W

should not automatically be treated as a PV fault.


15. AI Agent input

A useful AI-agent prompt can be structured around machine-readable input:

You are SolarPulse AI, an assistant responsible for
interpreting solar PV monitoring data.

Analyze:

PV voltage
PV current
PV power
panel temperature
solar irradiance
historical values
previous alerts

Determine:

1. Current operating condition
2. Whether an anomaly exists
3. Severity
4. Possible cause
5. Recommended action

Do not declare a hardware failure unless the available
measurements provide sufficient evidence.

Return JSON:

{
  "status": "NORMAL|WARNING|CRITICAL",
  "anomaly": true,
  "reason": "...",
  "recommendation": "...",
  "voice_message": "..."
}

16. AI agent decision example

Suppose:

Voltage = 18.4 V
Current = 2.9 A
Power = 53.36 W
Temperature = 41 °C
Irradiance = 820 W/m²

AI output:

{
  "status": "NORMAL",
  "anomaly": false,
  "reason": "PV output is consistent with the measured operating conditions.",
  "recommendation": "Continue monitoring.",
  "voice_message": "Solar PV system is operating normally."
}

For an abnormal case:

{
  "status": "WARNING",
  "anomaly": true,
  "reason": "PV current has decreased significantly while irradiance remains high.",
  "recommendation": "Inspect panel shading, connections and PV-side equipment.",
  "voice_message": "Warning. Solar PV output has dropped unexpectedly. Please inspect the system."
}

17. Telegram text alert

Example workflow:

ESP32
  ↓
n8n
  ↓
AI Agent
  ↓
Telegram Bot
  ↓
Mobile Phone

Example message:

⚠️ SOLARPULSE AI ALERT

Device: SOLARPULSE_001

Status: WARNING

PV Voltage: 18.1 V
PV Current: 0.72 A
PV Power: 13.0 W
Irradiance: 830 W/m²
Temperature: 44.2 °C

AI Analysis:
PV output is significantly below the expected level
for the measured irradiance.

Recommended Action:
Inspect the PV panel for shading, contamination or
connection problems.

18. Telegram voice alert

The voice-alert pipeline is:

AI Agent
   │
   ▼
Voice message text
   │
   ▼
Text-to-Speech service
   │
   ▼
Audio file
   │
   ▼
Telegram Bot
   │
   ▼
User's smartphone

Example spoken message:

"SolarPulse warning. PV output has dropped unexpectedly while solar irradiance remains high. Please inspect the solar panel and electrical connections."

This is particularly useful when the operator is not continuously looking at the dashboard.


19. Google Sheets integration

Google Sheets can act as a simple historical event/data repository.

Example:

Timestamp Device Voltage Current Power Temp Irradiance AI Status Alert
10:01 SP001 18.7 2.8 52.4 41.2 810 NORMAL No
10:02 SP001 18.5 2.7 49.9 41.5 825 NORMAL No
10:03 SP001 18.1 0.8 14.5 42.1 830 WARNING Yes

This makes it possible to perform later analysis such as:

  • daily energy

  • maximum power

  • minimum voltage

  • abnormal-event frequency

  • temperature/output relationship

  • historical performance


20. ThingSpeak architecture

ThingSpeak can provide a cloud IoT channel .

Example field assignment:

Field 1 → Voltage
Field 2 → Current
Field 3 → Power
Field 4 → Temperature
Field 5 → Irradiance
Field 6 → Energy
Field 7 → Status

Conceptually:

ESP32
  │
  │ HTTP/MQTT
  ▼
ThingSpeak
  │
  ├────► Charts
  ├────► Historical data
  └────► API

The webpage can either retrieve data from the cloud API or receive data through the project's backend architecture.


21. End-to-end communication

The complete sequence is:

1. Solar panel produces electricity
              ↓
2. Sensors measure PV parameters
              ↓
3. ESP32 reads sensors
              ↓
4. ESP32 filters/calculates measurements
              ↓
5. ESP32 calculates PV power
              ↓
6. ESP32 creates JSON packet
              ↓
7. Data transmitted over Wi-Fi
              ↓
8. Cloud/dashboard receives data
              ↓
9. n8n receives event
              ↓
10. n8n validates data
              ↓
11. AI Agent analyzes operating condition
              ↓
12. AI returns structured diagnosis
              ↓
13. n8n stores record in Google Sheets
              ↓
14. If abnormal:
              ↓
15. Telegram text alert
              ↓
16. Text converted to speech
              ↓
17. Telegram voice alert

22. ESP32 firmware architecture

The firmware should be divided into logical modules.

main()
 │
 ├── initializeSensors()
 │
 ├── initializeDisplay()
 │
 ├── connectWiFi()
 │
 ├── synchronizeTime()
 │
 └── loop()
       │
       ├── readVoltage()
       ├── readCurrent()
       ├── readTemperature()
       ├── readIrradiance()
       ├── calculatePower()
       ├── calculateEnergy()
       ├── validateMeasurements()
       ├── updateDisplay()
       └── sendCloudData()

23. Example ESP32 Arduino code

Below is a prototype/reference implementation. The voltage/current calibration values must be changed for the actual sensors used.

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

// ---------------------------
// Wi-Fi configuration
// ---------------------------
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASSWORD = "YOUR_PASSWORD";

// n8n webhook
const char* WEBHOOK_URL =
  "https://YOUR-N8N-DOMAIN/webhook/solarpulse";

// ---------------------------
// ESP32 pins
// ---------------------------
#define PV_VOLTAGE_PIN 34
#define PV_CURRENT_PIN 35
#define TEMP_PIN       4
#define STATUS_LED      2

// ---------------------------
// Temperature sensor
// ---------------------------
OneWire oneWire(TEMP_PIN);
DallasTemperature tempSensor(&oneWire);

// ---------------------------
// Calibration
// IMPORTANT:
// Replace these with values
// determined for your hardware.
// ---------------------------
float voltageScale = 6.0;
float currentOffset = 1.65;
float currentSensitivity = 0.066;

// ---------------------------
// Energy calculation
// ---------------------------
float energyWh = 0.0;

unsigned long previousMillis = 0;
const unsigned long sampleInterval = 10000;

// ---------------------------
// Read PV voltage
// ---------------------------
float readPVVoltage()
{
    int raw = analogRead(PV_VOLTAGE_PIN);

    float adcVoltage =
        (raw / 4095.0) * 3.3;

    return adcVoltage * voltageScale;
}

// ---------------------------
// Read PV current
// ---------------------------
float readPVCurrent()
{
    int raw = analogRead(PV_CURRENT_PIN);

    float sensorVoltage =
        (raw / 4095.0) * 3.3;

    float current =
        (sensorVoltage - currentOffset)
        / currentSensitivity;

    if (current < 0)
        current = 0;

    return current;
}

// ---------------------------
// Send JSON data
// ---------------------------
void sendData(
    float voltage,
    float current,
    float power,
    float temperature)
{
    if (WiFi.status() != WL_CONNECTED)
        return;

    HTTPClient http;

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

    StaticJsonDocument<512> doc;

    doc["device_id"] = "SOLARPULSE_001";
    doc["voltage"] = voltage;
    doc["current"] = current;
    doc["power"] = power;
    doc["temperature"] = temperature;
    doc["energy_wh"] = energyWh;

    String payload;

    serializeJson(doc, payload);

    int responseCode =
        http.POST(payload);

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

    http.end();
}

// ---------------------------
// Setup
// ---------------------------
void setup()
{
    Serial.begin(115200);

    pinMode(STATUS_LED, OUTPUT);

    tempSensor.begin();

    WiFi.begin(
        WIFI_SSID,
        WIFI_PASSWORD
    );

    Serial.print("Connecting");

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

    Serial.println();
    Serial.println("Wi-Fi connected");
    Serial.println(WiFi.localIP());
}

// ---------------------------
// Main loop
// ---------------------------
void loop()
{
    unsigned long currentMillis =
        millis();

    if (currentMillis - previousMillis
        >= sampleInterval)
    {
        previousMillis =
            currentMillis;

        float voltage =
            readPVVoltage();

        float current =
            readPVCurrent();

        tempSensor.requestTemperatures();

        float temperature =
            tempSensor.getTempCByIndex(0);

        float power =
            voltage * current;

        // Energy in Wh
        float hours =
            sampleInterval / 3600000.0;

        energyWh +=
            power * hours;

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

        Serial.print("Voltage: ");
        Serial.println(voltage);

        Serial.print("Current: ");
        Serial.println(current);

        Serial.print("Power: ");
        Serial.println(power);

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

        Serial.print("Energy: ");
        Serial.println(energyWh);

        sendData(
            voltage,
            current,
            power,
            temperature
        );
    }
}

24. Improved ESP32 architecture

For the final version, I would recommend adding:

Sensor
   ↓
Moving Average Filter
   ↓
Outlier Rejection
   ↓
Calibration
   ↓
Range Validation
   ↓
Power Calculation
   ↓
Energy Calculation
   ↓
Local Fault Detection
   ↓
Cloud Transmission

This prevents noisy sensor values from triggering unnecessary AI alerts.


25. Local fault detection

Some faults can be identified without AI.

For example:

if (voltage < 1.0 && current < 0.1)
{
    status = "LOW_OUTPUT";
}

or:

if (temperature > 75)
{
    status = "OVER_TEMPERATURE";
}

But thresholds should be configurable according to the actual PV system.

A useful architecture is:

               Sensor Data
                    │
           ┌────────┴────────┐
           │                 │
           ▼                 ▼
      Rule Engine         AI Agent
           │                 │
           └────────┬────────┘
                    ▼
             Final Decision

This reduces unnecessary AI calls.


26. n8n workflow pseudo-configuration

Node 1 — Webhook

POST /solarpulse

Receives:

{
  "device_id": "SOLARPULSE_001",
  "voltage": 18.7,
  "current": 2.8,
  "power": 52.36,
  "temperature": 42.1,
  "irradiance": 815
}

Node 2 — Code/Function

Calculate derived values:

const d = $json;

const power =
  Number(d.voltage) *
  Number(d.current);

return [{
  json: {
    ...d,
    calculated_power: power
  }
}];

Node 3 — Validation

Voltage valid?
       │
       ├── NO → Error workflow
       │
       └── YES
              ↓
Current valid?
       │
       ├── NO → Error workflow
       │
       └── YES

Node 4 — AI Agent

Send the validated sensor information.

Node 5 — Google Sheets

Append:

timestamp
device
voltage
current
power
temperature
irradiance
AI status
AI explanation

Node 6 — IF

AI status == WARNING
OR
AI status == CRITICAL

Node 7 — Telegram

Send notification.

Node 8 — Text-to-Speech

Generate audio.

Node 9 — Telegram Voice

Send audio message.


27. AI-agent conversation example

The project can document the AI Agent interaction as follows:

SYSTEM
You are SolarPulse AI.

USER
Device: SP001
Voltage: 18.2 V
Current: 0.71 A
Power: 12.9 W
Temperature: 43.7 °C
Irradiance: 840 W/m²

Analyze the PV operating condition.

AI AGENT
Status: WARNING

The measured power is substantially lower than
expected for the reported irradiance.

Possible causes include:
1. Panel shading
2. Surface contamination
3. Electrical connection problem
4. PV-side equipment issue

Recommended action:
Inspect the panel and electrical connections.

Then n8n converts the AI response into:

Telegram Text
       +
Telegram Voice
       +
Google Sheets Event

28. Multi-channel alert architecture

One of the major contributions of the project is that an event does not depend on a single notification channel.

                    AI DETECTS EVENT
                           │
             ┌─────────────┼─────────────┐
             │             │             │
             ▼             ▼             ▼
         Webpage       Telegram      Google Sheets
          Alert          Text           Log
                           │
                           ▼
                      Text-to-Speech
                           │
                           ▼
                     Voice Alert

Therefore:

  • dashboard = visual monitoring

  • Telegram = immediate textual notification

  • voice = hands-free notification

  • Sheets = historical record


29. Webpage software structure

A simple web application can have:

/frontend
    index.html
    style.css
    dashboard.js

/backend
    server.js
    api.js

/data
    sensor-data

/assets
    logo
    icons

Dashboard components:

Header
  │
  ├── Device status
  ├── Last update
  └── Connection status

Metrics
  │
  ├── Voltage
  ├── Current
  ├── Power
  ├── Temperature
  ├── Irradiance
  └── Energy

Charts
  │
  ├── Power vs Time
  ├── Voltage vs Time
  ├── Current vs Time
  └── Temperature vs Time

AI
  │
  ├── Status
  ├── Explanation
  └── Recommendation

Alerts
  │
  ├── Recent alerts
  └── Alert history

30. Dashboard HTML prototype

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>SolarPulse AI</title>

    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
            background: #101820;
            color: white;
        }

        header {
            padding: 20px;
            background: #17232c;
        }

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

        .card {
            background: #1d2d38;
            padding: 20px;
            border-radius: 15px;
        }

        .value {
            font-size: 32px;
            color: #ffd166;
        }

        .normal {
            color: #00e676;
        }

        .warning {
            color: #ffb300;
        }

        .critical {
            color: #ff5252;
        }
    </style>
</head>

<body>

<header>
    <h1>☀ SolarPulse AI</h1>
    <p>Intelligent Solar PV Monitoring System</p>
</header>

<div class="dashboard">

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

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

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

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

    <div class="card">
        <h3>Irradiance</h3>
        <div id="irradiance"
             class="value">-- W/m²</div>
    </div>

    <div class="card">
        <h3>AI Status</h3>
        <div id="status"
             class="value normal">
             NORMAL
        </div>
    </div>

</div>

<script>

async function updateDashboard()
{
    try
    {
        const response =
            await fetch("/api/latest");

        const data =
            await response.json();

        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";

        document.getElementById("irradiance")
            .innerText =
            data.irradiance + " W/m²";

        document.getElementById("status")
            .innerText =
            data.status;
    }
    catch(error)
    {
        console.error(error);
    }
}

setInterval(updateDashboard, 10000);

updateDashboard();

</script>

</body>
</html>

31. Complete project workflow

The complete SolarPulse AI system can therefore be represented as:

                         ☀ SUN
                           │
                           ▼
                     ┌───────────┐
                     │ SOLAR PV  │
                     │  PANEL    │
                     └─────┬─────┘
                           │
             ┌─────────────┼─────────────┐
             │             │             │
             ▼             ▼             ▼
          Voltage        Current      Temperature
          Sensor         Sensor          Sensor
             │             │             │
             └─────────────┼─────────────┘
                           ▼
                     ┌───────────┐
                     │   ESP32   │
                     │           │
                     │ Sampling  │
                     │ Filtering │
                     │ Compute   │
                     └─────┬─────┘
                           │
                         Wi-Fi
                           │
                           ▼
              ┌────────────────────────┐
              │     IoT CLOUD/API      │
              └───────────┬────────────┘
                          │
              ┌───────────┴────────────┐
              │                        │
              ▼                        ▼
        ┌───────────┐            ┌───────────┐
        │ ThingSpeak│            │    n8n    │
        └─────┬─────┘            └─────┬─────┘
              │                        │
              ▼                        ▼
        Cloud Charts             Data Validation
                                       │
                                       ▼
                                  Rule Engine
                                       │
                                       ▼
                                  AI AGENT
                                       │
                              ┌────────┼────────┐
                              │        │        │
                              ▼        ▼        ▼
                         Telegram    Voice    Sheets
                           Text      Alert      Log
                              │
                              ▼
                           USER
                              │
                              ▼
                       Corrective Action

32. Fault-detection logic

A useful rule hierarchy is:

Level 0 — Normal

All sensor readings valid
+
PV output consistent with conditions

Level 1 — Warning

Moderate deviation
OR
temperature approaching limit
OR
unexpected output reduction

Level 2 — Critical

Severe abnormal condition
OR
dangerous temperature
OR
sensor/system failure

Example:

                    Sensor Data
                         │
                         ▼
                ┌─────────────────┐
                │ Data Validation  │
                └────────┬────────┘
                         │
                   Valid data?
                    /          \
                  NO            YES
                  │              │
                  ▼              ▼
               SENSOR        AI ANALYSIS
               ERROR              │
                                  ▼
                            Severity Level
                          /       |        \
                       NORMAL   WARNING   CRITICAL
                         │         │          │
                         ▼         ▼          ▼
                       Log       Telegram   Telegram
                                  Voice      Voice

33. Security architecture

The final system should not expose credentials in ESP32 source code.

Avoid:

const char* API_KEY = "actual-secret";

for production repositories.

Instead use:

ESP32
  │
  └── HTTPS
       │
       ▼
Secure API/Webhook
       │
       ▼
n8n credentials
       │
       ├── Telegram credential
       ├── Google credential
       ├── AI API credential
       └── ThingSpeak credential

Recommended protections include:

  • HTTPS

  • authenticated webhook

  • API keys

  • secret/environment variables

  • n8n credential management

  • rate limiting

  • input validation

  • device identification

  • timestamp validation


34. Failure scenarios

The documentation should explicitly test:

Failure Expected response
Wi-Fi disconnected ESP32 retries connection
Internet unavailable Local buffering/retry
Sensor disconnected Sensor error
Abnormal voltage Warning/critical event
Current suddenly drops AI analysis
High temperature Temperature warning
n8n unavailable Retry transmission
Telegram unavailable Log event/retry
AI service unavailable Rule-based fallback
ThingSpeak unavailable Continue local/cloud retry
Invalid JSON Reject request

35. Important design principle: AI is not the only protection

The system should not depend exclusively on an AI model for electrical safety.

Use deterministic protection for hard limits:

Hardware protection
        ↓
Local ESP32 safety/range checks
        ↓
n8n rule engine
        ↓
AI interpretation
        ↓
Human notification

AI is particularly useful for contextual interpretation, rather than replacing electrical protection circuitry.


36. Project methodology

The project can be implemented in these stages.

Phase 1 — Hardware

  1. Assemble ESP32.

  2. Connect voltage sensor.

  3. Connect current sensor.

  4. Connect temperature sensor.

  5. Verify each sensor independently.

  6. Calibrate measurements.

  7. Test under controlled PV conditions.

Phase 2 — Firmware

  1. Configure ADC.

  2. Read voltage.

  3. Read current.

  4. Read temperature.

  5. Calculate power.

  6. Calculate energy.

  7. Add filtering.

  8. Add Wi-Fi.

  9. Create JSON payload.

  10. Send test data.

Phase 3 — Cloud

  1. Create ThingSpeak channel.

  2. Configure fields.

  3. Test cloud transmission.

  4. Verify charts.

  5. Configure API access.

Phase 4 — n8n

  1. Create webhook.

  2. Receive ESP32 JSON.

  3. Validate data.

  4. Calculate derived values.

  5. Add rule engine.

  6. Connect AI Agent.

  7. Add Google Sheets.

  8. Add Telegram.

  9. Add voice generation.

  10. Test complete workflow.

Phase 5 — Web application

  1. Create dashboard.

  2. Add metric cards.

  3. Add charts.

  4. Add status indicator.

  5. Add AI explanation.

  6. Add alert history.

  7. Connect backend/API.

Phase 6 — Testing

  1. Normal operation.

  2. Low irradiance.

  3. High temperature.

  4. Artificial current reduction.

  5. Sensor disconnection.

  6. Wi-Fi failure.

  7. n8n failure.

  8. Telegram failure.

  9. Recovery testing.


37. Suggested final project directory

SolarPulse-AI/
│
├── README.md
│
├── documentation/
│   ├── project-description.md
│   ├── system-architecture.md
│   ├── hardware-design.md
│   ├── software-design.md
│   ├── n8n-workflow.md
│   ├── ai-agent.md
│   ├── testing.md
│   └── user-manual.md
│
├── esp32/
│   ├── SolarPulse.ino
│   ├── sensors.h
│   ├── sensors.cpp
│   ├── config.h
│   └── calibration.h
│
├── web/
│   ├── index.html
│   ├── style.css
│   └── dashboard.js
│
├── n8n/
│   ├── solarpulse-workflow.json
│   └── ai-agent-prompt.txt
│
├── diagrams/
│   ├── system-block-diagram.png
│   ├── circuit-schematic.png
│   ├── data-flow.png
│   └── n8n-flow.png
│
└── tests/
    ├── sensor-test
    ├── api-test
    └── alert-test

38. Proposed research contribution

For an academic/project report, the novelty can be framed around the integration of multiple layers, rather than claiming that each individual technology is novel.

The proposed framework combines:

IoT sensing
     +
Edge processing
     +
Cloud monitoring
     +
Workflow automation
     +
AI-based contextual analysis
     +
Multi-channel notification

into one solar PV monitoring architecture.

A suitable research contribution statement is:

SolarPulse AI proposes an integrated IoT-agentic architecture for real-time photovoltaic performance monitoring in which edge-based ESP32 sensing, cloud telemetry, workflow automation, AI-assisted anomaly interpretation, historical logging, and multi-channel human notification operate as a unified monitoring pipeline.


39. Recommended final report structure

For a B.Tech/M.Tech/project thesis/paper, I would structure the documentation as:

CHAPTER 1
Introduction

CHAPTER 2
Literature Review

CHAPTER 3
Problem Statement

CHAPTER 4
Objectives and Scope

CHAPTER 5
Proposed SolarPulse AI Architecture

CHAPTER 6
Hardware Design

CHAPTER 7
ESP32 Firmware Design

CHAPTER 8
IoT and Cloud Architecture

CHAPTER 9
n8n Automation Architecture

CHAPTER 10
AI Agent Design

CHAPTER 11
Telegram Voice Alert System

CHAPTER 12
Google Sheets and ThingSpeak Integration

CHAPTER 13
Web Dashboard

CHAPTER 14
System Implementation

CHAPTER 15
Flowcharts and Algorithms

CHAPTER 16
Experimental Setup

CHAPTER 17
Results and Discussion

CHAPTER 18
Fault/Anomaly Detection

CHAPTER 19
Limitations

CHAPTER 20
Future Scope

CHAPTER 21
Conclusion

REFERENCES

APPENDIX
ESP32 Code
n8n Workflow
Circuit
API Configuration
Test Results

40. Final system in one diagram

                         ┌───────────────┐
                         │   SOLAR PV    │
                         │    PANEL      │
                         └───────┬───────┘
                                 │
                  ┌──────────────┼──────────────┐
                  │              │              │
                  ▼              ▼              ▼
             Voltage          Current       Temperature
              Sensor           Sensor          Sensor
                  │              │              │
                  └──────────────┼──────────────┘
                                 │
                                 ▼
                         ┌───────────────┐
                         │     ESP32     │
                         │               │
                         │ Sensor Read   │
                         │ Filtering     │
                         │ P = V × I     │
                         │ Energy        │
                         │ Wi-Fi         │
                         └───────┬───────┘
                                 │
                              HTTPS
                                 │
                  ┌──────────────┼──────────────┐
                  │                             │
                  ▼                             ▼
          ┌───────────────┐              ┌───────────────┐
          │  ThingSpeak   │              │  n8n Webhook  │
          │ Cloud Storage │              │   Automation  │
          └───────┬───────┘              └───────┬───────┘
                  │                              │
                  ▼                              ▼
          ┌───────────────┐              ┌───────────────┐
          │ IoT Dashboard │              │ Data Validate │
          └───────────────┘              └───────┬───────┘
                                                  │
                                                  ▼
                                          ┌───────────────┐
                                          │ Rule Engine   │
                                          └───────┬───────┘
                                                  │
                                                  ▼
                                          ┌───────────────┐
                                          │   AI AGENT    │
                                          │               │
                                          │ Analyze       │
                                          │ Explain       │
                                          │ Recommend     │
                                          └───────┬───────┘
                                                  │
                           ┌──────────────────────┼──────────────────────┐
                           │                      │                      │
                           ▼                      ▼                      ▼
                    ┌────────────┐        ┌──────────────┐       ┌────────────┐
                    │  Telegram  │        │ Text-to-     │       │  Google    │
                    │   Alert    │        │ Speech       │       │  Sheets    │
                    └────────────┘        └──────┬───────┘       └────────────┘
                                                  │
                                                  ▼
                                           ┌────────────┐
                                           │ Telegram   │
                                           │ Voice      │
                                           │ Alert      │
                                           └─────┬──────┘
                                                 │
                                                 ▼
                                             👤 USER

This gives you the complete conceptual and implementation foundation for SolarPulse AI. The next practical step is to turn this into a fully buildable version with the exact sensor modules you intend to use: a complete circuit/schematic, calibrated ESP32 firmware, n8n workflow JSON, AI-agent prompt, Telegram bot configuration, Google Sheets structure, ThingSpeak configuration, and a polished responsive web dashboard.

 

## SolarPulse AI — Project Summary **SolarPulse AI** is an IoT-enabled intelligent solar PV monitoring system that combines **ESP32 sensing, cloud monitoring, n8n automation, AI-based anomaly analysis, Telegram notifications/voice alerts, Google Sheets logging, ThingSpeak, and a web dashboard**. ### Core workflow ``` Solar PV Panel ↓ Voltage / Current / Temperature / Irradiance Sensors ↓ ESP32 ↓ Wi-Fi + JSON ↓ ┌───────────────┬────────────────┐ │ │ │ ▼ ▼ ▼ ThingSpeak Web Dashboard n8n ↓ Data Validation ↓ Rule Evaluation ↓ AI Agent ↓ ┌───────────────────┼─────────────────┐ ↓ ↓ ↓ Telegram Text Voice Alert Google Sheets ``` ### Main functions - **Real-time PV monitoring** - Voltage - Current - Power - Temperature - Irradiance - Energy generation - **ESP32 edge processing** - Sensor acquisition - Filtering/calibration - Power calculation - Energy calculation - Wi-Fi communication - **Cloud/IoT** - ThingSpeak data storage and visualization - Web dashboard for live monitoring - **n8n automation** - Receives ESP32 data - Validates measurements - Runs rules - Calls the AI agent - Logs events - Triggers notifications - **AI Agent** - Interprets PV operating conditions - Detects potential anomalies - Determines severity - Explains possible causes - Provides recommended actions - **Multi-channel alerts** - Telegram text - Telegram voice notification - Dashboard warning - Google Sheets event history ### Example AI scenario ``` Irradiance: 830 W/m² PV Voltage: 18.1 V PV Current: 0.72 A PV Power: 13 W Temperature: 44 °C ↓ AI Agent ↓ WARNING: PV output is significantly lower than expected for the measured irradiance. Possible causes: - Shading - Panel contamination - Electrical connection problem - PV equipment issue ↓ Telegram Text + Voice Alert + Google Sheets Log ``` ### Hardware Typical prototype: ``` ESP32 ├── PV Voltage Sensor ├── PV Current Sensor ├── DS18B20 Temperature Sensor ├── Irradiance/Light Sensor ├── OLED Display ├── Status LED └── Buzzer ``` ### Software stack ``` ESP32 / Arduino + Web Dashboard + ThingSpeak + n8n + AI Agent + Telegram Bot + Text-to-Speech + Google Sheets ``` ### Academic contribution The project integrates **IoT sensing + edge computing + cloud monitoring + workflow automation + AI-based anomaly interpretation + multi-channel alerting** into a unified solar PV monitoring framework. ### Suggested report title **“SolarPulse AI: An IoT-Enabled Intelligent Framework for Real-Time Solar PV Performance Monitoring and Multi-Channel AI Alerting”** The complete implementation can be organized into **hardware design → ESP32 firmware → IoT/cloud → n8n workflow → AI agent → Telegram voice alerts → Google Sheets → web dashboard → testing and results**.