In this project we've built IoT based smart and secure lock which have 4 layers of access. RFID + PIN + Fingerprint + OTP.
Things used in this project
Hardware components
Story
In this project we've built IoT based smart lock which have 4 layers of access. RFID + PIN + Fingerprint + OTP. We have slightly upgraded our previous version of the project. In this version we are going to add one more accessibility layer. That is biometric, means, we've added fingerprint based authentication.
-Also we are going to use different MCU development Board. In version 1 we have used Particle Photon Board, but in this project we will use ESP32 development board.
-So now, if user want to unlock this lock, then he or she should have Valid RFID, Fingerprint, PIN and OTP, means one time password.
-Also we have programmed this lock system to keep record data of user entries with user name and timestamp. This data will recorded on our dedicated mySQL database which is hosted on our webserver, hence the system Administrator can login to that web portal and, keep track of how many time this lock got opened.
-NextionTouchscreen HMI Display is used for interacting with this door lock.
Step 1: ESP32 and MFRC522 RFID Interfacing
Connect the components as shown in circuit diagram.
-Then install the latest Arduino IDE (if previously not install on your system)
-Install ESP32 Board core into an Arduino IDE - Video Tutorial
-Install MFRC522 library from Arduino IDE library manager
-use Dumpinfo sample code from library to check the working of interfacing
-In code, make sure to change the SS and RST pins as
#define SS_PIN 21 /*SDA/SS Pin of RFID Reader*/
#define RST_PIN 22 /*RESET Pin of RFID Reader*/
Using this example (Dumpinfo), get the UID's of RFID cards/Tags. Note them down. We'll require those to add authorized users in final code.
Step 2: ESP32 and Fingerprint Sensor Interfacing
Connect the components as shown in circuit diagram.
-Then install the latest Arduino IDE (if previously not install on your system)
-Install ESP32 Board core into an Arduino IDE - Video Tutorial
-Install Adafruit-Fingerprint-Sensor-Library from Arduino IDE library manager
-use enrollsample sketch from library to check the working of interfacing
-Use this sketch to enroll correct authorized fingers data in Sensors memory.
-It is recommended to enroll at least 4-5 templates (of one finger) for each user.
-Also keep note of each users template numbers(Finger ID's). We'll require those to add authorized users in final code.
Step 3: ESP32 and Nextion Display Interfacing
Important Points to Note before interfacing
-Download Iteadlib Nextion library from its official website. or Repository
-Install the Nextion Library in the Arduino IDE
-- You can use method of adding zip library -- Sketch > Include Library > Add.ZIP Library
-Before using Nextion library, we need to configure the Nextion Library for use with the ESP32. It is preconfigured for the ATMega 2560. We need to do some changes.
-ESP32 have 3 Hardware serial ports.
-In this project(in final circuit), we have connected Nextion display to Serial1 and Fingerprint sensor to Serial2
-So we'll use as as following
- dbSerial enabled --- (To get the debug messages ON on Serial)
- nexSerial to use our hardware serial i.e Serial1
- Fingerprint sensor to Serial2
To do above config open and edit NexConfig.h, and locate following line
#define DUBUG_SERIAL_ENABLE
and ensure that it is not commented out.
-Then, locate the line defining nexSerial
#define nexSerial Serial1
ensure it is Serial1 (pins GPIO09/GPIO10)
-Then next, Edit NexHardware.cpp to change the baud rates.
locate the nexInit() function, here we configure the baud rate for Serial Monitor and Nextion. as shown
dbSerial.begin(115200);
nexSerial.begin(9600);
Finally, Arduino's AVR Software serial is not compatible with Nextion, It throws errors. So we have to comment out following line from ‘Nexupload.cpp’ file of nextion library.
#include<softwareserial.h>
-Or you can just renamenexupload.cppand nexupload.h files from Nextion library folder itself with any other extensions like e.g nexupload.txt
-Among above two workarounds any one will bypass the nexupload error of nextion library.
To know more about how to get started with with Nextion display, refer this video, there we have explained how use Nextion IDE and how to upload GUI to Nextion HMI Touchscreen Display etc.
Step 4: Main Circuit Diagram
Demo
Project Source code, Schematics and all Nextion Display design files are available on following GitHub Repo
Project's improvement suggestions, Bugs, Queries and solutions are most welcomed.
Schematics
Code
The article was first published in hackster, April 5, 2022
cr: https://www.hackster.io/make2explore/iot-based-smart-and-secure-lock-v2-0-cfd6af
author: make2explore