Home
About Us
Achievement
Home
Raspberry-Pi Projects
_Raspberry Pi 4 Complete Guide
Arduino Project
_All Projects
Esp8266 Project
_All Projects
Esp32 Project
_Automation-with-feedback
Arduino And Rfid Based Attendance System
Just Do Electronics
May 01, 2020
Smart Attendance System
Circuit Diagram :-
Check SdCard In Serial Moniter :-
//Prateek //www.prateeks.in #include
#include
Sd2Card card; SdVolume volume; SdFile root; const int chipSelect = 4; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.print("\nInitializing SD card..."); // we'll use the initialization code from the utility libraries // since we're just testing if the card is working! if (!card.init(SPI_HALF_SPEED, chipSelect)) { Serial.println("initialization failed. Things to check:"); Serial.println("* is a card inserted?"); Serial.println("* is your wiring correct?"); Serial.println("* did you change the chipSelect pin to match your shield or module?"); while (1); } else { Serial.println("Wiring is correct and a card is present."); } // print the type of card Serial.println(); Serial.print("Card type: "); switch (card.type()) { case SD_CARD_TYPE_SD1: Serial.println("SD1"); break; case SD_CARD_TYPE_SD2: Serial.println("SD2"); break; case SD_CARD_TYPE_SDHC: Serial.println("SDHC"); break; default: Serial.println("Unknown"); } // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32 if (!volume.init(card)) { Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card"); while (1); } Serial.print("Clusters: "); Serial.println(volume.clusterCount()); Serial.print("Blocks x Cluster: "); Serial.println(volume.blocksPerCluster()); Serial.print("Total Blocks: "); Serial.println(volume.blocksPerCluster() * volume.clusterCount()); Serial.println(); // print the type and size of the first FAT-type volume uint32_t volumesize; Serial.print("Volume type is: FAT"); Serial.println(volume.fatType(), DEC); volumesize = volume.blocksPerCluster(); // clusters are collections of blocks volumesize *= volume.clusterCount(); // we'll have a lot of clusters volumesize /= 2; // SD card blocks are always 512 bytes (2 blocks are 1KB) Serial.print("Volume size (Kb): "); Serial.println(volumesize); Serial.print("Volume size (Mb): "); volumesize /= 1024; Serial.println(volumesize); Serial.print("Volume size (Gb): "); Serial.println((float)volumesize / 1024.0); Serial.println("\nFiles found on the card (name, date and size in bytes): "); root.openRoot(volume); // list all files in the card with date and size root.ls(LS_R | LS_DATE | LS_SIZE); } void loop(void) { }
Fineal Code :-
//Prateek //www.prateeks.in #include
LiquidCrystal lcd(3,2,14,15,16,17); #include
#include
#include
#include
#define CS_RFID 10 #define RST_RFID 9 #define CS_SD 4 \ File myFile; MFRC522 rfid(CS_RFID, RST_RFID); String uidString; RTC_DS1307 rtc; // Define check in time const int checkInHour = 11; const int checkInMinute = 50; int userCheckInHour; int userCheckInMinute; const int redLED = 6; const int greenLED = 7; const int buzzer = 5; void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(buzzer, OUTPUT); Serial.begin(9600); lcd.begin(16,2); while(!Serial); SPI.begin(); rfid.PCD_Init(); Serial.print("Initializing SD card..."); lcd.print("Initializing "); lcd.setCursor(0, 1); lcd.print("SD card..."); delay(3000); lcd.clear(); if(!SD.begin(CS_SD)) { Serial.println("initialization failed!"); lcd.print("Initializing "); lcd.setCursor(0, 1); lcd.print("failed!"); return; } Serial.println("initialization done."); lcd.print("Initialization "); lcd.setCursor(0, 1); lcd.print("Done..."); if(!rtc.begin()) { Serial.println("Couldn't find RTC"); lcd.clear(); lcd.print("Couldn't find RTC"); while(1); } else { // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); } if(!rtc.isrunning()) { Serial.println("RTC is NOT running!"); lcd.clear(); lcd.print("RTC Not Running!"); } } void loop() { //look for new cards if(rfid.PICC_IsNewCardPresent()) { readRFID(); logCard(); verifyCheckIn(); } delay(10); } void readRFID() { rfid.PICC_ReadCardSerial(); lcd.clear(); Serial.print("Tag UID: "); lcd.print("Tag UID: "); uidString = String(rfid.uid.uidByte[0]) + " " + String(rfid.uid.uidByte[1]) + " " + String(rfid.uid.uidByte[2]) + " " + String(rfid.uid.uidByte[3]); Serial.println(uidString); lcd.setCursor(0, 1); lcd.print(uidString); delay(2000); tone(buzzer, 2000); delay(200); noTone(buzzer); delay(200); } void logCard() { digitalWrite(CS_SD,LOW); myFile=SD.open("DATA.txt", FILE_WRITE); if (myFile) { Serial.println("File opened ok"); lcd.clear(); lcd.print("File opened ok"); delay(2000); myFile.print(uidString); myFile.print(", "); DateTime now = rtc.now(); myFile.print(now.year(), DEC); myFile.print('/'); myFile.print(now.month(), DEC); myFile.print('/'); myFile.print(now.day(), DEC); myFile.print(','); myFile.print(now.hour(), DEC); myFile.print(':'); myFile.println(now.minute(), DEC); Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.println(now.minute(), DEC); Serial.println("sucessfully written on SD card"); lcd.clear(); lcd.print(now.year(), DEC); lcd.print(':'); lcd.print(now.month(), DEC); lcd.print(':'); lcd.print(now.day(), DEC); lcd.print(' '); lcd.setCursor(11, 0); lcd.print(now.hour(), DEC); lcd.print(':'); lcd.print(now.minute(), DEC); lcd.setCursor(0, 1); lcd.print("Written on SD..."); delay(2000); myFile.close(); userCheckInHour = now.hour(); userCheckInMinute = now.minute(); } else { Serial.println("error opening data.txt"); lcd.clear(); lcd.print("error opening data.txt"); } digitalWrite(CS_SD,HIGH); } void verifyCheckIn(){ if((userCheckInHour < checkInHour)||((userCheckInHour==checkInHour) && (userCheckInMinute <= checkInMinute))){ digitalWrite(greenLED, HIGH); delay(2000); digitalWrite(greenLED,LOW); Serial.println("You're welcome!"); lcd.clear(); lcd.print("You're Welcome!"); } else{ digitalWrite(redLED, HIGH); delay(2000); digitalWrite(redLED,LOW); Serial.println("You are late..."); lcd.clear(); lcd.print("You are Late..."); delay(3000); lcd.clear(); lcd.print("Put RFID to Scan"); } }
PHOTO
0 Comments
Newer
Older
Build Your Own Gps Tracking System using Arduino
How To Make RFID & Keypad Based Door Lock
IoT Based Fingerprint Biometric Attendance System Using NodeMCU (Esp8266)
Ultrasonic Sensor as a Counter with Arduino
ESP32 Interfacing With LDR Sensor
IoT Based Patient Health Monitoring System Using Blynk App
OTP Based Door Lock Using Arduino And SIM800L
Nodemcu Interfacing With Em-18
Measure CO2 Level in Air Using Arduino
NRF Based Servo Motor Control
YouTube
Like on Facebook
Follow on Twitter
Follow on Google+
Follow on Instagram
Subscribe on Youtube
Hi WelCome To My Website If you have a creative mind and want to learn Electronics even without studying it then FRIENDS this Website And Youtube Channel is for you, I am crazy creators who love making Electronics things. I have a bunch of more than 130 Tutorial Videos on My YouTube Channel and I upload a new Tutorial every Sunday.
Tags
Arduino Project
Esp32 Project
Esp8266 Project
0 Comments