Thursday, 8 October 2026

IoT-Based Student Attendance Management System Using EM-18 RFID with Automated Telegram, Gmail and Google Sheets Integration

AI-Driven IoT Student Attendance Management System

Raspberry Pi Pico W + EM-18 RFID + 16×2 LCD + ESP32 + n8n + AI Agent + Telegram Voice + Gmail + Google Sheets + ThingSpeak + IoT Web Dashboard

Yes — all of the features you listed can be combined into one complete final-year/major-project architecture rather than treating them as separate projects.

The most practical design is:

  • Raspberry Pi Pico W → RFID reader + 16×2 LCD + local attendance controller
  • EM-18 RFID → reads student RFID card/tag
  • ESP32 → optional second IoT/AI edge controller and sensor/gateway node
  • n8n → central automation/orchestration layer
  • AI Agent → interprets attendance events, generates summaries and handles administrator queries
  • Google Sheets → attendance database
  • Telegram → instant attendance notifications
  • Telegram Voice → spoken alerts for important events
  • Gmail → attendance reports/alerts
  • ThingSpeak → cloud analytics and charts
  • IoT Web Dashboard → live attendance/status dashboard
  • 16×2 LCD → immediate local feedback

Raspberry Pi officially supports MicroPython on Pico W and provides Wi-Fi networking, UART, I²C, etc., making it suitable for this architecture. Raspberry Pi+1


1. Proposed Project Title

A good final title is:

AI-Driven IoT-Based Student Attendance Management System Using EM-18 RFID with Raspberry Pi Pico W, ESP32, n8n Automation, Telegram Voice Alerts, Gmail, Google Sheets, ThingSpeak and AI Agentic IoT Dashboard

A shorter academic title:

AI-Enabled IoT Student Attendance System Using RFID, Raspberry Pi Pico W, ESP32 and n8n Automation

2. Abstract

The proposed system is an intelligent IoT-based student attendance management system designed to automate the process of recording, storing, monitoring and reporting student attendance.

The system uses an EM-18 RFID reader to identify students through unique RFID cards or tags. A Raspberry Pi Pico W receives the RFID identification through UART, processes the card ID and displays the student's attendance status on a 16×2 LCD.

After successful identification, the Pico W sends an attendance event through Wi-Fi to an n8n automation server. n8n acts as the central integration and workflow engine. It records the attendance information into Google Sheets, updates the IoT cloud dashboard, and sends notifications through Telegram and Gmail.

An AI Agent is incorporated into the automation layer to analyze attendance patterns, generate natural-language reports, identify abnormal attendance behavior and respond to administrator queries.

An ESP32 can additionally operate as an AI/IoT edge node. It can monitor device health, environmental parameters or additional classroom sensors and communicate with the same n8n backend.

For critical events, n8n can generate a spoken notification and deliver it through Telegram as a voice message. Telegram's Bot API supports voice-message delivery, and n8n has a built-in Telegram integration. Telegram+1

ThingSpeak provides another cloud visualization layer through its REST API for writing and reading IoT channel data. MathWorks

The resulting system combines RFID, embedded systems, IoT, cloud computing, workflow automation, AI agents and real-time communication into a single smart attendance platform.


3. Main Objectives

The system should accomplish the following:

  1. Identify students automatically using RFID.
  2. Eliminate manual attendance marking.
  3. Display attendance confirmation on a 16×2 LCD.
  4. Send attendance data through Wi-Fi.
  5. Store attendance in Google Sheets.
  6. Send real-time Telegram notifications.
  7. Generate Telegram voice alerts.
  8. Send Gmail notifications/reports.
  9. Provide a live IoT dashboard.
  10. Store IoT statistics in ThingSpeak.
  11. Use AI to analyze attendance.
  12. Detect unusual attendance patterns.
  13. Provide administrator queries through an AI Agent.
  14. Maintain attendance history.
  15. Provide daily/weekly/monthly reports.
  16. Detect device/network failures.
  17. Provide a scalable architecture for multiple classrooms.

4. Overall System Architecture

                   ┌─────────────────────────┐
                   │      STUDENT RFID       │
                   │     Card / Key Tag      │
                   └────────────┬────────────┘
                                │
                                ▼
                     ┌───────────────────┐
                     │      EM-18        │
                     │   RFID READER     │
                     └─────────┬─────────┘
                               │ UART
                               ▼
                  ┌──────────────────────────┐
                  │    RASPBERRY PI PICO W   │
                  │                          │
                  │ RFID Processing           │
                  │ Student Validation        │
                  │ Attendance Logic           │
                  │ Wi-Fi Communication        │
                  │ LCD Control                │
                  └───────┬───────────┬──────┘
                          │             │
                     I²C  │             │ Wi-Fi
                          ▼             ▼
                  ┌────────────┐   ┌──────────────┐
                  │ 16×2 LCD   │   │     n8n      │
                  └────────────┘   │ Automation   │
                                   └──────┬───────┘
                                          │
                ┌─────────────────────────┼─────────────────────┐
                │                         │                     │
                ▼                         ▼                     ▼
        ┌──────────────┐        ┌────────────────┐     ┌──────────────┐
        │ Google Sheets│        │   AI AGENT     │     │  ThingSpeak  │
        │ Attendance DB│        │ AI Analytics   │     │ IoT Dashboard│
        └──────────────┘        └───────┬────────┘     └──────────────┘
                                        │
                          ┌─────────────┼──────────────┐
                          │             │              │
                          ▼             ▼              ▼
                     ┌─────────┐   ┌─────────┐   ┌────────────┐
                     │Telegram │   │ Gmail   │   │ Web        │
                     │Message  │   │Reports  │   │ Dashboard  │
                     └────┬────┘   └─────────┘   └────────────┘
                          │
                          ▼
                     ┌─────────┐
                     │ Telegram│
                     │  Voice  │
                     │  Alert  │
                     └─────────┘

