Rfid reader doesn't work

Hey, I have a Problem with my Rfid System. The rfid reader doesn't send any data to my arduino. Can you help me?

My Pins:

SDA Pin 10
SCK Pin 13
MOSI Pin 11
MISO Pin 12
GND GND
RST Pin 9
3.3V 3.3V

My Code:

#include <SPI.h>
#include <MFRC522.h>
 
#define RST_PIN   9     // SPI Reset Pin
#define SS_PIN    10    // SPI Slave Select Pin
 
MFRC522 mfrc522(SS_PIN, RST_PIN);   

void setup() {
  Serial.begin(9600);
  SPI.begin();   
  mfrc522.PCD_Init();
}
 
void loop() {
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial() ) {
    Serial.print("Gelesene UID:");
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
      Serial.print(mfrc522.uid.uidByte[i], HEX);
    } 
    Serial.println();
    mfrc522.PICC_HaltA();
    delay(1000);
  }
}

It is wired up all wrong. The SPI pins on the Mega are not the same as on a UNO. See:-
SPI Pins on a Mega

On top of that the RFID reader is powered by 3V3, and the Mega runs from 5V, so that means the signals sent to the reader by the Mega are above the reader's supply. This could / will damage the reader.

You have to sort out which signals are what and have a potential divider for the 5V ones, like in this diagram.
Note it is labelled for a Raspberry Pi but it will apply to signals into and out of the reader.

Hi, @zhut006
Welcome to the forum.
Thanks for using code tags for your code. :+1:

Have you Googled;

mega and rfiid reader

This might even help, even though it is a destructible project.

Tom.... :smiley: :coffee: :+1: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.