Monday, 28 September 2026

AI Smart Cradle with Baby Cry Detection & Sleep Analysis

Below is a complete reference design you can use as a final-year/academic IoT project, prototype, GitHub README, or implementation document. It combines ESP32, microphone-based baby-cry detection, sleep/activity analysis, n8n automation, an AI agent, Telegram voice alerts, Google Sheets, ThingSpeak, and a web dashboard.

AI Smart Cradle with Baby Cry Detection & Sleep Analysis

1. Project Overview

The AI Smart Cradle is an IoT-enabled intelligent baby-monitoring and automated cradle system designed to detect baby crying, monitor environmental conditions and cradle movement, estimate sleep/activity states, and automatically notify a parent or caregiver.

The system uses an ESP32 as the edge controller. Sensors collect information such as sound level, temperature, humidity, motion and cradle movement. A lightweight AI/ML model can classify audio into categories such as:

  • Baby crying

  • Baby vocalization

  • Normal/background sound

  • Other/noise

The ESP32 sends important events to an n8n automation server. n8n acts as the central workflow/orchestration layer and can:

  1. Receive sensor data from ESP32.

  2. Determine whether an event requires attention.

  3. Store measurements in Google Sheets.

  4. Send data to ThingSpeak.

  5. Invoke an AI agent for event interpretation.

  6. Send Telegram notifications.

  7. Generate or deliver a voice alert.

  8. Maintain an event history.

  9. Control the cradle according to predefined safety rules.

The system is designed as a monitoring and assistance system, not as a replacement for parental supervision or medical monitoring.


2. Main Objectives

The project has the following objectives:

Hardware objectives

  • Monitor baby crying.

  • Monitor temperature and humidity.

  • Detect cradle movement.

  • Detect whether the baby/cradle is moving.

  • Provide local indication using LEDs/buzzer/display.

  • Provide optional automatic rocking.

AI objectives

  • Detect crying from microphone/audio features.

  • Distinguish crying from ordinary environmental noise.

  • Estimate sleep/activity state using sensor history.

  • Detect repeated crying events.

  • Provide an AI-generated event summary.

IoT objectives

  • Connect ESP32 to Wi-Fi.

  • Send telemetry to the cloud.

  • Maintain historical data.

  • Provide a web dashboard.

  • Integrate ThingSpeak.

Automation objectives

  • Use n8n as the workflow engine.

  • Trigger notifications automatically.

  • Store events in Google Sheets.

  • Send Telegram alerts.

  • Generate voice notifications.

  • Provide an AI-agent interface.


3. High-Level Architecture

                    ┌─────────────────────────┐
                    │       BABY / CRADLE     │
                    └────────────┬────────────┘
                                 │
              ┌──────────────────┼──────────────────┐
              │                  │                  │
              ▼                  ▼                  ▼
        Microphone          Temperature        Motion/
        / Audio Sensor      & Humidity         Vibration
              │                  │                  │
              └──────────────────┼──────────────────┘
                                 ▼
                    ┌─────────────────────────┐
                    │          ESP32          │
                    │                         │
                    │ Sensor acquisition      │
                    │ Edge processing          │
                    │ Cry detection           │
                    │ Sleep/activity logic    │
                    │ Wi-Fi communication     │
                    └────────────┬────────────┘
                                 │
                         Wi-Fi / HTTP / MQTT
                                 │
                                 ▼
                    ┌─────────────────────────┐
                    │          n8n             │
                    │    Automation Server     │
                    │                         │
                    │ Webhook                 │
                    │ Rules                   │
                    │ AI Agent                │
                    │ Notifications           │
                    │ Data processing         │
                    └──────┬───────┬──────────┘
                           │       │
             ┌─────────────┘       └──────────────┐
             ▼                                    ▼
      ┌──────────────┐                    ┌──────────────┐
      │ Google Sheets│                    │  ThingSpeak  │
      │ Event Log    │                    │ IoT Charts   │
      └──────────────┘                    └──────────────┘
                           │
                           ▼
                    ┌───────────────┐
                    │ AI Agent      │
                    │ Event analysis│
                    └───────┬───────┘
                            │
                            ▼
                    ┌───────────────┐
                    │   Telegram    │
                    │ Text + Voice  │
                    │ Notifications │
                    └───────────────┘

4. Complete System Flow

START
  │
  ▼
ESP32 boots
  │
  ▼
Connect to Wi-Fi
  │
  ▼
Initialize sensors
  │
  ▼
Read microphone/audio
  │
  ├───────────────► Extract audio features
  │                         │
  │                         ▼
  │                   Cry classifier
  │                         │
  │                         ▼
  │                  Cry probability
  │
  ├───────────────► Temperature/Humidity
  │
  ├───────────────► Motion/Vibration
  │
  ▼
