Built to order

IoT Door Lock with OTP Authentication via Telegram

This project builds an IoT door lock where access is granted only by a one-time password delivered over Telegram. The owner requests an OTP from a Telegram bot, the ESP32 verifies the code typed on the 4x4 keypad, and the solenoid lock releases only on a match. A buzzer sounds on wrong attempts and every event is logged with a timestamp. Suitable for B.E./B.Tech final-year projects in IoT & Embedded.

Chat on WhatsApp — get a quotation

IoT & Embedded ESP32 · Wi-FiTelegram Bot APIArduino IDE · C/C++4x4 membrane keypad16x2 LCD · I2C12V solenoid lock · relayActive buzzerLittleFS event logHardware
IoT Door Lock with OTP Authentication via Telegram — project thumbnail preview
More project photos (3)

The problem

Shared keys get copied and fixed PIN codes get shared around — both defeat the point of a lock. One-time passwords solve this cleanly: a fresh code is generated for every entry, delivered over an existing messaging channel, and expires after a short window, so a leaked code is useless. This project implements exactly that on low-cost hardware. An ESP32 hosts the lock controller and talks to a Telegram bot over Wi-Fi; when the owner sends a request, a random 6-digit OTP is generated, pushed to Telegram, and accepted on the 4x4 keypad for a configurable validity window. On a match the relay fires the 12 V solenoid lock and the LCD confirms access; on repeated wrong entries a buzzer raises a local alarm. The design stays deliberately offline-first for the lock mechanism itself — the keypad, LCD and solenoid work without internet; only OTP delivery needs Wi-Fi.

SYSTEM FLOW

7 components 8 connections

Live flow
Drag to explore
100%
userOwner

Requests an OTP from the Telegram bot and receives the code in the registered chat.

Follow the working sequence

How it works

  1. The owner sends an OTP request to the project's Telegram bot; the ESP32 generates a random 6-digit code and records its issue time.
  2. The bot delivers the OTP to the owner's registered Telegram chat, and the LCD switches to "Enter OTP" mode.
  3. The visitor types the code on the 4x4 keypad; the firmware compares it digit-by-digit against the stored OTP and its validity window.
  4. On a match, the ESP32 energizes the relay for the configured hold time, the solenoid retracts, and the LCD shows "ACCESS GRANTED".
  5. On a mismatch, the attempt counter increments and the LCD shows "WRONG OTP"; after three failures the buzzer sounds and a Telegram alert is pushed.
  6. Every event — OTP issued, access granted, failed attempt, alarm — is timestamped and appended to the on-device log, retrievable with a Telegram command.
  7. The OTP expires after the validity window or after first successful use, whichever comes first, so each code is strictly single-use.

Tech stack:

  • ESP32 development board (Wi-Fi + Bluetooth)
  • Arduino IDE (C/C++ firmware)
  • Telegram Bot API over HTTPS
  • 4x4 membrane keypad + 16x2 LCD (I2C backpack)
  • 12 V solenoid lock + single-channel relay module
  • Active buzzer for alarm
  • 12 V DC adapter with buck converter for logic supply
  • SPIFFS/LittleFS on-device event log
Parameter Value
Controller ESP32 (dual-core, Wi-Fi), 3.3 V logic
OTP format 6 digits, random per request
Default validity window Approximately 2 minutes (configurable in firmware)
Keypad 4x4 membrane matrix
Display 16x2 character LCD with I2C backpack
Lock actuator 12 V DC solenoid lock, relay-driven
Wrong-attempt alarm Buzzer after 3 consecutive failures + Telegram alert
Event log Timestamped, stored in on-board flash (approx. 500 entries)
Power 12 V DC adapter; logic stepped to 5 V/3.3 V
Connectivity Wi-Fi 802.11 b/g/n for Telegram; lock works locally without it

