IoT Based Smart and Secure Lock V2.0

by make2explore in Circuits > Electronics

1051 Views, 4 Favorites, 0 Comments

IoT Based Smart and Secure Lock V2.0

Your-dashboard-Hackster.io.gif
Instructable-thumb-2.png

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.
  • Nextion Touchscreen HMI Display is used for interacting with this door lock.

Supplies

Parts Required

  1. NodeMCU ESP32 Development Board
  2. RC522 RFID Reader Module
  3. FPM10A Fingerprint Sensor
  4. 3.5" Nextion Touchscreen HMI Display
  5. MB102 Breadboard Power Supply module
  6. 12V Solenoid Lock
  7. 2 Channel Relay Board 5V
  8. Batteries - 7.4V LiPo, 11.1V LiPo and Power Bank.

ESP32 and MFRC522 RFID Interfacing

IoTLock-esp32-RFID.png

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.

ESP32 and Fingerprint Sensor Interfacing

IoTLock-esp32-Fingerprint.png

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 enroll sample 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.

ESP32 and Nextion Display Interfacing

IoTLock-esp32-Nextion.png

Important Points to Note before interfacing

-- 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 rename nexupload.cpp and 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.

Main Circuit Diagram

IoTLock-esp32-fullSchematics.png

Demonstration

IoT Based Smart Lock V2.0

In this video we've given detailed step wise explanation to build and implement this project.

Documentation

Project Source code, Schematics and all Nextion Display design files are available on following GitHub Repo

https://github.com/make2explore/IoTbasedLockV2.0

Project's improvement suggestions, Bugs, Queries and solutions are most welcomed.