Happy day to everyone. I have a problem with an RFID-RC522 connected to an ELEGOO board arduino if you want to see some details you can find them all at this link. The problem I am experiencing is that whatever tutorial I see does not work to recognize the card. I will put my sketch and a picture of the configuration I used. I hope to get help and I really hope it is not my RFID-RC522 that is the problem, thank you very much for listening.
/**
* Source code:
* https://www.italiantechproject.it/sensori-con-arduino/lettore-rfid
*/
#include <MFRC522.h>
MFRC522 rfid(10, 5);
void setup(){
Serial.begin(19200);
SPI.begin();
rfid.PCD_Init();
}
void loop(){
bool x=rfid.PICC_IsNewCardPresent();
bool y=rfid.PICC_ReadCardSerial();
Serial.println("===");
Serial.println(x);
Serial.println("###");
Serial.println(y);
Serial.println("===");
getUID();
if (rfid.PCD_PerformSelfTest()) Serial.println("Passed Self-Test");
//x and y alsays 0 in any case
if(x && y){
String uid = getUID();
Serial.println("RFID ID: " + uid);
}
else{
Serial.println("RFID ID not working ");}
delay(1000);
}
String getUID(){
String uid = "";
Serial.println("READING");
for(int i = 0; i < rfid.uid.size; i++){
uid += rfid.uid.uidByte[i] < 0x10 ? "0" : "";
uid += (rfid.uid.uidByte[i], HEX);
Serial.print(rfid.uid.uidByte[i]);
}
Serial.println("READED");
rfid.PICC_HaltA();
return uid;
}

