Skip to content

giovanesantossilva/srfid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Srfid

Simple arduino library for rfid RC522

Table of contents

Main

src/
├── Srfid.cpp       
└── Srfid.h

Getting started

Basic use

#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);

Methods

Srfid::Srfid(MFRC522 *rfid, MFRC522::MIFARE_Key *key)

Constructor of Srfid

  • *rfid: Pointer to MFRC522 instace
  • *key: Pointer to MIFARE_Key definition
Srfid myRfid(&rfid, &key);

void Srfid::init()

Init SRFID card

myRfid.init();

void Srfid::resetKey()

Clear Srfid key default

myRfid.resetKey();

void Srfid::verify()

Check if the card is present and valid

myRfid.verify();

void Srfid::finaly()

Closes all operations

myRfid.finaly();

String Srfid::getType()

Get type of card rfid

Serial.print("Type: ");
String type = myRfid.getType(); 
Serial.println(type);

String Srfid::getUUID()

Get uid of card rfid

Serial.print("UID: ");
String uid = myRfid.getUUID(); 
Serial.println(uid);

String Srfid::getName()

Get name of card rfid, sector 1, blockAddr 4, trailerBlock 7

Serial.print("Name: ");
String name = myRfid.getName(); 
Serial.println(name);

String Srfid::getLastName()

Get last name of card rfid, sector 0, blockAddr 1, trailerBlock 3

Serial.print("Last Name: ");
String lastName = myRfid.getLastName(); 
Serial.println(lastName);

String Srfid::getFullName(String separator)

Get full name of card rfid

  • separator: separator between strings
Serial.print("FullName: ");
String fullname = myRfid.getFullName(" ");
Serial.println(fullname);

void Srfid::setName(byte *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.setName(buffer);

void Srfid::setLastName(byte *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);

License

MIT © Giovane Santos

About

Simple arduino and esp8266 library for rfid RC522

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages