The project is for a better aid for factors that need very effiecient and strong security
PrabhΔsa Mantra is a custom multi-factor authentication system designed for high-security entry control. It combines:
-
Facial Recognition (Laptop, Python + OpenCV)
-
Cryptographic TOTP Mantra transmitted through:
- Light channel (color flashes via phone screen)
- Sound channel (high-frequency tones)
The authentication lock is implemented on an ESP32-S3 microcontroller, which receives the mantra via sensors, verifies its integrity, computes its own TOTP, and grants/denies access.
This repository contains all hardware, software, and protocol details required to fully build, flash, and run the system.
The system uses two layers of authentication:
- Python script using OpenCV (LBPH recognizer)
- Runs continuously, scanning the camera feed
- When an authorized face is detected β sends
LISTEN_FOR_MANTRAto the ESP32
After receiving the signal:
-
ESP32 activates:
- TCS34725 Color Sensor
- MAX9814 Microphone (FFT-based audio decoding)
-
Waits for the user to transmit the PrabhΔsa Mantra from the mobile app:
- 6-digit TOTP (SHA-256, 30s window)
- Transmitted first as color flashes, then as sound tones
-
ESP32 decodes both sequences
-
Validates:
- Light == Sound consistency
- Light == ESP32βs own internally generated TOTP
If valid β sends ACCESS_GRANTED
Otherwise β sends ACCESS_DENIED
- ESP32-S3 DevKitC-1
- TCS34725 RGB Color Sensor
- MAX9814 Microphone + Automatic Gain Control
- USB-Serial connection to laptop
-
Flutter App (Android/iOS)
- Displays TOTP
- Emits Light+Sound Mantra
-
Firebase
- Authentication (email + password)
- Firestore user profiles
-
ESP32 C++ Code (Arduino Framework)
- TOTP (HMAC-SHA256 using mbedTLS)
- FFT audio classification
- TCS34725 color classification
- Serial commands + state machine
-
Python Script (Laptop)
- OpenCV LBPH face recognition
- Serial communication with ESP32
Base32 Secret Key:
GAXG2435ONV6Y3T7MFQZ227VMFQ4W4ZKWSKCA53KPOJ4NEYLTMZVKGIY=
TOTP Parameters
| Parameter | Value |
|---|---|
| Digits | 6 |
| Hash | SHA-256 |
| Step | 30 seconds |
| Window | Strict (0 tolerance) |
6 color flashes, each:
- 500 ms color
- 200 ms black gap
| Digit | Color | Hex |
|---|---|---|
| 0 | Red | #FF0000 |
| 1 | Green | #00FF00 |
| 2 | Blue | #0000FF |
| 3 | Yellow | #FFFF00 |
| 4 | Magenta | #FF00FF |
| 5 | Cyan | #00FFFF |
| 6 | Orange | #FFA500 |
| 7 | Purple | #800080 |
| 8 | White | #FFFFFF |
| 9 | Turquoise | #40E0D0 |
6 high-frequency tones, each:
- 500 ms tone
- 200 ms silence
| Digit | Frequency |
|---|---|
| 0 | 12000 Hz |
| 1 | 12500 Hz |
| 2 | 13000 Hz |
| 3 | 13500 Hz |
| 4 | 14000 Hz |
| 5 | 14500 Hz |
| 6 | 15000 Hz |
| 7 | 15500 Hz |
| 8 | 16000 Hz |
| 9 | 16500 Hz |
| Direction | Message | Meaning |
|---|---|---|
| ESP32 β Laptop | TIME_REQUEST |
ESP32 asks laptop for current epoch |
| Laptop β ESP32 | TIME_RESPONSE <epoch> |
Laptop sends UNIX time (sec) |
| Laptop β ESP32 | LISTEN_FOR_MANTRA |
Face recognized; begin mantra capture |
| ESP32 β Laptop | ACCESS_GRANTED |
Lock opens |
| ESP32 β Laptop | ACCESS_DENIED |
Lock stays closed |
| TCS34725 Pin | ESP32-S3 Pin |
|---|---|
| VIN | 3.3V |
| GND | GND |
| LED | 3.3V |
| SDA | GPIO 8 |
| SCL | GPIO 9 |
| MAX9814 Pin | ESP32-S3 |
|---|---|
| VDD | 3.3V |
| GND | GND |
| OUT | GPIO 4 (ADC1_CH3) |
+-----------------+
| Laptop |
| Face Detect |
+--------+--------+
|
| LISTEN_FOR_MANTRA
|
+--------v--------+
| ESP32 |
| State: LISTEN |
+--------+--------+
|
-------------------------
| |
+---v---+ +-----v-----+
| Light | | Sound |
| Decode| | Decode |
+---+---+ +-----+-----+
| |
-----------+------------
|
+--------v--------+
| Compare codes |
+--------+--------+
|
+------v------+
| Generate |
| TOTP |
+------+-------+
|
+----------v-----------+
| Access Granted? |
+----------+-----------+
|
Yes ------------------- No
| |
ACCESS_GRANTED ACCESS_DENIED
-
Install Espressif ESP32 Arduino Core
-
Select board: ESP32S3 Dev Module
-
Install libraries:
- Adafruit_TCS34725
- ArduinoFFT
-
Wire hardware as shown above
-
Flash
main.cppto the ESP32
conda install -c conda-forge opencv numpy
pip install pyserial opencv-contrib-pythonpython main.py/enroll
face1.jpg
face2.jpg
Features:
-
Firebase Login
-
Biometric Unlock
-
TOTP generation using above secret
-
βTRANSMITβ button to emit:
- Light flashes (full-screen color)
- Audio tones (Ultrasonic band)
-
Run Python script β ensure βTIME_REQUESTβ appears
-
Bring face into camera β wait for recognition
-
When instructed, transmit mantra from phone:
- Hold phone screen 1β5 cm from color sensor
- Hold speaker close to MAX9814
-
Check ACCESS_GRANTED / ACCESS_DENIED on laptop
- Two-factor authentication (biometric + cryptographic)
- Offline, air-gapped transmission channels
- TOTP SHA-256 with strict window consistency
- Secret never transmitted over air or serial
- Sound + Light redundancy to prevent spoofing
- Laptop provides authoritative time sync
/
βββ firmware/
β βββ main.cpp # ESP32-S3 Firmware
βββ laptop/
β βββ main.py # Face recognition + serial control
βββ flutter_app/ # Mobile app source (if included)
βββ hardware/
β βββ wiring_diagram.png
β βββ notes.md
βββ README.md
Contributions are welcome! Feel free to open:
- Issues
- Pull Requests
- Feature suggestions