5. Where ESP32 Fits

You mentioned both Raspberry Pi Pico W and ESP32.

Rather than replacing the Pico W, I recommend making them complementary.

Pico W

Use the Pico W as the attendance terminal:

EM-18
  ↓
Pico W
  ↓
16×2 LCD
  ↓
Wi-Fi
  ↓
n8n

ESP32

Use ESP32 as the AI/IoT edge node:

ESP32
 │
 ├── Classroom sensors
 ├── Temperature
 ├── Humidity
 ├── Device health
 ├── Optional OLED
 └── IoT communication
          ↓
         n8n

This gives your project a stronger academic architecture than simply putting both boards in parallel without a purpose.


6. Hardware Components

Core Hardware

Component Purpose
Raspberry Pi Pico W Main attendance controller
EM-18 RFID reader RFID card detection
RFID cards/tags Student identification
16×2 LCD Attendance display
I²C LCD backpack Reduces GPIO usage
ESP32 IoT/AI edge controller
5V power supply System power
Breadboard/PCB Prototyping
Jumper wires Connections

Optional Hardware

  • Buzzer
  • Green LED
  • Red LED
  • Push button
  • DS3231 RTC
  • DHT22/BME280
  • OLED display
  • MicroSD card
  • Relay
  • Door lock
  • ESP32-CAM

7. EM-18 RFID Reader

The EM-18 is the RFID identification component.

Typical communication:

RFID CARD
   ↓
EM-18
   ↓
UART serial data
   ↓
Pico W

The reader produces the RFID card's identifier through serial communication.

The Pico W's UART capability makes this straightforward; Raspberry Pi's documentation provides UART examples using machine.UART. Raspberry Pi Docs


8. Recommended Pico W Wiring

Use UART1 for the EM-18.

EM-18 → Pico W

EM-18 Pico W
VCC Appropriate supply according to your EM-18 module
GND GND
TX GPIO9 / UART1 RX
RX Usually unused

For the Pico W:

GPIO8 → UART1 TX
GPIO9 → UART1 RX

We only need the EM-18's TX because the reader is transmitting the RFID number to the Pico.

Important

Check the exact voltage specification of your EM-18 module before connecting it to Pico W GPIO.

Do not assume that every EM-18 breakout board has identical power/logic characteristics.


9. 16×2 LCD I²C Wiring

An I²C backpack is strongly recommended.

LCD I2C       Pico W
----------------------
VCC     →     5V/appropriate supply
GND     →     GND
SDA     →     GPIO4
SCL     →     GPIO5

Conceptually:

              Raspberry Pi Pico W

             ┌─────────────────┐
             │                 │
EM-18 TX ───►│ GPIO9           │
             │                 │
LCD SDA ────►│ GPIO4           │
LCD SCL ────►│ GPIO5           │
             │                 │
             │ Wi-Fi           │
             └───────┬─────────┘
                     │
                     ▼
                  Internet

Be careful with I²C voltage levels, especially if your LCD backpack is powered from 5 V. Use a suitable level-shifting arrangement where required.


10. Complete Schematic Concept

                         +5V
                          │
              ┌───────────┴────────────┐
              │                        │
          ┌───▼────┐               ┌───▼────┐
          │  EM-18 │               │  LCD   │
          │ RFID   │               │ 16×2   │
          └───┬────┘               └───┬────┘
              │ TX                     │ I²C
              │                        │
              ▼                        ▼
        ┌────────────────────────────────────┐
        │          Raspberry Pi Pico W       │
        │                                    │
        │ GPIO9 ← EM-18 TX                   │
        │ GPIO4 ↔ LCD SDA                    │
        │ GPIO5 ↔ LCD SCL                    │
        │                                    │
        │          Wi-Fi                     │
        └────────────────┬───────────────────┘
                         │
                         │ HTTPS
                         ▼
                  ┌─────────────┐
                  │     n8n     │
                  │ Automation  │
                  └──────┬──────┘
                         │
       ┌─────────────────┼─────────────────────┐
       │                 │                     │
       ▼                 ▼                     ▼
 Google Sheets        AI Agent             ThingSpeak
       │                 │                     │
       ▼                 ▼                     ▼
 Attendance DB      AI Analysis            Charts
                         │
              ┌──────────┼──────────┐
              ▼          ▼          ▼
          Telegram     Gmail       Web
          Message      Email      Dashboard
              │
              ▼
        Telegram Voice

11. Attendance Data Format

I recommend sending JSON from Pico W.

Example:

{
  "device_id": "CLASSROOM_01",
  "rfid_uid": "A1B2C3D4",
  "event": "attendance",
  "date": "2026-10-08",
  "time": "09:15:32",
  "status": "present"
}

n8n receives this JSON.


12. Student Database

Create a Google Sheet called:

Student_Master

Columns:

RFID_UID
Student_ID
Student_Name
Department
Year
Section
Email
Parent_Email
Telegram_ID
Status

Example:

A1B2C3D4 | STU001 | Rahul | ECE | 3 | A | ...
B4C5D6E7 | STU002 | Priya | CSE | 3 | A | ...

Then create another sheet:

Attendance_Log

Columns:

Timestamp
Date
Time
RFID_UID
Student_ID
Student_Name
Department
Year
Section
Device_ID
Status
Network_Status
AI_Flag

13. Complete Attendance Workflow

The fundamental workflow is:

Student taps RFID card
          ↓
EM-18 reads UID
          ↓
Pico W receives UID
          ↓
Pico W validates format
          ↓
LCD displays:
"Card Detected"
          ↓
Pico W sends HTTPS POST
          ↓
n8n Webhook
          ↓
Find RFID in student database
          ↓
