DIY OTP primarily based Locker to Open Door Lock Wirelessly


We regularly want an OTP primarily based locker that permits us to share a digital key for one-time use to unlock it. This sort of clever door lock system offers the flexibleness to grant entry to supply individuals or buddies through the use of an OTP (One-Time Password), whereas additionally notifying us about every locking and unlocking occasion.

Nonetheless, these locks are usually fairly costly. At present, we are going to design a sensible door lock that assists you in creating an OTP which could be shared with buddies, kinfolk, or parcel supply personnel for momentary entry. The first management of the door stays with you.

The most effective half is that you may obtain messages and notifications, in addition to management each step, utilizing your favourite chat app—no extra installations are required.

Wireless OTP based Locker
OTP-based sensible wi-fi locking system

Beforehand we construct the OTP-Based mostly Sensible Wi-fi Locking System Utilizing Arduino.

Right here, we are going to make the most of Telegram to generate or share the OTP and lock/unlock the door utilizing the offered OTP.

So let’s start the design with a group of the next components-

Invoice of Supplies:

Elements Amount  Description Worth Approx INR
ESP 32 1 WiFi Board  400
Solenoid lock 1 5V Seloniod  100
Relay Module  1 5v SPST  100
Wires 10 Jumper wires  20
Whole  620

Getting ready Chat Bot

Initially, we have now to create an AI BOT to make our AI digital camera chat with us, reply to us, and evaluate our messages. This AI BOT receives the message, processes that message, and responds to us as an alternative of a human being.

Additionally Test: AI BoT utilizing ML

For this, we will create BOT in any messaging app like WhatsApp, Telegram, or every other messaging app. For now, we’re getting ready a Telegram chatbot because it’s open supply, easy, simple, and free to make use of. First, we have to go to Botfather in Telegram after which we have to create a brand new chatbot. It is possible for you to to see the directions on the Telegram web site to create a brand new bot and get the API token.

Now, after creating the brand new bot, get the API token. This API token helps us with getting the message, reviving the message, and responding utilizing the BOT utilizing our Telegram channel. After receiving the API token, save the API token as we’d like it within the subsequent a part of coding.

Subsequent, begin the BOT by looking for the BOT title you might have simply created.

My bot’s title is Darwin. Therefore, I’ll seek for Darwin after which begin my bot with the command /begin.

Chat BoT for OTP based Locker
Chatbot setup

You’ll be able to learn the next earlier DIY article for reference on creating the telegram bot and interfacing with Arduino: DIY Chat BoT.

OTP-based Locker – Coding

To start, let’s add the ESP32 board to the Arduino IDE. After that, we have to set up the Telegram async library in Arduino. With these preparations accomplished, we at the moment are prepared to start out coding.

First, we are going to create an array of letters and numbers that will probably be used to generate the OTP. This array will function the premise for producing random OTP codes.

Subsequent, we have to set the Wi-Fi credentials to which the lock will join. This entails offering the suitable SSID and password for the specified Wi-Fi community.

Lastly, we have to set the API key of the Telegram bot that we created within the earlier steps. This API key will enable our code to interface with the Telegram platform and ship/obtain messages.

With these preliminary configurations in place, we will proceed with the remainder of the code implementation.

OTP based locker system Code
Code for OTP-based locker system

Now, let’s create the loop operate the place we will probably be checking the incoming messages to the Telegram bot. If the acquired message is to generate an OTP, we are going to confirm the password, which is thought solely to the admin or the actual proprietor of the lock. As soon as the password is verified, the lock will generate the OTP and ship a reply message containing the OTP to the admin.

The admin can then use this OTP to unlock the lock for themselves or share it with anybody they want to grant one-time entry to.

Moreover, we are going to create one other situation within the loop operate to verify the OTP despatched to the lock by way of a Telegram message. If the OTP is right, the lock will unlock the door. In any other case, it is going to reply with a message instructing the person to regenerate the OTP.

As soon as the coding is full, add the code to the ESP32 board by deciding on the suitable port and board settings.

OTP based Locker System Code
OTP-based Locker System Code

OTP-based Locker Circuit Diagram

Start by establishing the connection between the relay and ESP as per the offered circuit diagram. Subsequent, join the solenoid lock to the NO (Usually Open) pin of the relay. Join one wire from the solenoid to the 5V energy provide’s GND (Floor) terminal, and join the opposite -Ve (Unfavorable) terminal of the 5V energy provide to the Frequent pin of the relay.

Connection for OTP-based Locker System

Testing OTP-based Locker

Telegram BoT to open door lock using OTP
Telegram OTP lock
Telegram BOT for Door Lock

To start, energy up the system and make sure that it’s locked. Wait a couple of seconds for it to ascertain a connection together with your Wi-Fi community and the Telegram API. Subsequent, open the Telegram bot you might have beforehand created and ship a message to generate the OTP.

Be certain to incorporate the distinctive password you might have set within the code. If the password is right, the lock will generate the OTP and ship it to you as a reply in Telegram.

Now, you may create a QR code from the Telegram bot. Share this QR code with the individual you want to grant entry to, together with the OTP you acquired. The individual can then scan the QR code and open the Telegram bot. They need to ship the OTP to unlock the door.

If the OTP is right, the lock will reply with a message confirming the door unlock, and it’ll proceed to unlock the door utilizing the solenoid lock linked to the relay.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles