A Smart Lock Made With Raspberry Pi (Fingerprint and RFID)

Kamaluddin Khan
5 min readJan 7, 2021

You can also use RFID HAT For Raspberry Pi or RFID Breakout Board & for fingerprint use PiFinger Fingerprint HAT for Raspberry Pi

Have you ever wanted a more accessible way to secure your house? If so, this is the solution for you!

I made SafetyLock, this is a lock that can be opened with your fingerprint, a RFID badge and even through a website. Thanks to this concept you will always know who entered your home at what time of the day, you’ll also see how many times someone stepped in front of your door that day.

This is my first project in my field of study: Multimedia and communication Technology (MCT) at Howest (Kortrijk belgium).

Step 1: Components and Materials

For my project I used multiple parts that I will be listing below, I’ll also add the excel file with all the corresponding prices of the components as also the websites from which I ordered them.

Components:

Materials:

MDF wood 6mmHinges

Tools:

Step 2: Putting the Hardware Together

I have build my circuit by following my Fritzing scheme that I made, I uploaded the scheme below. The circuit has multiple sensors and an actuator that works together as one. I will list which different circuits there are, how you will need to connect these u can find in the scheme.

Step 3: Database Model (mySQL)

You can see my ERD diagram above, I will also link a dump file so you can import the database for yourself.

With this database you will be able to show multiple things like:

  • Who opened the door
  • Users who have access to enter
  • Which RFID-tags are linked with the system
  • How many fingerprints are stored
  • etc..

If you want to recreate this database you will need to make a new user so you can connect to your Raspberry Pi.

Step 4: Connection With the Raspberry Pi

First of all you will need to download MobaXterm, there is a free version available on their website. You’ll also need Raspbian which you can download here.

When you open MobaXterm you’ll need to click on ‘session’. When you have done that you’ll need to fill in the IP address of the Pi under ‘Remote Host’. Then you can enter a username which you can choose. then click on ‘OK’.

Normally after all these steps it will automatically start-up a connection. Then you’ll need to enter your password, and you’re connected.

Step 5: Software on the Raspberry Pi

For my code to work (which I will link below) you’ll need to install some packages and libraries. First thing that is needed is for you to update your Pi.

First, update your system’s package list by entering the following command: sudo apt-get update

Next, upgrade all your installed packages to their latest versions with the following command: sudo apt-get dist-upgrade

After you have installed the packages you’ll need to install some libraries:

Step 6: Setting Up a Webserver on Raspberry Pi

Go to your MobaXterm console.

we’re going to install Apache webserver. By doing so you will be able to open the website on any device connected to your network.

Type the following command and press enter: sudo apt-get install apache2

Now go to the folder: /var/www/html/

Here can you place all your files from your website and the index.html page will be opened whenever you browse to the IP of your Pi.

be careful not to type a capital I in index.html otherwise it will not automatically open the index page.

Step 7: Software: Python

I made multiple python scripts, I will link my github here so you can view the code for yourself. But I’ll explain it a little bit already.

I coded some classes for the PIR sensor and LCD. I used libraries for the fingerprint scanner and RFID-reader. Eventually I use only one file to make the full project work, this is named app.py. Also in this file I coded some routes so I could read data from my database and sent in to a json object which I then used in my javascript files.

Step 8: Software: Website

Because I wanted to see who opened the lock and when, I made a website to show me this data. Through the website you can also open the lock, closing it is not needed because after 7 seconds it closes automatically.

While the Pi is booting up, it will start running my python script. This will be taking care of getting the data to show on the website and making it possible to open the lock.

The site is also responsive so it could be opened on mobile without losing features or otherwise.

My code can be found on GitHub right here.

Step 9: Building the Case

For my case, I build a little home with a door in it. Also I put the smart lock in the front panel. This made it easier for me to integrate ma circuit in the case. All the holes for the sensors where cut out by a laser. I’ll put my file which I used to laser cut it, down below.

I also put pictures where you can see the process of building the case.

For the measurements I’ll also uploaded a file below where you can see my schematic of how you could recreate it.

Step 10: User Manuel

Here you can find a quick manual of how the project works.

Hopefully your house is better secured by the end of this tutorial!

Thank you for reading.

for the original Project

Originally published at https://www.hackster.io.

--

--