Introduction
Radio-frequency identification
(RFID) and Barcode detectors are being used in different sectors
for various purposes. They are being used in Shopping malls, Software firm,
Library, Labs and many other places. As there wasn’t any project using RFID or
Barcodes so we thought about doing a project implementing RFID.
What is RFID?
Radio-frequency identification
(RFID) is a technology that uses radio waves to transfer data from an
electronic tag, called RFID tag or label, attached to an object, through a
reader for the purpose of identifying and tracking the object. Some RFID tags
can be read from several meters away and beyond the line of sight of the
reader. The application of bulk reading enables an almost-parallel reading of
tags.
The tag's information is stored electronically. The
RFID tag includes a small RF transmitter and receiver. An RFID reader transmits
an encoded radio signal to interrogate the tag. The tag receives the message
and responds with its identification information. Many RFID tags do not use a
battery. Instead, the tag uses the radio energy transmitted by the reader as
its energy source. The RFID system design includes a method of discriminating
several tags that might be within the range of the RFID reader.
Our Project
The objective of this project is to implement an
automated attendance system for schools with a comparatively new and promising
technology known as Radio-Frequency Identification or RFID in short. In
this system every student has a RFID tag containing a unique identity code.
Before entering the school the student will have to hold the RFID tag near a
RFID reader which is directly connected to a PC using serial port. A software
program inside the PC will collect the identity codes from the RFID reader and
take necessary actions to save the attendance information inside a database. On
each working day after a predefined time the software will scan the database to
find those students who are not present that day and send SMS to their
guardians. The same software will be used to view attendance history by student
or by class, generate and print attendance oriented reports and for the overall
management of the system.
No. |
Instrument |
Quantity |
Price (BDT) |
1. |
Radio-frequency identification (RFID) |
1 |
5000 |
2. |
MAX 232 |
1 |
- |
3. |
RFID Tags |
Many |
15(Per Tag) |
4. |
Breadboard |
1 |
200 |
5. |
Serial Converter |
1 |
200 |
6. |
IC 7805 |
1 |
- |
7. |
Capacitors(.1/1/10 microF) |
Many |
- |
8. |
Wires |
Many |
- |
Initially an amount around 7000/- BDT is required.
Our project also requires a PC. Also a serial port (for desktop computer) or a
serial converter (for laptop) is required to interface the RFID with the PC.
Additional equipments can be used to improve the project such as an antenna to
improve the signal or a GPRS device to send sms.
Additional Equipment and
Their Cost (optional)
No. |
Instrument |
Quantity |
Price (BDT) |
1. |
GPRS device |
1 |
5500 |
2. |
RFID Antenna |
1 |
- |
Design and Procedure
Our project can be best described in four parts.
1) Circuit
Design and interfacing:
Our
plan was very simple and easy to implement. The Block diagram is as follows:
The
circuit was a simple interfacing of the RFID with MAX232 using the TX pin and
then another connection using the TX pin of the MAX232 with the PC. A buzzer
was connected to determine whether the RFID responds to the Tags or not. A vcc
of 5V was given through the 7805 using a 12V source. The detailed circuit
diagram is given below:
2) Identification:
The
RFID will generate a number after receiving signal from any RFID tag. The
numbers are used for identification and saved to a text document. A simple java
program is written for taking reading from RFID tags and saving them in a text
document. Also a timer was set so that the readings will be taken for a set
amount of time and after that the database will start checks the readings for
necessary updates.
The
code is given below:
import
java.util.Date; import
java.text.DateFormat; import
java.text.SimpleDateFormat; import
java.util.Calendar; import
java.io.*; import
java.util.*; import
javax.comm.*; import
java.io.FileReader; import
java.io.FileWriter; import
java.io.IOException; public
class SimpleRead implements Runnable, SerialPortEventListener { static CommPortIdentifier portId; static Enumeration portList; InputStream inputStream; SerialPort serialPort; Thread readThread; static byte[] readBuffer; public static void main(String[] args) { DateFormat dateFormat = new
SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Calendar cal =
Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
System.out.println(cal.getTime().getHours()+":"+cal.getTime().getMinutes()+"
"); int hour=cal.getTime().getHours(); int
minute=cal.getTime().getMinutes(); int
second=cal.getTime().getSeconds(); int
currentTime=hour*3600*1000+minute*60*1000+second*1000; int TargetHourStart=12; int TargetHourEnd=17; int TargetMinStart=00; int
TargetMinEnd=(TargetMinStart+2)%60; int
TargetTime=TargetHourStart*3600*1000+TargetMinStart*60*1000; int
TargetTimeEnd=TargetHourEnd*3600*1000+TargetMinEnd*60*1000; int TimeDifference=(TargetTime-currentTime+24*3600*1000)%(24*3600*1000);
if(!(currentTime>=TargetTime&¤tTime<=TargetTimeEnd)) { try {
Thread.currentThread().sleep(TimeDifference); } catch(Exception e) { } } cal=Calendar.getInstance();
System.out.println(cal.getTime().getHours()+":"+cal.getTime().getMinutes()+"
"); try { } catch(Exception e) { System.out.println("File
open Failed"); } System.out.println("After
File"); portList =
CommPortIdentifier.getPortIdentifiers(); while(true) { while
(portList.hasMoreElements()) { portId = (CommPortIdentifier)
portList.nextElement(); if (portId.getPortType() ==
CommPortIdentifier.PORT_SERIAL) { if
(portId.getName().equals("COM13")) { SimpleRead reader =
new SimpleRead(); cal =
Calendar.getInstance(); hour=cal.getTime().getHours();
minute=cal.getTime().getMinutes();
second=cal.getTime().getSeconds();
currentTime=hour*3600*1000+minute*60*1000+second*1000;
if(currentTime>TargetTimeEnd) {
Thread.currentThread().destroy(); } } else {
System.out.println("The port is:"+portId.getName()); } } } } } public SimpleRead() { System.out.println("Reader
waiting for data..."); try { serialPort = (SerialPort)
portId.open("SimpleReadApp", 2000); } catch (PortInUseException e) {} try { inputStream =
serialPort.getInputStream(); } catch (IOException e) {} try {
serialPort.addEventListener(this); } catch (TooManyListenersException e)
{}
serialPort.notifyOnDataAvailable(true); try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch
(UnsupportedCommOperationException e) {} readThread = new Thread(this); readThread.start(); } public void run() { try { Thread.sleep(20000); } catch (InterruptedException e) {} } public void serialEvent(SerialPortEvent
event) { switch(event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case
SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: readBuffer = new byte[20]; try { while
(inputStream.available() > 0) { int numBytes =
inputStream.read(readBuffer); } System.out.println(new
String(readBuffer,1,11)); FileWriter outputStream =
null; outputStream = new FileWriter("D:\\rfid.txt",true); outputStream.write(new
String(readBuffer,1,11)+"\r\n");
System.out.println("AFTER WRITE"); outputStream.close(); } catch (IOException e) {
System.out.println("File Error"); } break; } } } |
3) Database
access and update:
The
database contains the necessary information of all the students. A timer was
set for the database to start checking
after the timer for reading the RFID tags has ended. Then the database will
read the RFID tags from the text
document and make necessary update to the database. Finally the name and mobile
numbers of the parents of the students who are absent will be saved in another
text document.
4) Finalizing
and sending sms:
We
used the API from Grameen Phone in our code for sending sms. The program will
read the name and mobile numbers from the text documents and send sms to inform
them the students were absent. The code is given below:
/* * To change this template, choose Tools |
Templates * and open the template in the editor. */ package
sms2; /** * * @author Nayeem */ import
java.util.Date; import
java.text.DateFormat; import
java.text.SimpleDateFormat; import
java.util.Calendar; import
java.io.*; import
java.util.*; import
javax.comm.*; import
com.grameenphone.playground.*; import
com.grameenphone.*; import
com.grameenphone.sendsmsrequest_xml.SendSMSRequest; import
java.net.URL; import
java.security.SecureRandom; import
java.security.cert.CertificateException; import
java.security.cert.X509Certificate; import
javax.net.ssl.HostnameVerifier; import
javax.net.ssl.HttpsURLConnection; import
javax.net.ssl.KeyManager; import
javax.net.ssl.SSLContext; import
javax.net.ssl.SSLSession; import
javax.net.ssl.TrustManager; import
javax.net.ssl.X509TrustManager; import
java.io.*; import
java.sql.*; import
java.util.Calendar; /** * * @author Nayeem */ public
class SMS2 { /** * @param args the command line arguments */ public static void override_security() { try { X509TrustManager tm = new
X509TrustManager() { @Override public X509Certificate[]
getAcceptedIssuers() { return null; } @Override public void
checkServerTrusted(X509Certificate[] paramArrayOfX509Certificate, String
paramString) throws CertificateException { } @Override public void
checkClientTrusted(X509Certificate[] paramArrayOfX509Certificate, String
paramString) throws CertificateException { } }; SSLContext ctx =
SSLContext.getInstance("TLS"); ctx.init(null, new
TrustManager[]{tm}, null); SSLContext.setDefault(ctx); HttpsURLConnection conn =
(HttpsURLConnection) new
URL("https://serverAddress").openConnection(); conn.setHostnameVerifier(new
HostnameVerifier() { @Override public boolean verify(String
paramString, SSLSession paramSSLSession) { return true; } }); conn.connect(); } catch (Exception ex) {
System.out.println("Exceptional Code!\n\n\n\n\n"); ex.printStackTrace(); } } public static void send_sms(String to,
String content) { String registrationID =
"vampireegg";//provide your registered user ID String password =
"ohyV7N3Q5"; //provide password which you got after registering
from web String fromMSISDN =
"8801731125092"; //provide the mobile number that was registered
with your user ID. String toMSISDN = to;//provide any GP
mobile number String smsPort = "5001"; double charge = 0.00; // //String chargedParty =
"8801718026337"; // chargedParty should be the source mobile number int msgType = 4; //provide 1-Ring
tone, 2-Logo, 3-Uap Push, 4-Text (160 character) String contentArea =
"test"; String msgContent = content;
//provide message which want to send try {
System.out.println("Successful World1!\n\n\n\n\n");
WebServiceGPADPBizTalkSMSOrchestrations service = new
WebServiceGPADPBizTalkSMSOrchestrations();
WebServiceGPADPBizTalkSMSOrchestrationsSoap port =
service.getWebServiceGPADPBizTalkSMSOrchestrationsSoap(); SendSMSRequest messageRequest =
new SendSMSRequest(); System.out.println("Successful
World2!\n\n\n\n\n");
messageRequest.setRegistrationID(registrationID);
messageRequest.setPassword(password);
messageRequest.setSourceMsisdn(fromMSISDN); messageRequest.setDestinationMsisdn(toMSISDN);
messageRequest.setSmsPort(smsPort);
messageRequest.setMsgType(msgType); messageRequest.setCharge(charge);
System.out.println("Successful World3!\n\n\n\n\n");
messageRequest.setChargedParty("8801731125092");
messageRequest.setContentArea(contentArea);
messageRequest.setMsgContent(msgContent);
System.out.println("Successful World4!\n\n\n\n\n"); sendsmsresponse_xml.schemas.biztalk.adp.gp.SendSMSResponse
result = port.sendSMS(messageRequest);
/*sendsmsresponse_xm1.schemas.bizta1k.adp.gp.SendSMSResponse result = port.sendSMS(messageRequest);*/ System.out.println("Result =
" + result.getStatus() + " " + result.getMsgID()); //It shows
message sending result…
System.out.println("Successful World!\n\n\n\n\n"); } catch (Exception ex) {
System.out.println("Exceptional World!\n\n\n\n\n"); ex.printStackTrace(); } } public static void main(String[] args) { override_security(); DateFormat dateFormat = new
SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Calendar cal =
Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
System.out.println(cal.getTime().getHours()+":"+cal.getTime().getMinutes()+"
"); int hour=cal.getTime().getHours(); int
minute=cal.getTime().getMinutes(); int second=cal.getTime().getSeconds(); int
currentTime=hour*3600*1000+minute*60*1000+second*1000; int TargetHourStart=11; int TargetHourEnd=15; int TargetMinStart=3; int TargetMinEnd=52; int
TargetTime=TargetHourStart*3600*1000+TargetMinStart*60*1000; int
TargetTimeEnd=TargetHourEnd*3600*1000+TargetMinEnd*60*1000; int
TimeDifference=(TargetTimeEnd-currentTime+24*3600*1000)%(24*3600*1000); if(!(currentTime>=TargetTimeEnd)) { try { //
Thread.sleep(TimeDifference); } catch(Exception e) { } } cal=Calendar.getInstance();
System.out.println(cal.getTime().getHours()+":"+cal.getTime().getMinutes()+"
"); System.out.println("Hello
World!\n\n\n\n\n"); try{ // Open the file that is the
first // command line parameter FileInputStream fstream = new
FileInputStream("D:\\sms.txt"); // Get the object of
DataInputStream DataInputStream in = new
DataInputStream(fstream); BufferedReader br = new
BufferedReader(new InputStreamReader(in)); String value; int i=0; String
name="",cellno=""; while((value = br.readLine()) !=
null) { if(i==0) { name=value; i=1; } else if(i==1) { cellno=value;
System.out.println("name = "+name+" cell =
"+cellno);
send_sms(cellno,name+" is absent today."); i=0; Thread.sleep(5000); } System.out.println(i+"
name = "+name+"cell = "+cellno); //if(i==0)i=1; //if(i==1)i=0; //System.out.println(value); } //
send_sms("8801718026337", "Hi Nayeem"); } catch(Exception ex){ System.out.println("Unable to
read file"); } } } |
Problems and Solutions
We encountered many problems as this was our first
time using RFID and also there was very little information available about it.
We did our best to learn from our mistakes and experimenting again and again.
1) RFID
is available in very few places in Bangladesh and it also costs more than twice
its usual price where it is available. We bought ours at PYLABs but they could
help us very little about how to use it effectively.
2) The
range of the RFIDs available is very short. It was said that the range would be
5-10 meters but in practical when we were using it, the range barely seemed to
be 2-4 meters at most. This was a big problem for us since we thought the RFID
wasn’t working properly.
The range can be
improved by adding an antenna to the RFID to receive signal from a afar.
3) The
pins of the RFID were very short and it was impossible to place it on any
breadboard normally. We tried to use rails but even that couldn’t solve our
problems. Finally we had to take a risk and weld wires to the pins to use the
RFID. It was a risky procedure as the RFID could be damaged.
4) The
RFID wasn’t working properly without a 12-5 volt converter. Giving direct 12
volt to the RFID is suicidal as one of our RFIDs was damaged in this way. So
care should be always taken when connecting power to the RFID.
5) When
taking inputs from the RFID, various times garbage values were shown instead of
proper values. This could be caused by incorrect connection or small diode.
Also this could have caused by the noise around as the RFID detects radio
frequency from the RFID tags. Care should be taken to avoid this problem.
6) RFID
tags aren’t unique. Two tags can have the same value. So it isn’t always
possible to detect if someone cheated whether intentionally or unintentionally.
Unless a solution for this is found RFID is risky to use in high level or
important sector.