Combine sensor information
  │
  ▼
Calculate current state
  │
  ├── Normal
  ├── Sleeping
  ├── Moving
  ├── Possible crying
  └── Repeated crying
  │
  ▼
Send JSON to n8n
  │
  ▼
n8n Webhook
  │
  ▼
Validate data
  │
  ├──► Google Sheets
  │
  ├──► ThingSpeak
  │
  └──► AI Agent
           │
           ▼
      Analyze event
           │
           ▼
     Is alert required?
       /           \
     NO             YES
     │               │
     ▼               ▼
   Log only      Telegram message
                     │
                     ▼
                 Voice alert
                     │
                     ▼
                  Parent

5. Hardware Components

Required components

Component Purpose
ESP32 DevKit Main controller
Microphone/audio sensor Baby-cry detection
DHT22/SHT31 Temperature/humidity
MPU6050 Motion/tilt detection
Vibration sensor Cradle vibration/activity
OLED display Local status
LED Status indication
Buzzer Local warning
5V power supply System power
Optional motor Automatic rocking
Motor driver Motor control
Wi-Fi router Internet connectivity

For an improved audio system, an I2S MEMS microphone is preferable to a basic analog sound sensor because it provides actual audio samples suitable for feature extraction and ML classification.


6. Suggested ESP32 Hardware Architecture

                    ESP32
              ┌────────────────┐
              │                │
 I2S Mic ────►│ I2S            │
              │                │
 DHT22 ──────►│ GPIO           │
              │                │
 MPU6050 ────►│ I2C            │
              │                │
 OLED ───────►│ I2C            │
              │                │
 Vibration ──►│ GPIO           │
              │                │
 LED ◄────────│ GPIO           │
              │                │
 Buzzer ◄─────│ GPIO           │
              │                │
 Motor Driver◄│ PWM/GPIO       │
              │                │
 Wi-Fi ◄─────►│ Wi-Fi          │
              └────────────────┘

7. Example Pin Configuration

A possible ESP32 configuration is:

Device ESP32 pin
DHT22 DATA GPIO 4
MPU6050 SDA GPIO 21
MPU6050 SCL GPIO 22
Vibration sensor GPIO 27
Status LED GPIO 2
Buzzer GPIO 26
Motor driver IN1 GPIO 18
Motor driver IN2 GPIO 19
OLED SDA GPIO 21
OLED SCL GPIO 22

For an I2S microphone, choose the I2S pins according to the microphone module and firmware configuration.

Important: Do not connect a cradle motor directly to an ESP32 GPIO. Use an appropriate motor driver, separate motor power supply, flyback protection where applicable, and suitable mechanical safety limits.


8. Electrical Block Diagram

                  5V POWER SUPPLY
                        │
             ┌──────────┴──────────┐
             │                     │
             ▼                     ▼
          ESP32                 Motor Driver
             │                     │
       ┌─────┼──────┐              ▼
       │     │      │            Motor
       │     │      │
       ▼     ▼      ▼
     DHT22 MPU6050 Microphone
       │     │      │
       │     │      └──── Audio
       │     │
       │     └──── Motion
       │
       └──────── Temperature

9. Baby Cry Detection

The microphone continuously samples the surrounding sound.

A basic system can calculate:

  • RMS energy

  • Zero-crossing rate

  • Spectral centroid

  • Spectral bandwidth

  • Mel-frequency features

  • MFCC features

A machine-learning model can then classify an audio window.

Example:

Audio
  │
  ▼
Sampling
  │
  ▼
Noise filtering
  │
  ▼
Audio window
  │
  ▼
Feature extraction
  │
  ├── RMS
  ├── ZCR
  ├── MFCC
  └── Spectral features
  │
  ▼
ML classifier
  │
  ▼
Probability
  │
  ├── Cry = 0.91
  ├── Normal = 0.06
  └── Noise = 0.03
  │
  ▼
Cry detected

A threshold such as 0.80 can be used in a prototype, but it should be determined experimentally from a properly collected and labelled dataset rather than assumed to be universally accurate.


10. AI Model

A practical architecture is:

Microphone
     │
     ▼
Audio preprocessing
     │
     ▼
MFCC / Mel spectrogram
     │
     ▼
Small neural network
     │
     ▼
Classification
     │
 ┌───┼─────────────┐
 ▼   ▼             ▼
Cry  Vocalization  Noise

Possible model approaches include:

  • TensorFlow Lite Micro

  • Edge Impulse

  • Custom small neural network

  • Logistic regression/SVM for a simpler prototype

For an ESP32, the model should be kept small enough for available RAM/flash and inference time.


11. Sleep Analysis

The system should describe sleep as an estimated state, not medically diagnose sleep.

For example:

