So, every month one or two employees arrive late or leave early. What about an employee time clock with RFID?
How it will work?Every employee will receive one RFID card. When they arrive they will have to out the card over the reader and the time and card serial will be saved into a microSD text file. Once a month, accountant department will be able to open the text file and view arrive and departure times for every employee.
For this project, Arduino MKRZero board will be used due to microSD card reader and RTC clock. Of course you can also use a standard Arduino, an external microSD and an external RTC but MKRZero is the best choice.
We will also use a buzzer to let you know that the system is ready and to let each employee know that time has been registered.
ConnectionsPin 6 and 7 will be used for RFID RST and SS
#define RST_PIN 6 //reset del RC522
#define SS_PIN 7 // SS (SDA) del RC522
There are the libraries required
#include <SD.h>
#include <RTCZero.h>
#include <SPI.h>
#include <MFRC522.h>
This is the code to start SPI and 522
SPI.begin();
mfrc522.PCD_Init();
To detect a new card present:
if ( mfrc522.PICC_ReadCardSerial())
To read card ID:
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
s1 = s1 + (mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
s1 = s1 + String(mfrc522.uid.uidByte[i], HEX);
}
To save into SD:
File dataFile = SD.open("datalog.txt", FILE_WRITE);
dataString= getTime()+" Tarjeta: "+s1;
// Si el arcchivo esta se graba
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
}
// el archivo no esta abierto
else {
Serial.println("Error abriendo datalog.txt");
}
Project demo below:
ImprovementsThere are lots of things to do from here. You can also open an automated door lock with the same card. You can send the card ID and time through the web to an external database so you don't have to read the microSD, etc
Comments