Introduction: SafetyLock: a Smart Lock Made With Raspberry Pi (Fingerprint and RFID)

About: student MCT at Howest (Kortrijk Belgium)

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.


  • Raspberry Pi 3 model B+
  • Raspberry Pi power supply
  • Raspberry Pi T-cobbler
  • Electronic doorlock 25cm
  • Electronic doorlock 6mm
  • Universal AC-DC adaptor
  • Relay module Velleman
  • PIR motion sensor Velleman
  • RFID module - RC522
  • RFID tag
  • Optical fingerprint scanner
  • USB to TLL serial adaptor
  • Raspberry Pi camera module V2
  • LCD display 16*2
  • Jumper wires (m to f) and (m to m)
  • 10 Kohm resistors


  • MDF wood 6mm
  • Hinges


  • Soldering iron
  • Super glue
  • Saw
  • Sandpaper
  • Lasercutter

In the Excel file below you can see the complete price list.

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.

  1. There is a PIR sensor, this sensor will detect the motion in front of the door.
  2. A RFID-reader which will see if the used RFID tag can enter the home or not.
  3. A fingerprint scanner which works the same way as the RFID-reader but with fingerprints.
  4. A LCD screen which displays the IP of the website and if the acces was denied or granted.
  5. The door lock which opens and closes in certain circumstances.

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 acces to enter
  • Which RFID-tags are linked with the sytem
  • 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 startup 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:

  • Flask
  • flask_cors
  • datetime
  • threading
  • mfrc522
  • time
  • pyfingerprint
  • subprocess
  • mysql
  • SocketIO

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 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 smartlock 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 lasercut it, down below.

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

For the measurments 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.

Sensors Contest

Participated in the
Sensors Contest