www.svsembedded.com SVSEMBEDDED svsembedded@gmail.com,
CONTACT: 9491535690, 7842358459

1. Project Overview
This project creates an AI-powered IoT monitoring platform using ESP32,
HC-SR04 Ultrasonic Sensor, ThingSpeak Cloud, Google Sheets,
Telegram Voice Notifications and n8n Automation.
- Distance Measurement
- Cloud Data Logging
- AI Prediction Engine
- Telegram Voice Alerts
- Google Sheets Integration
- ThingSpeak Dashboard
2. Components Required
| Component |
Quantity |
| ESP32 Dev Board | 1 |
| HC-SR04 Sensor | 1 |
| Jumper Wires | Several |
| Breadboard | 1 |
| USB Cable | 1 |
| WiFi Router | 1 |
3. Circuit Connections
| HC-SR04 |
ESP32 |
| VCC | 5V |
| GND | GND |
| TRIG | GPIO5 |
| ECHO | GPIO18 |
4. Flowchart
START
|
Initialize WiFi
|
Read Distance
|
Send to ThingSpeak
|
Trigger n8n Webhook
|
Store in Google Sheets
|
AI Analysis
|
Threshold Check
|
Telegram Voice Alert
|
Repeat
5. ESP32 Source Code
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid="YOUR_WIFI";
const char* password="YOUR_PASSWORD";
String apiKey="YOUR_THINGSPEAK_KEY";
#define TRIG 5
#define ECHO 18
void setup()
{
Serial.begin(115200);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED)
{
delay(500);
}
}
float getDistance()
{
digitalWrite(TRIG,LOW);
delayMicroseconds(2);
digitalWrite(TRIG,HIGH);
delayMicroseconds(10);
digitalWrite(TRIG,LOW);
long duration=pulseIn(ECHO,HIGH);
return duration*0.034/2;
}
void loop()
{
float distance=getDistance();
HTTPClient http;
String url =
"https://api.thingspeak.com/update?api_key="
+ apiKey +
"&field1=" + String(distance);
http.begin(url);
http.GET();
http.end();
delay(15000);
}
6. ThingSpeak Setup
- Create ThingSpeak Account
- Create New Channel
- Add Fields:
- Distance
- Prediction
- Alert Status
- Copy Write API Key
7. Telegram Bot Setup
- Open Telegram
- Search BotFather
- Create New Bot
- Copy Bot Token
- Get Chat ID
8. Google Sheets Structure
| Timestamp |
Distance |
Prediction |
Alert |
9. n8n Workflow
Webhook
|
Code Node
|
Google Sheets
|
IF Condition
|
Telegram Alert
10. AI Prediction Logic
const current = $json.distance;
const prediction =
current + Math.random()*5;
return [{
distance: current,
prediction: prediction
}];
11. Telegram Voice Alert Logic
Distance Alert
|
Generate TTS Audio
|
Telegram Send Audio
Example Voice Message:
Warning.
Object detected at eight centimeters.
Please check immediately.
12. Power Consumption Prediction
| Mode |
Current |
| WiFi Active |
180mA |
| Processing |
120mA |
| Deep Sleep |
10µA |
Battery Life =
Battery Capacity / Average Current
13. Future Enhancements
- Multi-Sensor Integration
- Temperature Monitoring
- Humidity Monitoring
- Gas Detection
- ESP32 Camera AI Vision
- Digital Twin Dashboard
- Edge AI Inference
14. Deployment Architecture
ESP32
↓
ThingSpeak
↓
n8n
↓
Google Sheets
↓
Telegram
15. Expected Output
Distance = 24.6 cm
Prediction = 25.1 cm
Status = NORMAL
This PHP file can be saved as index.php, hosted on a PHP server (XAMPP, WAMP, LAMP, or Apache), and viewed as a complete project documentation webpage. For a professional final-year project, you can further split it into:
index.php (dashboard)
components.php
circuit.php
esp32_code.php
n8n_workflow.php
thingspeak_setup.php
telegram_setup.php
deployment_guide.php
with Bootstrap styling, navigation menus, downloadable source code sections, and an admin dashboard layout.
Comments
Post a Comment