Sensor history
     │
     ├── Sound level
     ├── Cry events
     ├── Movement
     ├── Cradle activity
     └── Time
           │
           ▼
     Feature aggregation
           │
           ▼
     Sleep-state algorithm
           │
     ┌─────┼─────────────┐
     ▼     ▼             ▼
  Quiet  Light activity  Active
  sleep

Example state logic:

If movement is low
AND cry probability is low
AND sound level is low
for a continuous interval:

    estimated_state = "QUIET_SLEEP"

If movement increases:

    estimated_state = "ACTIVE"

If repeated high cry probability occurs:

    estimated_state = "CRYING"

The algorithm should use time windows rather than making a sleep-state decision from one sensor reading.


12. Example JSON Sent from ESP32

{
  "device_id": "SMART_CRADLE_01",
  "timestamp": 1750000000,
  "temperature": 27.4,
  "humidity": 61.2,
  "motion": 0.18,
  "sound_level": 54,
  "cry_probability": 0.91,
  "cry_detected": true,
  "sleep_state": "CRYING",
  "battery": 87
}

This JSON becomes the primary data structure passed to n8n.


13. n8n Architecture

n8n is the central automation layer.

ESP32
  │
  │ HTTP POST
  ▼
Webhook
  │
  ▼
Validate JSON
  │
  ▼
Normalize data
  │
  ├───────────────┐
  │               │
  ▼               ▼
Google Sheets   ThingSpeak
  │
  ▼
Decision/Routing
  │
  ▼
AI Agent
  │
  ▼
Alert decision
  │
  ▼
Telegram
  │
  ▼
Voice notification

14. n8n Workflow

Recommended nodes:

  1. Webhook

  2. Code / Set

  3. IF

  4. Google Sheets

  5. HTTP Request – ThingSpeak

  6. AI Agent

  7. Telegram

  8. HTTP Request/TTS service

  9. Telegram voice/audio

  10. Response

Example:

[Webhook]
     |
     v
[Validate JSON]
     |
     v
[Store Event]
     |
     +------> [Google Sheets]
     |
     +------> [ThingSpeak]
     |
     v
[IF Cry Probability > Threshold]
     |
   YES
     |
     v
[AI Agent]
     |
     v
[Generate Alert]
     |
     v
[Telegram Text]
     |
     v
[Text-to-Speech]
     |
     v
[Telegram Voice]

15. AI Agent

The AI agent should not directly make unrestricted hardware decisions.

A safer architecture is:

ESP32
  │
  ▼
n8n validation
  │
  ▼
Rule engine
  │
  ▼
AI Agent
  │
  ▼
Structured response
  │
  ▼
Allowed action list

Example AI input:

Temperature: 27.4 C
Humidity: 61%
Cry probability: 0.91
Motion: low
Cry duration: 18 seconds
Previous cry events: 3

Example structured response:

{
  "event": "possible_baby_cry",
  "priority": "high",
  "message": "Possible baby crying detected for approximately 18 seconds.",
  "recommended_action": "check_baby"
}

The AI agent should be prevented from issuing unsafe commands such as uncontrolled motor operation.


16. Telegram Alert

Example text alert:

🚨 Smart Cradle Alert

Possible baby crying detected.

Cry probability: 91%
Temperature: 27.4°C
Humidity: 61%
Movement: Low
Estimated state: Crying

Please check the baby.

The voice notification can communicate the same information in a concise form.

Example:

"Smart Cradle alert. Possible baby crying has been detected. Please check the baby."

17. Telegram Conversation

A useful Telegram interface can support commands such as:

Parent:
 /status

Smart Cradle:
 Temperature: 27.4°C
 Humidity: 61%
 State: Quiet Sleep
 Cry probability: 4%
 Last event: 12 minutes ago

Another example:

Parent:
 /today

Smart Cradle:
 Today's summary:

 Cry events: 7
 Estimated quiet periods: 5
 Movement events: 14
 Average temperature: 27.1°C
 Average humidity: 60.4%

AI-agent interaction:

Parent:
 Why did I receive the last alert?

AI Agent:
 The system detected a high cry probability for approximately
 18 seconds and generated an alert because the event exceeded
 the configured threshold.

18. Google Sheets Database

Create columns such as:

Timestamp Device Temperature Humidity Motion Cry Probability Cry Sleep State Alert
21:10 CRADLE01 27.2 60 0.1 0.03 No Sleep No
21:20 CRADLE01 27.3 61 0.2 0.91 Yes Crying Yes

Google Sheets is useful for:

  • Prototype logging

  • Project demonstrations

  • Data analysis

  • Generating graphs

  • Training-data collection

  • Event history

For a production-scale system, a proper time-series/database backend would generally be more appropriate.


19. ThingSpeak

ThingSpeak can be used for time-series visualization.

Possible fields:

