So, today we will make a smart attendance system that can reliably check the punch in and punch out times. It follows two steps to confirm attendance:
- It checks the face of the person.
- Then it checks the RFID tag to mark attendance.
What can it do?
- It can automatically record the entry and exit times (through a gate/door) using low cost RFID tags.
- It has a face recognition feature for noting the entry and exit. This ensures accuracy and hence, no cheating takes place.
- It can automatically save data and keep a record of entry and exit with the help of a facial picture.
Where can it be used?
- Offices (for attendance).
- Hotels (to automatically record check in and check out times with the help of face recognition for safety).
- Airports (for automatic check in and check out with the help smart RFID airline ticket).
- Hall, multiplexes, banks, auditoriums (for managing entry and exit of the crowd).
Before starting our project, let’s collect the following components:
Bill of materials
Before starting our code, we need to setup some libraries in our Arduino IDE
To do so, go to Tools → Manage Libraries → Library Manager and install the following libraries:
- Ug82 Oled library
Then search and install the libraries
After that, setup the following libraries for Python:
- Face recognition
To install the above libraries in Python, follow the instructions given in the libraries’ official page
Or you can use the following command to install the library:
sudo pip install library name
Now after doing all the basic setup, we can start our coding.
Here, we create three codes for three different functions
- The SD card writing code
- The RFID reading code
- The face recognition code
The SD card writing code
This part of the code reads the name sent by the Raspberry Pi and the RFID and then saves the attendance data (date and time) in the SD card.
First of all, we will initialise the libraries like Time, SD, SPI, Wire. These will be followed by the variables, which will store different values. (Refer Fig 1.)
Now, we create a setup function to setup the baud rate for serial communication, SPI and I2C. (Refer Fig 2.)
Next, we will create a loop function that will check the name stored in the RFID device and the face that was recognised by the Raspberry Pi. This will call the function named ‘attend’ to save the data in the SD card. (Refer Fig 3.)
Now, we will create a function called ‘attend’ that will save the attendance data to the SD card. (Refer Fig 4)
Now our SD card code is finished.
The RFID reading code
In this code, we will include the libraries like MFRC522, SPI and Software Serial along with the pin nos. for Software Serial (Refer Fig 5.)
After that, we setup the RFID card and Software Serial baud rate in the setup function. (Refer Fig 6.)
Then we create a loop function that will check the RFID for a person’s name and will later send it from the RFID cards/tags to another Arduino to mark the attendance (Refer Fig 7.)
Now, we will create a face recognition code for Raspberry that will recognise the face and send it to the Arduino.
Face recognition Code
Here, we will create a face recognition code for marking attendance. First, we need to import the required libraries like serial, cv2, espeak (optional), face_recognition, numpy in our code. (Refer Fig 8.)
Then after setting the image a file and name we try to detect the person face in code and then after detection of name we send the name over serial port as in Code snippet below.
Now we have completed our coding so we can connect the components
Arduino 1 to RFID module connection
|3.3V pin of Arduino.||VCC|
Arduino 2 to SD card module connection
|Arduino 2||Sd Card Module|
Arduino 1 to OLED module connection
Arduino 2 to RTC module connection
For Software Serial connection of the Arduino boards, connect the Software Serial Rx of Arduino 1 to Tx of Software Serial of Arduino 2 and vice versa.
Now connect the data cable of Arduino 2 to USB of Raspberry Pi.
Then connect the camera of Raspberry Pi to the camera port of Raspberry Pi.
Now, power both the Arduinos and Raspberry Pi to run the face script of Python. Then bring your face in front of the camera and after its recognition, put the RFID card on the RFID module. After a successful reading of the card, the name and attendance confirmation will be shown in the OLED display. At the same time, the 2nd Arduino will save the attendance time along with the RFID name and the person’s face. To see the whole database of smart attendance system, open the text file of attendance in the SD card.
Note: To set the name of the RFID card, run the Read-Write code of RFID module and give the name. The Read – Write code can be found in the example of MFRC522 library.