AI-Based Smart Exam Proctoring System Using Face Tracking
ESP32 + AI Agent + IoT Webpage + n8n Automation + Telegram Voice Alerts + Google Sheets + ThingSpeak Cloud Dashboard
1. Complete Project Title
AI-Based Smart Exam Proctoring System Using Face Tracking with ESP32, AI Agent, n8n Automation, Telegram Voice Alerts, Google Sheets and ThingSpeak Cloud Dashboard.
2. Full Project Description
The AI-Based Smart Exam Proctoring System Using Face Tracking is an intelligent examination monitoring system that combines Artificial Intelligence, Computer Vision, IoT, ESP32, cloud computing, workflow automation and real-time notification services.
The main purpose of this project is to monitor examination environments using face detection and face tracking technology. The system analyzes the candidate's presence, face position, head direction and number of detected faces.
When the system detects unusual or suspicious events such as multiple faces, absence of the candidate or repeated looking away from the examination screen, an event is generated.
The event is transmitted through an IoT communication system to an ESP32 and cloud-based automation platform.
The n8n automation workflow receives the event and automatically performs multiple actions.
- Stores the event in Google Sheets.
- Updates the ThingSpeak cloud dashboard.
- Sends a Telegram text alert.
- Generates a Telegram voice notification.
- Allows an AI agent to analyze the examination event.
- Generates a risk score and examination summary.
The ESP32 functions as the IoT controller and can monitor system status, environmental parameters and power consumption.
The project provides a complete Agentic IoT architecture combining AI, ESP32, n8n automation, Telegram alerts, cloud dashboards and intelligent data analysis.
3. Main Project Objectives
- Monitor examination candidates using AI-based face tracking.
- Detect whether the candidate is present.
- Detect multiple faces in the examination area.
- Monitor head direction and repeated looking away.
- Generate automatic suspicious activity alerts.
- Use ESP32 for IoT communication and sensor monitoring.
- Use n8n for workflow automation.
- Send Telegram text and voice alerts.
- Store examination events in Google Sheets.
- Display cloud data using ThingSpeak.
- Use AI agents for event analysis.
- Predict future power consumption.
4. System Architecture
5. Hardware Components List
| Component | Purpose |
|---|---|
| ESP32 Development Board | Main IoT controller |
| USB Camera | Face tracking and monitoring |
| ESP32-CAM | Optional camera-based alternative |
| OLED Display | Displays system status |
| Buzzer | Local warning alert |
| Red LED | Suspicious activity indicator |
| Green LED | Normal system status indicator |
| DHT11 or DHT22 | Temperature and humidity monitoring |
| PIR Sensor | Optional movement detection |
| LDR Sensor | Light monitoring |
| MicroSD Module | Local event storage |
| 5V Power Supply | System power |
6. Hardware Circuit Schematic
OLED Connection
| OLED Pin | ESP32 Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO 21 |
| SCL | GPIO 22 |
DHT11 Connection
| DHT11 Pin | ESP32 Pin |
|---|---|
| VCC | 3.3V |
| DATA | GPIO 4 |
| GND | GND |
7. Software Flowchart
8. AI Face Tracking Logic
The AI camera captures the candidate's video stream and analyzes each frame.
- Capture video frame.
- Detect all faces.
- Count the number of detected faces.
- Extract face landmarks.
- Estimate head direction.
- Measure the duration of unusual behavior.
- Apply a time threshold.
- Generate an examination event.
- Send the event to the server and automation workflow.
Possible Event Types
- NORMAL
- FACE_NOT_DETECTED
- MULTIPLE_FACES
- LOOKING_LEFT
- LOOKING_RIGHT
- LOOKING_DOWN
- LOOKING_AWAY
- EXAM_STARTED
- EXAM_FINISHED
- SYSTEM_ERROR
9. Face Detection Decision Logic
10. AI Event JSON Format
{
"student_id": "STUDENT_001",
"exam_id": "EXAM_2026_001",
"event_type": "MULTIPLE_FACES",
"face_count": 2,
"confidence": 0.94,
"timestamp": "2026-07-20T10:30:00",
"device_id": "ESP32_PROCTOR_01",
"temperature": 28.5,
"humidity": 62
}
11. ESP32 Source Code
#include <WiFi.h>
#include <HTTPClient.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define OLED_ADDRESS 0x3C
Adafruit_SSD1306 display(
SCREEN_WIDTH,
SCREEN_HEIGHT,
&Wire,
OLED_RESET
);
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(
DHTPIN,
DHTTYPE
);
#define BUZZER_PIN 25
#define RED_LED 26
#define GREEN_LED 27
const char* WIFI_SSID =
"YOUR_WIFI_NAME";
const char* WIFI_PASSWORD =
"YOUR_WIFI_PASSWORD";
String serverURL =
"http://YOUR_SERVER_IP/proctoring_event.php";
String thingSpeakURL =
"https://api.thingspeak.com/update";
String thingSpeakAPIKey =
"YOUR_THINGSPEAK_WRITE_API_KEY";
String deviceID =
"ESP32_PROCTOR_01";
void setup()
{
Serial.begin(115200);
pinMode(
BUZZER_PIN,
OUTPUT
);
pinMode(
RED_LED,
OUTPUT
);
pinMode(
GREEN_LED,
OUTPUT
);
digitalWrite(
BUZZER_PIN,
LOW
);
digitalWrite(
RED_LED,
LOW
);
digitalWrite(
GREEN_LED,
HIGH
);
dht.begin();
display.begin(
SSD1306_SWITCHCAPVCC,
OLED_ADDRESS
);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(
SSD1306_WHITE
);
display.setCursor(0, 0);
display.println(
"AI PROCTORING"
);
display.println(
"SYSTEM STARTING"
);
display.display();
WiFi.begin(
WIFI_SSID,
WIFI_PASSWORD
);
while (
WiFi.status()
!= WL_CONNECTED
)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println(
"WiFi Connected"
);
display.clearDisplay();
display.setCursor(0, 0);
display.println(
"WiFi Connected"
);
display.println(
WiFi.localIP()
);
display.display();
delay(2000);
}
void loop()
{
float temperature =
dht.readTemperature();
float humidity =
dht.readHumidity();
if (isnan(temperature))
{
temperature = 0;
}
if (isnan(humidity))
{
humidity = 0;
}
display.clearDisplay();
display.setCursor(0, 0);
display.println(
"AI PROCTORING"
);
display.setCursor(0, 15);
display.println(
"STATUS: MONITORING"
);
display.setCursor(0, 30);
display.print(
"TEMP: "
);
display.print(
temperature
);
display.println(
" C"
);
display.setCursor(0, 45);
display.print(
"HUM: "
);
display.print(
humidity
);
display.println(
" %"
);
display.display();
sendThingSpeakData(
temperature,
humidity,
1
);
delay(15000);
}
12. ESP32 Suspicious Activity Alert Function
void activateSuspiciousAlert()
{
digitalWrite(
RED_LED,
HIGH
);
digitalWrite(
GREEN_LED,
LOW
);
digitalWrite(
BUZZER_PIN,
HIGH
);
delay(1000);
digitalWrite(
BUZZER_PIN,
LOW
);
delay(1000);
digitalWrite(
RED_LED,
LOW
);
digitalWrite(
GREEN_LED,
HIGH
);
}
13. ESP32 HTTP Event Function
void sendProctoringEvent(
String eventType,
int faceCount,
float confidence
)
{
if (
WiFi.status()
== WL_CONNECTED
)
{
HTTPClient http;
http.begin(
serverURL
);
http.addHeader(
"Content-Type",
"application/json"
);
float temperature =
dht.readTemperature();
float humidity =
dht.readHumidity();
String jsonData = "{";
jsonData +=
"\"device_id\":\"";
jsonData +=
deviceID;
jsonData +=
"\",";
jsonData +=
"\"event_type\":\"";
jsonData +=
eventType;
jsonData +=
"\",";
jsonData +=
"\"face_count\":";
jsonData +=
faceCount;
jsonData +=
",";
jsonData +=
"\"confidence\":";
jsonData +=
confidence;
jsonData +=
",";
jsonData +=
"\"temperature\":";
jsonData +=
temperature;
jsonData +=
",";
jsonData +=
"\"humidity\":";
jsonData +=
humidity;
jsonData +=
"}";
int responseCode =
http.POST(
jsonData
);
Serial.print(
"Server Response: "
);
Serial.println(
responseCode
);
http.end();
}
}
14. ThingSpeak Cloud Update Code
void sendThingSpeakData(
float temperature,
float humidity,
int systemStatus
)
{
if (
WiFi.status()
== WL_CONNECTED
)
{
HTTPClient http;
String url =
thingSpeakURL +
"?api_key=" +
thingSpeakAPIKey +
"&field1=" +
String(
temperature
) +
"&field2=" +
String(
humidity
) +
"&field3=" +
String(
systemStatus
);
http.begin(
url
);
int responseCode =
http.GET();
Serial.print(
"ThingSpeak Response: "
);
Serial.println(
responseCode
);
http.end();
}
}
15. PHP Backend API
Create a file named:
proctoring_event.php
<?php
header(
"Content-Type: application/json"
);
$data = json_decode(
file_get_contents(
"php://input"
),
true
);
if (!$data)
{
echo json_encode(
[
"status" => "error",
"message" =>
"Invalid JSON data"
]
);
exit;
}
$device_id =
$data["device_id"]
?? "UNKNOWN";
$event_type =
$data["event_type"]
?? "UNKNOWN";
$face_count =
$data["face_count"]
?? 0;
$confidence =
$data["confidence"]
?? 0;
$temperature =
$data["temperature"]
?? 0;
$humidity =
$data["humidity"]
?? 0;
$timestamp =
date(
"Y-m-d H:i:s"
);
$log =
[
"device_id" =>
$device_id,
"event_type" =>
$event_type,
"face_count" =>
$face_count,
"confidence" =>
$confidence,
"temperature" =>
$temperature,
"humidity" =>
$humidity,
"timestamp" =>
$timestamp
];
file_put_contents(
"proctoring_logs.json",
json_encode(
$log
) . PHP_EOL,
FILE_APPEND
);
echo json_encode(
[
"status" =>
"success",
"message" =>
"Proctoring event received",
"data" =>
$log
]
);
?>
16. IoT Monitoring Dashboard
The IoT webpage displays the latest examination monitoring event and event history.
17. n8n Automation Workflow
18. n8n Workflow JSON
{
"name":
"AI Exam Proctoring Automation",
"nodes":
[
{
"parameters":
{
"httpMethod":
"POST",
"path":
"exam-proctoring"
},
"name":
"Proctoring Webhook",
"type":
"n8n-nodes-base.webhook"
},
{
"parameters":
{
"conditions":
{
"string":
[
{
"value1":
"={{$json.event_type}}",
"operation":
"notEqual",
"value2":
"NORMAL"
}
]
}
},
"name":
"Suspicious Event Check",
"type":
"n8n-nodes-base.if"
},
{
"parameters":
{
"chatId":
"YOUR_TELEGRAM_CHAT_ID",
"text":
"AI EXAM PROCTORING ALERT"
},
"name":
"Telegram Alert",
"type":
"n8n-nodes-base.telegram"
},
{
"parameters":
{
"operation":
"append",
"documentId":
"YOUR_GOOGLE_SHEET_ID",
"sheetName":
"ExamEvents"
},
"name":
"Google Sheets Logger",
"type":
"n8n-nodes-base.googleSheets"
}
]
}
19. Telegram Bot Setup
- Open Telegram.
- Search for BotFather.
- Send /start.
- Send /newbot.
- Enter the bot name.
- Copy the generated bot token.
- Configure the Telegram credential in n8n.
- Find the Telegram chat ID.
- Configure the chat ID in the Telegram node.
Example Telegram Alert
Event: MULTIPLE_FACES
Detected Faces: 2
AI Confidence: 94%
Device: ESP32_PROCTOR_01
Action: Supervisor review recommended.
20. Telegram Voice Notification Automation
Example voice message:
Attention. Suspicious examination activity has been detected. Multiple faces were identified in the examination area. Supervisor review is recommended.
21. Google Sheets Integration
| Timestamp | Student ID | Device ID | Event Type | Face Count | Confidence | Temperature | Humidity |
|---|---|---|---|---|---|---|---|
| 2026-07-20 10:30:00 | STUDENT_001 | ESP32_PROCTOR_01 | MULTIPLE_FACES | 2 | 0.94 | 28.5 | 62 |
22. ThingSpeak Cloud Dashboard Setup
| Field | Data |
|---|---|
| Field 1 | Temperature |
| Field 2 | Humidity |
| Field 3 | Face Count |
| Field 4 | Suspicious Event Code |
| Field 5 | AI Confidence |
| Field 6 | Exam Status |
| Field 7 | Power Consumption |
| Field 8 | Risk Score |
23. AI Power Consumption Prediction Logic
The system can monitor voltage, current, environmental parameters and device activity to estimate power consumption.
Power = Voltage x Current Example: Voltage = 5V Current = 0.45A Power = 5 x 0.45 Power = 2.25 Watts
24. AI Risk Score Logic
Multiple Face Detection = +50 Points Face Missing = +30 Points Repeated Looking Away = +20 Points Repeated Suspicious Events = Additional Points Risk Score = Total Event Score 0 - 20 = NORMAL 21 - 50 = LOW RISK 51 - 75 = MEDIUM RISK 76 - 100 = HIGH RISK
25. AI Agent Architecture
26. Complete Project Workflow
27. Recommended Project Folder Structure
AI-Exam-Proctoring/
|
+-- esp32/
| +-- exam_proctoring.ino
|
+-- ai/
| +-- face_tracking.py
| +-- face_detection.py
| +-- requirements.txt
|
+-- web/
| +-- index.php
| +-- proctoring_event.php
| +-- config.php
| +-- proctoring_logs.json
|
+-- n8n/
| +-- exam_proctoring_workflow.json
|
+-- database/
| +-- exam_events.sql
|
+-- documentation/
+-- project_report.md
28. Installation Procedure
Step 1: Install Arduino IDE
Install Arduino IDE and configure the ESP32 board package.
Step 2: Install Required Libraries
- WiFi.h
- HTTPClient.h
- Wire.h
- Adafruit GFX Library
- Adafruit SSD1306 Library
- DHT Sensor Library
Step 3: Configure Wi-Fi
const char* WIFI_SSID =
"YOUR_WIFI_NAME";
const char* WIFI_PASSWORD =
"YOUR_WIFI_PASSWORD";
Step 4: Upload ESP32 Firmware
- Connect ESP32 to computer.
- Select ESP32 board.
- Select COM port.
- Compile the program.
- Upload the program.
- Open Serial Monitor.
Step 5: Configure PHP Server
Place the PHP files inside the XAMPP htdocs folder.
C:/xampp/htdocs/proctoring/
Step 6: Configure n8n
- Create Webhook node.
- Add JSON processing node.
- Add IF condition.
- Add Telegram node.
- Add Google Sheets node.
- Add HTTP Request node for ThingSpeak.
- Add voice notification automation.
- Activate the workflow.
29. Security Recommendations
- Use HTTPS communication.
- Use API authentication tokens.
- Protect the PHP API.
- Use secure passwords.
- Restrict database access.
- Use role-based access control.
- Do not store unnecessary raw video.
- Protect biometric information.
- Use encrypted communication.
30. Privacy and Responsible AI Design
Because this project uses face tracking and AI-based monitoring, it should be deployed responsibly.
- Inform candidates about monitoring.
- Obtain appropriate consent where required.
- Avoid unnecessary storage of raw video.
- Protect sensitive personal data.
- Use AI alerts as review signals.
- Do not automatically declare a student guilty based only on AI detection.
- Provide human review for important examination decisions.
- Consider false positives caused by poor lighting, camera failure and network problems.
31. Future Enhancements
- Advanced face recognition.
- Registered candidate verification.
- Eye gaze tracking.
- Advanced head pose estimation.
- Multi-camera monitoring.
- AI object detection.
- Cloud database integration.
- Mobile application.
- AI-generated examination reports.
- Advanced power consumption prediction.
- Edge AI processing.
- Offline event storage.
- Multi-examination center support.
32. Final Project Abstract
The AI-Based Smart Exam Proctoring System Using Face Tracking is an intelligent examination monitoring solution that combines artificial intelligence, computer vision, ESP32-based IoT technology, cloud services and workflow automation.
The system continuously monitors a candidate's face during an examination and identifies events such as face absence, multiple faces and repeated head movement or looking away.
The ESP32 controller collects environmental and device information and communicates with the IoT webpage and cloud platforms.
Through n8n automation, the system processes detected events and automatically logs them into Google Sheets, updates the ThingSpeak cloud dashboard and sends real-time Telegram text and voice notifications to the examination supervisor.
An AI agent can analyze the complete event history, calculate a risk score and generate an examination monitoring summary.
The proposed system reduces the need for continuous manual supervision and provides a scalable, intelligent and automated platform for modern online and computer-based examinations.
33. Complete Technology Stack
Computer Vision
Face Tracking
ESP32
IoT
PHP Webpage
n8n Automation
AI Agent
Telegram Alerts
Voice Notifications
Google Sheets
ThingSpeak Cloud Dashboard
No comments:
Post a Comment