Field 1 = Temperature
Field 2 = Humidity
Field 3 = Motion
Field 4 = Sound Level
Field 5 = Cry Probability
Field 6 = Sleep State

Example :

ESP32
  │
  ▼
n8n
  │
  ▼
HTTP Request
  │
  ▼
ThingSpeak
  │
  ▼
Charts

20. IoT Web Dashboard

The webpage can contain:

┌───────────────────────────────────────────────┐
│              AI SMART CRADLE                 │
├───────────────────────────────────────────────┤
│ Temperature       Humidity        Baby State │
│   27.4 °C           61 %           SLEEPING  │
├───────────────────────────────────────────────┤
│ Cry Probability                              │
│ ███████████░░░░░░░░  42%                    │
├───────────────────────────────────────────────┤
│              LIVE SENSOR DATA                │
│ Temperature  ────────────────                │
│ Humidity     ────────────────                │
│ Cry level    ────────────────                │
│ Movement     ────────────────                │
├───────────────────────────────────────────────┤
│ Recent Events                                │
│ 21:15 Cry detected                           │
│ 21:08 Quiet sleep                            │
│ 20:55 Movement detected                      │
└───────────────────────────────────────────────┘

The webpage can obtain data through:

ESP32 → n8n → Database/API → Webpage

or:

ESP32 → ThingSpeak → Webpage

21. ESP32 Firmware

The ESP32 firmware has five major responsibilities:

setup()
  │
  ├── Wi-Fi
  ├── sensors
  ├── display
  └── audio
       │
       ▼
loop()
  │
  ├── Read sensors
  ├── Process audio
  ├── Determine state
  ├── Send telemetry
  └── Wait

A minimal ESP32 telemetry prototype can be implemented as follows.

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

#define DHT_PIN 4
#define DHT_TYPE DHT22

#define MOTION_PIN 27
#define LED_PIN 2

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

const char* N8N_WEBHOOK =
  "https://YOUR_N8N_SERVER/webhook/smart-cradle";

DHT dht(DHT_PIN, DHT_TYPE);

unsigned long lastSend = 0;
const unsigned long SEND_INTERVAL = 10000;

float estimateCryProbability()
{
    /*
       Replace this function with the actual ML model.

       This placeholder demonstrates the software architecture.
    */

    int motion = digitalRead(MOTION_PIN);

    if (motion == HIGH)
        return 0.05;

    return 0.02;
}

String determineSleepState(float cryProbability, int motion)
{
    if (cryProbability > 0.80)
        return "CRYING";

    if (motion == HIGH)
        return "ACTIVE";

    return "QUIET_SLEEP";
}

void sendTelemetry()
{
    float temperature = dht.readTemperature();
    float humidity = dht.readHumidity();

    if (isnan(temperature) || isnan(humidity))
        return;

    int motion = digitalRead(MOTION_PIN);

    float cryProbability = estimateCryProbability();

    bool cryDetected = cryProbability >= 0.80;

    String sleepState =
        determineSleepState(cryProbability, motion);

    String json = "{";
    json += "\"device_id\":\"SMART_CRADLE_01\",";
    json += "\"temperature\":" + String(temperature, 2) + ",";
    json += "\"humidity\":" + String(humidity, 2) + ",";
    json += "\"motion\":" + String(motion) + ",";
    json += "\"cry_probability\":" +
            String(cryProbability, 3) + ",";
    json += "\"cry_detected\":" +
            String(cryDetected ? "true" : "false") + ",";
    json += "\"sleep_state\":\"" + sleepState + "\"";
    json += "}";

    HTTPClient http;

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

    int responseCode = http.POST(json);

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

    http.end();
}

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

    pinMode(MOTION_PIN, INPUT);
    pinMode(LED_PIN, OUTPUT);

    dht.begin();

    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

    Serial.print("Connecting to Wi-Fi");

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

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

void loop()
{
    if (millis() - lastSend >= SEND_INTERVAL)
    {
        lastSend = millis();

        sendTelemetry();
    }
}

This is the IoT communication prototype. The estimateCryProbability() function must be replaced by an actual trained audio classifier for genuine AI-based cry detection.


22. n8n Webhook Input

The webhook receives:

{
  "device_id": "SMART_CRADLE_01",
  "temperature": 27.4,
  "humidity": 61.2,
  "motion": 0,
  "cry_probability": 0.91,
  "cry_detected": true,
  "sleep_state": "CRYING"
}

A Code node can normalize the information:

const data = $json;

const cryProbability =
    Number(data.cry_probability || 0);

const alertRequired =
    data.cry_detected === true &&
    cryProbability >= 0.80;

return [{
  json: {
    ...data,
    alert_required: alertRequired,
    received_at: new Date().toISOString()
  }
}];

23. n8n Decision Logic

