AI-Powered ESP 32 Human-Detection & Agentic IoT Robot — Complete Project Documentation
Project scope: This design is for human detection, remote monitoring, search/rescue, inspection, and safety alerts. It deliberately excludes weapons, autonomous targeting, firing mechanisms, or instructions for harming people.
1. Project title
AI Smart Battlefield/Field Assistance Robot with Human Detection, ESP32 IoT, n8n Agentic Automation, Telegram Voice Alerts, Google Sheets and ThingSpeak Dashboard
A more safety-oriented project title for academic use is:
“AI-Powered ESP32 Smart Field Assistance Robot for Human Detection and IoT-Based Emergency Monitoring”
2. Project abstract
The proposed system is a mobile IoT robot capable of detecting the presence of people, collecting environmental/robot telemetry, transmitting information through Wi-Fi, and automatically generating remote notifications.
The system combines:
-
ESP32 microcontroller
-
Human-detection sensor/camera subsystem
-
Ultrasonic/ToF distance sensing
-
Temperature/humidity/environment sensors
-
Wi-Fi connectivity
-
Local ESP32 web dashboard
-
n8n workflow automation
-
AI-agent decision support
-
Telegram notifications
-
Telegram voice alerts
-
Google Sheets event logging
-
ThingSpeak cloud visualization
-
Optional GPS location
-
Battery/robot-status monitoring
The ESP32 communicates with the Internet through Wi-Fi. ESP32's Arduino framework officially supports station mode for connecting to an access point and Internet-connected IoT applications. Espressif Systems+1
3. Overall system architecture
┌─────────────────────────┐
│ HUMAN / │
│ ENVIRONMENT DETECTED │
└────────────┬────────────┘
│
┌────────────────▼────────────────┐
│ ROBOT SENSORS │
│ │
│ Camera / Human Detection │
│ Ultrasonic / ToF │
│ Temperature / Humidity │
│ Battery Monitoring │
│ GPS (optional) │
└────────────────┬─────────────────┘
│
▼
┌────────────────────────┐
│ ESP32 │
│ │
│ Sensor Processing │
│ Detection State │
│ Wi-Fi │
│ Local Web Server │
│ JSON Telemetry │
└───────────┬────────────┘
│ HTTPS/HTTP
▼
┌────────────────────────┐
│ n8n WEBHOOK │
└───────────┬────────────┘
│
┌──────▼──────┐
│ Data Parser │
└──────┬──────┘
│
┌───────────▼────────────┐
│ AI AGENT / RULES │
│ │
│ Analyze sensor state │
│ Generate explanation │
│ Select notification │
└───────┬────────┬───────┘
│ │
┌─────────────┘ └──────────────┐
▼ ▼
┌───────────────┐ ┌──────────────┐
│ Google Sheets │ │ ThingSpeak │
│ Event Log │ │ Dashboard │
└───────────────┘ └──────────────┘
│
▼
┌────────────────┐
│ Telegram │
│ Text Alert │
│ Voice Alert │
└────────────────┘
n8n is designed to connect applications and APIs into automated workflows and also supports AI functionality. n8n Documentation
4. Functional block diagram
┌───────────────────────┐
│ POWER │
│ Battery + 5V/3.3V │
└──────────┬────────────┘
│
┌────────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌────────────┐ ┌───────────┐
│ Camera / │ │ Ultrasonic │ │ DHT22 / │
│ AI Vision│ │ / ToF │ │ BME280 │
└────┬─────┘ └─────┬──────┘ └─────┬─────┘
│ │ │
└────────────────────┼────────────────────┘
▼
┌─────────────┐
│ ESP32 │
│ │
│ GPIO │
│ Wi-Fi │
│ Web Server │
└──────┬──────┘
│
▼
INTERNET
│
▼
┌─────────────┐
│ n8n │
│ Automation │
└──────┬──────┘
│
┌──────────────┼───────────────┐
▼ ▼ ▼
┌─────────┐ ┌────────────┐ ┌───────────┐
│AI Agent │ │Google Sheet│ │ThingSpeak │
└────┬────┘ └────────────┘ └───────────┘
│
▼
┌───────────┐
│ Telegram │
│ Text/Voice│
└───────────┘
5. Hardware required
| Component | Purpose |
|---|---|
| ESP32 DevKit | Main controller |
| ESP32-CAM or suitable camera subsystem | Visual detection |
| HC-SR04 / ToF sensor | Distance measurement |
| BME280/DHT22 | Environmental sensing |
| GPS module | Optional location |
| Motor driver | Robot movement |
| DC geared motors | Robot movement |
| Robot chassis | Mechanical platform |
| Battery pack | Power |
| Voltage regulator | Stable supply |
| LEDs | Status indication |
| Buzzer | Local warning |
| Push button | Emergency/manual stop |
| Wi-Fi router/hotspot | Internet connectivity |
For a simple prototype, you can initially omit the motors and construct it as a stationary AI-IoT detection node. That makes debugging considerably easier.
6. Important design decision: ESP32 vs ESP32-CAM
A normal ESP32 is excellent for:
-
sensor acquisition
-
Wi-Fi
-
HTTP communication
-
MQTT
-
web server
-
telemetry
-
automation
However, complex computer vision is generally better performed by a dedicated camera/edge-AI device or cloud/AI service rather than expecting a basic ESP32 to perform a large neural network.
Therefore I recommend this architecture:
Camera / AI vision
│
▼
Human detected?
│
▼
ESP32
│
▼
n8n
│
▼
AI / automation
The ESP32 should primarily be the IoT controller and telemetry gateway.
7. Human-detection logic
The system should not simply react to one sensor reading.
Use multiple signals:
Camera detection
+
Distance sensor
+
Motion/state information
│
▼
Detection confidence
│
├── LOW → Ignore/log
│
├── MEDIUM → Monitor
│
└── HIGH → Alert operator
Example:
Human detection = TRUE
Distance = 4.2 m
Temperature = 28.4 °C
Battery = 76 %
Wi-Fi RSSI = -61 dBm
Robot state = NORMAL
↓
ESP32 sends JSON
↓
n8n receives event
↓
AI summarizes event
↓
Telegram alert
+
Google Sheets record
+
ThingSpeak update
8. ESP32 telemetry JSON
A useful data structure is:
{
"device_id": "FIELD_ROBOT_01",
"human_detected": true,
"confidence": 0.91,
"distance_m": 4.2,
"temperature_c": 28.4,
"humidity": 61.2,
"battery_percent": 76,
"rssi": -61,
"status": "ALERT",
"timestamp": "2026-09-28T21:07:00"
}
This JSON becomes the interface between the ESP32 and n8n.
9. ESP32 wiring example
Ultrasonic sensor
HC-SR04 ESP32
VCC ───────────── 5V
GND ───────────── GND
TRIG ───────────── GPIO 5
ECHO ───────────── GPIO 18
Important: many HC-SR04 modules produce a 5-V ECHO signal. ESP32 GPIOs are 3.3-V logic, so use an appropriate voltage divider/level shifter on ECHO.
BME280
BME280 ESP32
VCC ───────────── 3.3V
GND ───────────── GND
SDA ───────────── GPIO 21
SCL ───────────── GPIO 22
Status LED
ESP32 GPIO 2
│
220Ω
│
LED
│
GND
10. Complete basic ESP32 firmware
This version demonstrates the IoT architecture without depending on a particular AI-camera implementation.
#include <WiFi.h>
#include <HTTPClient.h>
#include <WebServer.h>
#include <ArduinoJson.h>
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASSWORD = "YOUR_PASSWORD";
const char* N8N_WEBHOOK =
"https://YOUR-N8N-DOMAIN/webhook/robot";
#define TRIG_PIN 5
#define ECHO_PIN 18
#define LED_PIN 2
WebServer server(80);
bool humanDetected = false;
float distanceM = 0.0;
float temperatureC = 28.0;
float humidity = 60.0;
int batteryPercent = 80;
unsigned long lastSend = 0;
const unsigned long SEND_INTERVAL = 10000;
// --------------------------------------------------
// Distance measurement
// --------------------------------------------------
float readDistance()
{
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
long duration =
pulseIn(ECHO_PIN, HIGH, 30000);
if (duration == 0)
return -1;
float distance =
duration * 0.0343 / 2.0;
return distance / 100.0;
}
// --------------------------------------------------
// Example detection logic
// --------------------------------------------------
void updateDetection()
{
distanceM = readDistance();
/*
Replace this section with the actual
output from your camera/AI detector.
This demonstration uses distance only.
*/
if (distanceM > 0 &&
distanceM < 5.0)
{
humanDetected = true;
}
else
{
humanDetected = false;
}
}
// --------------------------------------------------
// Send JSON to n8n
// --------------------------------------------------
void sendTelemetry()
{
if (WiFi.status() != WL_CONNECTED)
return;
HTTPClient http;
http.begin(N8N_WEBHOOK);
http.addHeader(
"Content-Type",
"application/json"
);
JsonDocument doc;
doc["device_id"] = "FIELD_ROBOT_01";
doc["human_detected"] = humanDetected;
doc["confidence"] = humanDetected ? 0.85 : 0.0;
doc["distance_m"] = distanceM;
doc["temperature_c"] = temperatureC;
doc["humidity"] = humidity;
doc["battery_percent"] = batteryPercent;
doc["rssi"] = WiFi.RSSI();
doc["status"] =
humanDetected ? "ALERT" : "NORMAL";
String payload;
serializeJson(doc, payload);
int responseCode =
http.POST(payload);
Serial.print("n8n response: ");
Serial.println(responseCode);
http.end();
}
// --------------------------------------------------
// Local web page
// --------------------------------------------------
String webpage()
{
String html;
html += "<!DOCTYPE html>";
html += "<html>";
html += "<head>";
html += "<meta name='viewport' ";
html += "content='width=device-width,initial-scale=1'>";
html += "<title>AI Field Robot</title>";
html += "<style>";
html += "body{font-family:Arial;background:#101820;";
html += "color:white;text-align:center}";
html += ".card{background:#1e2933;";
html += "margin:15px;padding:20px;";
html += "border-radius:15px}";
html += ".alert{color:#ff5555}";
html += ".normal{color:#55ff88}";
html += "</style>";
html += "</head><body>";
html += "<h1>AI Field Assistance Robot</h1>";
html += "<div class='card'>";
html += "<h2>Human Detection</h2>";
if (humanDetected)
html += "<h2 class='alert'>DETECTED</h2>";
else
html += "<h2 class='normal'>NO DETECTION</h2>";
html += "</div>";
html += "<div class='card'>";
html += "Distance: ";
html += String(distanceM);
html += " m<br>";
html += "Temperature: ";
html += String(temperatureC);
html += " °C<br>";
html += "Humidity: ";
html += String(humidity);
html += " %<br>";
html += "Battery: ";
html += String(batteryPercent);
html += " %<br>";
html += "WiFi RSSI: ";
html += String(WiFi.RSSI());
html += "</div>";
html += "</body></html>";
return html;
}
// --------------------------------------------------
// Web server
// --------------------------------------------------
void handleRoot()
{
server.send(
200,
"text/html",
webpage()
);
}
// --------------------------------------------------
// Setup
// --------------------------------------------------
void setup()
{
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
WiFi.begin(
WIFI_SSID,
WIFI_PASSWORD
);
Serial.print("Connecting");
while (
WiFi.status() != WL_CONNECTED
)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.print("IP: ");
Serial.println(WiFi.localIP());
server.on(
"/",
handleRoot
);
server.begin();
}
// --------------------------------------------------
// Main loop
// --------------------------------------------------
void loop()
{
server.handleClient();
updateDetection();
digitalWrite(
LED_PIN,
humanDetected ? HIGH : LOW
);
if (
millis() - lastSend >
SEND_INTERVAL
)
{
lastSend = millis();
sendTelemetry();
}
delay(100);
}
The ESP32 Wi-Fi implementation supports station mode, where the board connects to an access point for Internet communication. Espressif Systems
11. Local ESP32 webpage
The ESP32 can host a local dashboard:
http://ESP32-IP-ADDRESS/
Example:
┌─────────────────────────────────────────┐
│ AI FIELD ASSISTANCE ROBOT │
├─────────────────────────────────────────┤
│ │
│ Human Detection │
│ │
│ 🟢 NO DETECTION │
│ │
├─────────────────────────────────────────┤
│ Distance 7.25 m │
│ Temperature 28.4 °C │
│ Humidity 61 % │
│ Battery 76 % │
│ WiFi RSSI -61 dBm │
└─────────────────────────────────────────┘
For a production deployment, HTTPS/authentication should be added rather than exposing an unauthenticated device webpage.
12. n8n workflow
The main workflow should look like:
ESP32
│
▼
┌─────────────┐
│ Webhook │
└──────┬──────┘
│
▼
┌─────────────┐
│ Validate │
│ JSON │
└──────┬──────┘
│
▼
┌─────────────┐
│ Normalize │
│ Data │
└──────┬──────┘
│
▼
┌──────────┐
│ IF node │
└────┬─────┘
│
┌───────┴────────┐
│ │
NORMAL ALERT
│ │
▼ ▼
Google Sheets AI Agent
│
┌─────────┼─────────┐
▼ ▼ ▼
Telegram Sheets ThingSpeak
Text
│
▼
Voice
Alert
n8n provides built-in Telegram functionality for sending messages and handling Telegram-related automation. n8n Documentation
13. n8n Webhook
Create:
Webhook
Method:
POST
Example endpoint:
/webhook/robot
The ESP32 sends:
{
"device_id": "FIELD_ROBOT_01",
"human_detected": true,
"confidence": 0.91,
"distance_m": 4.2,
"temperature_c": 28.4,
"humidity": 61.2,
"battery_percent": 76,
"rssi": -61,
"status": "ALERT"
}
14. n8n validation
Add an IF node:
human_detected == true
and optionally:
confidence >= 0.75
So:
Webhook
│
▼
Validate JSON
│
▼
human_detected?
/ \
NO YES
│ │
▼ ▼
Log only Check confidence
│
confidence > threshold
/ \
NO YES
│ │
▼ ▼
Log AI analysis
This prevents every telemetry packet from becoming an alert.
15. AI Agent function
The AI component should summarize and classify telemetry, rather than autonomously controlling potentially dangerous physical actions.
Example input:
Device: FIELD_ROBOT_01
Human detected: YES
Confidence: 0.91
Distance: 4.2 m
Temperature: 28.4 C
Humidity: 61.2 %
Battery: 76 %
RSSI: -61 dBm
Example AI output:
{
"event_type": "human_detection",
"priority": "high",
"summary": "Human presence detected by the field robot.",
"operator_message":
"Human presence detected approximately 4.2 meters from the robot. Battery is 76 percent.",
"voice_message":
"Attention. Human presence detected. Approximate distance four point two meters. Robot battery is seventy six percent."
}
A safe system prompt could be:
You are an IoT monitoring assistant.
Analyze telemetry from a field-assistance robot.
Your responsibilities are:
1. Identify abnormal sensor conditions.
2. Summarize human-detection events.
3. Report battery and communication problems.
4. Generate concise operator notifications.
5. Clearly distinguish measured data from uncertain inference.
6. Never identify a person by name.
7. Never recommend harming, targeting, pursuing, trapping,
or attacking a person.
8. Never autonomously control weapons or harmful mechanisms.
9. Do not invent sensor measurements.
10. If data is uncertain, explicitly state that it is uncertain.
Return structured JSON.
16. Google Sheets database
Create a spreadsheet:
AI_ROBOT_EVENTS
Columns:
Timestamp
Device_ID
Human_Detected
Confidence
Distance_m
Temperature_C
Humidity
Battery_Percent
RSSI
Status
AI_Summary
Alert_Sent
Example:
| Timestamp | Device | Detection | Confidence | Distance | Battery | Status |
|---|---|---|---|---|---|---|
| 21:07:03 | ROBOT_01 | TRUE | 0.91 | 4.2 m | 76% | ALERT |
| 21:07:13 | ROBOT_01 | FALSE | 0.00 | 7.1 m | 75% | NORMAL |
This gives you an historical event database.
17. ThingSpeak dashboard
ThingSpeak can accept IoT data through its REST API using HTTP GET or POST requests. MathWorks+1
Create a channel such as:
FIELD ROBOT MONITOR
Suggested fields:
Field 1 = Human Detection
Field 2 = Detection Confidence
Field 3 = Distance
Field 4 = Temperature
Field 5 = Humidity
Field 6 = Battery
Field 7 = Wi-Fi RSSI
For example:
Field 1 = 1
Field 2 = 0.91
Field 3 = 4.2
Field 4 = 28.4
Field 5 = 61.2
Field 6 = 76
Field 7 = -61
ThingSpeak provides REST endpoints for writing channel data. MathWorks
18. ThingSpeak request
Conceptually:
https://api.thingspeak.com/update
with:
api_key = YOUR_WRITE_API_KEY
field1 = human_detected
field2 = confidence
field3 = distance
field4 = temperature
field5 = humidity
field6 = battery
field7 = rssi
Do not publish your actual Write API Key in source code, screenshots, GitHub repositories, or project reports.
19. Telegram text alert
Example:
🚨 FIELD ROBOT ALERT
Device: FIELD_ROBOT_01
Human detection: YES
Confidence: 91%
Distance: 4.2 m
Temperature: 28.4 °C
Humidity: 61.2%
Battery: 76%
Status: ALERT
Please verify the situation using the operator dashboard.
Telegram's Bot API supports HTTP-based bot requests and sendMessage; it also supports sendVoice for voice messages. Telegram
20. Telegram voice alert architecture
ESP32
│
▼
n8n Webhook
│
▼
AI Agent
│
▼
Generate concise alert text
│
▼
Text-to-Speech
│
▼
Audio file
│
▼
Telegram sendVoice
│
▼
Operator's phone
Telegram currently supports voice-message delivery through sendVoice; the Bot API documentation specifies supported voice formats and upload methods. Telegram
21. Example voice message
The generated speech can be:
“Attention. Human presence detected by Field Robot 01. Detection confidence is ninety-one percent. Approximate distance is four point two meters. Battery level is seventy-six percent.”
Keep the voice notification short.
22. n8n workflow in detail
Recommended nodes:
1. Webhook
↓
2. Set / Edit Fields
↓
3. IF – Validate telemetry
↓
4. IF – Human detected?
↓
5. AI Agent
↓
6. Google Sheets
↓
7. ThingSpeak HTTP Request
↓
8. Telegram Send Message
↓
9. Text-to-Speech
↓
10. Telegram Send Voice
For normal telemetry:
Webhook
↓
Validation
↓
Google Sheets
↓
ThingSpeak
For an alert:
Webhook
↓
Validation
↓
Human Detected
↓
AI Agent
↓
Google Sheets
├──► ThingSpeak
│
└──► Telegram Text
│
▼
Telegram Voice
23. AI-agent decision logic
Use AI for interpretation, but deterministic rules for safety-critical notification conditions.
Sensor data
│
▼
Validation layer
│
▼
Deterministic rules
│
┌────────┴────────┐
│ │
Normal Alert
│ │
│ ▼
│ AI summary
│ │
└────────┬────────┘
▼
Data logging
│
┌─────┴─────┐
▼ ▼
ThingSpeak Telegram
This is preferable to allowing an LLM alone to decide whether a physical system should take consequential actions.
24. Web dashboard architecture
You can have two dashboards.
Local dashboard
Hosted by ESP32:
ESP32
│
└── http://ESP32-IP/
Used for:
-
current sensor values
-
connectivity
-
battery
-
current detection state
Cloud dashboard
ThingSpeak:
Internet
│
▼
ThingSpeak
│
├── Temperature graph
├── Humidity graph
├── Battery graph
├── Distance graph
└── Detection events
25. Full project data flow
┌──────────────┐
│ CAMERA │
└──────┬───────┘
│
Human detected
│
▼
┌───────────────┐ ┌──────────────┐
│ Environmental │──────►│ │
│ Sensors │ │ ESP32 │
└───────────────┘ │ │
│ Wi-Fi │
┌───────────────┐ │ HTTP/JSON │
│ Distance │──────►│ Web Server │
│ Sensor │ └──────┬───────┘
└───────────────┘ │
│
▼
┌────────────┐
│ n8n │
│ Webhook │
└─────┬──────┘
│
▼
┌───────────┐
│ AI Agent │
└─────┬─────┘
│
┌──────────────┼───────────────┐
│ │ │
▼ ▼ ▼
Google Sheets ThingSpeak Telegram
│
┌────┴────┐
▼ ▼
Text Voice
26. Telegram conversational interface
You can also make Telegram a control/monitoring interface.
Example:
USER:
status
BOT:
Robot 01
Status: NORMAL
Battery: 76%
Temperature: 28.4°C
Wi-Fi: -61 dBm
Last detection: 18 minutes ago
Another:
USER:
last alert
BOT:
Last recorded event:
Human detection
Confidence: 91%
Distance: 4.2 m
Time: 21:07
And:
USER:
battery
BOT:
Battery: 76%
Status: NORMAL
The Telegram node in n8n supports Telegram automation and message operations. n8n Documentation
27. Suggested Telegram commands
/start
/status
/battery
/sensors
/lastalert
/dashboard
/help
Avoid commands that directly provide autonomous control over dangerous physical mechanisms.
28. Emergency-stop architecture
Include a physical emergency stop:
┌──────────────┐
│ EMERGENCY │
│ STOP BUTTON │
└──────┬───────┘
│
▼
Motor power cut
│
▼
Robot stops
The emergency stop should work without Internet connectivity, n8n, AI, Telegram, or software.
That is an important engineering principle.
29. Robot power architecture
Battery
│
Fuse / Protection
│
┌──────┴──────┐
│ │
▼ ▼
Motor supply DC regulator
│
▼
5 V / 3.3 V
│
┌────────┴────────┐
▼ ▼
ESP32 Sensors
Do not power motors directly from an ESP32 GPIO.
Use a suitable motor driver and separate regulated logic supply.
30. Recommended software stack
Firmware:
Arduino IDE / PlatformIO
│
▼
ESP32 Arduino framework
IoT:
HTTP / JSON / Wi-Fi
Automation:
n8n
AI:
LLM through n8n
Database:
Google Sheets
IoT dashboard:
ThingSpeak
Messaging:
Telegram Bot API
Optional:
GPS
Camera
MQTT
OTA firmware updates
31. Project folder structure
AI_Field_Robot/
│
├── firmware/
│ ├── main.ino
│ ├── config.h
│ ├── sensors.h
│ ├── sensors.cpp
│ ├── wifi_manager.h
│ └── web_server.h
│
├── n8n/
│ └── field_robot_workflow.json
│
├── dashboard/
│ ├── index.html
│ ├── style.css
│ └── script.js
│
├── documentation/
│ ├── architecture.md
│ ├── wiring.md
│ ├── testing.md
│ └── user_manual.md
│
└── README.md
32. Development stages
Do not build everything simultaneously.
Stage 1 — ESP32
Verify:
ESP32
↓
Wi-Fi
↓
Serial monitor
Stage 2 — sensors
Add:
ESP32
├── distance
├── temperature
└── humidity
Stage 3 — local webpage
Verify:
Phone/laptop
│
▼
ESP32 webpage
Stage 4 — n8n
Verify:
ESP32 → n8n
Stage 5 — Google Sheets
Verify:
ESP32
↓
n8n
↓
Google Sheets
Stage 6 — ThingSpeak
Verify:
ESP32
↓
n8n
↓
ThingSpeak
Stage 7 — Telegram
Verify:
ESP32
↓
n8n
↓
Telegram
Stage 8 — AI
Finally:
Sensors
↓
n8n
↓
AI
↓
Telegram
33. Testing plan
| Test | Expected result |
|---|---|
| ESP32 power-on | Board boots |
| Wi-Fi test | IP address obtained |
| Sensor test | Correct readings |
| Webpage test | Dashboard opens |
| Webhook test | n8n receives JSON |
| Sheets test | Row created |
| ThingSpeak test | Graph updated |
| Telegram test | Text received |
| Voice test | Voice message received |
| Detection test | Alert generated |
| Wi-Fi loss | Robot remains locally safe |
| n8n unavailable | Local operation continues |
| Telegram unavailable | Event remains logged |
| Emergency stop | Motors stop independently |
34. Fault-tolerant architecture
A good design should not depend completely on the cloud:
┌──────────────┐
│ ESP32 │
└──────┬───────┘
│
┌─────────┴─────────┐
│ │
LOCAL INTERNET
│ │
▼ ▼
Local detection n8n
Local alarm │
Emergency stop ├── Sheets
Local webpage ├── ThingSpeak
└── Telegram
If Internet disappears:
Cloud unavailable
│
▼
ESP32 continues
│
├── Sensors
├── Detection
├── Local status
└── Emergency stop
35. Security requirements
Never put secrets directly into public firmware repositories.
Bad:
const char* WIFI_PASSWORD = "MyPassword";
Better:
#include "secrets.h"
and:
const char* WIFI_PASSWORD =
WIFI_PASSWORD_SECRET;
Keep these private:
Wi-Fi password
n8n webhook authentication
Telegram bot token
ThingSpeak Write API Key
AI API key
GPS/private location data
Telegram bot authentication uses a bot token and the Bot API communicates over HTTPS. Telegram
36. Example final alert workflow
Suppose the detector produces:
Human = TRUE
Confidence = 0.91
Distance = 4.2 m
Battery = 76%
The complete sequence becomes:
HUMAN DETECTED
│
▼
CAMERA
│
▼
ESP32
│
JSON packet
│
▼
n8n
│
Validate data
│
▼
AI Agent
│
┌─────────┼──────────┐
│ │ │
▼ ▼ ▼
Sheets ThingSpeak Telegram
│
┌───────┴──────┐
▼ ▼
Text Voice
37. Example Google Sheets record
2026-09-28 21:07:03
FIELD_ROBOT_01
TRUE
0.91
4.2
28.4
61.2
76
-61
ALERT
Human presence detected.
TRUE
38. Example ThingSpeak data
Field 1: 1
Field 2: 0.91
Field 3: 4.2
Field 4: 28.4
Field 5: 61.2
Field 6: 76
Field 7: -61
The ThingSpeak REST API supports channel data updates and charting of channel fields. MathWorks+1
39. Project sequence diagram
Operator Robot/ESP32 n8n AI Sheets Telegram
│ │ │ │ │ │
│ │ │ │ │ │
│ │ Human │ │ │ │
│ │ detected │ │ │ │
│ │─────────────►│ │ │ │
│ │ JSON │ │ │ │
│ │ │ │ │ │
│ │ │────────►│ │ │
│ │ │ analyze │ │ │
│ │ │◄────────│ │ │
│ │ │ │ │ │
│ │ │───────────────────►│ │
│ │ │ log │ │
│ │ │ │ │ │
│ │ │───────────────────────────────►│
│ │ │ │ │ alert
│ │ │ │ │ │
│◄───────────────────────────────────────────────────────────────│
│ Telegram alert │
40. What makes this “agentic IoT”?
A conventional IoT system:
Sensor → Server → Notification
An agentic IoT system adds a reasoning/automation layer:
Sensor
↓
Context
↓
Rules
↓
AI interpretation
↓
Select appropriate information workflow
↓
Log
↓
Notify operator
For this project, the AI agent can:
-
summarize events
-
correlate multiple sensor values
-
explain abnormal conditions
-
prioritize notifications
-
produce concise voice messages
-
query historical events
-
answer operator questions about telemetry
It should not independently make harmful physical decisions.
41. Recommended final architecture
┌───────────────────────┐
│ ROBOT PLATFORM │
│ │
│ ESP32 │
│ Camera │
│ Distance │
│ Environment │
│ Battery │
│ GPS (optional) │
└───────────┬───────────┘
│
▼
Wi-Fi / HTTPS
│
▼
┌────────────────┐
│ n8n │
│ │
│ Webhook │
│ Validation │
│ Rules │
│ AI Agent │
└───────┬────────┘
│
┌───────────────┼────────────────┐
│ │ │
▼ ▼ ▼
Google Sheets ThingSpeak Telegram
│ │ │
│ │ ┌──────┴──────┐
│ │ ▼ ▼
│ │ Text Voice
│ │
└───────────────┴──────────────────────┐
│
▼
Operator Dashboard
42. Final implementation order
-
Assemble ESP32 + power supply.
-
Test Wi-Fi.
-
Add distance sensor.
-
Add environmental sensor.
-
Build ESP32 local webpage.
-
Create n8n webhook.
-
Send ESP32 JSON to n8n.
-
Add Google Sheets logging.
-
Create ThingSpeak channel.
-
Add ThingSpeak HTTP request.
-
Create Telegram bot.
-
Add Telegram text notification.
-
Add text-to-speech.
-
Add Telegram voice notification.
-
Add camera/human-detection subsystem.
-
Add AI interpretation.
-
Add physical emergency stop.
-
Test Internet-loss behavior.
-
Test false detections.
-
Package the complete robot.
This architecture uses ESP32 for edge/IoT control, n8n for orchestration, AI for interpretation, Google Sheets for event history, ThingSpeak for telemetry visualization, and Telegram for operator notifications. It also keeps safety-critical physical behavior independent of the AI/cloud layer.
Project Summary
Project: AI-Powered ESP32 Smart Field Assistance Robot with Human Detection, n8n Automation, AI Agent, Telegram Voice Alerts, Google Sheets and ThingSpeak .
Core workflow
Sensors / Camera
↓
ESP32
↓
Wi-Fi + JSON
↓
n8n
↓
Validation + Rules
↓
AI Agent
↓
┌────┼──────────────┐
↓ ↓ ↓
Sheets ThingSpeak Telegram
↓
Text + Voice
Main hardware
-
ESP32 / ESP32-CAM
-
Human-detection camera subsystem
-
HC-SR04 or ToF distance sensor
-
BME280/DHT22
-
Battery monitoring
-
GPS — optional
-
Robot chassis and motors — optional
-
Motor driver
-
Emergency-stop switch
-
Regulated power supply
Main software
-
Arduino IDE / PlatformIO
-
ESP32 Arduino framework
-
ESP32 local web server
-
HTTP/JSON
-
n8n
-
AI agent
-
Google Sheets
-
ThingSpeak
-
Telegram Bot API
-
Text-to-speech for voice alerts
Example detection
Human detected: YES
Confidence: 91%
Distance: 4.2 m
Temperature: 28.4 °C
Humidity: 61%
Battery: 76%
Wi-Fi RSSI: -61 dBm
n8n receives this data, validates it, logs it to Google Sheets, updates ThingSpeak, and can generate a concise AI summary for Telegram.
Telegram alert
🚨 FIELD ROBOT ALERT
Human presence detected.
Confidence: 91%
Distance: 4.2 m
Battery: 76%
Please verify the situation using
the operator dashboard.
A corresponding voice notification can be generated through the n8n workflow and sent through Telegram.
Development sequence
1. ESP32 + Wi-Fi
2. Sensors
3. Local webpage
4. n8n webhook
5. JSON telemetry
6. Google Sheets
7. ThingSpeak
8. Telegram text
9. Telegram voice
10. Human-detection camera
11. AI agent
12. Safety testing
13. Final robot integration
Key safety architecture
The AI/cloud system should be used for monitoring, interpretation, logging and notification. A physical emergency stop and other safety-critical functions should remain independent of n8n, AI, Telegram and Internet connectivity.
The complete project therefore functions as an agentic IoT monitoring and field-assistance platform, rather than an autonomous weapon or targeting system.
AI Smart Field Assistance Robot — Mind Map
┌──────────────────────────────┐
│ AI SMART FIELD ASSISTANCE │
│ ROBOT │
│ Human Detection + IoT + AI │
└──────────────┬───────────────┘
│
┌───────────────────────────────┼───────────────────────────────┐
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ HARDWARE │ │ ESP32 │ │ SOFTWARE │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
├─ ESP32 / ESP32-CAM ├─ Wi-Fi ├─ Arduino IDE
├─ Camera ├─ GPIO ├─ ESP32 Web Server
├─ Distance Sensor ├─ Sensor Processing ├─ n8n
├─ BME280 / DHT22 ├─ JSON Telemetry ├─ AI Agent
├─ Battery Sensor ├─ Local Dashboard ├─ Google Sheets
├─ GPS (optional) └─ HTTP/HTTPS ├─ ThingSpeak
├─ Motors / Driver └─ Telegram
└─ Emergency Stop
│
▼
┌────────────────────┐
│ HUMAN DETECTION │
└─────────┬──────────┘
│
┌─────────┼─────────┐
│ │ │
▼ ▼ ▼
Camera Distance Motion/
AI Sensor State
│ │ │
└─────────┼─────────┘
▼
Detection
Confidence
│
▼
┌────────────────────┐
│ n8n WORKFLOW │
└─────────┬──────────┘
│
┌────────────────┼────────────────┐
│ │ │
▼ ▼ ▼
Webhook Validation Rules
│ │ │
└────────────────┼────────────────┘
▼
┌────────────┐
│ AI AGENT │
└─────┬──────┘
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
Summarize Analyze Generate
Event Telemetry Alert
│ │ │
└───────────────┼───────────────┘
│
┌───────────────────────┼───────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ GOOGLE SHEETS │ │ THINGSPEAK │ │ TELEGRAM │
└───────┬───────┘ └───────────────┘ └───────┬───────┘
│ │
▼ ┌───────┴───────┐
Event History │ │
▼ ▼
Text Alert Voice Alert
│ │
└───────┬───────┘
▼
OPERATOR
│
▼
Human Verification
Safety & reliability branch
SAFETY
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Emergency Stop Local Operation Fail-Safe
│ │ │
▼ ▼ ▼
Motor power Works without Internet/
disconnected cloud/AI n8n failure
Data-flow mind map
Sensors
↓
ESP32
↓
JSON
↓
n8n
↓
AI + Rules
↓
┌──────────┬───────────┬──────────┐
↓ ↓ ↓
Sheets ThingSpeak Telegram
↓
Voice/Text
↓
Operator
This gives you the complete conceptual structure for the project: sensing → edge processing → IoT → automation → AI interpretation → cloud logging → operator notification.

No comments:
Post a Comment