RFID Card Read Component Documentation
The RFID Card Read component is a peripheral device that allows for the reading of Radio-Frequency Identification (RFID) tags embedded in cards, passports, or other objects. This component is commonly used in access control systems, inventory tracking, and identification applications.
Technical Specifications:
Operating Frequency: 13.56 MHz
Communication Interface: UART (Universal Asynchronous Receiver-Transmitter)
Reading Range: Up to 10 cm (4 inches)
Supported RFID Protocols: ISO 14443A, ISO 14443B, ISO 18092
Power Supply: 5V DC, 100 mA
### Example 1: Basic RFID Card Reading using Arduino
This example demonstrates how to use the RFID Card Read component with an Arduino board to read an RFID card and display the card's unique identifier (UID) on the serial monitor.
```c++
#include <SoftwareSerial.h>
#define RFID_RX_PIN 2
#define RFID_TX_PIN 3
SoftwareSerial rfidSerial(RFID_RX_PIN, RFID_TX_PIN);
void setup() {
Serial.begin(9600);
rfidSerial.begin(9600);
}
void loop() {
String tagUid = readRfidTag();
if (tagUid != "") {
Serial.print("RFID Tag UID: ");
Serial.println(tagUid);
}
delay(1000);
}
String readRfidTag() {
String tagUid = "";
byte val = 0;
if (rfidSerial.available() > 0) {
val = rfidSerial.read();
if (val == 0x02) { // Start of RFID tag response
for (int i = 0; i < 5; i++) {
val = rfidSerial.read();
tagUid += String(val, HEX);
}
}
}
return tagUid;
}
```
### Example 2: Using the RFID Card Read component with Raspberry Pi (Python)
This example demonstrates how to use the RFID Card Read component with a Raspberry Pi to read an RFID card and store the card's UID in a SQLite database.
```python
import serial
import sqlite3
# Open the serial connection to the RFID reader
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
# Connect to the SQLite database
conn = sqlite3.connect('rfid_database.db')
cursor = conn.cursor()
while True:
# Read the RFID tag
tag_uid = read_rfid_tag(ser)
if tag_uid:
# Insert the tag UID into the database
cursor.execute("INSERT INTO rfid_tags (uid) VALUES (?)", (tag_uid,))
conn.commit()
print("RFID Tag UID: ", tag_uid)
# Sleep for 1 second before reading the next tag
time.sleep(1)
def read_rfid_tag(ser):
tag_uid = ""
while True:
val = ser.read()
if val == b'x02': # Start of RFID tag response
for i in range(5):
val = ser.read()
tag_uid += format(val, '02x')
break
return tag_uid
```
These code examples demonstrate the basic usage of the RFID Card Read component in different contexts. You can modify and extend these examples to suit your specific application requirements.