Wednesday, 27 May 2026

AI Smart Surveillance Robot with Face and Motion Detection

AI Smart Surveillance Robot with Face & Motion Detection ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
AI Smart Surveillance Robot with Face & Motion Detection ESP32 + AI Agentic IoT + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard 1. Project Overview This project is an AI-powered smart surveillance robot using an ESP32-CAM and IoT automation. The robot can: Detect motion Perform face detection Capture images Send Telegram alerts Send voice notifications Store logs in Google Sheets Upload sensor values to ThingSpeak Trigger AI-based automation via n8n Predict power usage using simple AI logic Provide remote cloud monitoring 2. System Architecture ┌─────────────────┐ │ ESP32-CAM │ │ Motion + Camera │ └────────┬────────┘ │ WiFi ▼ ┌─────────────────┐ │ n8n │ │ Automation Hub │ └──────┬──────────┘ │ ┌────────────────┼────────────────┐ ▼ ▼ ▼ Telegram Bot Google Sheets ThingSpeak Voice Alerts Data Logging Cloud Dashboard │ ▼ AI Notification & Automation Agent 3. Features Smart Surveillance Motion detection using PIR sensor Face detection using ESP32-CAM AI library Intruder image capture AI Automation Event classification Intelligent alert triggering AI power consumption estimation Cloud Features Real-time dashboard Cloud logging Remote monitoring Notifications Telegram instant alerts Telegram voice alerts Sensor event messages 4. Required Components Component Quantity ESP32-CAM Module 1 FTDI Programmer 1 PIR Motion Sensor HC-SR501 1 Servo Motors (Robot movement) 2 L298N Motor Driver 1 DC Gear Motors 2 Ultrasonic Sensor HC-SR04 1 Buzzer 1 Li-ion Battery Pack 1 Voltage Regulator 5V 1 Jumper Wires Many Robot Chassis 1 Breadboard 1 Optional: IR LEDs for night vision Solar charging module Relay module 5. Circuit Connections ESP32-CAM Pin Mapping Device ESP32 Pin PIR OUT GPIO 13 Buzzer GPIO 12 Servo Left GPIO 14 Servo Right GPIO 15 Ultrasonic TRIG GPIO 2 Ultrasonic ECHO GPIO 4 Motor Driver IN1 GPIO 16 Motor Driver IN2 GPIO 17 6. Circuit Schematic (Text Representation) +-------------------+ | ESP32-CAM | | | PIR ---->| GPIO13 | Buzzer ->| GPIO12 | Servo1 ->| GPIO14 | Servo2 ->| GPIO15 | TRIG --->| GPIO2 | ECHO --->| GPIO4 | +-------------------+ │ WiFi ▼ Internet / Router ▼ n8n Automation Server │ ┌──────────┼───────────┐ ▼ ▼ ▼ Telegram GoogleSheet ThingSpeak 7. Working Principle PIR sensor detects movement ESP32 activates camera Face detection algorithm runs Snapshot captured Data sent to n8n webhook n8n: Sends Telegram message Sends voice alert Updates Google Sheets Uploads ThingSpeak data AI logic predicts battery consumption 8. Flowchart START │ ▼ Initialize ESP32 │ ▼ Connect WiFi │ ▼ Detect Motion? ┌────┴─────┐ │ │ NO YES │ │ ▼ ▼ Continue Capture Image Monitoring │ ▼ Face Detection │ ▼ Send to n8n │ ┌───────────┼───────────┐ ▼ ▼ ▼ Telegram Google ThingSpeak Alerts Sheets Upload │ ▼ Voice Notification │ ▼ END 9. ESP32 Source Code (Arduino) #include "WiFi.h" #include "HTTPClient.h" #include "esp_camera.h" const char* ssid = "YOUR_WIFI"; const char* password = "YOUR_PASSWORD"; String webhook = "https://YOUR_N8N/webhook/surveillance"; #define PIR_PIN 13 #define BUZZER 12 void setup() { Serial.begin(115200); pinMode(PIR_PIN, INPUT); pinMode(BUZZER, OUTPUT); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } Serial.println("WiFi Connected"); } void loop() { int motion = digitalRead(PIR_PIN); if (motion == HIGH) { digitalWrite(BUZZER, HIGH); HTTPClient http; http.begin(webhook); http.addHeader("Content-Type", "application/json"); String payload = "{\"motion\":\"detected\"}"; int response = http.POST(payload); Serial.println(response); http.end(); delay(5000); digitalWrite(BUZZER, LOW); } delay(500); } 10. ESP32-CAM Face Detection Use the built-in ESP-WHO library. Enable: #define CONFIG_ESP_FACE_DETECT_ENABLED Functions: Face detection Face recognition Object tracking 11. n8n Workflow Overview Workflow Nodes Webhook Trigger IF Motion Detected Telegram Send Message Telegram Voice Notification Google Sheets Append Row ThingSpeak HTTP Request AI Decision Node 12. Example n8n Workflow JSON { "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook" }, { "name": "Telegram", "type": "n8n-nodes-base.telegram" }, { "name": "Google Sheets", "type": "n8n-nodes-base.googleSheets" } ] } 13. Telegram Bot Setup Step 1 — Create Bot Open Telegram and search: BotFather Official Telegram Bot Commands: /newbot Save: Bot Token Bot Username Step 2 — Get Chat ID Open: Get Telegram Chat ID Bot Step 3 — Test Message API https://api.telegram.org/botBOT_TOKEN/sendMessage?chat_id=CHAT_ID&text=MotionDetected 14. Telegram Voice Notification Use Telegram sendVoice. Generate voice using: Google TTS gTTS Python library ElevenLabs API Example n8n flow: Webhook → AI Text → TTS → Telegram Voice Example alert: "Warning. Motion detected near the entrance." 15. Google Sheets Integration Create Sheet Columns: Timestamp Motion Face Battery Distance Google Cloud Setup Create Google Cloud Project Enable Google Sheets API Create Service Account Download credentials JSON Connect credentials in n8n Useful resources: Google Sheets API Documentation n8n Official Website 16. ThingSpeak Dashboard Setup Create account: ThingSpeak Official Website Fields Field Data Field1 Motion Field2 Battery Field3 Distance Field4 AI Risk Score ESP32 Upload API String url = "http://api.thingspeak.com/update?api_key=APIKEY&field1=1"; 17. AI Power Consumption Prediction Logic Inputs Camera active time WiFi usage Motor activity Alert frequency Formula P=V×I Battery prediction: E=P×t Example AI Logic if motion_events > 50: power_mode = "HIGH" if battery < 20: disable_camera() 18. AI Agentic Automation The AI agent can: Analyze motion frequency Detect suspicious patterns Reduce false alarms Predict battery depletion Trigger emergency alerts 19. Voice Automation Pipeline ESP32 Event │ ▼ n8n Webhook │ ▼ AI Message Generator │ ▼ Text-to-Speech │ ▼ Telegram Voice Alert 20. Security Features Secure HTTPS webhook Telegram authentication API key encryption Cloud access control 21. Future Enhancements AI Upgrades Face recognition database Intruder classification Weapon detection Edge AI object tracking IoT Upgrades GPS tracking Live video streaming MQTT communication Home Assistant integration Robotics Autonomous navigation SLAM mapping Obstacle avoidance AI 22. Deployment Guide Local Deployment Home security robot Office surveillance Warehouse monitoring Cloud Deployment VPS-hosted n8n server Remote dashboard access Multi-device monitoring Recommended platforms: n8n Cloud Google Cloud Platform AWS IoT Core 23. Suggested Folder Structure AI_Surveillance_Robot/ │ ├── ESP32_Code/ ├── n8n_Workflow/ ├── Telegram_Bot/ ├── GoogleSheets/ ├── ThingSpeak/ ├── AI_Logic/ ├── Documentation/ └── Circuit_Diagram/ 24. Estimated Cost Total:₹8000–₹8500 Approx 25. Final Outcome This project creates a: ✅ Smart AI surveillance robot ✅ Cloud-connected IoT security system ✅ Real-time Telegram alert system ✅ AI-powered automation platform ✅ Edge AI + cloud AI hybrid architecture ✅ Expandable smart security ecosystem

No comments:

Post a Comment

AI Smart Traffic Signal Control Using Real-Time Vehicle Density Analysis

AI Smart Traffic Signal Control Using Real-Time Vehicle Density Analysis Agentic IoT System using ESP32 + AI + n8n + Telegram Voice Alerts +...