Student found?
       /       \
     YES        NO
      │          │
      ▼          ▼
 Mark Present  Unknown Card
      │          │
      └────┬─────┘
           ▼
     Google Sheets
           │
           ├──────► Telegram
           │
           ├──────► Gmail
           │
           ├──────► ThingSpeak
           │
           └──────► AI Agent

14. Duplicate Attendance Protection

This is an important feature.

Suppose a student scans the same card five times in 10 seconds.

Without protection:

Rahul → Present
Rahul → Present
Rahul → Present
Rahul → Present

That's incorrect.

Instead n8n checks:

Has this student already been marked
present for this class/session?

If yes:

STATUS = DUPLICATE

and no new attendance record is created.


15. Pico W Software Architecture

The firmware should be divided into functions:

main()
 │
 ├── connect_wifi()
 │
 ├── initialize_lcd()
 │
 ├── initialize_rfid()
 │
 ├── read_rfid()
 │
 ├── validate_uid()
 │
 ├── display_message()
 │
 └── send_attendance()

16. Pico W MicroPython Code

Below is a practical starting firmware.

import network
import time
import urequests
from machine import UART, Pin, I2C

# -------------------------------
# Wi-Fi configuration
# -------------------------------

WIFI_SSID = "YOUR_WIFI"
WIFI_PASSWORD = "YOUR_PASSWORD"

N8N_WEBHOOK = "https://YOUR-N8N-DOMAIN/webhook/attendance"

DEVICE_ID = "CLASSROOM_01"

# -------------------------------
# RFID UART
# EM-18 TX -> Pico GPIO9
# -------------------------------

rfid = UART(
    1,
    baudrate=9600,
    tx=Pin(8),
    rx=Pin(9)
)

# -------------------------------
# LED / buzzer
# -------------------------------

LED = Pin("LED", Pin.OUT)
BUZZER = Pin(15, Pin.OUT)

# -------------------------------
# I2C LCD
# -------------------------------

i2c = I2C(
    0,
    scl=Pin(5),
    sda=Pin(4),
    freq=400000
)

# -------------------------------
# Wi-Fi
# -------------------------------

def connect_wifi():

    wlan = network.WLAN(network.STA_IF)

    wlan.active(True)

    if not wlan.isconnected():

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

        wlan.connect(
            WIFI_SSID,
            WIFI_PASSWORD
        )

        timeout = 20

        while not wlan.isconnected() and timeout > 0:
            time.sleep(1)
            timeout -= 1

    if wlan.isconnected():

        print("Wi-Fi connected")
        print(wlan.ifconfig())

        return True

    print("Wi-Fi connection failed")

    return False


# -------------------------------
# Buzzer
# -------------------------------

def beep():

    BUZZER.value(1)

    time.sleep(0.1)

    BUZZER.value(0)


# -------------------------------
# RFID reading
# -------------------------------

def read_rfid():

    if rfid.any():

        data = rfid.readline()

        if data:

            try:

                uid = data.decode(
                    "utf-8"
                ).strip()

                return uid

            except Exception as e:

                print("RFID decode error:", e)

    return None


# -------------------------------
# Send data to n8n
# -------------------------------

def send_attendance(uid):

    payload = {
        "device_id": DEVICE_ID,
        "rfid_uid": uid,
        "event": "attendance",
        "status": "detected"
    }

    try:

        response = urequests.post(
            N8N_WEBHOOK,
            json=payload,
            headers={
                "Content-Type":
                "application/json"
            }
        )

        print(
            "n8n response:",
            response.text
        )

        response.close()

        return True

    except Exception as e:

        print(
            "Network error:",
            e
        )

        return False


# -------------------------------
# Main
# -------------------------------

print("AI IoT Attendance System")

connect_wifi()

while True:

    uid = read_rfid()

    if uid:

        print(
            "RFID:",
            uid
        )

        LED.value(1)

        beep()

        success = send_attendance(
            uid
        )

        if success:

            print(
                "Attendance sent"
            )

        else:

            print(
                "Offline / failed"
            )

        time.sleep(2)

        LED.value(0)

    time.sleep(0.1)

The LCD portion should be implemented using the particular I²C LCD backpack/library you choose, because the I²C backpack controller address can vary between modules.


17. Better Production Firmware

For the final project, I recommend improving the above code with:

Wi-Fi reconnect
      ↓
Offline queue
      ↓
Retry mechanism
      ↓
Duplicate RFID filtering
      ↓
HTTP timeout
      ↓
Watchdog
      ↓
LCD status
      ↓
Heartbeat

For example:

Internet available?

       YES
        │
        ▼
    Send n8n
        │
        ▼
     Success
        │
        ▼
     Continue


       NO
        │
        ▼
 Store locally
        │
        ▼
Reconnect Wi-Fi
        │
        ▼
Send pending records

That makes the system much more robust.


18. n8n Architecture

n8n is the central automation engine. It is designed to connect applications/APIs and can also build AI functionality. n8n Documentation

Create a workflow:

Webhook
   ↓
Validate JSON
   ↓
Find Student
   ↓
IF Student Exists
   │
   ├── NO → Unknown RFID
   │
   └── YES
          ↓
      Duplicate Check
          ↓
      Attendance Record
          ↓
    Google Sheets
          ↓
     Parallel Tasks
      /     |      \
     /      |       \
Telegram  Gmail   ThingSpeak
             \
              AI Agent
                 ↓
             AI Analysis

19. n8n Webhook

Configure:

Node:
Webhook

HTTP Method:
POST

Path:
attendance

Your Pico sends:

POST /webhook/attendance

with:

{
  "device_id": "CLASSROOM_01",
  "rfid_uid": "A1B2C3D4",
  "event": "attendance"
}

20. n8n Student Lookup

The next operation searches:

Student_Master

for:

rfid_uid == incoming RFID

Example:

Incoming:
A1B2C3D4

Database:
A1B2C3D4
STU001
Rahul
ECE
3
A

The resulting object becomes:

