Introduction
In modern institutions, monitoring attendance is a critical task that ensures efficiency and accountability. Traditional methods of marking attendance, such as roll calls or manual entries, can be time-consuming and prone to errors. An RFID-based attendance system provides a streamlined, automated solution to this problem. In this article, we’ll explore how to design and implement an RFID-based attendance system using a PIC microcontroller.
System Overview
The RFID-based attendance system uses an RFID reader to detect RFID tags. Each RFID tag corresponds to a unique ID assigned to an individual (e.g., a student or employee). When a person scans their RFID tag, the microcontroller processes the ID, logs the attendance, and displays the details on an LCD screen. The system can also be integrated with a computer or database for further processing and record-keeping.
Components Required
PIC Microcontroller (e.g., PIC16F877A) - The main controller for processing the RFID data.
RFID Reader Module (e.g., EM-18) - Used to read RFID tags.
RFID Tags - Unique identifiers assigned to individuals.
16x2 LCD Display - Displays attendance status and information.
Buzzer (optional) - Provides auditory feedback on successful or unsuccessful scans.
Resistors, Capacitors, and Potentiometer - Basic components for interfacing and setting up the circuit.
Breadboard and Connecting Wires - For assembling the circuit.
Power Supply - To power the system.
Circuit Diagram
Below is a basic circuit diagram for connecting the RFID reader and LCD to the PIC microcontroller.
[Insert a circuit diagram here showing connections: RFID reader's TX pin to the PIC microcontroller's RX pin (e.g., RC7), LCD connections to PORTD, and a buzzer connected to a digital I/O pin.]
Working Principle
The RFID reader continuously scans for RFID tags. When a tag is detected, it sends the unique ID to the PIC microcontroller via serial communication. The microcontroller processes this data to determine if the ID is valid and then logs the attendance. The details are displayed on the LCD screen, and an optional buzzer can provide feedback.
Step-by-Step Implementation
Step 1: Setting Up the Development Environment
Ensure you have the necessary tools installed:
MPLAB X IDE - For writing and debugging code for PIC microcontrollers.
XC8 Compiler - To compile C code into a hex file for the microcontroller.
Step 2: Writing the Code
Start by initializing the PIC microcontroller and setting up the serial communication for the RFID reader.
Code Outline:
#include <xc.h>
#include "lcd.h" // Include LCD library
#define _XTAL_FREQ 20000000 // Define the crystal frequency (20MHz)
// Configuration bits for PIC16F877A
#pragma config FOSC = HS // High-Speed Oscillator
#pragma config WDTE = OFF // Watchdog Timer Disabled
#pragma config PWRTE = OFF // Power-up Timer Disabled
#pragma config BOREN = ON // Brown-out Reset Enabled
#pragma config LVP = OFF // Low Voltage Programming Disabled
#pragma config CPD = OFF // Data EEPROM Memory Code Protection Disabled
#pragma config WRT = OFF // Flash Program Memory Write Enable
#pragma config CP = OFF // Flash Program Memory Code Protection Disabled
// Function prototypes
void UART_Init(void);
char UART_Read(void);
void Check_RFID(char *id);
void main(void) {
char id[12]; // Array to store RFID tag ID
UART_Init(); // Initialize UART
Lcd_Init(); // Initialize LCD
Lcd_Clear();
while(1) {
Lcd_Set_Cursor(1, 1);
Lcd_Write_String("Scan Your Tag");
for (int i = 0; i < 12; i++) {
id[i] = UART_Read(); // Read RFID tag ID
}
Check_RFID(id); // Process and validate RFID tag ID
__delay_ms(2000); // Wait for 2 seconds before next scan
}
}
// Initialize UART for serial communication
void UART_Init(void) {
TRISC6 = 1; // TX pin as input
TRISC7 = 1; // RX pin as input
SPBRG = 31; // Baud rate of 9600 for 20MHz crystal
TXSTA = 0x20; // Enable TX
RCSTA = 0x90; // Enable RX and serial port
}
// Read a character from UART
char UART_Read(void) {
while (!RCIF); // Wait until reception is complete
return RCREG; // Return the received character
}
// Function to check if the RFID tag is valid
void Check_RFID(char *id) {
Lcd_Clear();
Lcd_Set_Cursor(1, 1);
if (strcmp(id, "123456789012") == 0) { // Compare with predefined ID
Lcd_Write_String("ID: Valid");
Lcd_Set_Cursor(2, 1);
Lcd_Write_String("Welcome John!");
} else {
Lcd_Write_String("ID: Invalid");
Lcd_Set_Cursor(2, 1);
Lcd_Write_String("Access Denied");
}
}
3: Connecting the RFID Reader
Connect the TX pin of the RFID reader to the RX pin of the PIC microcontroller (e.g., RC7).
Power the RFID reader by connecting the VCC and GND pins to the corresponding power rails.
Connect the RST pin to a digital I/O pin on the PIC, if required, to reset the module.
Step 4: Interfacing the LCD
Connect the LCD data pins (D4-D7) to the microcontroller’s PORTD.
Connect the RS, RW, and E control pins to the appropriate digital I/O pins on the PIC (e.g., RD0, RD1, and RD2).
Use a potentiometer to adjust the contrast of the LCD.
Step 5: Compiling and Uploading the Code
Write and compile the code using MPLAB X IDE and XC8 compiler.
Generate the hex file and upload it to the PIC microcontroller using a programmer (e.g., PICkit 3).
Step 6: Testing the System
Power up the system and scan an RFID tag. The system should display whether the tag is valid and provide the corresponding message on the LCD. If a buzzer is connected, it can also give auditory feedback for valid or invalid tags.
Applications
Educational Institutions: Automate student attendance tracking.
Corporate Offices: Monitor employee attendance and access control.
Event Management: Track attendee entries in real-time.
Conclusion
Building an RFID-based attendance system using a PIC microcontroller is an excellent way to delve into microcontroller programming and RFID technology. This project can be further enhanced by integrating features like wireless data transmission, database connectivity, or even mobile app integration for remote monitoring. The flexibility and scalability of this system make it suitable for various applications, ensuring efficient and accurate attendance management.
Want us to guide you through your project or make the project for you ?
Create Various Projects
Check out our Free Arduino Projects Playlist - Arduino Projects
Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects
Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects
Check out our Free IoT Projects Playlist - IoT Projects
Check out our Free Home Automation Projects Playlist - Home Automation Projects
Check out our Free NodeMCu Projects Playlist - NodeMCu Projects
Comments