In this article, we are going to discuss the design process of our Arduino Radio Frequency Identification (RFID) Database Security System Project. This will walk you through the way I design my own RFID Project that connects to the database to verify if an RFID tag is allowed or not.
There are lots of tutorials online that I have read about this and I seem to be confused about some of the stuff that is being discussed. This is my own design process on how I would create the project and I am hoping that beginners could get something from this.
I have divided this project into several posts so as to focus on the important stuff per each post.
- Designing the Project
- Create database to store our RFID code using SQLLite
- Create the application that would interact with the database
- Putting it all together
Please watch the following demo for the final output.
Designing the Project
The following diagram shows the design diagram of my Arduino-powered RFID Database Security System.
Let us discuss each block of the diagram to know more about the role of each component
Radio Frequency Identification or RFID in short is a contactless technology being used in tollgate systems, security and access control, and so on. It consists mainly of two components. The transponder or tag will identify a user or an object and a Transceiver or Reader/Writer modules that will emit the electromagnetic field.
Both the RFID tag or the reader/writer does not need to be in line of sight or in clear contact with each other making this a good technology in many of our Internet of Things Project.
In this project, we are gonna be using an MFRC522 RFID Reader that will be powered by our Arduino to read our tag or card. Please see the following wikipedia page to know more about RFID Technology.
A database will contain our collection of data. In our case, this will contain the list of valid RFID code that is able to access our security system. We will be storing a list of valid RFID codes in our table.
Supposed we have a table called Students that contains the following information above. If we map our RFID tags or key per each student then we would be able to validate if the following tag or key is authenticated and is allowed entry.
There are lots of choices in choosing your database. You can use MySQL or PostgreSQL or any other database of your choice. The only problem with those databases is that you need to have knowledge in administration, configuration, and running of it. If you are not familiar with those items then you will have to study a bit. In this project, we are gonna be using SQLLite to create our database.
If you want to jump in on how to create the database that we are gonna be using in this project then click this link. The relative ease of using SQLLite will shift your focus on coding your application rather than understanding the database terms.
Why do we need an application between our database and our Arduino Microcontroller? What is an application by the way? As good as our Arduino component is in interfacing with our electronic components such as the MFRC522 Card Reader or a servo motor connected to the door that will get open or closed depending if an RFID tag or key is authenticated or not. It does not have the capability to directly communicate with the database.
An “Application” is our “interface” to the database. This will be the one to insert, delete or query records from the database. In return, our Arduino project will communicate with the application thru its interfaces. An application can be built depending on your choice. Some use PHP, Java, or Python to communicate with the database. In our case project, we will be using Python and we will develop a REST interface that returns a JSON response.
In future articles, I will write about what is REST and JSON specifically for Microcontroller or Internet of Things (IOT) projects. But for this project, we will retrieve information from our application and parse it back to the Arduino to verify if an RFID tag or key is authenticated or not.
The image above is a sample response that we will be returned by the application if we pass in a sample rf_id_code, it will return to us a JSON response if user is authorized or not.
We will use the ESP8266 ESP-01 to communicate with our application thru wireless means. This small module contains the capability to execute TCP/IP connections.
We will program the ESP-01 separately from the Arduino so that it can retrieve the JSON response coming from our application. If you want to jump in and learn how to program ESP-01 using your Arduino then read the following link.
It will communicate with Arduino by using the Serial Interface to pass in the JSON response from the application.
The Arduino will read the RFID tag from the MFRC522 reader. It will retrieve the RFID detail from either the tag or key. We will extract the UID of each tag or key whenever we placed it near the reader. The extracted UID will then be sent to the ESP 8266 ESP-01 thru the serial interface.
The ESP8266 ESP-01 would then communicate with our Application by passing the RFID UID. Whatever the response from the application will then be sent back to the Arduino by serial interface also.
The Arduino will then parse the response and do the necessary action base on the message coming from the ESP-01. If the RFID tag is authorized then it could trigger other events such as sending commands to servo motors to open the door. In our project, we will just be lighting up LED.
In the next part of this Arduino RFID Database Security System, we will be discussing how to create a database that will store our valid RFID. Please click the following link.