{
  "student_id": "STU001",
  "student_name": "Rahul",
  "department": "ECE",
  "year": "3",
  "section": "A"
}

21. Unknown RFID Handling

If no student is found:

EM-18
  ↓
Pico W
  ↓
n8n
  ↓
Student NOT found
  ↓
Telegram Alert

Telegram:

⚠️ UNKNOWN RFID

UID: A1B2C3D4
Device: CLASSROOM_01
Time: 09:21:33

Action required:
Register this RFID if it belongs to a student.

22. Successful Attendance

Example Telegram message:

✅ Attendance Recorded

Student: Rahul
ID: STU001
Department: ECE
Year: 3
Section: A

Time: 09:15:32
Room: Classroom 01
Status: PRESENT

n8n's Telegram integration supports sending messages and audio files, among other operations. n8n Documentation


23. Gmail Integration

The Gmail workflow can send:

Student Attendance Confirmation

or daily faculty reports.

Example:

Subject:
Daily Attendance Report – ECE Section A

Body:

Date: 08 October 2026

Total Students: 60
Present: 52
Absent: 8
Attendance Percentage: 86.67%

Students requiring attention:
...

n8n's Gmail integration supports sending messages and also supports approval-oriented workflows, which can be useful for administrative actions. n8n Documentation


24. Google Sheets Integration

Google Sheets becomes your primary simple database.

Example:

Timestamp RFID Student ID Status
09:01 A1B2 Rahul STU001 Present
09:04 B2C3 Priya STU002 Present
09:05 C3D4 Arjun STU003 Present

The major advantage is that faculty members can inspect attendance without needing a separate database application.


25. ThingSpeak Integration

ThingSpeak can be used for IoT analytics rather than as the authoritative student database.

For example:

Field 1 = Total scans
Field 2 = Present count
Field 3 = Absent count
Field 4 = Attendance %
Field 5 = Unknown RFID
Field 6 = Device status
Field 7 = Wi-Fi RSSI

ThingSpeak provides REST endpoints for writing and reading channel data. MathWorks

Example HTTP request:

https://api.thingspeak.com/update

with:

api_key=YOUR_WRITE_KEY
field1=52
field2=48
field3=4
field4=92.3

26. AI Agent

This is where your project becomes more than a normal RFID attendance system.

The AI Agent can answer questions such as:

"How many students were absent today?"

or:

"Which students have attendance below 75%?"

or:

"Summarize today's attendance."

or:

"Did anyone repeatedly scan their card?"

or:

"Which section has the lowest attendance?"

27. AI Agent Architecture

                   ┌───────────────┐
                   │ Administrator │
                   └───────┬───────┘
                           │
                           ▼
                    ┌────────────┐
                    │  Telegram  │
                    └──────┬─────┘
                           │
                           ▼
                    ┌────────────┐
                    │ n8n Trigger│
                    └──────┬─────┘
                           │
                           ▼
                    ┌────────────┐
                    │ AI Agent   │
                    └──────┬─────┘
                           │
             ┌─────────────┼─────────────┐
             │             │             │
             ▼             ▼             ▼
       Google Sheets   ThingSpeak    Attendance API
             │             │             │
             └─────────────┼─────────────┘
                           ▼
                     AI Response
                           │
                           ▼
                       Telegram

n8n's current documentation includes AI Agent functionality and tool-based workflows. n8n Documentation


28. Example AI Agent System Prompt

Use a prompt conceptually like:

You are an AI attendance management assistant.

Your job is to analyze student attendance data.

You can:

1. Query attendance records.
2. Calculate attendance percentages.
3. Identify students below the attendance threshold.
4. Summarize daily attendance.
5. Identify repeated or suspicious RFID scans.
6. Generate faculty reports.
7. Explain attendance statistics.

Never invent attendance data.

If information is unavailable, clearly state that
the information is unavailable.

When reporting attendance, include:
- Student name
- Student ID
- Date
- Attendance percentage
- Status

Keep responses concise and professional.

29. AI Attendance Analysis

Suppose the database contains:

Rahul    92%
Priya    87%
Arjun    68%
Sneha    94%
Kiran    71%

Administrator asks:

Show students below 75%.

AI responds:

Attendance Alert

2 students are below 75%:

1. Arjun – 68%
2. Kiran – 71%

These students may require attendance counseling.

30. Agentic IoT

Your project can legitimately be described as Agentic IoT if the AI agent is given tools/actions rather than merely generating text.

For example:

AI Agent
 │
 ├── read_attendance()
 │
 ├── search_student()
 │
 ├── calculate_percentage()
 │
 ├── get_device_status()
 │
 ├── generate_report()
 │
 ├── send_telegram()
 │
 └── send_email()

Then:

Administrator:
"Check today's attendance and alert me
if anyone is below 75%."

AI Agent
      ↓
Read Google Sheets
      ↓
Calculate percentages
      ↓
Find <75%
      ↓
Generate report
      ↓
Send Telegram

That's substantially stronger than simply calling an LLM an "AI Agent."


31. Telegram Voice Alerts

Your voice-alert pipeline can be:

Attendance Event
      ↓
n8n
      ↓
AI Agent
      ↓
Generate text
      ↓
Text-to-Speech
      ↓
Audio file
      ↓
Telegram
      ↓
Faculty phone

Example spoken message:

"Attendance alert. Three students from Section A are below the required attendance threshold."

Telegram's Bot API has a sendVoice method for sending audio as a playable voice message. Telegram

n8n's Telegram node supports sending audio as well. n8n Documentation


32. Voice Alert Conditions

Don't generate a voice message for every RFID scan.

That would become annoying.

Use voice alerts for important events:

IF unknown RFID
      ↓
Voice Alert

IF attendance < 75%
      ↓
Voice Alert

IF device offline
      ↓
Voice Alert

IF unusual scanning pattern
      ↓
