Giới thiệu Module thẻ từ RFID RC522 SPI
Module thẻ từ RFID RC522 SPI sử dụng IC MFRC522 của Phillip dùng để đọc và ghi dữ liệu cho thẻ NFC tần số 13.56mhz, với mức giá rẻ thiết kế nhỏ gọn, module này là sự lựa chọn hàng đầu cho các ứng dụng về ghi đọc thẻ RFID.
RFID (Radio Frequency Identification) là công nghệ nhận dạng đối tượng bằng sóng vô tuyến. Công nghệ này cho phép nhận biết các đối tượng thông qua hệ thống thu phát sóng radio, từ đó có thể giám sát, quản lý hoặc lưu vết từng đối tượng.
Một hệ thống RFID thường bao gồm 2 thành phần chính là thẻ tag (chip RFID chứa thông tin) và đầu đọc (reader) đọc các thông tin trên chip.
Ngoài ra còn có : Lora – NRF24L01,…
Các truyền không dây: HC-12 / RF / RFID,…
Anten đi kèm: Anten 433MHz

Chức năng các chân
- 3.3V : Cấp nguồn 3.3V.
- RST : Reset chuẩn SPI.
- GND : Cấp nguồn 0V
- IRQ : Không kết nối.
- MISO : Truyền SPI
- MOSI : Truyền SPI
- SCK : Tạo xung SPI
- SS : Cho phép SPI

Thông số kỹ thuật MODULE RFID RC522
- Điện áp hoạt động : 3.3V
- Dòng điện hoạt động : 26mA
- Dòng điện chờ : 1A
- Dòng điện nghĩ : 80uA
- Công suất : 86mW
- Tần số sóng mang : 13.56MHz
- Chuẩn truyền : SPI
- Khoảng cách hoạt động : 0~60mm(mifare1 card)
- Giao tiếp : SPI
- Tốc độ truyền dữ liệu : tối đa 10Mbit/s
- Các loại card RFID hỗ trợ : mifare1 S50, mifare1 S70, mifare UltraLight, mifare Pro, mifare Desfire
- Nhiệt độ hoạt động : -10°C – 60°C
- Số chân : 8
- Loại : Module
- Kích thước : 40mm*60mm
Chương trình Test
Nguyên lý kết nối

Chương trình
Thư viện : Tải MFRC522.h Cài trực tiếp trên phần mềm Arduino IDE
#include <SPI.h> //include the SPI bus library
#include <MFRC522.h> //include the RFID reader library
#define SS_PIN 10 //slave select pin
#define RST_PIN 5 //reset pin
MFRC522 mfrc522(SS_PIN, RST_PIN); // instatiate a MFRC522 reader object.
MFRC522::MIFARE_Key key; //create a MIFARE_Key struct named 'key', which will hold the card information
//this is the block number we will write into and then read.
int block=2;
byte blockcontent[16] = {"Last-Minute-Engg"}; //an array with 16 bytes to be written into one of the 64 card blocks is defined
//byte blockcontent[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //all zeros. This can be used to delete a block.
//This array is used for reading out a block.
byte readbackblock[18];
void setup()
{
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card (in case you wonder what PCD means: proximity coupling device)
Serial.println("Scan a MIFARE Classic card");
// Prepare the security key for the read and write functions.
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF; //keyByte is defined in the "MIFARE_Key" 'struct' definition in the .h file of the library
}
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.println("card selected");
//the blockcontent array is written into the card block
writeBlock(block, blockcontent);
//read the block back
readBlock(block, readbackblock);
//uncomment below line if you want to see the entire 1k memory with the block written into it.
//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
//print the block contents
Serial.print("read block: ");
for (int j=0 ; j<16 ; j++)
{
Serial.write (readbackblock[j]);
}
Serial.println("");
}
//Write specific block
int writeBlock(int blockNumber, byte arrayAddress[])
{
//this makes sure that we only write into data blocks. Every 4th block is a trailer block for the access/security info.
int largestModulo4Number=blockNumber/4*4;
int trailerBlock=largestModulo4Number+3;//determine trailer block for the sector
if (blockNumber > 2 && (blockNumber+1)%4 == 0){Serial.print(blockNumber);Serial.println(" is a trailer block:");return 2;}
Serial.print(blockNumber);
Serial.println(" is a data block:");
//authentication of the desired block for access
byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print("PCD_Authenticate() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return 3;//return "3" as error message
}
//writing the block
status = mfrc522.MIFARE_Write(blockNumber, arrayAddress, 16);
//status = mfrc522.MIFARE_Write(9, value1Block, 16);
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_Write() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return 4;//return "4" as error message
}
Serial.println("block was written");
}
//Read specific block
int readBlock(int blockNumber, byte arrayAddress[])
{
int largestModulo4Number=blockNumber/4*4;
int trailerBlock=largestModulo4Number+3;//determine trailer block for the sector
//authentication of the desired block for access
byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print("PCD_Authenticate() failed (read): ");
Serial.println(mfrc522.GetStatusCodeName(status));
return 3;//return "3" as error message
}
//reading a block
byte buffersize = 18;//we need to define a variable with the read buffer size, since the MIFARE_Read method below needs a pointer to the variable that contains the size...
status = mfrc522.MIFARE_Read(blockNumber, arrayAddress, &buffersize);//&buffersize is a pointer to the buffersize variable; MIFARE_Read requires a pointer instead of just a number
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_read() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return 4;//return "4" as error message
}
Serial.println("block was read");
}
Tham khảo chương trình mẫu và thông tin linh kiện chi tiết tại:

