i brought a rfid module which is rc 522 but when i upload the code it is not reading the card even when i upload example code i have returned it 2 times and got it replaced but the same problem may i know the solution
#include "SPI.h" // SPI library
#include "MFRC522.h" // RFID library (https://github.com/miguelbalboa/rfid)
const int pinRST = 9;
const int pinSDA = 10;
MFRC522 mfrc522(pinSDA, pinRST); // Set up mfrc522 on the Arduino
void setup() {
SPI.begin(); // open SPI connection
mfrc522.PCD_Init(); // Initialize Proximity Coupling Device (PCD)
Serial.begin(9600); // open serial connection
}
void loop() {
if (mfrc522.PICC_IsNewCardPresent()) { // (true, if RFID tag/card is present ) PICC = Proximity Integrated Circuit Card
if(mfrc522.PICC_ReadCardSerial()) { // true, if RFID tag/card was read
Serial.print("RFID TAG ID:");
for (byte i = 0; i < mfrc522.uid.size; ++i) { // read id (in parts)
Serial.print(mfrc522.uid.uidByte[i], HEX); // print id as hex values
Serial.print(" "); // add space between hex blocks to increase readability
}
Serial.println(); // Print out of id is complete.
}
}
}
this is one of the many codes i used
-
1What gets printed? You have a lot of serial prints there, can you please edit the question and share what you see?Nick Gammon– Nick Gammon ♦2021年11月08日 06:17:45 +00:00Commented Nov 8, 2021 at 6:17
-
1i just see nothingAkshit Singh– Akshit Singh2021年11月08日 14:50:48 +00:00Commented Nov 8, 2021 at 14:50
-
Possibly you have wired it incorrectly. Without seeing any photos, links to the module you bought, or schematics, it is very hard, if not impossible, to say.Nick Gammon– Nick Gammon ♦2021年11月09日 06:15:45 +00:00Commented Nov 9, 2021 at 6:15
-
SDA 10, SCK 13, MOSI 11, MISO 12, IRQ UNUSED, GND GND, RST 9, 3.3V 3.3V, i dont feel they are wrongAkshit Singh– Akshit Singh2021年11月09日 14:05:04 +00:00Commented Nov 9, 2021 at 14:05
lang-cpp