Voice Alert

IF daily attendance completed
      ↓
Optional Voice Report

33. Example Voice Alert

⚠️ Attendance Alert

Section A attendance is currently 68 percent.

Seven students are absent.

Three students are below the 75 percent
attendance threshold.

34. IoT Web Dashboard

The web dashboard should display:

┌──────────────────────────────────────────┐
│       SMART ATTENDANCE DASHBOARD         │
├──────────────────────────────────────────┤
│                                          │
│  Total Students       60                 │
│  Present              52                 │
│  Absent                8                 │
│  Attendance          86.7%               │
│                                          │
├──────────────────────────────────────────┤
│ Today's Attendance                      │
│                                          │
│ ████████████████████░░░ 86.7%           │
│                                          │
├──────────────────────────────────────────┤
│ Recent Scans                            │
│                                          │
│ Rahul       STU001     PRESENT            │
│ Priya       STU002     PRESENT            │
│ Arjun       STU003     PRESENT            │
│                                          │
├──────────────────────────────────────────┤
│ DEVICE STATUS                            │
│                                          │
│ Pico W      🟢 ONLINE                    │
│ ESP32       🟢 ONLINE                    │
│ n8n         🟢 ONLINE                    │
│                                          │
└──────────────────────────────────────────┘

35. Dashboard Data Flow

RFID
 ↓
Pico W
 ↓
n8n
 ↓
Google Sheets / Database
 ↓
Dashboard API
 ↓
Web Browser

For a prototype, Google Sheets can be the data source.

For a larger deployment:

Pico W
 ↓
n8n
 ↓
PostgreSQL
 ↓
Web Dashboard

would be more appropriate.


36. ESP32 Firmware Concept

The ESP32 can publish device-health information.

Example:

{
  "device": "ESP32_CLASSROOM_01",
  "temperature": 27.4,
  "humidity": 62,
  "wifi_rssi": -58,
  "status": "online"
}

Send this periodically:

Every 30 seconds
      ↓
ESP32
      ↓
n8n webhook
      ↓
ThingSpeak
      ↓
Dashboard

37. ESP32 Arduino Example

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

const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASSWORD";

const char* webhook =
  "https://YOUR-N8N-DOMAIN/webhook/esp32";

void setup() {

  Serial.begin(115200);

  WiFi.begin(
    ssid,
    password
  );

  while (
    WiFi.status() != WL_CONNECTED
  ) {

    delay(500);

    Serial.print(".");
  }

  Serial.println(
    "\nWiFi connected"
  );
}

void loop() {

  if (
    WiFi.status() == WL_CONNECTED
  ) {

    HTTPClient http;

    http.begin(webhook);

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

    String json =
      "{"
      "\"device\":\"ESP32_CLASSROOM_01\","
      "\"wifi_rssi\":" +
      String(WiFi.RSSI()) +
      ","
      "\"status\":\"online\""
      "}";

    int code =
      http.POST(json);

    Serial.print(
      "HTTP: "
    );

    Serial.println(code);

    http.end();
  }

  delay(30000);
}

38. Full n8n Workflow

I recommend actually building four workflows, rather than putting everything into one huge workflow.

Workflow 1 — Attendance

Webhook
   ↓
Validate
   ↓
Student Lookup
   ↓
Duplicate Check
   ↓
Google Sheets
   ↓
Telegram

Workflow 2 — AI Agent

Telegram Trigger
       ↓
AI Agent
       ↓
Tools
 ┌─────┼──────────┐
 ▼     ▼          ▼
Sheets ThingSpeak Attendance API
       ↓
AI Response
       ↓
Telegram

Workflow 3 — Device Monitoring

ESP32/Pico heartbeat
        ↓
Webhook
        ↓
Store status
        ↓
ThingSpeak
        ↓
Dashboard

Workflow 4 — Daily Report

Schedule Trigger
       ↓
Get Today's Attendance
       ↓
Calculate Statistics
       ↓
AI Summary
       ↓
Google Sheets
       ↓
Gmail
       ↓
Telegram
       ↓
Optional Voice

39. Daily Report Workflow

At 5:00 PM:

Scheduler
   ↓
Read Attendance
   ↓
Count Students
   ↓
Count Present
   ↓
Count Absent
   ↓
Calculate %
   ↓
AI Summary
   ↓
Generate HTML Report
   ↓
Gmail
   ↓
Telegram

Example:

DAILY ATTENDANCE REPORT

Date: 08-Oct-2026

Total Students: 60
Present: 52
Absent: 8

Attendance: 86.67%

Low Attendance:
- Arjun – 68%
- Kiran – 71%

Unknown RFID Attempts:
2

Device Status:
Pico W – Online
ESP32 – Online

40. System Flowchart

                    START
                      │
                      ▼
               Initialize Pico W
                      │
                      ▼
                 Connect Wi-Fi
                      │
               ┌──────┴───────┐
               │              │
             Fail           Success
               │              │
               ▼              ▼
          Retry Wi-Fi     Wait for RFID
                              │
                              ▼
                        RFID Detected?
                         /          \
                       NO            YES
                       │              │
                       └──────┐       ▼
                              │    Read UID
                              │       │
                              │       ▼
                              │   Send to n8n
                              │       │
                              │       ▼
                              │  Student Found?
                              │    /       \
                              │   NO        YES
                              │   │          │
                              │   ▼          ▼
                              │ Unknown   Duplicate?
                              │   │        /    \
                              │   │      YES     NO
                              │   │       │       │
                              │   │       ▼       ▼
                              │   │    Reject   Record
                              │   │               │
                              │   └──────┬────────┘
                              │          ▼
                              │      Notifications
                              │          │
                              │    ┌─────┼──────┐
                              │    ▼     ▼      ▼
                              │ Telegram Gmail ThingSpeak
                              │
                              ▼
                         Return to Scan

