IoTยท

SmartAttend IoT โ€” Facial Recognition Attendance System

A professional-grade facial recognition attendance system built on Raspberry Pi. Features a real-time Python recognition engine, I2C OLED status alerts, a Nuxt.js admin dashboard, and a FastAPI backend with SQLAlchemy for seamless classroom deployment.
Face RecognitionRaspberry PiComputer VisionPythonFastAPINuxt.jsOpenCVEmbedded Systems

๐Ÿง  Overview

SmartAttend-IoT is an automated attendance system that leverages facial recognition technology on an edge IoT device. Running on a Raspberry Pi (or desktop for development), it captures video, identifies registered students in real time, displays status on an I2C OLED screen with buzzer feedback, and syncs attendance data with a central FastAPI backend. A Nuxt.js web dashboard allows administrators to manage students and view attendance reports.

The system follows a client-server architecture where the IoT device acts as a smart edge client โ€” performing face detection and matching locally for speed, while syncing records to the cloud for persistence and administration.

๐ŸŽฏ Key Features

  • Real-Time Face Recognition: 128-dimensional face encoding via dlib's face_recognition library, matched against a local database in a dedicated background thread for zero UI blocking
  • I2C OLED Status Display: SSD1306 OLED screen connected via I2C shows real-time attendance status โ€” recognized name, timestamp, and system state
  • Buzzer Audio Feedback: Audible confirmation when a face is successfully recognized and attendance is logged
  • Smart Debounce Logic: Configurable 10-minute debounce prevents duplicate entries even with continuous camera exposure
  • Cross-Platform Camera: Factory pattern auto-detects Raspberry Pi (PiCamera2 with XRGB8888) or desktop (USB webcam via OpenCV VideoCapture)
  • FastAPI REST Backend: Async API for student CRUD, face encoding generation from uploaded photos, attendance event logging, and device sync
  • Nuxt.js Admin Dashboard: Vue 3 + Tailwind CSS interface for student registration (with photo upload), attendance reports, and system management
  • SQLAlchemy ORM: Unified database layer supporting SQLite (development) and PostgreSQL (production)

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          IoT Edge Device (Raspberry Pi)  โ”‚
โ”‚                                          โ”‚
โ”‚  Camera โ†’ Recognition Engine โ†’ Matcher   โ”‚
โ”‚              โ†“                    โ†“      โ”‚
โ”‚         OLED Display         API Client  โ”‚
โ”‚         + Buzzer                 โ†“       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                   โ”‚
                            HTTP REST API
                                   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Server Side                 โ”‚
โ”‚                                          โ”‚
โ”‚  FastAPI Backend โ†โ†’ SQLite/PostgreSQL    โ”‚
โ”‚        โ†‘                                 โ”‚
โ”‚  Nuxt.js Dashboard (Admin)               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”„ Data Flow

Student Registration

  1. Admin uploads a student photo and name via the Nuxt.js Dashboard
  2. FastAPI Backend receives the photo
  3. Backend detects the face and generates a 128-dimensional encoding using dlib
  4. The encoding is serialized (pickled) and stored in the Database

Attendance Marking

  1. IoT Device boots up and calls GET /students/sync to download all face encodings
  2. Camera captures frames at 640ร—480 resolution
  3. Recognition Engine resizes frames to 1/4 scale and detects faces
  4. Encodings are compared using Euclidean distance against the local database
  5. On match (with debounce check), attendance is logged and OLED + buzzer confirm
  6. API Client syncs the record to POST /attendance

๐Ÿ› ๏ธ Technical Stack

IoT / Edge Device

  • Python 3.9+ โ€” Core runtime
  • face_recognition (dlib) โ€” 128D face encoding and matching
  • OpenCV โ€” Video capture, frame processing, and display
  • Adafruit SSD1306 โ€” I2C OLED display driver via Adafruit Blinka
  • Pillow โ€” Image rendering for OLED text display
  • PiCamera2 โ€” Raspberry Pi Camera Module 3 support (XRGB8888 format)

Backend

  • FastAPI โ€” Async Python web framework for REST API
  • SQLAlchemy โ€” ORM with aiosqlite (dev) and PostgreSQL (prod)
  • Pydantic โ€” Request/response validation schemas

Frontend

  • Nuxt.js (Vue 3) โ€” Server-side rendered admin dashboard
  • Tailwind CSS โ€” Utility-first responsive styling

Hardware

  • Raspberry Pi 4 โ€” Edge computing platform
  • Pi Camera Module 3 โ€” Video capture
  • SSD1306 OLED (128ร—64) โ€” I2C status display
  • Piezo Buzzer โ€” Audio feedback on recognition
  • USB Webcam โ€” Desktop fallback camera

๐Ÿ“ Project Structure

SmartAttend-IoT/
โ”œโ”€โ”€ backend/              # FastAPI Server
โ”‚   โ”œโ”€โ”€ main.py           # API entry point & endpoints
โ”‚   โ”œโ”€โ”€ models.py         # SQLAlchemy DB models (Student, Attendance)
โ”‚   โ””โ”€โ”€ schemas.py        # Pydantic validation schemas
โ”œโ”€โ”€ core/                 # IoT Device Logic
โ”‚   โ”œโ”€โ”€ api_client.py     # HTTP client for backend sync
โ”‚   โ”œโ”€โ”€ camera.py         # Camera hardware abstraction (Factory pattern)
โ”‚   โ”œโ”€โ”€ recognition.py    # Face detection & matching (threaded)
โ”‚   โ””โ”€โ”€ database.py       # Local SQLAlchemy DB connection
โ”œโ”€โ”€ frontend/             # Nuxt.js Web Dashboard
โ”‚   โ”œโ”€โ”€ app/              # Vue components & pages
โ”‚   โ””โ”€โ”€ nuxt.config.ts    # Nuxt configuration
โ”œโ”€โ”€ tests/                # Unit tests with mock camera
โ”œโ”€โ”€ main.py               # IoT device entry point
โ”œโ”€โ”€ train.py              # Batch face encoding trainer
โ””โ”€โ”€ requirements.txt      # Python dependencies

๐Ÿš€ Deployment

The system supports dual deployment:

  • Edge Device: Runs main.py on Raspberry Pi with camera, OLED, and buzzer connected โ€” performs local face recognition and syncs to backend
  • Server: FastAPI backend deployed separately (supports Docker), serving the Nuxt.js dashboard and REST API for multi-device management