cry_probability >= 0.80?
          │
      ┌───┴───┐
      │       │
     YES      NO
      │       │
      ▼       ▼
  Check      Log only
  duration
      │
      ▼
Repeated event?
   │       │
  YES      NO
   │        │
   ▼        ▼
Alert      Log

A duration requirement is useful because it can reduce false alerts caused by a short sound.


24. Example n8n AI-Agent Prompt

You are the event-analysis component of an AI smart cradle.

Analyze the supplied sensor event.

You must:
1. Describe the event using only the supplied data.
2. Never claim that the system has medically diagnosed the baby.
3. Never claim certainty when the classifier only provides a probability.
4. Recommend that a caregiver check the baby when a sustained high-probability
   crying event is detected.
5. Return concise structured JSON.

Input:

Temperature: {{$json.temperature}}
Humidity: {{$json.humidity}}
Motion: {{$json.motion}}
Cry probability: {{$json.cry_probability}}
Cry detected: {{$json.cry_detected}}
Sleep state: {{$json.sleep_state}}

Return:

{
  "event": "...",
  "priority": "...",
  "message": "...",
  "recommended_action": "..."
}

25. Telegram Bot Integration

The Telegram workflow can be:

n8n
 │
 ▼
Telegram node
 │
 ├── Text message
 │
 └── Voice/audio message

Example alert:

🚨 AI SMART CRADLE

Possible crying detected.

Cry probability: 91%
Duration: 18 seconds
Temperature: 27.4°C
Humidity: 61%

Please check the baby.

26. Voice Alert Pipeline

AI Agent
   │
   ▼
Alert text
   │
   ▼
Text-to-Speech
   │
   ▼
Audio file
   │
   ▼
Telegram
   │
   ▼
Parent's phone

The TTS provider can be selected according to project requirements. The n8n workflow only needs an HTTP/API step between the generated text and Telegram.


27. Web Dashboard API

A simple backend endpoint can return:

{
  "temperature": 27.4,
  "humidity": 61.2,
  "cry_probability": 0.04,
  "sleep_state": "QUIET_SLEEP",
  "last_alert": "2026-09-28T20:52:00",
  "device_status": "ONLINE"
}

The webpage can periodically request this endpoint.

Example JavaScript:

async function updateDashboard() {
    const response = await fetch("/api/status");
    const data = await response.json();

    document.getElementById("temperature").textContent =
        data.temperature + " °C";

    document.getElementById("humidity").textContent =
        data.humidity + " %";

    document.getElementById("state").textContent =
        data.sleep_state;

    document.getElementById("cry").textContent =
        Math.round(data.cry_probability * 100) + "%";
}

setInterval(updateDashboard, 5000);

updateDashboard();

28. Example HTML Dashboard

<!DOCTYPE html>
<html>
<head>
    <title>AI Smart Cradle</title>

    <style>
        body {
            font-family: Arial, sans-serif;
            background: #eef4ff;
            margin: 0;
            padding: 30px;
        }

        h1 {
            color: #183153;
        }

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

        .card {
            background: white;
            padding: 25px;
            border-radius: 15px;
            box-shadow: 0 4px 15px #0002;
        }

        .value {
            font-size: 32px;
            font-weight: bold;
            color: #2463eb;
        }
    </style>
</head>

<body>

<h1>AI Smart Cradle</h1>

<div class="grid">

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

    <div class="card">
        <h3>Humidity</h3>
        <div class="value" id="humidity">--</div>
    </div>

    <div class="card">
        <h3>Cry Probability</h3>
        <div class="value" id="cry">--</div>
    </div>

    <div class="card">
        <h3>Baby State</h3>
        <div class="value" id="state">--</div>
    </div>

</div>

<script src="dashboard.js"></script>

</body>
</html>

29. Complete Data Flow

                 ┌──────────────┐
                 │  Microphone  │
                 └──────┬───────┘
                        │
                        ▼
                 ┌──────────────┐
                 │    ESP32     │
                 │ Edge AI      │
                 └──────┬───────┘
                        │
              JSON over Wi-Fi
                        │
                        ▼
                 ┌──────────────┐
                 │     n8n      │
                 └──────┬───────┘
                        │
          ┌─────────────┼──────────────┐
          │             │              │
          ▼             ▼              ▼
      Google        ThingSpeak      AI Agent
      Sheets             │              │
                         │              ▼
                         │          Alert decision
                         │              │
                         └──────┬───────┘
                                ▼
                           Telegram
                           /       \
                         Text     Voice
                           │         │
                           └────┬────┘
                                ▼
                              Parent

30. Project Operating Modes

Normal mode

No crying
↓
Log sensor values
↓
Update dashboard
↓
No alert

Cry detection mode

Cry probability > threshold
↓
Start event timer
↓
Confirm persistence
↓
Generate alert
↓
Telegram
↓
Voice notification