41. Sequence Diagram

Student       EM-18       Pico W       n8n       Sheets       Telegram
  │             │            │           │           │            │
  │──Tap Card──►│            │           │           │            │
  │             │──UID──────►│           │           │            │
  │             │            │──POST────►│           │            │
  │             │            │           │──Lookup──►│            │
  │             │            │           │◄─Student──│            │
  │             │            │           │           │            │
  │             │            │           │──Record──►│            │
  │             │            │           │           │            │
  │             │            │           │──Message────────────────►│
  │             │            │           │           │            │
  │             │            │◄──────────Response────│            │
  │◄────LCD─────│            │           │           │            │

42. State Machine

The Pico W firmware can also be represented as:

              ┌───────────────┐
              │     BOOT      │
              └───────┬───────┘
                      ▼
              ┌───────────────┐
              │ CONNECT WIFI  │
              └───────┬───────┘
                      ▼
              ┌───────────────┐
              │ WAIT FOR RFID │◄──────────────┐
              └───────┬───────┘               │
                      ▼                        │
              ┌───────────────┐               │
              │ READ RFID UID │               │
              └───────┬───────┘               │
                      ▼                        │
              ┌───────────────┐               │
              │ SEND TO n8n   │               │
              └───────┬───────┘               │
                      ▼                        │
              ┌───────────────┐               │
              │ SHOW RESULT   │               │
              └───────┬───────┘               │
                      ▼                        │
              ┌───────────────┐               │
              │  WAIT 2 SEC   │───────────────┘
              └───────────────┘

43. LCD User Interface

Startup

SMART ATTENDANCE
System Starting...

Wi-Fi connecting

Connecting WiFi
Please Wait...

Ready

SCAN YOUR CARD
                :)

Card detected

CARD DETECTED
Processing...

Successful

RAHUL
PRESENT 09:15

Unknown

UNKNOWN CARD
CONTACT ADMIN

Duplicate

ALREADY MARKED
ATTENDANCE

Network failure

NETWORK ERROR
RETRYING...

44. Buzzer/LED Logic

You can add simple physical feedback:

Successful:
Green LED + short beep

Unknown:
Red LED + two beeps

Network failure:
Red LED + long beep

System ready:
Green LED

45. Security Architecture

Do not put credentials directly into public source code.

Avoid:

WIFI_PASSWORD = "mypassword"

in a repository that you publish.

For demonstration, use:

WIFI_SSID = "YOUR_WIFI"
WIFI_PASSWORD = "YOUR_PASSWORD"

and explain that production deployments should use protected configuration.

Also secure the n8n webhook.

A stronger architecture is:

Pico W
   ↓
HTTPS
   ↓
Authenticated webhook
   ↓
n8n

rather than an unrestricted public webhook.

n8n provides security-audit functionality that can identify issues including unprotected webhooks and security configuration problems. n8n Documentation


46. Data Security

Attendance information is personal data.

Therefore:

  • Don't publish student names publicly.
  • Don't expose Google Sheets publicly.
  • Don't put Telegram IDs in frontend JavaScript.
  • Don't expose API keys.
  • Use HTTPS.
  • Protect n8n credentials.
  • Restrict dashboard access.
  • Keep minimum required student information.
  • Use role-based administrator access for a real deployment.

47. AI Anomaly Detection

One advanced feature can be:

Suspicious attendance pattern

Suppose:

STU001 → 09:00
STU002 → 09:01
STU003 → 09:02
STU001 → 09:03
STU004 → 09:04
STU001 → 09:05

AI can flag:

Potential anomaly:
STU001 scanned multiple times within a short interval.

The AI should flag the event rather than automatically accuse a student of fraud.


48. Attendance Percentage

Use:

Attendance % =
(Present Classes / Total Classes) × 100

Example:

Present = 42
Total = 50

Attendance =
42 / 50 × 100

= 84%

49. AI Risk Classification

You can classify:

>= 85%
    GOOD

75–84%
    WARNING

< 75%
    CRITICAL

Then:

84% → WARNING
71% → CRITICAL
93% → GOOD

This is useful for your AI dashboard.


50. Recommended Dashboard Pages

Page 1 — Overview

Total Students
Present
Absent
Attendance %
Devices Online

Page 2 — Live Attendance

Student
RFID
Time
Status
Device

Page 3 — Analytics

Daily attendance
Weekly attendance
Monthly attendance
Section comparison

Page 4 — Low Attendance

Student
Percentage
Risk

Page 5 — Device Monitoring

Pico W
ESP32
Wi-Fi
Last heartbeat
Status

Page 6 — AI Assistant

Ask:
"Who was absent today?"
"Show students below 75%"
"Summarize this week"

51. Complete Data Flow

                 ┌─────────────┐
                 │ RFID Card   │
                 └──────┬──────┘
                        ▼
                 ┌─────────────┐
                 │    EM-18    │
                 └──────┬──────┘
                        ▼
                 ┌─────────────┐
                 │   Pico W    │
                 └──────┬──────┘
                        │
                 ┌──────▼──────┐
                 │  Wi-Fi/HTTP │
                 └──────┬──────┘
                        ▼
                 ┌─────────────┐
                 │     n8n     │
                 └──────┬──────┘
                        │
        ┌───────────────┼────────────────┐
        │               │                │
        ▼               ▼                ▼
   Student DB       Attendance       AI Agent
        │               │                │
        └───────┬───────┘                │
                ▼                        │
          Google Sheets                  │
                │                        │
       ┌────────┼────────┐               │
       ▼        ▼        ▼               ▼
   Telegram   Gmail   ThingSpeak     AI Report
       │        │        │               │
       └────────┴────────┴──────┬────────┘
                                ▼
                         Web Dashboard

52. Recommended Project Folder Structure