IC SỐ SN74HC14 CỔNG NOT, IC CỔNG LOGIC 14 CHÂN DIP
Vi điều khiển Pic16F877A DIP, Họ PIC của Microchip
IC SỐ SN74HC11 CỔNG AND, IC CỔNG LOGIC 14 CHÂN DIP
Động cơ DC Encoder JGA25-370 12V 60rpm, Động cơ giảm tốc
Đế ra chân ESP32 38 Pin, Kit phát triển esp32 38 pin
Bộ chuyển đổi độ K 4-20mA dãy 0-1300ºC, Bộ chuyển đổi nhiệt độ K
MODULE CẢM BIẾN DHT22 TỐT, ĐO NHIỆT ĐỘ VÀ ĐỘ ẨM
IC SỐ SN74HC153 CỔNG MUX, CỔNG LOGIC GHÉP KÊNH DIP
Module giảm áp XL4015, Ổn áp DC-DC giảm áp 5A
Pic12F629 DIP, VI ĐIỀU KHIỂN HỌ PIC CỦA MICROCHIP
Pic16F684 DÁN SMD, VI ĐIỀU KHIỂN HỌ PIC CỦA MICROCHIP
LED 7ĐOẠN 2SỐ ANODE 0.56IN ĐỎ, LED 7 SEG 25x19x8MM
IC SỐ SN74HC00 CỔNG NAND, IC CỔNG LOGIC 14 CHÂN DIP
ANTEN 433Mhz 12dBi 22CM KIM TRONG, ANTEN LORA, RF
Bộ chuyển đổi Pt100 4-20mA -20-80ºC, Nhiệt độ -20-80 độ C - Loại thường
Module thẻ từ RFID PN532 UART SPI I2C, Mạch thẻ từ NFC 13.56MHz
Phíp đồng lỗ đơn 2 mặt màu xanh 4x6cm, Board PCB lỗ 2 lớp
LED 5MM PHỦ MÀU VÀNG CHÂN NGẮN, LED SIÊU SÁNG - 40 CON
Module cảm biến đo điện áp dòng điện INA3221 , Đo điện áp dòng điện
LED 7ĐOẠN 1SỐ ANODE 0.56IN ĐỎ, LED 7 SEG 12.5x19x8MM
ĐỘ K THỦY TINH M12 2000MM, CẢM BIẾN ĐỘ K LÒ XO
Dây cảm biến nhiệt độ LM35 1m, Đo nhiệt độ môi trường
TRANSISTOR NPN C2383 DIP, DÃY HOẠT ĐỘNG 160V VÀ 1A
CẦU DIODE KBP610 DIP, CHỈNH LƯU TOÀN KỲ 6A - 1000V
Hàng rào Cái vuông đôi thẳng 2*40P 2.54mm, Jump header đôi 40 pin
IC SỐ SN74HC02 CỔNG NOR, IC CỔNG LOGIC 2-INPUT DIP
Công tắc hành trình BEM-156-1C25 250V, Công tắc hành trình hãng BERM
Bộ vitme T8 250mm trục đứng khớp mềm, Trục in 3D bằng đai ốc 30x34mm
Điện trở 18R 1/4W 5 vòng màu, Điện trở 1/4W - 100 con
Module giảm áp XL4005 ADJ 5A, Module ổn áp DC-DC giảm áp 5A
CẢM BIẾN MÀU SẮC TCS3200, NHẬN DIỆN MÀU RGB
Jack DC Cái 5.5x2.1mm đầu domino, Đầu nối nguồn thông dụng
ĐIỆN TRỞ 7K5 10W, ĐIỆN TRỞ CÔNG SUẤT SỨ
Pic12F683 DÁN SMD, VI ĐIỀU KHIỂN HỌ PIC CỦA MICROCHIP
Module giảm áp ASM1117 5V ngang , Mạch giảm áp DC-DC 800mA
Module giảm áp ASM1117 3.3V ngang , Mạch giảm áp DC-DC 800mA
Dây bus 6pin 40cm 24AWG cùng hướng XH2.54mm, Kích thước chân 2.54mm
Điện trở 270R 1/4W 5 vòng màu, Điện trở 1/4W - 100 con
Kìm cắt linh kiện YTH-101 93mm, Kìm cắt dây điện
IC SN74HC125 3 TRẠNG THÁI, IC CỔNG LOGIC 14 CHÂN DIP
IC SỐ SN4HC245 IC ĐỆM, IC 3 TRẠNG THÁI 8BIT DIP
Dây bus 3pin 40cm 24AWG cùng hướng XH2.54mm, Kích thước chân 2.54mm
CẦU DIODE KBPC810 DIP, CHỈNH LƯU TOÀN KỲ 8A - 1000V
TIỆM CẬN KIM LOẠI LJ18A3-8-J/EZ 2 DÂY 90-250VAC, CẢM BIẾN THƯỜNG MỞ
Bộ thanh trượt tròn T8 200mm Trục đứng, Thanh trượt cố định đai ốc vitme
IC SỐ SN74HC238 3 SANG 8, IC CỔNG LOGIC MỞ RỘNG DIP
IC KIA 7809 ổn áp nhựa, ngõ ra điện áp dương 9V
TRANSISTOR NPN 2N5551 DIP, HOẠT ĐỘNG 160V VÀ 300mA
Anten 2.4G/5.8Ghz 10dBi 15cm kim trong, anten wifi, zigbee
Cảm biến phao điện tử P75 220V, Công tắc phao điện tử
Điện trở 15R 1/4W 5 vòng màu, Điện trở 1/4W - 100 con
ĐỘ K WRN LỖ VÍT M4 1000MM, CẢM BIẾN ĐẦU DÒ DÂY HỢP KIM
Module Dimmer PWM DC 20A 10-60VDC tốt, Điện áp ngõ ra 12 - 48V
Điện trở 33R 1/4W 5 vòng màu, Điện trở 1/4W - 100 con
Cảm biến lực FSR402 1Kg, Cảm biến áp suất điện trở
Pic16F946 DÁN SMD, VI ĐIỀU KHIỂN HỌ PIC CỦA MICROCHIP
ĐỘNG CƠ SERVO 25KG, ĐỘNG CƠ QUAY GÓC 0 - 180 ĐỘ
ANTEN 2.4G/5.8GHz 8DBI 16CM LỖ TRONG, ANTEN WIFI, ZIGBEE
Pic16F688 DIP, VI ĐIỀU KHIỂN HỌ PIC CỦA MICROCHIP
Module GPS GY-NEO 6M Anten rời, Mạch định vị tọa độ GPS 















Đánh giá
Chưa có đánh giá nào.