Introduction: Un/Lock IT - Smart Lock (Web & RFID)
Don't we all want an easier way to secure our houses. That's the reason I made Un/Lock IT.
Un/Lock IT is a lock than can be opened thanks to this web application or via an RFID batch. This makes it a lot more difficult to enter into your home and makes a key worthless. The lock is equipped with a motion sensor that tells you when someone is at your door. This is all build up on a electric door opener.
This concept is being developped as a final project within the first year of multimedia and communication technology, shortly NMCT, at Howest Kortrijk, Belgium.
Step 1: Hardware: the Materials
In order to build this concept you will need the following items:
- Raspberry Pi
- GEV Electronic door opener (e.g. https://www.gev.de/ )
- 12V AC Adapter
- Relay module
- PIR Motion Sensor
- RFID Module: RC522
- RFID card, tag, ...
- Resistor (10 kOhm)
- 3D-printed case
- MDF plates
You can find the prices and the links where I bought these items at the end of this instructables file, in the BOM file.
Step 2: Hardware: Put It Together
The diagram above shows how the circuit is built. Below is also a small explanation.
In the concept, there are 3 seperate circuits which are communicating together.
- There is the PIR sensor, which has 3 pins, that is attached to the + (pos.) side, - (neg) side and to a GPIO with an 10 kOhm resistor in between.
- Second is the RFID-reader. In the list below you see which pin is connected to which pin of the Raspberry Pi
- Third and last is the electronic opener itself. The opener is connected to a 12V adapter and then leads to an Relay (NO side). That relay wil go to the + (pos.) side, - (neg) side and to a GPIO.
SDA -> CE0
SCK -> SCLK
MOSI -> SPI MOSI
MISO -> SPI MISO
Gnd -> Gnd
RST -> GPIO 25
3.3V -> 3.3V
Step 3: Database (mySQL)
Above you see my ERD Diagram, this shows you the structure of my database.
Make sure that everything is linked to each other except for the contact table.
Every table gets connected to the system table. This is important so you can see:
- who may access
- who closed the door yesterday
- to have multiple devices
To create this database you have to first of all create a new user so you can make the connection from database to pycharm.
Step 4: Raspberry Pi Setup Part 1
When you start programming in your flask project on the pi, keep in mind that you need to install python3 and a handfull of other packages to make it possible to let your raspberry pi run the project.
You need to install:
Mysql: server, client and the connector
Step 5: Software: Web Application
In order to have the possibility to open and close a lock trough web, and to see the data that the lock and the sensor captures, I've set up a website running on the pi through flask.
The whole application includes the flask project, this project also controls the relay, which opens and closes the electronical opener.
Next to the flask application, there are 2 seperate scripts running.
- One that controls the RFID reader
- another one that controls the PIR sensor
Code can be found on GitHub:
Step 6: Raspberry Pi Setup Part 2
In my concept the pi starts the Flask and the other 2 scripts by default when you boot the raspberry pi.
This is by making an sh-script to make this run like a startscript. So when the pi boots up he will perform the commands that are in this script.
Also wifi is enabled. This makes it possible to surf to your WAN address and communicate wireless with the raspberry pi.
Attention! This only works in the same network otherwise you need to connect the pi to your router and turn Port Forwarding on.
Step 7: Casing: 3D Model
For housing my RFID-reader and my PIR sensor, I opted for a 3D printed box. This box will hang on the wall. When you want to go in with the batch, you need to hold your batch on the black zone.
I opted for this because it's lightweighted and very easy to work with. The round shape on top is just the cap of my PIRsensor. I made a hole in my drawing which fits perfectly.
H => 16cm
W => 7cm
D => 3cm
Step 8: Casing: Door
To have a clear and good concept to show the lectors of Howest, I made a miniature door. I've made this door from MDF. Eventualy I used glue as well as nails to make the door from the plates I had. In that way the glue is supported by the nails so it can't fall apart.
2 * 38x10cm
2 * 30x10cm
2 * 28x15cm
Step 9: The Final Product
So on these pictures you see the final product, this is my lock with a door for presentation purpose only.
So this is Un/Lock IT.
Step 10: Files
Participated in the
Internet of Things Contest 2017