AI-IoT-Attendance/
│
├── pico/
│   ├── main.py
│   ├── config.py
│   ├── lcd.py
│   ├── rfid.py
│   ├── wifi.py
│   └── boot.py
│
├── esp32/
│   ├── main.ino
│   ├── config.h
│   └── sensors.h
│
├── n8n/
│   ├── attendance.json
│   ├── ai_agent.json
│   ├── daily_report.json
│   └── device_monitor.json
│
├── dashboard/
│   ├── index.html
│   ├── style.css
│   └── app.js
│
├── documentation/
│   ├── architecture.md
│   ├── wiring.md
│   ├── installation.md
│   └── testing.md
│
└── README.md

53. Development Stages

Do not build everything simultaneously.

Build it in these stages.

Stage 1 — RFID

EM-18 → Pico W

Verify the UID.

Stage 2 — LCD

RFID → Pico W → LCD

Display:

Card ID:
A1B2C3D4

Stage 3 — Wi-Fi

Pico W → Wi-Fi

Verify internet connectivity.

Stage 4 — n8n

Pico W → Webhook

Verify JSON.

Stage 5 — Google Sheets

n8n → Google Sheets

Stage 6 — Telegram

n8n → Telegram

Stage 7 — Gmail

n8n → Gmail

Stage 8 — ThingSpeak

n8n → ThingSpeak

Stage 9 — AI

Telegram → AI Agent → Sheets

Stage 10 — Voice

AI → TTS → Telegram Voice

Stage 11 — ESP32

ESP32 → n8n

Stage 12 — Dashboard

Database → Web Dashboard

54. Testing Plan

Create a formal test table for your project report.

Test Input Expected Output
RFID detection Registered card UID detected
Unknown RFID Unknown card Unknown warning
LCD Valid card Student status
Wi-Fi Network available Connected
n8n Attendance JSON Workflow triggered
Sheets Valid student Row inserted
Telegram Attendance Notification
Gmail Daily report Email received
ThingSpeak Statistics Chart updated
Duplicate Same card twice Duplicate rejected
AI Attendance query Correct answer
Voice Critical alert Voice notification
ESP32 Heartbeat Device online
Network loss Disconnect Wi-Fi Retry/offline mode

55. Failure Handling

The system should not collapse if one service is unavailable.

For example:

RFID
 ↓
Pico W
 ↓
Internet unavailable
 ↓
Local queue
 ↓
LCD:
"OFFLINE MODE"

When Wi-Fi returns:

Wi-Fi restored
       ↓
Send queued attendance
       ↓
Server confirms
       ↓
Delete queue

This is a very good feature to mention during your project viva.


56. Why Use Both Google Sheets and ThingSpeak?

They have different roles.

Google Sheets

Best for:

Student records
Attendance records
Faculty access
Reports
Manual correction

ThingSpeak

Best for:

IoT statistics
Time-series data
Charts
Device health
Attendance trends

So:

Google Sheets = operational attendance database

ThingSpeak = IoT analytics platform

This distinction makes the architecture much clearer.


57. Why Use n8n?

Without n8n:

Pico W
 ├── Google API
 ├── Telegram API
 ├── Gmail API
 ├── ThingSpeak API
 └── AI API

The embedded firmware becomes complicated.

With n8n:

Pico W
    │
    ▼
  n8n
 / | | \
/  | |  \
Sheets Telegram Gmail ThingSpeak
       │
       AI

The microcontroller only needs to send an attendance event.

n8n handles the integration.

That is one of the strongest architectural arguments for this project.


58. Why Use AI?

Normal RFID attendance:

RFID
 ↓
Database

Your proposed system:

RFID
 ↓
IoT
 ↓
Cloud
 ↓
Automation
 ↓
AI
 ↓
Analytics
 ↓
Decision support
 ↓
Notifications

The AI is useful for:

  • Attendance summaries
  • Low-attendance identification
  • Natural-language queries
  • Trend analysis
  • Anomaly flagging
  • Automated reports
  • Notification generation

59. Final System Architecture

The final architecture I would present in your project report is:

                         STUDENTS
                            │
                            ▼
                     ┌──────────────┐
                     │ RFID CARD    │
                     └──────┬───────┘
                            ▼
                     ┌──────────────┐
                     │ EM-18        │
                     └──────┬───────┘
                            │ UART
                            ▼
                ┌────────────────────────┐
                │ Raspberry Pi Pico W    │
                │                        │
                │ RFID Processing        │
                │ LCD Interface          │
                │ Wi-Fi                  │
                │ Local Queue            │
                └───────────┬────────────┘
                            │
                            │ HTTPS
                            ▼
                    ┌───────────────┐
                    │      n8n      │
                    │ IoT Automation│
                    └───────┬───────┘
                            │
             ┌──────────────┼───────────────┐
             │              │               │
             ▼              ▼               ▼
       ┌──────────┐   ┌───────────┐   ┌───────────┐
       │ Google   │   │ AI Agent  │   │ ThingSpeak│
       │ Sheets   │   │           │   │           │
       └────┬─────┘   └─────┬─────┘   └───────────┘
            │               │
            │       ┌───────┼────────┐
            │       │       │        │
            │       ▼       ▼        ▼
            │   Telegram  Gmail   Voice/TTS
            │
            └──────────────┬──────────────────┐
                           │                  │
                           ▼                  ▼
                    ┌─────────────┐    ┌─────────────┐
                    │ Web Dashboard│    │ ESP32 IoT   │
                    │ Live Status  │    │ Edge Node   │
                    └─────────────┘    └──────┬──────┘
                                               │
                                               ▼
                                              n8n

60. Key Innovation Points for Your Project

For your presentation/viva, emphasize these:

1. RFID automation

Students don't need manual attendance.

2. Edge processing

Pico W immediately handles RFID events and LCD feedback.

3. IoT connectivity

Attendance reaches the cloud automatically.

4. Workflow automation

