This project aims to automate the process of taking attendance on pen and paper and prevent any fraudulent entry. It uses RFID tags to record attendance. Each student is assigned a unique tag, which he/she is required to swipe over the reader to give his/her attendance. This system benefits both the teacher and student as its quick and hassle free. This setup can be used in any educational institution regardless of whichever board they follow. Data is stored in a CSV file which keeps track of each day’s attendance.
System Design: The main component of the system is the RFID reader which transmits a 12-byte ASCII string via the TTL-level SOUT pin. This helps to identify a student from the rest, as each TAG generates a unique ASCII string. This String is then fed to the AVR’s RX line which processes it for marking his/her attendance.
Exclusive Digi-key Tools
The start byte and stop byte are used to easily identify that a correct string has been received from the reader (they correspond to a line feed and carriage return characters, respectively). The middle ten bytes are the actual tag's unique ID. This ID is then matched with the ID stored on MCU’s flash memory to get the name, roll no and other details. Once a match has been found it is then dumped to the SD card along with the date and time stamp.
Data entry and retrieval: For this project to work Student name and roll number along with their tag ID must be preconfigured in the program. To get the Tag ID of a new RFID card I have written a simple program which can be used when the database is been updated. Adding or editing any info is as simple as modifying the array. All information is stored in 3 different arrays namely “tag”, “name”, “roll”. Care must be taken while editing the information with respect to array index. Whenever there’s a hit with the tag ID the corresponding name and roll number is returned.
Data is stored on a SD card for convenience. Every day a new file gets created with date as the filename (e.g. 5102013.CSV) and records the attendance. File extension is comma separated value (CSV) which can be imported by Excel or MS Access.
Usage: Usage is fairly simple. The Tag card must be brought close to the RFID reader so that the student can record his/her attendance. An LED on board the RFID reader blinks to acknowledge the same.
Circuit Diagram: All the processing and calculation is done by a popular AVR development board called Arduino. The Tx line of the RFID reader is connected with Rx of the AVR. For RTC the respective I2C lines(SCL,SDA) are connected with AVR’s SCL and SDA. SD card is connected with the AVR’s SPI line after proper logic level conversion. SD cards operate at 3.3V volts whereas AVR operate at 5V. LCD is connected in 4 bit parallel mode with the AVR.
Project Images
Pictures:
Circuit:
Code:
Code for viewing Tag ID:-
String gettag=String();
int bytesread=0,val=0;
void setup()
{
Serial.begin(9600);
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2,HIGH);
}
void loop()
{
if(Serial.available()>0) // if data available from reader
{
if((val=Serial.read())==10) // check for header
{
bytesread=0;
while(bytesread<10) // read 10 digit code
{
if(Serial.available()>0)
{
val=Serial.read();
if((val==10)||(val==13)) // if header or stop bytes before the 10 digit reading
{
break; // stop reading
}
gettag=gettag+val; // add the digit
bytesread++; // ready to read next digit
}
}
if(bytesread==10) // if 10 digit read is complete
{
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(gettag);
}
bytesread=0;
digitalWrite(2, LOW); // deactivate the RFID reader for a moment so it will not flood
delay(1500); // wait for a bit
digitalWrite(2, HIGH); // Activate the RFID reader
gettag=NULL;
}
}
}
Main application code:-
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <RTClib.h>
#include <LiquidCrystal.h>
String tag[2]={
"54544848536956666652","54544848536956695751"};
String name[2]={
"Rahul Kar","Engineers Garage"};
String roll[2]={
"20130174","20130207"};
const int chipSelect=10;
int val=0,n=2;
int bytesread=0;
int buttonState=0;
String gettag=String();
char filename[]="00000000.CSV";
RTC_DS1307 RTC;
LiquidCrystal lcd(9,8,7,6,5,4);
void setup()
{
Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps
lcd.begin(16,2);
Wire.begin(); // Initiate I2C
RTC.begin(); // Initiate RTC
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2,HIGH); // Activate the RFID reader
//Serial.print("Initializing SD card...");
pinMode(10,OUTPUT); // 53 for Mega 10 for UNO
if(!SD.begin(chipSelect)) // See if the card is present and can be initialized
{
//Serial.println("Card failed, or not present");
return;
}
delay(100);
//Serial.println("Card initialized.");
if(!RTC.isrunning())
{
//Serial.println("RTC is NOT running!");
}
char filename[]="00000000.CSV";
}
void getFilename(char *filename)
{
DateTime now=RTC.now();
int year=now.year();
int month=now.month();
int day=now.day();
filename[0]='2';
filename[1]='0';
filename[2]=(year-2000)/10+'0';
filename[3]=year%10+'0';
filename[4]=month/10+'0';
filename[5]=month%10+'0';
filename[6]=day/10+'0';
filename[7]=day%10+'0';
filename[8]='.';
filename[9]='C';
filename[10]='S';
filename[11]='V';
return;
}
void printdate_time()
{
DateTime now=RTC.now();
lcd.setCursor(0,1); // set column zero row 2
lcd.print("Time"); // display the word "time"
lcd.setCursor(5,1); // set column 5 row 2
lcd.print(now.hour(),DEC); // display hour
lcd.setCursor(7,1); // set column 7 row 2
lcd.print(':'); // display colon
lcd.setCursor(8,1); // set column 8 row 2
lcd.print(now.minute(),DEC); // display minute
lcd.setCursor(10,1); // set column 9 row 2
lcd.print(':'); // display colon
lcd.setCursor(11,1); // set column 11 row 2
lcd.print(now.second(), DEC); // display seconds
// display DATE on FIRST ROW
lcd.setCursor(0, 0); // set column zero row 1
lcd.print("Date"); // display the word "Date"
lcd.setCursor(5, 0); // set column 5 row 1
lcd.print(now.month(), DEC); // display current month
lcd.setCursor(7, 0); // set column 7 row 1
lcd.print('/'); // display forwared slash
lcd.setCursor(8, 0); // set column 8 row 1
lcd.print(now.day(), DEC); // display current day
lcd.setCursor(10, 0); // set column 10 row 1
lcd.print('/'); // display forward slash
lcd.setCursor(11, 0); // set column 11 row 1
lcd.print(now.year(), DEC); // print current year
}
void printdata(String name,String roll)
{
lcd.clear();
lcd.print(name);
lcd.setCursor(0,1);
lcd.print(roll);
delay(800);
lcd.clear();
printdate_time();
}
String getname(String t)
{
int index=0;
for(int i=0;i<n;i++)
{
if(t.equals(tag[i]))
{
index=i;
break;
}
}
return name[index];
}
String getroll(String t)
{
int index=0;
for(int i=0;i<n;i++)
{
if(t.equals(tag[i]))
{
index=i;
break;
}
}
return roll[index];
}
void readtag_dumpSD()
{
if(Serial.available()>0) // if data available from reader
{
if((val=Serial.read())==10) // check for header
{
bytesread=0;
while(bytesread<10) // read 10 digit code
{
if(Serial.available()>0)
{
val=Serial.read();
if((val==10)||(val==13)) // if header or stop bytes before the 10 digit reading
{
break; // stop reading
}
gettag=gettag+val; // add the digit
bytesread++; // ready to read next digit
}
}
if(bytesread==10) // if 10 digit read is complete
{
DateTime now=RTC.now();
String stu=getname(gettag); //Get student name
String rol=getroll(gettag); //Get student roll..
digitalWrite(2, LOW); // deactivate the RFID reader for a moment so it will not flood
delay(1500); // wait for a bit
digitalWrite(2, HIGH); // Activate the RFID reader
getFilename(filename);
if(!SD.exists(filename)) //If filename doesnt exist create one
{
File dataFile=SD.open(filename,FILE_WRITE);
if(dataFile)
{
dataFile.print("Name");
dataFile.print(",");
dataFile.print("Roll");
dataFile.print(",");
dataFile.print("Time");
dataFile.println();
dataFile.print(stu);
dataFile.print(",");
dataFile.print(rol);
dataFile.print(",");
dataFile.print(now.hour());
dataFile.print(":");
dataFile.print(now.minute());
dataFile.print(":");
dataFile.print(now.second());
dataFile.println();
dataFile.close();
printdata(stu,rol);
}
}
else if(SD.exists(filename)) //If filename exist then use it
{
File dataFile=SD.open(filename,FILE_WRITE);
if(dataFile)
{
dataFile.print(stu);
dataFile.print(",");
dataFile.print(rol);
dataFile.print(",");
dataFile.print(now.hour());
dataFile.print(":");
dataFile.print(now.minute());
dataFile.print(":");
dataFile.print(now.second());
dataFile.println();
dataFile.close();
printdata(stu,rol);
}
else // if the file isn't open, pop up an error:
{
//Serial.println("Error opening file");
}
}
}
bytesread=0;
digitalWrite(2, LOW); // deactivate the RFID reader for a moment so it will not flood
delay(1500); // wait for a bit
digitalWrite(2, HIGH); // Activate the RFID reader
gettag=NULL;
}
}
}
void loop()
{
printdate_time();
readtag_dumpSD();
}
Không có nhận xét nào:
Đăng nhận xét