Intro: Arduino RFID Lock
The Arduino RFID lock
How does it work?
The Arduino RFID lock is a lock that can be opened easily, but is secure. The lock works with a server database that can register card codes. On the door there is a RFID reader connected to the lock. If the RFID reader reads a registered card the door will open. One of the pictures gives a schematic overview of the functionality of the Arduino RFID lock.
In this instructable there will be explained how to setup a database, how to connect the RFID reader and how to set up the Arduino controlled lock.
What materials are used?
· Arduino (we used an Uno, but any kind is possible)
· RFID reader
· Mechanical cylindrical lock
Step 1: The Database
How to make?
Step 1: The database and PHP.
This link has one file with all the codes in it. For the database use the PHP_final.rar.
Create a Mysql database that is named ‘doorsystem’ and exists of 4 columns:
In the upper image you can see the settings for the different columns. In the lower picture you see the different values for the columns. (Note the id is auto incremented so you don't have to manually assign it, and works as the key for the database)
Make sure you add an account named ‘admin’, the php files will automatically assign admin privileges to this account.
When the database is online, open the connection.php file and enter the database connection data.
The rest of the files can be uploaded as is. Check the system by going to the index page and logging in with your admin account. Try adding some users.
Step 2: The Lock and Arduino
As you can see in the Fritzing file above, connecting the servo to the Arduino is as simple as connecting the 5v, ground and signal cables. To be able to use a button from the inside, this is also connected, with a pull down resistor, so when the button is pressed, it sends a signal to the Arduino.
For attaching the servo to the lock, you may need to drill some holes in the lock.
The red dots indicate where to drill the holes.
Put the screws through the holes of the servo, and then through the lock, to attach the servo firmly to the lock. Of course any other kind of binding material would work, e.g. we used duct-tape in the testing phase.
Step 3: Connecting the RFID Reader
Use the Door_final.rar
The final Part of our system is to validate users in our system. We do this with a processing sketch that reads the incoming tags from a rfid reader.The sketch is named ‘Door_final’ The rfid reader is connected to a usb port on a computer or server. On that computer/server there’s a processing sketch that will validate the tags it gets and if a tag is validated sends a bit to the arduino to open the door.
We used this rfid reader. Other rfid readers may require work on the code before operating correctly.
The files come with a library that needs to be ‘installed’ in processing before the sketch will work.
the ‘Rfid_final’ sketch can be used to check what the tag of a card is so you can add a user to the database.
Step 4: Conclusion and Improvements
Use the Python file
The doorsystem is now working (if everything went correctly) but it is still very basic, it is up to you to customize the code to make it special. Down here we have listed some things that still need to be done and or can be improved on. The code has all been commented and should be easy to understand. If you made a special addition to the system mail us and maybe we’ll add it here. Note that the original system is open source but still belongs to us, don’t claim it is yours.
Things to improve:
- Create a better user login part (with for example the option to edit their own RFID code).
- More user-friendliness in the admin part (like a warning box before you delete a user).
- Make sure the door is actually closed before the Arduino turns the servo back.
- If the Python script could be fixed it would be a great improvement, and it would run natively on the Raspberry Pi.
Future development ideas:
-Log of people opening the door. This could be stored in mysql database.