Project features

  • [OTP over Telegram] The owner requests a code via a Telegram bot; the ESP32 generates a random 6-digit OTP, sends it to the registered chat, and accepts it on the keypad within a configurable validity window (default approximately 2 minutes).
  • [Keypad entry with LCD feedback] A 4x4 membrane keypad accepts the OTP while the 16x2 LCD shows entry prompts, remaining validity and lock status — no phone needed at the door itself.
  • [Solenoid lock actuation] A relay module drives the 12 V solenoid lock; the strike releases only on a verified match and re-locks automatically after a configurable hold time.
  • [Wrong-attempt alarm] Three consecutive wrong entries trigger the buzzer and a Telegram intrusion alert, with the keypad locked out for a cooldown period.
  • [Event log with timestamps] Every OTP request, successful entry, failed attempt and alarm is timestamped and stored in the ESP32's flash, viewable on demand via the Telegram bot.
  • [Owner controls via Telegram] The owner can request a new OTP, revoke the current one, check the event log and lock/unlock remotely from the Telegram chat.
  • [Fail-safe behavior] Power loss leaves the solenoid in its locked state (fail-secure configuration); the keypad and local verification keep working if Wi-Fi drops, using the last-issued OTP window.

What is included

  • Working prototype: ESP32 board, keypad, LCD, relay, solenoid lock and buzzer wired on a base
  • Complete ESP32 firmware (OTP generation, Telegram bot handling, keypad/LCD drivers, lock logic)
  • Telegram bot creation and token setup guide
  • Wiring diagram and connection table
  • Calibration/configuration guide (validity window, hold time, attempt limits)
  • Project report PDF (background, OTP security concept, methodology, working, results)
  • PPT presentation for final review
  • Viva Q&A preparation document (ESP32, Telegram API, relay interfacing, OTP security)

Limitations & prerequisites

  • OTP delivery needs an active internet connection; without Wi-Fi no new OTP can be issued (the lock itself still works locally with the last window).
  • Telegram message delivery typically takes a few seconds — this is a messaging-channel delay, not a lock defect, and the validity window accounts for it.
  • The solenoid draws significant current when energized; the 12 V adapter must be rated for the lock's inrush (specified in the wiring guide).
  • Event log capacity is bounded by flash size (approximately 500 entries); old entries are overwritten in a ring buffer.
  • The prototype demonstrates the concept on a demo door rig; fitting it to a real door frame is installation work outside the project scope.
  • Like any keypad system, the code can be shoulder-surfed — the single-use OTP design is the mitigation, and the report explains this honestly.

Frequently Asked Questions

How is this different from a fixed-PIN lock?

A fixed PIN can be shared, copied or guessed over time. Here every entry needs a fresh OTP that expires in about 2 minutes and works only once — a leaked code is useless, and the owner controls issuance from Telegram.

What happens if the Wi-Fi goes down?

The lock keeps working locally: the keypad, LCD and solenoid run entirely on the ESP32. Only new OTP issuance over Telegram needs internet; the currently valid OTP window continues to work.

Can the owner open the door remotely?

Yes — a Telegram command unlocks the relay directly, and every remote unlock is logged with a timestamp like any other event.

Is the OTP secure?

The OTP is a random 6-digit code valid for roughly 2 minutes and single-use. Security rests on the owner's Telegram account; the report documents this honestly along with the wrong-attempt lockout as brute-force mitigation.

What powers the solenoid?

A 12 V DC adapter; a buck converter steps down to 5 V/3.3 V for the ESP32 and logic. The relay isolates the lock's 12 V side from the controller.

Is this project suitable for a final-year project?

Yes — for IoT & Embedded programs. It combines embedded firmware, relay/actuator interfacing, keypad/LCD I/O, HTTPS bot communication and a real security concept (OTP lifecycle) in one demonstrable build. Suitable for B.E./B.Tech final-year projects in IoT & Embedded.

Components & software requirements
  • ESP32 development board (Wi-Fi + Bluetooth)
  • Arduino IDE (C/C++ firmware)
  • Telegram Bot API over HTTPS
  • 4x4 membrane keypad + 16x2 LCD (I2C backpack)
  • 12 V solenoid lock + single-channel relay module
  • Active buzzer for alarm
  • 12 V DC adapter with buck converter for logic supply
  • SPIFFS/LittleFS on-device event log
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Get a quotation