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.

Components:

  • 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

Materials:

  • MDF wood 6mm
  • Hinges

Tools:

  • 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
  • RPI.GPIO
  • 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 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 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

This is an entry in the
Sensors Contest

Share

    Recommendations

    • Classroom Science Contest

      Classroom Science Contest
    • Paint Challenge

      Paint Challenge
    • Games Contest

      Games Contest

    7 Discussions

    0
    None
    yannick.godeau

    4 weeks ago

    really well written instructable

    0
    None
    vodkalolz

    Tip 4 weeks ago on Step 1

    I found your EXCEL file now. I hope it does not contain a Virus...forcing your readers to download a file is a clear security flaw. Even if on paper you cant put a virus into a Excel document...( pretty sure you can but have not checked if it has been fixed ) but anywayes there is always the risk of security flaws that have not been made offical yet that blackhats use. So there could be a "zero-day-exploit" we did not know about .excel files. Those the NSA find and keep on stock for when they need them :S So please write it all on the guide page instead.

    0
    None
    vodkalolz

    Tip 4 weeks ago

    And please add a picture to the hardware list also. A picture you can click on and it becomes full seize. Because in worst case people will need to find the part not based on name, but looks. Or a combination. Sometimes item descriptions on Amazon are not perfect, so you have to use your eyes to judge what part is the right one and not. In case your US link/item is sold out/gone. Then we got a picture and a short item description to go fom :)

    0
    None
    vodkalolz

    Tip 4 weeks ago

    If possible please give Amazon links to the hardware needed. There are so many devices, vendors, copies, different Voltages, Watts, Amps...it is a jungle where you easily buy the wrong parts if your new like me :) Also I use Amazon.de or Amazon.co.uk because I live in the EU to avoid import taxes from outside the EU. Amazon is just a fantastic place to find parts no matter where you live in the world :) If you link US website a guy like me could get stuck not able to find the same part from another vendor here in EU :) But with amazon you can always find the right part on the other Amazon sites if somebody links the parts on the .com domain :) I could even use Amazon.(France) and Amazon.(Spain) if I needed to, to find the parts I need :)

    0
    None
    vodkalolz

    Question 4 weeks ago

    Can it be made with a Raspberry Pi Zero W?

    I assume so, but have to ask :)

    1
    None
    vodkalolz

    4 weeks ago

    Really good work!

    I love how you think, and go all in upgrading the normal fingerprint sensor to a smart sensor/lock.

    Thanks for sharing!