RFID based students attendance system with message Alert
Table of Contents
Description:
RFID based students attendance system with message Alert- In this tutorial, I will show you how to make an RFID students attendance system with an SMS alert using Arduino, MFRC522 RFID module, and GSM SIM900A Module. This tutorial explains step by step how to create your graphical user interface application in Visual Basic.Net “Vb.net”. Before we discuss anything, first let me tell you in a few words how this project actually works.
First of all, a teacher swipes a card and is marked Present, then the timer is started and messages are sent to the students, that the teacher has arrived. As each student has given an RFID card, so if every student swipes his/her RFID card within the specified time, the student will be marked present. While the rest of the students will be marked absent and messages will be sent to their parents.
Amazon Links:
Arduino Nano USB-C Type (Recommended)
MFRC522 RFID module with tags:
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
First, let’s start with the GSM module:
This is the GSM module, in the market, we have different types of GSM modules, the one I will be using today is sim900A if you want you can also use any other gsm module, like for example sim900D. I have also tested the same programming using sim900D but with a different baud rate, the rest of the program remains the same.
If you are from Pakistan, Bangladesh or India make sure you double-check the GSM module and purchase the unlocked version of the sim900A. This GSM sim900A module as you can see on the screen has no Onboard voltage regulator, so be careful while applying the voltage. The ideal voltage for this GSM module is 4.7v but you can also connect it with a 5v adaptor. If you don’t have a 5v adaptor then you can make your power supply using an lm317t adjustable variable voltage regulator, I have a very detailed tutorial on lm317t explaining everything. You can watch this video tutorial on my YouTube channel “Electronic Clinic”.
As you can see clearly in the picture above this module has so many pins that are clearly labeled, but we will be using only 5 of these pins, the power supply pins, GND, Rxd 5v, and TXD 5v. The GND will be connected with the Arduino GND, TXD will be connected with the Arduino pin 2 and RXD will be connected with the Arduino pin 4.
MFRC522 RFID Module and its Pinout.
The first pin of the RFID module is the VCC and this will be connected with 3.3v of the Arduino.
Pin number 2 is the RST or reset, pin number 3 is the ground, while the MISO pin, MOSI PIN, SCK pin and NSS pin, these four pins in the Arduino are the SPI pins While in Arduino Mega these pins are different. So these pins will be connected with the Arduino SPI pins, In Arduino Uno the SPI pins are as follow.
pin number 13 is the SCK
pin number 12 is the MISO
pin number 11 is the mosi and
pin number 10 is the ss.
What is SPI :
SPI stands for “Serial Peripheral Interface”. It is a Synchronous serial data bus, which means that the data can travel in both the directions at the same time, as opposed to (for example) the I2c bus that cannot do so. To use Synchronous data transmission, the SPI bus makes use of the four wires, and they are called.
MISO: The MISO stands for Mater in, Slave Out. The purpose of this line is to carry data from the SPI support devices back to Arduino.
SCK: The SCK stands for the Serial Clock.
The IRQ pin is not used
MOSI: The MOSI stands for Master Out, Slave In. the purpose of this line is to carry data from the Arduino to the SPI supported devices.
SS: The SS stands for Slave Select. Each SPI supported device needs a unique SS line back to Arduino.
RFID based Students Attendance Circuit Diagram:
The complete circuit diagram is already explained in my previous articles, you can also watch video given at the end. But as a reminder, the ideal voltage to the SIM900A module is from 4.7 volts to 5 volts.
RFID based students attendance Arduino Programming:
Tags reading Program:
This is the program written for finding the identity numbers of RFID tags. Before you can control anything using the RFID system, first you need to find out the identity number of each tag, and then you can use that identification number to identify a RFID tag to control anything you want.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
/* * Pin layout should be as follows: * Signal Pin Pin Pin * Arduino Uno Arduino Mega MFRC522 board * ------------------------------------------------------------ * Reset 9 5 RST * SPI SS 10 53 SDA * SPI MOSI 11 51 MOSI * SPI MISO 12 50 MISO * SPI SCK 13 52 SCK * voltage 3.3v */ #include <SPI.h> #include <MFRC522.h> #define SS_PIN 10 #define RST_PIN 9 MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. void setup() { Serial.begin(9600); // Initialize serial communications with the PC SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 card //Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks."); } void loop() { // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. MFRC522::MIFARE_Key key; for (byte i = 0; i < 6; i++) { key.keyByte[i] = 0xFF; } // Look for new cards if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } // Now a card is selected. The UID and SAK is in mfrc522.uid. // Dump UID Serial.print("Card UID:"); for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], DEC); } Serial.println(); // Dump PICC type byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); Serial.print("PICC type: "); Serial.println(mfrc522.PICC_GetTypeName(piccType)); if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { //Serial.println("This sample only works with MIFARE Classic cards."); return; } } |
RFID and GSM sim900A combined programming of the Students attendance system:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
/* terminal1 program ----------------------------------------------------------------------------- * Pin layout should be as follows: * Signal Pin Pin Pin * Arduino Uno Arduino Mega MFRC522 board * ------------------------------------------------------------ * Reset 9 5 RST * SPI SS 10 53 SDA * SPI MOSI 11 51 MOSI * SPI MISO 12 50 MISO * SPI SCK 13 52 SCK * voltage 3.3v */ /* l , m , n , o are the commands for student1 , student2 ... respectively. when the controller receives any of these commands a message will be sent to the parents of that student. a, b , c and d commands are used to let the students know that the teacher has arrived */ #include <SPI.h> #include <MFRC522.h> #include <SoftwareSerial.h> SoftwareSerial SIM900(2, 4); String textForSMS; #define SS_PIN 10 #define RST_PIN 9 MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. void setup() { Serial.begin(9600); // Initialize serial communications with the PC SIM900.begin(19200); SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 card //Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks."); randomSeed(analogRead(0)); delay(5000); } void loop() { if(Serial.available() == 0) { // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. MFRC522::MIFARE_Key key; for (byte i = 0; i < 6; i++) { key.keyByte[i] = 0xFF; } // Look for new cards if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } // Now a card is selected. The UID and SAK is in mfrc522.uid. // Dump UID Serial.print("Card UID:"); for (byte i = 0; i < mfrc522.uid.size; i++) { // Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); // Serial.print(mfrc522.uid.uidByte[i], DEC); } Serial.println(); // Dump PICC type byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); // Serial.print("PICC type: "); //Serial.println(mfrc522.PICC_GetTypeName(piccType)); if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { //Serial.println("This sample only works with MIFARE Classic cards."); return; } // defining Cards here // teacher if( (mfrc522.uid.uidByte[0] == 192) && (mfrc522.uid.uidByte[1] == 47) && (mfrc522.uid.uidByte[2] == 254) && (mfrc522.uid.uidByte[3] == 121) ) // teacher card { Serial.println("teacher"); delay(2000); } // student1 if( (mfrc522.uid.uidByte[0] == 189) && (mfrc522.uid.uidByte[1] == 54) && (mfrc522.uid.uidByte[2] == 235) && (mfrc522.uid.uidByte[3] == 213) ) // student1 card { Serial.println("stu1"); delay(2000); } // student2 if( (mfrc522.uid.uidByte[0] == 198) && (mfrc522.uid.uidByte[1] == 69) && (mfrc522.uid.uidByte[2] == 34) && (mfrc522.uid.uidByte[3] == 75) ) // student2 card { Serial.println("stu2"); delay(2000); } // student3 if( (mfrc522.uid.uidByte[0] == 00) && (mfrc522.uid.uidByte[1] == 47) && (mfrc522.uid.uidByte[2] == 115) && (mfrc522.uid.uidByte[3] == 137) ) // student3 card { Serial.println("stu3"); delay(2000); } else Serial.println("unregistered user"); } // commands from graphical user interface application if ( Serial.available() > 0 ) { char data = Serial.read(); delay(1000); // messages to the students that the teacher has arrived if(data == 'a') { textForSMS = "\nFahad:Teacher has arrived"; sendSMS5(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } if( data == 'b') { textForSMS = "\nRam:Teacher has arrived"; sendSMS6(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } if( data == 'c') { textForSMS = "\nJan sher:Teacher has arrived"; sendSMS7(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } if( data == 'd') { textForSMS = "\nWadood:Teacher has arrived"; sendSMS8(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } // messages to their parents to let them know their son/daughter is absent if(data == 'l') { textForSMS = "\nFahad was absent today"; sendSMS1(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } if( data == 'm') { textForSMS = "\nRam was absent today"; sendSMS2(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } if( data == 'n') { textForSMS = "\nJan sher was absent today"; sendSMS3(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } if( data == '0') { textForSMS = "\nWadood was absent today"; sendSMS4(textForSMS); Serial.println(textForSMS); Serial.println("message sent."); data = 'z' ; // garbage value delay(5000); } } } // user defined functions for sending messages to students and parents // messages to students // student1 void sendSMS5(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923339218213\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // student2 void sendSMS6(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923462573150\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // student3 void sendSMS7(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923417088988\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // student4 void sendSMS8(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923444442500\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // parents numbers void sendSMS1(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923339218213\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // parents number2 void sendSMS2(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923339313613\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // parents number3 void sendSMS3(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923315248222\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } // parents number4 void sendSMS4(String message) { SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message delay(100); SIM900.println("AT + CMGS = \"+923336719515\""); // recipient's mobile number, in international format delay(100); SIM900.println(message); // message to send delay(100); SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26 delay(100); SIM900.println(); delay(5000); // give module time to send SMS // SIM900power(); // turn off module } |
Computer application Programming of students attendance system:
This application is designed in Visual Basic 2010 express Edition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
Option Explicit Dim BUFFERS$ Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim message As Integer Dim search As String Dim strTest As String Dim user1 As Integer Dim user2 As Integer Dim time1 As Integer Dim time2 As Integer Dim mins As Integer Dim secs As Integer Dim teacherflag As Integer Dim sflag1 As Integer ' student 1 flag Dim sflag2 As Integer ' student 2 flag Dim sflag3 As Integer ' student 3 flag Dim msending As Integer ' message sending flag Dim absent1 As Integer Dim absent2 As Integer Dim absent3 As Integer Dim absentflag As Integer Dim flag1 As Integer Dim flag2 As Integer Dim flag3 As Integer Dim counter As Integer Private Sub Form_Load() mins = 0 Timer3.Enabled = False teacherflag = 0 sflag1 = 0 sflag2 = 0 sflag3 = 0 msending = 0 absent1 = 0 absent2 = 0 absent3 = 0 absentflag = 0 flag1 = 0 flag2 = 0 flag3 = 0 counter = 0 'MSComm1.Settings = "9600,n,8,1" 'Change this with the Baud rate of your modem (The one you use with Hyper Terminal) 'MSComm1.CommPort = 10 ' Change this with the port your Modem is attached,(eg bluetooth) 'MSComm1.PortOpen = True With MSComm1 .CommPort = 3 .Settings = "9600,N,8,1" .Handshaking = comRTS .RTSEnable = True .DTREnable = True .RThreshold = 1 .SThreshold = 1 .InputMode = comInputModeText .InputLen = 0 .PortOpen = True 'must be the last End With End Sub Private Sub Timer1_Timer() txtrec.Text = MSComm1.Input search = txtrec.Text If (InStr(search, "teacher") And (teacherflag = 0)) Then ' when the teacher will swipe the rfid card the word teacher will be sent to the computer Check3.Value = 1 Timer3.Enabled = True ' timer3 is used for timing mins and secs teacherflag = 1 Timer4.Enabled = True End If If (InStr(search, "stu1") And (sflag1 = 0) And mins < 6) Then ' then the student1 will be marked present Check4.Value = 1 sflag1 = 1 End If If (InStr(search, "stu2") And (sflag2 = 0) And mins < 6) Then ' then the student1 will be marked present Check5.Value = 1 sflag2 = 1 End If If (InStr(search, "stu3") And (sflag3 = 0) And mins < 6) Then ' then the student1 will be marked present Check6.Value = 1 sflag3 = 1 End If End Sub Private Sub Timer2_Timer() Label5.Caption = Time End Sub Private Sub Timer3_Timer() secs = secs + 1 Label7.Caption = secs If secs > 59 Then secs = 0 mins = mins + 1 Label3.Caption = mins End If End Sub Private Sub Timer4_Timer() ' sending message to students to let them know that the teacher has arrived. ' in the controller program each and every user will have its own message sending function in which his number will be specified. counter = counter + 1 Label3.Caption = counter If ((teacherflag = 1) And ((counter > 10) And (counter < 20)) And (Check8.Value = 0)) Then Check8.Value = 1 End If If ((teacherflag = 1) And ((counter > 30) And (counter < 40)) And (Check9.Value = 0)) Then Check9.Value = 1 End If If ((teacherflag = 1) And ((counter > 50) And (counter < 60)) And (Check10.Value = 0)) Then Check10.Value = 1 End If If ((teacherflag = 1) And ((counter > 90) And (counter < 120)) And (Check12.Value = 0)) Then ' this when checked means all messages are sent Check12.Value = 1 End If ' check box for parents messages If ((Check12.Value = 1) And ((counter > 300) And (counter < 320) And (Check4.Value = 0))) Then ' this when checked means all messages are sent Check13.Value = 1 End If If ((Check12.Value = 1) And ((counter > 330) And (counter < 350) And (Check5.Value = 0))) Then ' this when checked means all messages are sent Check14.Value = 1 End If If ((Check12.Value = 1) And ((counter > 370) And (counter < 380) And (Check6.Value = 0))) Then ' this when checked means all messages are sent Check15.Value = 1 End If If ((Check12.Value = 1) And ((counter > 390) And (counter < 400) And (Check7.Value = 0))) Then ' this when checked means all messages are sent Check16.Value = 1 End If '************************************* If ((Check8.Value = 1) And (flag1 = 0)) Then MSComm1.Output = "a" flag1 = 1 End If If ((Check9.Value = 1) And (flag2 = 0)) Then MSComm1.Output = "b" flag2 = 1 End If If ((Check10.Value = 1) And (flag3 = 0)) Then MSComm1.Output = "c" flag3 = 1 End If ' messages sending to their parents If ((Check13.Value = 1) And (absent1 = 0)) Then MSComm1.Output = "l" absent1 = 1 End If If ((Check14.Value = 1) And (absent2 = 0)) Then MSComm1.Output = "m" absent2 = 1 End If If ((Check15.Value = 1) And (absent3 = 0)) Then MSComm1.Output = "n" absent3 = 1 End If End Sub |
Watch Video Tutorial:
do the system work with sim800l if yes what changes needed in code plz reply
In which language is this code written, can i know please..