Quiet sleep mode

Low sound
+
Low movement
+
No detected crying
+
Sufficient observation time
↓
Estimated quiet sleep

Repeated crying mode

Cry event
↓
Recovery
↓
Cry event
↓
Recovery
↓
Cry event
↓
Repeated-event rule
↓
Higher-priority notification

31. False-Positive Reduction

This is an important part of the project.

Do not trigger an alert from one noisy audio sample.

Instead:

Audio detected
     │
     ▼
Classifier
     │
     ▼
Probability > threshold?
     │
    YES
     │
     ▼
Persistence timer
     │
     ▼
Still crying?
     │
    YES
     │
     ▼
Generate alert

Potential sources of false positives include:

  • Television

  • Music

  • Adult speech

  • Dogs

  • Door sounds

  • Fan noise

  • Motor noise

  • Other babies

  • Sudden environmental sounds

Training data should include these negative examples.


32. AI Training Dataset

Create a labelled dataset with categories such as:

dataset/
│
├── crying/
│   ├── cry001.wav
│   ├── cry002.wav
│   └── ...
│
├── vocalization/
│   ├── vocal001.wav
│   └── ...
│
├── background/
│   ├── fan001.wav
│   ├── tv001.wav
│   └── ...
│
└── other_noise/
    ├── door001.wav
    └── ...

Recommended process :

Collect audio
     ↓
Label audio
     ↓
Remove unusable recordings
     ↓
Split train/validation/test
     ↓
Extract features
     ↓
Train model
     ↓
Evaluate
     ↓
Quantize/compress
     ↓
Deploy to ESP32

Do not collect or upload recordings of real babies without appropriate consent, privacy safeguards, and compliance with applicable requirements.


33. AI Model Evaluation

Do not report only accuracy.

Measure:

  • Precision

  • Recall

  • F1 score

  • False-positive rate

  • False-negative rate

  • Confusion matrix

  • Inference time

  • RAM consumption

  • Flash usage

Example confusion matrix:

                  Predicted
              Cry     Noise
Actual Cry     TP       FN
Actual Noise  FP       TN

For a baby-monitoring prototype, false alarms and missed events should both be explicitly evaluated rather than hiding them behind a single accuracy number.


34 . Safety Architecture

The cradle should have hardware safety mechanisms independent of the AI agent.

                 AI Agent
                     │
                     ▼
              Suggested action
                     │
                     ▼
             Safety controller
                /          \
             ALLOW         BLOCK
               │             │
               ▼             ▼
          Limited action    Stop

Recommended safeguards:

  • Physical motor limit

  • Maximum rocking duration

  • Emergency stop

  • Independent power cutoff

  • Watchdog timer

  • Motor driver protection

  • No unrestricted AI control

  • Local manual override

  • Sensor-failure detection

  • Wi-Fi failure fallback

Most importantly, the prototype should not rely on automated rocking or software to guarantee infant safety.


35. Power Architecture

                 AC/DC Adapter
                       │
                 ┌─────┴─────┐
                 │           │
                 ▼           ▼
               ESP32       Motor
                 │
        ┌────────┼─────────┐
        ▼        ▼         ▼
      DHT22    MPU6050   Microphone

Keep motor power and logic power appropriately isolated/decoupled, and ensure the selected supply, wiring, driver and enclosure are electrically and mechanically appropriate.


36. Project Software Stack

Firmware
    └── Arduino IDE / PlatformIO
          └── ESP32 C/C++

AI
    └── TensorFlow Lite Micro /
        Edge ML framework

Automation
    └── n8n

Cloud
    ├── Google Sheets
    └── ThingSpeak

Notification
    └── Telegram

Dashboard
    ├── HTML
    ├── CSS
    └── JavaScript

Optional backend
    └── Node.js / Python / n8n API

37. Recommended Development Sequence

Phase 1 – ESP32

First make the ESP32 read:

Temperature
Humidity
Motion

Phase 2 – Wi-Fi

Confirm:

ESP32 → Wi-Fi → Internet

Phase 3 – n8n

Create:

ESP32 → n8n Webhook

Phase 4 – Google Sheets

Add:

n8n → Google Sheets

Phase 5 – ThingSpeak

Add:

n8n → ThingSpeak

Phase 6 – Telegram

Add:

n8n → Telegram

Phase 7 – Audio

Add:

Microphone → ESP32

Phase 8 – AI

Deploy:

Audio → ML model → Cry probability

Phase 9 – AI Agent

Add:

Sensor data → AI agent → structured event summary

Phase 10 – Dashboard

Add:

Cloud data → Web dashboard

Phase 11 – Testing

Test every subsystem independently before integrating the entire cradle.


