In this tutorial, I will show you How to build Raspberry pi RFID attendance system complete process, Below are some of the things you need to know to complete this project
How to Setup MYSQL Database and PHPMyAdmin on the Raspberry Pi and I will try to give you an idea on this subject after which I will go to see the main project
For this project, you have to need flowing Equipment
- Raspberry Pi
- Micro SD Card
- Power Supply
- RC522 RFID Reader
- Breadboard
- Breadboard Wire
This book will help you to gain more knowledge about Raspberry Pi
Setting up MYSQL on a Raspberry Pi:
Before we get started with installing MySQL to our Raspberry Pi, we must first update our package list and all installed packages.
running the following two commands.
sudo apt update
sudo apt upgrade
The next step is to install the MySQL server software for your Raspberry Pi.
running the following commands Installing MySQL to the Raspberry Pi is
sudo apt install mariadb-server
Now you have to need to secure it by setting a password for the “root” user.
By default, MySQL is installed without any password set up meaning you can access the MySQL server without any authentication.
Run the following command to begin the MySQL securing process.
sudo mysql_secure_installation
Just follow the prompts to set a password for the root user and to secure your MySQL installation.
For a more secure installation, you should answer “Y” to all prompts if you want to access your Raspberry Pi’s MySQL server and start making changes or something work your databases, you can enter the following command.
sudo mysql -u root -p
You can now enter MYSQL commands to create, alter, and delete databases. Through this interface, you can also create or delete users and assign them the right to manage any database.
There are two different ways you can quit out of the MYSQL command line, the first of those is to type “quit” into the MySQL interface.
The other way of quitting out of the MYSQL command line is to press Ctrl + D.
Ok great, you will now have successfully set up MySQL on your Raspberry Pi.
Now time to Install PHPMyAdmin on the Raspberry Pi
To install the PHPMyAdmin package to our Raspberry Pi, we need to run the command below.sudo apt install phpmyadmin
sudo apt install phpmyadmin
You have to need to configure PHPMyAdmin to connect to our MYSQL server. We will also need to set up some details so that we can log in to the PHPMyAdmin software.
To do this select “<Yes>” at them all next prompt.
It will now ask you to set a password for PHPMyAdmin itself. It is best to set this password to something different to your root SQL password. Doing this will help secure the server.
This password is what PHPMyAdmin will use to connect to the MySQL server.
To do this, we will need to first login to the MySQL command-line interface using the “root” user with the password you set up.
sudo mysql -u root -p
Now time to run the command below to create a user and permit it to access all databases on the MySQL server.
Make sure you replace “username” with the username of your choice.
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
You can exit out of the MySQL command-line interface by typing “quit” in the terminal.
Configuring Apache for PHPMyAdminBefore you can load the PHPMyAdmin interface on our Raspberry Pi, we will need to make some configuration changes to Apache.
entering This the following into the terminal.
sudo nano /etc/apache2/apache2.conf
Now we need to add the following line to the bottom of this file.
Include /etc/phpmyadmin/apache.conf
Once done we can save and exit by pressing CTRL + X and then pressing Y then ENTER.
Now we need to restart the Apache service on our Raspberry Pi by running the command below.
sudo service apache2 restart
Configuring PHPMyAdmin
To do this, we need to run the following command on our Raspberry Pi.
sudo ln -s /usr/share/phpmyadmin /var/www/html
now you able to access your Raspberry Pi’s PHPMyAdmin interface from a web browser using your IP address.
In my case
http://169.254.219.186/phpmyadmin
Now time to build your Raspberry Pi RFID Attendance System
Notice
You have to need read this tutorial for how to Building the RFID RC522 Reader Circuit and how to Enabling the SPI interface go to
How to interface RFID-RC522 with Raspberry Pi
The first thing you need to do is move on from the link above and gain an idea about the RFID.
Raspberry pi to RFID-RC522 wiring
- SDA connects to Pin 24.
- SCK connects to Pin 23.
- MOSI connects to Pin 19.
- MISO connects to Pin 21.
- GND connects to Pin 6.
- RST connects to Pin 22.
- 3.3v connects to Pin 1.
Now your job is to create a database for the RFID attendance system. I will now show you how to create a database.
Now it is time to load up into the MYSQL command-line tool by running the following command
sudo mysql -u root -p
Now you need to create a database according to the command line given below
We will be naming this database, “attendancesy_stem“. To create this database, run the following command
CREATE DATABASE attendance_system;
With our database created, let’s now create a user called “attendance_admin” we will utilize this user in our Python scripts to read from our newly created database.
Make sure you set the password for this to something unique and hard to guess. For our example, we will be just using “your_password” as the password
CREATE USER 'attendance_admin'@'localhost' IDENTIFIED BY 'your_password';
Now that we have created our user we need to give it the rights to access our “attendancesy_stem” database.
We can do this by running the following command. This command will give our “attendance_admin” user full privileges on any table within our database.
GRANT ALL PRIVILEGES ON attendance_system.* TO 'attendance_admin'@'localhost';
Before we create our tables, we need to utilize the “use” command so that we are directly interacting with the “attendance_system” database.
Begin interacting with the database by running the following command.
use attendance_system;
Now that we are dealing directly with the database that we want to utilize we can now start creating the tables where all our data will be stored
You can leave the MYSQL tool by entering exit;
Recording a User in the Attendance System
Before we get writing our attendance system scripts, we need first to install the Python “MYSQL Connector” using pip.
Install the connector library by running the following command on your Pi.
sudo pip3 install mysql-connector-python
Recording a User in the Attendance System Code
Recording Attendance
Now you can check your Database for update
My Previous project
- PIR Motion Sensor using Raspberry Pi4 | Interfacing Tutorial
- Raspberry pi4 Workshop PIR Sensor -Email Sending Movement Detector using IFTTT
- Controlling a DC Motor with Raspberry Pi4
- How to Use the Raspberry Pi4 Camera And PIR Sensor to Send Emails
- How to Use the Raspberry Pi4 Camera And PIR Sensor to Send Emails
- Raspberry Pi4 Distance Sensor using the JSN-SR04T
- How to connect 16x2 LCD with Raspberry pi4
- How to interface RFID-RC522 with Raspberry Pi
Comments