coolcat231
Published © CC BY-SA

Simple RFID tutorial

I will explain how an RFID reader works and how to use one. Enjoy :)

IntermediateFull instructions provided4,637
Simple RFID tutorial

Things used in this project

Hardware components

RFID reader (generic)
blue or red
×1
Arduino UNO
Arduino UNO
or mega
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Resistor 220 ohm
Resistor 220 ohm
×2
Jumper wires (generic)
Jumper wires (generic)
×10
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematics

Schematics, RFID reader in the description

Schematics image

RFID schematic in the description. If not clear, connections are also in the description. :)

Code

Code

C/C++
Paste into your ide and change the uid.
#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() 
{
  pinMode(4,OUTPUT);
  pinMode(3,OUTPUT);
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Approximate your card to the reader...");
  Serial.println();

}
void loop() 
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "53 F7 CE 18") //to find card uid go to the serial moniter, scan your card and copy uid into the section

  {
    digitalWrite(4,HIGH);
    digitalWrite(3,LOW);
    Serial.println("Authorized access");
    Serial.println();
    delay(3000);
  }
 
 else   {
    digitalWrite(4,LOW);
    digitalWrite(3,HIGH);
    Serial.println(" Access denied");
    delay(3000);
  }
} 

Credits

coolcat231

coolcat231

0 projects • 0 followers

Comments