RFID (Radio Frequency Identification) PDF

Document Details

SpiritedHibiscus6249

Uploaded by SpiritedHibiscus6249

University of Petra

Tags

RFID Radio Frequency Identification technology electronics

Summary

This document provides an overview of RFID (Radio Frequency Identification) technology. It covers the definition, history, applications, and key components of RFID systems. This includes different types of RFID tags such as passive, active, and semi-passive. The document also presents practical examples of RFID applications and programming examples using Arduino.

Full Transcript

RFID (Radio Frequency Identification) Introduction to RFID Definition: RFID (Radio Frequency Identification) is a technology that uses radio waves to automatically identify, and track tags attached to objects. Brief history: Developed during World War II for radar identification, com...

RFID (Radio Frequency Identification) Introduction to RFID Definition: RFID (Radio Frequency Identification) is a technology that uses radio waves to automatically identify, and track tags attached to objects. Brief history: Developed during World War II for radar identification, commercial applications began in the 1980s. Key concept: RFID involves a reader and a tag that communicates via radio frequency to exchange data. Applications of RFID Inventory Management: Track goods in warehouses. Retail: Streamline checkout and prevent theft. Access Control: Manage entry to buildings or restricted areas. Transportation: Toll collection, vehicle tracking. Healthcare: Track patients, medical equipment. Agriculture: Livestock tracking. Components of an RFID System RFID Tag: Types: Passive, Active, Semi-passive. Components: Microchip for storing data, antenna for transmitting and receiving signals. RFID Reader: Device that emits radio waves and receives signals from tags. Antenna: Facilitates communication between the reader and tags. Backend System: Software to process and manage the data collected from tags. How RFID Works The RFID reader emits radio waves to interrogate a tag. The tag's antenna receives the signal and powers the microchip in passive tags. The tag sends data back to the reader, which processes and forwards it to the backend system. Types of RFID Tags: Passive Tags: No internal power source. Rely on energy from the reader's signal. Cost-effective but limited range. Active Tags: Powered by an internal battery. Longer range and more memory. Higher cost. Semi-passive Tags: Internal battery to power the chip but rely on the reader for communication. Balanced cost and performance. RC522 module connections The RC522 module has a total of 8 pins that connect it to the outside world. The connections are as follows: Pin 9 Example: Reading RFID Data with Arduino * Typical pin layout used: * ----------------------------------------------------------------------------------------- * MFRC522 Arduino Arduino Arduino Arduino Arduino * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro * Signal Pin Pin Pin Pin Pin Pin * ----------------------------------------------------------------------------------------- * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST * SPI SS SDA(SS) 10 53 D10 10 10 * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 * * More pin layouts for other boards can be found here: https://github.com/miguelbalboa/rfid#pin-layout */ Reading RFID Data with Arduino #include #include #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 // Configurable, see typical pin layout above MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance void setup() { Serial.begin(9600); // Initialize serial communications with the PC while (!Serial); // Do nothing if no serial port is opened SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 delay(4); // Optional delay. Some board do need more time after init to be ready, mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));// f() for memory optimization } Reading RFID Data with Arduino void loop() { // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle. if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } // Dump debug info about the card; PICC_HaltA() is automatically called mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); } Another version of code for Reading RFID Data with Arduino void loop() { #include if (!rfid.PICC_IsNewCardPresent() || ! #include rfid.PICC_ReadCardSerial()) #define RST_PIN 9 return; Serial.print("UID:"); #define SS_PIN 10 for (byte i = 0; i < rfid.uid.size; i++) { MFRC522 rfid(SS_PIN, RST_PIN); Serial.print(rfid.uid.uidByte[i] < 0x10 ? void setup() { " 0" : " "); Serial.begin(9600); Serial.print(rfid.uid.uidByte[i], HEX); SPI.begin(); } rfid.PCD_Init(); Serial.println(); rfid.PICC_HaltA(); Serial.println("Scan an RFID } tag."); } Practical example Develop a system that activates a stepper motor when a valid RFID tag is scanned. The system uses RFID technology to identify authorized tags and controls the stepper motor using the Arduino microcontroller. Unauthorized tags will not trigger the motor, and a red LED will indicate an invalid attempt. Practical example Code Explanation Initialization: Libraries (SPI.h, MFRC522.h, AccelStepper.h) are included to handle SPI communication, RFID functionality, and motor control. Constants for RFID pins (RST_PIN and SS_PIN) and the LED pin (PIN_LED_RED) are defined.Two valid RFID tag IDs (uid1 and uid2) are stored in arrays for comparison. Hardware Setup:The MFRC522 object is initialized to handle RFID communication. The AccelStepper object is configured for the stepper motor with a HALF4WIRE setup and pin assignments. Practical example Code Explanation Logic Flow: When a tag is detected, its UID is read and compared to the predefined valid UIDs. If the UID matches uid1 or uid2: The move flag is set to true to trigger motor movement. If the UID is invalid: The isRed flag turns the red LED on to indicate unauthorized access. Motor Control: When move is true, the stepper motor is activated using the AccelStepper library. LED Feedback: The red LED provides visual feedback for invalid attempts. Code of Practical example #include #include #include #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 // Configurable, see typical pin layout above MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance #define PIN_LED_RED 7 //boolean isRed = false; boolean move = false; boolean atMaxPosition = false; // Tracks if the motor is at the max position // Insert the IDs of your personal NFC tags byte uid1[] = {0x09, 0x66, 0x03, 0x5D};// this taken from reading the UID information byte uid2[] = {0x5A, 0x2D, 0x5D, 0x02}; // Define motor interface type and pins AccelStepper stepper(AccelStepper::HALF4WIRE, 3, 5, 4, 6); Code of Practical example void setup() { SPI.begin(); mfrc522.PCD_Init(); stepper.setMaxSpeed(700); // Set maximum speed (steps per second) stepper.setAcceleration(300); // Set acceleration (steps per second^2) pinMode(PIN_LED_RED, OUTPUT); } void loop() { // PICC = proximity integrated circuit card if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) return; if (isTagValid(mfrc522.uid.uidByte, mfrc522.uid.size)) { move = true; } else { move = false; digitalWrite(PIN_LED_RED, HIGH); delay(1000); digitalWrite(PIN_LED_RED, LOW); Code of Practical example if (move) { if (atMaxPosition) { // Move to min position stepper.moveTo(-2048); // One full revolution counterclockwise stepper.runToPosition(); atMaxPosition = false; // Toggle state } else { // Move to max position stepper.moveTo(2048); // One full revolution clockwise stepper.runToPosition(); atMaxPosition = true; // Toggle state } delay(1000); // Optional delay between movements } mfrc522.PICC_HaltA(); } Code of Practical example // Function to check if the scanned tag is valid boolean isTagValid(byte *uid, byte size) { if (size != 4) return false; if (memcmp(uid, uid1, 4) == 0 || memcmp(uid, uid2, 4) == 0) { return true; } return false; } RFID UIDs are stored as arrays of bytes. Since you can't directly compare arrays using the == operator in C/C++, memcmp provides a reliable way to compare their contents.

Use Quizgecko on...
Browser
Browser