Simple arduino library for rfid RC522
src/
├── Srfid.cpp
└── Srfid.h
#include <SPI.h> // Dependencies
#include <MFRC522.h> // Dependencies
#include <Srfid.h> // Library Srfid
#define PIN_SS 4
#define PIN_RESET 5
MFRC522::MIFARE_Key key;
MFRC522 rfid(PIN_SS, PIN_RESET);
Srfid myRfid(&rfid, &key);
Constructor of Srfid
- *rfid: Pointer to MFRC522 instace
- *key: Pointer to MIFARE_Key definition
Srfid myRfid(&rfid, &key);
Init SRFID card
myRfid.init();
Clear Srfid key default
myRfid.resetKey();
Check if the card is present and valid
myRfid.verify();
Closes all operations
myRfid.finaly();
Get type of card rfid
Serial.print("Type: ");
String type = myRfid.getType();
Serial.println(type);
Get uid of card rfid
Serial.print("UID: ");
String uid = myRfid.getUUID();
Serial.println(uid);
Get name of card rfid, sector 1, blockAddr 4, trailerBlock 7
Serial.print("Name: ");
String name = myRfid.getName();
Serial.println(name);
Get last name of card rfid, sector 0, blockAddr 1, trailerBlock 3
Serial.print("Last Name: ");
String lastName = myRfid.getLastName();
Serial.println(lastName);
Get full name of card rfid
- separator: separator between strings
Serial.print("FullName: ");
String fullname = myRfid.getFullName(" ");
Serial.println(fullname);
Set name in the card if valid authenticate
- *buffer: string with content
byte buffer[34], len;
Serial.setTimeout(20000L);
Serial.println(F("Enter the name, then the character #"));
len = Serial.readBytesUntil('#', (char *) buffer, 30);
for (byte i = len; i < 30; i++) buffer[i] = ' ';
srfid.setName(buffer);
Set name in the card if valid authenticate
- *buffer: string with content
byte buffer[34], len;
Serial.setTimeout(20000L);
Serial.println(F("Enter the name, then the character #"));
len = Serial.readBytesUntil('#', (char *) buffer, 30);
for (byte i = len; i < 30; i++) buffer[i] = ' ';
srfid.setLastName(buffer);