Skip to content

LordSpudnik/Real-Time-Seat-Occupancy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoT Seat Occupancy & Crowd Management System

A real-time seat occupancy monitoring system built with an ESP32 microcontroller, FSR pressure sensors, Firebase Realtime Database, and a vanilla JS web dashboard.


How It Works

  1. FSR sensors under each seat detect pressure via a voltage divider circuit
  2. ESP32 reads sensor values every 300ms and compares against a threshold (ADC > 500)
  3. On state change, ESP32 pushes the update to Firebase (/seats/A1/state)
  4. Web dashboard listens to Firebase in real time and updates the seat map instantly
  5. Alert banner triggers automatically when occupancy exceeds 85%

Project Structure

├── index.html          # Dashboard UI and seat map
├── style.css           # Styling and seat state visuals
├── main.js             # Firebase listener and occupancy logic
├── config.js           # Firebase config (not committed — see below)
├── config.example.js   # Template for Firebase config
├── FSR.ino             # ESP32 Arduino firmware
└── secrets.h           # WiFi and Firebase credentials (not committed — see below)

Setup

Firebase

  1. Create a Firebase project at firebase.google.com
  2. Enable Realtime Database
  3. Set database rules to allow read/write (restrict appropriately for production)

Frontend

  1. Copy config.example.jsconfig.js
  2. Fill in your Firebase project credentials
  3. Open index.html in a browser or deploy as a static site

ESP32 Firmware

  1. Open FSR.ino in Arduino IDE
  2. Install dependencies:
    • FirebaseESP32 library
    • WiFi library (bundled with ESP32 board package)
  3. Create a secrets.h file in the same folder as FSR.ino with the following contents:
// secrets.h — DO NOT COMMIT
#define WIFI_SSID      "your_wifi_ssid"
#define WIFI_PASSWORD  "your_wifi_password"
#define FIREBASE_HOST  "your-project-default-rtdb.your-region.firebasedatabase.app"
#define FIREBASE_AUTH  "your_firebase_auth_key"
  1. Flash FSR.ino to your ESP32 board

Wiring

Component ESP32 Pin
FSR Seat A1 G32
FSR Seat A2 G33
FSR Seat A3 G34
FSR Seat A4 G35
LED A1 G13
LED A2 G27
LED A3 G14
LED A4 G25

Each FSR is wired as a voltage divider with a 10kΩ resistor. All FSRs use ADC1 pins to avoid interference from the Wi-Fi module, which disables ADC2 when active.


Features

  • Live seat status updates with under 2 second latency
  • Per-seat LED indicators that work offline
  • Occupancy percentage and count summary
  • High-density alert banner at 85% occupancy
  • Responsive web dashboard for desktop and mobile
  • Change-only Firebase writes to minimize network usage

Limitations

  • Fixed ADC threshold of 500 may need tuning depending on seat type, cushion thickness, or user weight
  • Dashboard requires active Wi-Fi and Firebase connection to reflect live data
  • One ESP32 handles up to 4 ADC1-connected sensors; additional seats require additional boards
  • Static objects on seats such as bags will register as occupied

Security

config.js contains your Firebase API key and secrets.h contains your WiFi and Firebase credentials. Neither file should ever be committed. Both are listed in .gitignore. Use config.example.js as the committed reference template for the frontend config. For the firmware, manually create secrets.h locally using the template provided above.


Tech Stack

  • Hardware: ESP32, FSR pressure sensors, LEDs
  • Firmware: C++ via Arduino IDE
  • Backend: Firebase Realtime Database
  • Frontend: HTML5, CSS3, Vanilla JavaScript, Firebase Web SDK

Contributors

Name
Akilan V S
Subash Venkat
Abhishek Prabakar

About

Real-time seat occupancy monitoring system using ESP32 + FSR pressure sensors. Sensor data is pushed to Firebase Realtime Database and visualized on a live web dashboard with occupancy stats, seat maps, and high-density alerts. Built for smart classrooms, libraries, and public spaces.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages

  • HTML 41.2%
  • CSS 36.3%
  • C++ 14.1%
  • JavaScript 8.4%