Arduino YUN using RC522

Hello everyone, has anyone tried to build a circuit using this RFID shield? I have been trying to connect it with Arduino’s Monitor but not been succesful. As i didnt find any example for wiring the YUN, i connected like the Leonardo but still i havent been able to send anything through the serial port or to read the serial number of a card.

I have included a picture of how i connected the board and the sketch it’s like this:

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
#define SS_PIN 10 //Pin 10 para el SS (SDA) del RC522
MFRC522 mfrc522(SS_PIN, RST_PIN); //Creamos el objeto para el RC522

void setup() {
Serial.begin(9600); //Iniciamos la comunicación serial
SPI.begin(); //Iniciamos el Bus SPI
mfrc522.PCD_Init(); // Iniciamos el MFRC522
Serial.println(“Lectura del UID”);
}

void loop() {
// Revisamos si hay nuevas tarjetas presentes
if ( mfrc522.PICC_IsNewCardPresent())
{
//Seleccionamos una tarjeta
if ( mfrc522.PICC_ReadCardSerial())
{
// Enviamos serialemente su UID
Serial.print(“Card UID:”);
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " ");
_ Serial.print(mfrc522.uid.uidByte*, HEX); _
_
}_
_
Serial.println();_
_
// Terminamos la lectura de la tarjeta actual*_
* mfrc522.PICC_HaltA();
_
} _
_
}_
_
}_
Maybe you saw that I have this in my code: #define RST_PIN 9 , the program it is for an Arduino UNO but the author said I only need to do the wiring different for another card and it would work, but it doesnt.
If you may be so kind of helping me with this. I am just beginning with Arduinos.
Thank you

*

You are using pin 9 as your reset line, but you don't have anything connected to it. Instead, it appears you have the RFID module's reset connected to the ICSP header reset line. This means that it will be reset whenever the AVR processor is reset, but the sketch will not have the ability to reset the module. This could be causing your communication issues?

Also, in your diagram, it looks like you have some wires connected to pins 0 and 1, but the drawing is cut off and it doesn't show what goes there. On the Yun, those pins are dedicated to communications with the Linux processor. If you have external circuitry connected there, it is likely to cause problems.

Thank for replying, you are right, I am going to connect something to the pins 0 and 1, that will be a fingerprint reader. I am planning to build an Access control terminal using MIFARE cards and/or fingerprint. But i want to start step by step, first i want to make work each individual module, so that I dont have anything connected there yet.

I have connected the reset to the pin 9 but it didn’t worked. I tried the example provided withing the library:

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_PIN 10 // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F(“Scan PICC to see UID, type, and data blocks…”));
}

void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}

// Dump debug info about the card; PICC_HaltA() is automatically called
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

Even i used an Arduino UNO with the same connection explained in the sketch but anyway not working. i just got this in the serial monitor:

Firmware Version: 0x0 = (unknown)
WARNING: Communication failure, is the MFRC522 properly connected?
Scan PICC to see UID, type, and data blocks…

But it still can’t read any card. Do you think the RFID is damaged?
The example is for MFRC522, and it’s called DumpInfo

carloshm:
Thank for replying, you are right, I am going to connect something to the pins 0 and 1, that will be a fingerprint reader.

You need to start making new plans, as your planned connections will not work. You can use pins 0 and 1 for serial communications on most other Arduino boards, but you cannot do that with a Yun. Those pins are dedicated for bridge communications with the Linux processor. You cannot also use them for any other purpose.

Come up with another way of connecting your fingerprint reader, like using SoftwareSerial on a different set of pins. If using SoftwareSerial, make sure to read the limitations on pin selection as they apply to a Leonardo board. The Yun and the Leonardo use the same processor, and they have the same restriction that not all pins can be used for SoftwareSerial communications.

But it still can't read any card. Do you think the RFID is damaged?

If it doesn't work with two different types of controller boards, then it could indeed be damaged. In taking a closer look at your wiring diagram, and some quick searches on the RFID-RC522 board, it appears that the board runs on 3.3 volts. In your diagram, you are powering it from the 5 volt pin of the ICSP connector. The MFRC522 chip's data sheet gives a maximum supply voltage of 3.6 volts. It's quite likely that the 5 volt supply has permanently damaged the chip.

The Yun does have a 3.3 volt power supply output pin, but it is limited to 50 mA. From the data sheet, it looks like the MFRC522 chip draws more than three times that much current, so you cannot power the board directly from the Yun. You will very likely have to use an external voltage regulator to properly power this RFID board. Or, start with an Arduino compatible board that runs natively on 3.3V instead of 5V.

I solved it, but it was not what I expected. First, i wanna say that the example in Arduino says that these are the connections:


  • MFRC522 Arduino Arduino Arduino Arduino Arduino
  • Reader/PCD Uno Mega Nano v3 Leonardo/Micro Pro Micro
  • Signal Pin Pin Pin Pin Pin Pin

  • RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
  • SPI SS SDA(SS) 10 53 D10 10 10
  • SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
  • SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
  • SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15

I tried yo use the Leonardo’s because the pinout is identical than Yun, but it didnt work, then when i changed Reset to PIN 9, just like the sketch shows below this table, it worked perfectly.

I also tried what you told me, i used a sketch with SoftwareSerial and the fingerprint reader connected to non-RX-TX pins and it worked well, those where pins 2 and 3.

But now i have another doubt, why the **** it worked when i changed computer?? I was programming from a Windows 7 x64 system, then i tried with a Windows 7 x32 system. I don’t know if it has anything to do but anyway, now it’s working. With the windows x64 i couldnt even use a LCD screen hahaha.

Here is the info is it’s useful for anyone.