Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

😛 NightKnight (KN)

A comprehensive IoT security and monitoring system combining Arduino hardware, AI-powered vision classification, and a web-based interface for real-time alerts and monitoring.

🔗 Links

Overview

NightKnight is an intelligent surveillance system that combines:

  • Arduino UNO Q: Motion and tilt detection via accelerometer/gyroscope sensors
  • Edge AI Model: Real-time video classification using Edge Impulse trained models
  • Web UI: Live monitoring dashboard and system control interface

Project Structure

├── sketch/                          # Arduino UNO firmware
│   ├── sketch.ino                  # Main Arduino sketch with motion detection
│   └── sketch.yaml                 # Arduino configuration
│
├── python/                         # Backend AI & web server
│   ├── main.py                     # Main application with AI vision logic
│   └── requirements.txt            # Python dependencies
│
├── assets/                         # Web frontend
│   ├── index.html                  # Web UI markup
│   ├── index-*.css                 # Compiled stylesheets
│   ├── index-*.js                  # React app compiled code
│   └── bridge.js                   # Communication bridge for hardware
│
├── app.yaml                        # Application configuration
└── README.md                       # This file

Components & Architecture

1) Arduino UNO Q (sketch/sketch.ino)

Hardware: Arduino UNO with Modulino Movement kit (accelerometer/gyroscope)

Features:

  • Real-time motion detection using 6-axis IMU
  • Tilt/rotation monitoring with calibration
  • RGB LED status indicators (dual LED rings)
  • Motion event debouncing with 1.5s cooldown
  • Thresholds:
    • Motion: ±0.20G acceleration
    • Rotation: ±20 DPS
    • Tilt: ±25 degrees

Communication:

  • Communicates with Python backend via Arduino Router Bridge
  • Sends motion/tilt events and sensor data
  • Receives commands and LED control signals

2) Edge AI Model (python/main.py)

Framework: Arduino App Bricks with Edge Impulse

Features:

  • Real-time video classification using a pre-trained Edge Impulse model
  • State machine with 3 states:
    • clear: Normal monitoring state
    • waiting: Person detected in front (confidence > 75%)
    • blackout: No-light/dark conditions (confidence > 90%)
  • Sliding window history (8 samples) for state stability
  • Debouncing mechanism (0.2s) to filter false positives
  • Confidence-based classification with configurable thresholds

Model Path:

  • /home/arduino/.arduino-bricks/ei-models/gdaniels-project-1-linux-aarch64-v9.eim
  • Classifications: Waiting in front, Blackout, unknown

Output:

  • JSON state changes with timestamps (ISO 8601)
  • Real-time WebSocket updates to frontend
  • Event history tracking

3) Web UI (assets/)

Framework: React + Vite (compiled static assets)

Features:

  • Real-time monitoring dashboard
  • Live camera feed from video brick
  • System state display (clear / waiting / blackout)
  • Motion alerts and notifications
  • Control panel for arm/disarm
  • Event history visualization

bridge.js responsibilities:

  • Establishes WebSocket connection to Python backend
  • Handles bidirectional communication
  • Manages camera stream and state updates
  • Converts hardware events to UI updates

How It Works

Detection Flow

1. Arduino UNO (Motion Sensors)
   ├─> Detects movement/tilt
   └─> Sends event to backend

2. Python Backend (AI Processing)
   ├─> Receives motion alert
   ├─> Processes video frame via Edge Impulse
   ├─> Performs state classification
   └─> Updates WebSocket clients

3. Web UI (Real-time Dashboard)
   ├─> Receives state updates
   ├─> Displays camera feed
   ├─> Shows alert notifications
   └─> Provides user control

State Machine Logic

idle/clear state
↓ (person detected + confidence > 75%)
↓
waiting state ─── (person leaves or timeout)
↓ ↗
↓ (lights out + confidence > 90%)
↓
blackout state ─── (lights restored)
↓ ↗
└─ back to clear

Configuration

app.yaml

name: KN
description: NightKnight UI
ports:
  - 7000

bricks:
  - arduino:web_ui: {}
  - arduino:video_image_classification:
      variables:
        EI_V_CLASSIFICATION_MODEL: /home/arduino/.arduino-bricks/ei-models/gdaniels-project-1-linux-aarch64-v9.eim

icon: 😛

Bricks Used:

  • web_ui: Hosts the web frontend on port 7000
  • video_image_classification: Runs Edge Impulse AI model for vision classification

Requirements

  • Arduino UNO R4 WiFi (or compatible)
  • Modulino Movement Kit (accelerometer + gyroscope)
  • Micro-SD card (for Edge Impulse model storage)
  • Arduino IDE with required libraries
  • Python 3.8+
  • Modern web browser (Chrome, Firefox, Safari, Edge)

Installation & Deployment

  1. Arduino Setup

    • Upload sketch/sketch.ino to Arduino UNO
    • Configure Modulino Movement connections
    • Calibrate accelerometer baseline
  2. Python Backend

    cd python/
    pip install -r requirements.txt
  3. Run Application

    • Deploy to Arduino Cloud
    • Application auto-starts on device boot
    • Monitor via web dashboard at http://device:7000

Use Cases

  • Home Security: Detect unauthorized entry and motion
  • Office Monitoring: Track workspace activity during off-hours
  • Package Protection: Alert when delivery packages are detected
  • Facility Management: Log visitor arrival patterns

Development Notes

  • Uno Q (Arduino UNO Q): Handles hardware acceleration and sensor processing
  • Web UI Brick: Provides real-time monitoring and control
  • Edge AI Model: Runs on-device for privacy and low-latency inference

Last Updated: 2026-03-02

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages