One killer feature of the updated library is dynamic tag control. You don't have to stop the simulation to change the UID. Use the Proteus Virtual Terminal:
This allows you to test access control logic, logging, and error handling without hardware.
Even with the update, you might encounter problems. Here’s the troubleshooting guide:
Use the standard MFRC522 library in your real Arduino IDE, but when compiling for Proteus, place the compiled .HEX file in the Arduino’s properties in Proteus.
#include <SPI.h> #include <MFRC522.h>#define RST_PIN 9 #define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init(); Serial.println("Place your tag...");
void loop() if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) Serial.print("UID: "); for (byte i = 0; i < mfrc522.uid.size; i++) Serial.print(mfrc522.uid.uidByte[i], HEX); Serial.print(" "); Serial.println(); mfrc522.PICC_HaltA();
After compiling in Arduino IDE, go to Sketch > Export Compiled Binary. In Proteus, double-click the Arduino UNO, browse to the .HEX file in the Program File field. Run the simulation. As soon as you click "Play," the virtual RC522 will read the pre-configured UID and display it in the virtual serial terminal.
The updated RC522 library opens doors for sophisticated simulation:
Download the MFRC522 library from GitHub (by miguelbalboa). Use this updated code:
#include <SPI.h> #include <MFRC522.h> #include <LiquidCrystal.h>#define RST_PIN 9 #define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN); LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup() Serial.begin(9600); lcd.begin(16, 2); lcd.print("Place RFID Tag");
SPI.begin(); mfrc522.PCD_Init();
// New feature: Check for updated simulated version byte version = mfrc522.PCD_ReadRegister(mfrc522.VersionReg); Serial.print("Chip Version: 0x"); Serial.println(version, HEX); // Expected in simulation: 0x92 or 0x91 (not 0x12 from old buggy lib)
void loop() if (!mfrc522.PICC_IsNewCardPresent()) return; if (!mfrc522.PICC_ReadCardSerial()) return;
lcd.clear(); lcd.print("UID:"); for (byte i = 0; i < mfrc522.uid.size; i++) lcd.print(mfrc522.uid.uidByte[i], HEX); lcd.print(" ");
mfrc522.PICC_HaltA(); delay(2000);
One killer feature of the updated library is dynamic tag control. You don't have to stop the simulation to change the UID. Use the Proteus Virtual Terminal:
This allows you to test access control logic, logging, and error handling without hardware.
Even with the update, you might encounter problems. Here’s the troubleshooting guide:
Use the standard MFRC522 library in your real Arduino IDE, but when compiling for Proteus, place the compiled .HEX file in the Arduino’s properties in Proteus.
#include <SPI.h> #include <MFRC522.h>#define RST_PIN 9 #define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init(); Serial.println("Place your tag...");
void loop() if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) Serial.print("UID: "); for (byte i = 0; i < mfrc522.uid.size; i++) Serial.print(mfrc522.uid.uidByte[i], HEX); Serial.print(" "); Serial.println(); mfrc522.PICC_HaltA();
After compiling in Arduino IDE, go to Sketch > Export Compiled Binary. In Proteus, double-click the Arduino UNO, browse to the .HEX file in the Program File field. Run the simulation. As soon as you click "Play," the virtual RC522 will read the pre-configured UID and display it in the virtual serial terminal.
The updated RC522 library opens doors for sophisticated simulation:
Download the MFRC522 library from GitHub (by miguelbalboa). Use this updated code:
#include <SPI.h> #include <MFRC522.h> #include <LiquidCrystal.h>#define RST_PIN 9 #define SS_PIN 10
MFRC522 mfrc522(SS_PIN, RST_PIN); LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup() Serial.begin(9600); lcd.begin(16, 2); lcd.print("Place RFID Tag");
SPI.begin(); mfrc522.PCD_Init();
// New feature: Check for updated simulated version byte version = mfrc522.PCD_ReadRegister(mfrc522.VersionReg); Serial.print("Chip Version: 0x"); Serial.println(version, HEX); // Expected in simulation: 0x92 or 0x91 (not 0x12 from old buggy lib)
void loop() if (!mfrc522.PICC_IsNewCardPresent()) return; if (!mfrc522.PICC_ReadCardSerial()) return;
lcd.clear(); lcd.print("UID:"); for (byte i = 0; i < mfrc522.uid.size; i++) lcd.print(mfrc522.uid.uidByte[i], HEX); lcd.print(" ");
mfrc522.PICC_HaltA(); delay(2000);