38. Final Integrated Workflow

                         SMART CRADLE
                              │
         ┌────────────────────┼────────────────────┐
         │                    │                    │
         ▼                    ▼                    ▼
    Microphone             DHT22              MPU6050
         │                    │                    │
         └────────────────────┼────────────────────┘
                              ▼
                           ESP32
                              │
                    Edge processing
                              │
                    Cry probability
                              │
                              ▼
                            Wi-Fi
                              │
                              ▼
                         n8n Webhook
                              │
             ┌────────────────┼────────────────┐
             │                │                │
             ▼                ▼                ▼
       Google Sheets      ThingSpeak        AI Agent
             │                │                │
             │                │                ▼
             │                │          Event interpretation
             │                │                │
             └────────────────┼────────────────┘
                              │
                              ▼
                       Alert decision
                              │
                              ▼
                         Telegram
                         /       \
                       Text      Voice
                         │         │
                         └────┬────┘
                              ▼
                           Parent

                              │
                              ▼
                       Web Dashboard

39. Expected Final Demonstration

A project demonstration can follow this sequence:

  1. Power on the smart cradle.

  2. ESP32 connects to Wi-Fi.

  3. Dashboard shows ONLINE.

  4. Temperature and humidity appear.

  5. Motion sensor reports cradle activity.

  6. Audio is processed.

  7. Cry classifier produces a probability.

  8. A sustained crying event is detected.

  9. ESP32 sends JSON to n8n.

  10. n8n stores the event in Google Sheets.

  11. n8n updates ThingSpeak.

  12. AI agent interprets the event.

  13. n8n sends Telegram text notification.

  14. n8n generates a voice notification.

  15. Parent receives the alert.

  16. Dashboard changes to the current state.

  17. Event remains available in the history.

40. Final Project Title

A suitable formal project title is:

“AI Smart Cradle with Baby Cry Detection, Sleep-State Analysis and Agentic IoT Automation Using ESP32, n8n, Telegram, Google Sheets and ThingSpeak.”

Alternative shorter title:

“AI-Powered Smart Cradle with ESP32 and Agentic IoT Automation.”

41. Key Innovation

The main innovation is not simply detecting sound. It is the integration of:

EDGE AI
   +
IoT SENSORS
   +
ESP32
   +
n8n AUTOMATION
   +
AI AGENT
   +
CLOUD DATA
   +
TELEGRAM VOICE ALERTS
   +
WEB DASHBOARD

This creates an end-to-end agentic IoT monitoring platform in which the ESP32 performs local sensing, n8n coordinates events and services, the AI agent interprets events, and the caregiver receives actionable notifications.

The system should always be presented as an assistive prototype. Cry detection and sleep-state estimation are probabilistic and should not be represented as medical diagnosis or as a substitute for direct caregiver supervision.

 

Project Summary

AI Smart Cradle with Baby Cry Detection & Sleep Analysis is an IoT-based smart cradle using ESP32 + AI/ML + n8n + Telegram + Google Sheets + ThingSpeak + Web Dashboard.

Core workflow

Baby
 ↓
Microphone + Temperature + Humidity + Motion Sensors
 ↓
ESP32
 ↓
AI Cry Detection + Sleep/Activity Estimation
 ↓
Wi-Fi
 ↓
n8n Automation
 ├── Google Sheets → Data/Event Logging
 ├── ThingSpeak → Cloud Graphs
 ├── AI Agent → Event Analysis
 └── Telegram → Text + Voice Alerts
              ↓
            Parent

Main functions

  • 🎤 Detect possible baby crying using an audio ML model.

  • 🌡️ Monitor temperature and humidity.

  • 📡 Monitor cradle/baby movement.

  • 😴 Estimate states such as quiet sleep, active, or possible crying.

  • 🤖 Use an AI agent to summarize events.

  • ⚙️ Use n8n to automate the complete workflow.

  • 📱 Send Telegram notifications.

  • 🔊 Send Telegram voice alerts through a TTS service.

  • 📊 Store historical data in Google Sheets.

  • 📈 Visualize IoT data with ThingSpeak.

  • 🌐 Provide a live web dashboard.

Hardware

  • ESP32 DevKit

  • I2S microphone

  • DHT22/SHT31

  • MPU6050

  • Vibration sensor

  • OLED display

  • LED/buzzer

  • Optional motor + motor driver

Software

ESP32
  ↓
Arduino IDE / PlatformIO
  ↓
Edge AI / TensorFlow Lite Micro
  ↓
n8n
  ├── Google Sheets
  ├── ThingSpeak
  ├── AI Agent
  └── Telegram
       ├── Text
       └── Voice
  ↓
Web Dashboard

Important design principle

The AI agent should not directly control the cradle motor without independent safety controls. Hardware limits, watchdogs, emergency stop/manual override, and bounded operating times should be implemented separately.

The complete project can therefore be presented as an end-to-end Agentic IoT system:

