AI Agent Air Quality Intelligence Platform with Automated Voice Alerts and Predictive Pollution Analysis

AI Agent Air Quality Intelligence Platform ESP32 + Air Quality Sensors + n8n Automation + AI Agent + Telegram Voice Alerts + Google Sheets + ThingSpeak Dashboard
<?php echo $title; ?>

AI Agent Air Quality Intelligence Platform

ESP32 + AI Agent + n8n + Telegram Voice Alerts + Google Sheets + ThingSpeak

Project Overview

This project develops an AI-powered Air Quality Monitoring System using ESP32, MQ135 Air Quality Sensor, DHT22, ThingSpeak Cloud, n8n Automation, Telegram Voice Alerts, Google Sheets Logging, and Predictive Analytics.

  • Real-Time Air Quality Monitoring
  • Cloud Dashboard Visualization
  • AI-Based Pollution Prediction
  • Telegram Voice Notifications
  • Google Sheets Data Logging
  • Agentic Decision Making

System Architecture

MQ135 + DHT22
       |
       V
     ESP32
       |
       V
    WiFi Cloud
       |
       V
   ThingSpeak
       |
       V
       n8n
   /    |    \
Sheets Telegram AI
            |
            V
      Voice Alerts

Components List

Component Quantity
ESP321
MQ135 Sensor1
DHT22 Sensor1
OLED Display1
Breadboard1
Jumper Wires20
WiFi Router1

Circuit Connections

MQ135

VCC  -> 5V
GND  -> GND
AOUT -> GPIO34

DHT22

VCC  -> 3.3V
GND  -> GND
DATA -> GPIO4

OLED

VCC -> 3.3V
GND -> GND
SDA -> GPIO21
SCL -> GPIO22

Flowchart

Start
 |
Initialize ESP32
 |
Connect WiFi
 |
Read Sensors
 |
Calculate AQI
 |
Upload to ThingSpeak
 |
Trigger n8n
 |
AI Analysis
 |
High Pollution?
 / \
Yes No
 |   |
Send Alert
 |
Voice Notification
 |
Store in Google Sheets
 |
Loop

AQI Classification

AQI Status
0-50Good
51-100Moderate
101-150Unhealthy for Sensitive Groups
151-200Unhealthy
201-300Very Unhealthy
301+Hazardous

ESP32 Sample Code

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

const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";

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

 WiFi.begin(ssid,password);

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

void loop()
{
 int airValue=analogRead(34);

 HTTPClient http;

 String url=
 "https://api.thingspeak.com/update?api_key=KEY"
 "&field1="+String(airValue);

 http.begin(url);
 http.GET();
 http.end();

 delay(60000);
}

ThingSpeak Setup

  1. Create ThingSpeak Account
  2. Create New Channel
  3. Add AQI Field
  4. Copy Write API Key
  5. Paste into ESP32 Code

Telegram Bot Setup

  1. Open Telegram
  2. Search BotFather
  3. Create New Bot
  4. Copy Bot Token
  5. Get Chat ID
  6. Configure in n8n

n8n Workflow

Webhook
  |
IF AQI > 150
  |
OpenAI Analysis
  |
Google Sheets
  |
Telegram Alert
  |
Text-to-Speech
  |
Telegram Voice Message

AI Prediction Logic

Moving Average

Predicted AQI =
(AQI1+AQI2+AQI3+AQI4+AQI5)/5

Linear Regression

AQI = m*x + c

Advanced AI Models

  • Random Forest
  • XGBoost
  • LSTM
  • Time Series Forecasting

Voice Notification Message

Warning!

Air quality is unhealthy.

Current AQI: 185

Predicted AQI: 230

Avoid outdoor activities.

Google Sheets Columns

Timestamp AQI Temperature Humidity Prediction Status

Future Enhancements

  • Machine Learning Forecasting
  • Solar-Powered ESP32
  • LoRaWAN Communication
  • Mobile Application
  • GIS Air Pollution Maps
  • Industrial Deployment
  • Smart City Integration

Estimated Cost

Item Cost (₹)
ESP32500
MQ135250
DHT22250
OLED250
Accessories200
Total 1450
For a professional final-year project, you could further split this into: index.php (dashboard) esp32_code.php thingspeak_setup.php telegram_setup.php n8n_workflow.php ai_prediction.php deployment_guide.php and add Bootstrap, charts, login authentication, live ThingSpeak data fetching, and downloadable PDF documentation.

Comments