AI-Based Smart Bus Tracking and Passenger Monitoring System

AI-Based Smart Bus Tracking & Passenger Monitoring System Using ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak
AI Smart Bus Tracking System

🚍 AI-Based Smart Bus Tracking System

ESP32 + IoT + AI + n8n + Telegram + Google Sheets + ThingSpeak

Last Updated:

📌 Project Overview

This system uses ESP32 to track bus location, monitor passengers, predict power usage using AI logic and send alerts via Telegram.

🧠 Key Features

  • Live GPS Tracking
  • Passenger Counting System
  • AI Power Prediction
  • Cloud Dashboard (ThingSpeak)
  • Google Sheets Logging
  • Telegram Voice Alerts via n8n

🔧 Components Used

  • ESP32 Board
  • NEO-6M GPS Module
  • IR Sensors (2)
  • ACS712 Current Sensor
  • DHT11 Sensor
  • Buzzer

📡 System Architecture

Sensors → ESP32 → Cloud (ThingSpeak / Google Sheets)
                 ↓
              n8n Automation
                 ↓
        Telegram Voice Alerts + Dashboard
        

📊 AI Prediction Formula

Power Prediction:

P = (0.5 × Temperature) + (0.8 × Passenger Count) + (0.3 × Current)
        

🚨 Alert System Logic

if (passengerCount > 40) {
    sendTelegramAlert("Overcrowding detected!");
}
        

📥 ESP32 Data Flow

GPS → Latitude, Longitude
IR Sensors → Passenger Count
DHT11 → Temperature
ACS712 → Power Usage

All data → ThingSpeak + Google Sheets
        

🤖 n8n Automation Flow

Webhook Trigger
   ↓
Check Passenger Limit
   ↓
Generate Alert Message
   ↓
Send Telegram Voice Notification
   ↓
Store Data in Google Sheets
        

📲 Telegram Integration

BotFather → Create Bot
Get Token
Send API Request:

https://api.telegram.org/bot/sendMessage
        

☁️ ThingSpeak Setup

Channel Fields:
Field1 → Latitude
Field2 → Longitude
Field3 → Passenger Count
Field4 → Temperature
Field5 → Power Prediction
        

📈 Future Enhancements

  • AI Camera Passenger Detection
  • Mobile App Integration
  • Face Recognition for Driver
  • Smart Ticketing System
  • Edge AI (TinyML on ESP32)

🏁 Conclusion

This project is a complete AI-powered IoT transportation system combining ESP32, cloud computing, automation, and real-time analytics for smart city applications.

✅ OPTIONAL (API FILE FOR ESP32 → PHP SERVER) If you want ESP32 to send data to PHP instead of ThingSpeak: create file: api.php ✅ ESP32 CALL EXAMPLE String url = "http://yourserver.com/api.php?lat=" + String(latitude,6) + "&lon=" + String(longitude,6) + "&pass=" + String(passengerCount) + "&temp=" + String(temp); If you want next upgrade 🚀 I can also convert this into: 🔥 Full React Dashboard UI 📊 Live Map tracking (Leaflet / Google Maps) 🤖 AI ML model integration (Python backend) 📱 Mobile App (Flutter) ☁️ AWS / Firebase version 📡 Real-time WebSocket dashboard Just tell 👍

Comments