I tried many ways to get and print UID and other data from MIFARE Ultralight but it always ends with error. I am using RFID-RC522
reader with Arduino UNO and MFRC522 Library.
I can normally get and print the PICC type of chip, but that's the only thing that works.
That's how I have connected my RC522 reader:
(source: ytimg.com)
This is my code:
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9
#define SS_PIN 10
MFRC522 rfid(SS_PIN, RST_PIN);
unsigned long noSignal = 0;
bool lastState = true;
bool read = true;
void setup()
{
pinMode(2, OUTPUT); //Red led
pinMode(3, OUTPUT); //Green led
Serial.begin(9600);
SPI.begin();
while (!Serial);
rfid.PCD_Init();
Serial.println("RFID ctecka byla uspesne spustena."); //Prints "RFID Reader succesfully started"
Serial.println();
changeLed(true);
}
void changeLed(bool red)
{
digitalWrite(2, red);
digitalWrite(3, !red);
}
void loop()
{
if (millis() - noSignal >= 300)
{
changeLed(true);
read = true;
}
bool state = !rfid.PICC_IsNewCardPresent() && !rfid.PICC_ReadCardSerial();
if (state != lastState)
if (state)
noSignal = millis();
else if (read)
{
read = false;
changeLed(false);
noSignal = millis();
Serial.println("---------Cip detekovan----------"); //Prints "Chip detected"
Serial.println();
MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
Serial.print("Znacka cipu: ");//Prints chip type
Serial.println(rfid.PICC_GetTypeName(piccType));
rfid.PICC_DumpToSerial(&rfid.uid); //Here is the error
Serial.println();
Serial.println("---------Cteni skoncilo----------");//prints "Read ended"
Serial.println();
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
lastState = state;
}
Serial monitor snapshot:
Maybe important thing is that when i call PCD_DumpVersionToSerial()
i get:
Firmware Version: 0x12 = (unknown)
Somewere I read that my Arduino isn't compatibile with MIFARE Ultralight and I need MIFARE Classic cards. Is that true? Can I solve this problem by using other library or it's hardware problem? Thanks
Btw. Sorry for my english, it's not my native language.
EDIT: I asked my friend, which have arduino too from same shop like me, if he can read MIFARE Ultralight cards. He said that it's working for him. So my problem will be probably on hardware side. We both have unoficial arduino from aliexpress.