Sense → Analyze → Automate → Store → Notify → Visualize.

 

🧠 AI Smart Cr adle — Mind Map

                              ┌──────────────────────────────┐
                              │      AI SMART CRADLE         │
                              │ Baby Cry Detection + Sleep   │
                              │ Analysis + Agentic IoT       │
                              └──────────────┬───────────────┘
                                             │
       ┌─────────────────────────────────────┼─────────────────────────────────────┐
       │                                     │                                     │
       ▼                                     ▼                                     ▼
┌───────────────┐                     ┌───────────────┐                     ┌───────────────┐
│   HARDWARE    │                     │     AI/ML     │                     │     IoT       │
└───────┬───────┘                     └───────┬───────┘                     └───────┬───────┘
        │                                     │                                     │
        ├── ESP32                             ├── Audio preprocessing                ├── Wi-Fi
        ├── I2S Microphone                    ├── MFCC / Mel features                ├── HTTP/JSON
        ├── DHT22 / SHT31                     ├── Cry classifier                     ├── n8n
        ├── MPU6050                            ├── Cry probability                    ├── Google Sheets
        ├── Vibration sensor                  ├── Sleep estimation                   ├── ThingSpeak
        ├── OLED                              ├── Activity detection                 └── Cloud API
        ├── LED
        ├── Buzzer
        └── Optional Motor
                                             │
                                             ▼
                                  ┌─────────────────────┐
                                  │   EVENT ANALYSIS    │
                                  └──────────┬──────────┘
                                             │
                          ┌──────────────────┼──────────────────┐
                          │                  │                  │
                          ▼                  ▼                  ▼
                       Normal            Sleeping           Crying
                          │                  │                  │
                          └──────────────────┼──────────────────┘
                                             │
                                             ▼
                                  ┌─────────────────────┐
                                  │   n8n AUTOMATION    │
                                  └──────────┬──────────┘
                                             │
                  ┌──────────────────────────┼─────────────────────────┐
                  │                          │                         │
                  ▼                          ▼                         ▼
          ┌───────────────┐          ┌───────────────┐         ┌───────────────┐
          │ Google Sheets │          │  ThingSpeak   │         │   AI AGENT    │
          └───────────────┘          └───────────────┘         └───────┬───────┘
                  │                          │                         │
                  ▼                          ▼                         ▼
             Event Log                  IoT Graphs              Event Summary
                                                                        │
                                                                        ▼
                                                            ┌────────────────────┐
                                                            │  ALERT DECISION     │
                                                            └─────────┬──────────┘
                                                                      │
                                                       ┌──────────────┴─────────────┐
                                                       │                            │
                                                       ▼                            ▼
                                                Telegram Text                Telegram Voice
                                                       │                            │
                                                       └──────────────┬─────────────┘
                                                                      ▼
                                                                  👨‍👩‍👧 Parent
                                                                      │
                                                                      ▼
                                                            ┌──────────────────┐
                                                            │  WEB DASHBOARD   │
                                                            └────────┬─────────┘
                                                                     │
                                      ┌──────────────────────────────┼───────────────────────┐
                                      │                              │                       │
                                      ▼                              ▼                       ▼
                                Temperature                    Humidity              Cry Probability
                                      │                              │                       │
                                      └──────────────────────────────┼───────────────────────┘
                                                                     │
                                                                     ▼
                                                               Baby State

🔄 Core Concept

SENSE
  ↓
ESP32 Sensors
  ↓
PROCESS
  ↓
Edge AI / Cry Detection
  ↓
ANALYZE
  ↓
n8n + AI Agent
  ↓
AUTOMATE
  ↓
Google Sheets + ThingSpeak
  ↓
NOTIFY
  ↓
Telegram Text + Voice
  ↓
VISUALIZE
  ↓
Web Dashboard

🎯 Project Goal

“Build an intelligent, connected cradle that detects possible crying and activity locally, analyzes events through an automated AI/IoT pipeline, stores historical data, and provides timely caregiver notifications.”

 

AI Smart Battlefield Assistance Robot with Human Detection

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

  1. Assemble ESP32 + power supply.

  2. Test Wi-Fi.

  3. Add distance sensor.

  4. Add environmental sensor.

  5. Build ESP32 local webpage.

  6. Create n8n webhook.

  7. Send ESP32 JSON to n8n.

  8. Add Google Sheets logging.

  9. Create ThingSpeak channel.

  10. Add ThingSpeak HTTP request.

  11. Create Telegram bot.

  12. Add Telegram text notification.

  13. Add text-to-speech.

  14. Add Telegram voice notification.

  15. Add camera/human-detection subsystem.

  16. Add AI interpretation.

  17. Add physical emergency stop.

  18. Test Internet-loss behavior.

  19. Test false detections.

  20. 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.