n8n connects multiple services.

5. AI Agent

Administrators can interact with attendance information using natural language.

6. Agentic IoT

The AI can invoke tools/actions rather than merely generate text.

7. Multi-channel alerts

Telegram
Gmail
Voice
Web

8. Cloud analytics

ThingSpeak provides time-series visualization.

9. Device monitoring

ESP32/Pico health can be monitored.

10. Offline resilience

Attendance can be queued during temporary network failures.


61. Recommended Final Technology Stack

Layer Technology
RFID EM-18
Main MCU Raspberry Pi Pico W
Display 16×2 LCD I²C
Secondary MCU ESP32
Embedded language MicroPython / Arduino C++
Communication UART / I²C
Network Wi-Fi
Protocol HTTPS/REST
Automation n8n
Database/prototype Google Sheets
IoT analytics ThingSpeak
AI n8n AI Agent + LLM
Messaging Telegram
Voice TTS + Telegram
Email Gmail
Frontend HTML/CSS/JavaScript
Cloud workflow n8n

62. Important Design Decision

I would not put the AI model directly on the Pico W or ESP32 for this project.

Instead:

Pico W / ESP32
       ↓
     n8n
       ↓
    AI Agent

The microcontrollers perform deterministic, real-time tasks.

The AI performs higher-level reasoning.

That separation is cleaner, more reliable and much easier to demonstrate.


63. Official Technical References

For implementation, Raspberry Pi's current documentation covers Pico W MicroPython, wireless operation and its hardware peripherals. Raspberry Pi+1

Raspberry Pi Pico W documentation

Raspberry Pi MicroPython documentation

n8n documents its integrations, automation and AI functionality, including Telegram and Gmail nodes. n8n Documentation+2

n8n documentation

Telegram's official Bot API documents sendVoice for voice-message delivery. Telegram

Telegram Bot API

ThingSpeak's official documentation describes its REST API for writing and reading IoT channel data. MathWorks

ThingSpeak REST API documentation


64. What the Complete Project Demonstrates

The finished project can therefore be presented as:

An AI-enabled agentic IoT attendance platform in which an RFID-based embedded edge device automatically identifies students, displays attendance locally, securely transmits attendance events to an n8n automation layer, stores records in Google Sheets, publishes IoT analytics through ThingSpeak, sends real-time Telegram and Gmail notifications, generates Telegram voice alerts for important events, and provides an AI Agent through which administrators can query, analyze and act on attendance information.

That is a substantially stronger project than an RFID attendance logger alone.

For the actual build, I recommend implementing the Pico W + EM-18 + LCD + n8n path first, then adding Google Sheets/Telegram, then AI/voice, and finally ESP32 + dashboard. This minimizes debugging complexity while still giving you the complete architecture described above. Raspberry Pi+1

Project Summary

The proposed project is an AI-driven IoT-based student attendance management system that automates attendance using EM-18 RFID, Raspberry Pi Pico W, and a 16×2 LCD, while connecting the system to cloud services and AI automation.

Core Workflow

Student RFID Card
       ↓
    EM-18 RFID
       ↓
 Raspberry Pi Pico W
       ↓
   16×2 LCD
       ↓
      Wi-Fi
       ↓
      n8n
       ↓
 ┌─────┼──────────┬──────────┐
 ↓     ↓          ↓          ↓
Sheets Telegram  Gmail   ThingSpeak
       ↓
    AI Agent
       ↓
 Telegram Voice
       ↓
 Web Dashboard

Main Components

  • EM-18 RFID — identifies students.
  • Raspberry Pi Pico W — processes RFID data, controls LCD and communicates over Wi-Fi.
  • 16×2 LCD — displays messages such as SCAN CARD, PRESENT, UNKNOWN CARD, etc.
  • ESP32 — optional secondary IoT/edge device for classroom sensors, device monitoring and additional IoT functions.
  • n8n — central workflow automation platform.
  • Google Sheets — attendance database and reporting.
  • Telegram — instant attendance and administrator notifications.
  • Telegram Voice — voice alerts for critical events.
  • Gmail — daily/weekly attendance reports.
  • ThingSpeak — IoT statistics and time-series visualization.
  • AI Agent — natural-language attendance queries, summaries, anomaly detection and automated reporting.
  • Web Dashboard — live attendance, analytics and device-status visualization.

Key AI Features

The AI Agent can answer questions such as:

  • “Who was absent today?”
  • “Which students are below 75% attendance?”
  • “Summarize today's attendance.”
  • “Which section has the lowest attendance?”
  • “Are there suspicious repeated RFID scans?”
  • “Generate today's attendance report.”

Important Features

  • Automatic attendance marking
  • Duplicate-scan prevention
  • Unknown RFID detection
  • Real-time notifications
  • Gmail reports
  • Telegram voice alerts
  • AI-powered analytics
  • IoT cloud dashboard
  • Device-health monitoring
  • Offline attendance queue/retry
  • Daily/weekly/monthly reports

Recommended Architecture

Use the Pico W as the dedicated RFID attendance terminal and the ESP32 as an optional IoT/edge node. Keep the AI in the cloud/n8n layer rather than attempting to run the AI model directly on the microcontroller.

RFID + Pico W
      ↓
   n8n
      ↓
Database / Automation
      ↓
 AI Agent
      ↓
Telegram + Gmail + Voice
      ↓
Dashboard + Analytics

Project Innovation

The project combines embedded systems + RFID + IoT + cloud integration + workflow automation + AI agents + voice notifications into one intelligent attendance platform.

The strongest description for a report is:

An AI-enabled agentic IoT attendance platform that automatically identifies students through RFID, records attendance through a Raspberry Pi Pico W, synchronizes data with cloud services, provides real-time Telegram/Gmail/voice notifications, visualizes IoT analytics, and uses an AI Agent to analyze attendance and assist administrators.