Arduino Nano not reading RFID (Works on ESP32 & Uno)

I have this RFID working on an ESP32 and an Arduino Uno R4. But I cannot get this to work on the Nano.

Photo below. I've checked the wires 10 times and I've even uploaded a photo to ChatGPT and it says its right too.

I cannot figure out what is wrong

I have

SDA (SS) → D10
SCK → D13
MOSI → D11
MISO → D12
RST → D9
3.3V → 3.3V

Sketch below, (works on ESP32 and Uno R4)

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

// for ESP32 we use SS_PIN=5 and RST_PIN=22
#define SS_PIN 10
#define RST_PIN 9
 
MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  Serial.println("init");
}

void loop() {
  if(rfid.PICC_IsNewCardPresent()) {
    Serial.println("\nI know this card!");
  }
  delay(100);
}

Any ideas what could be wrong with the nano setup? These are Elegoo boards. I've tried 2 diff ones so far.

edit: this is the board I bought

A few questions for you to ponder and research:

  1. On your clone Nano, the 3.3V pin is supplied by the CH340 USB IC. How much current can that IC supply on the 3.3V output?
  2. How much current does your RFID board require?
  3. Is the answer to question #2 greater than the answer to question #1?
  4. How are you accounting for the fact that your Nano has 5V I/O levels but the inputs on your RFID are not 5V tolerant (read "Section 11. Limiting values" in the datasheet and see for yourself)?

for 1. I could measure the current with my multi-meter but that won't tell me how much it can supply total. Not sure how I'd look that up, since it's a clone, it's lacking documentation.

  1. The RFID chip requires 13-26ma
  2. need to figure out 1 to answer this one
  3. Good point, I didn't consider that only 3.3v was to power, and the others would still be 5v. I just wired up RST, SS, SCK and MISO to a 1k resistor each. Same problem though, no read on the RFID.

I should note that using the Uno, even though it's pins are also 5v, the RFID worked fine for that. In the long run I probably should limit the voltage, but it seems like it should still work on the nano in this manner since it works on the uno in that manner.

Not if the answer to question #2 is greater than the answer to question #1 it won't. On the Uno the 3.3V line is supplied from a proper regulator. A wimpy regulator, but still a regulator. And it can supply more current than the CH340 can.

I'm not sure how to find out more about the clone chip, But it looks like it's about 50 mA to 100 mA. So it looks like 2 is less then 1.

Are you thinking these clones are just bad? Maybe a genuine nano would work perhaps?

I think the clones are probably just fine. You're just asking the 3.3V output of the CH340 to supply more current than it's capable of. If you really think you can get 50-100mA out of the V3 line on the CH340, I wish you good luck.

So you're thinking the only way to get the RFID working is to get an external battery and a voltage regulator to step that down to 3.3v?

FWIW I did power the arduino with a 9V battery instead via the VIN pin, but I'm not sure if that provides more current through the 3v3 pin or not.

Also FWIW, I also tried using the 3v on the UNO (with a common ground between the uno, nano and rfid) to give the same regulated 3v that works on the uno to the rfid. That also did not work.

Are the Nano headers soldered to the Nano? It's not quite clear from the image.

If not, solder them.

My next step would be to check if the reader still works with e.g. the ESP32; incorrect wiring might have resulted in damage to the reader.

That is not the way to do it; you need either voltage dividers or level converters. MISO does not need one but MOSI does.

Yeah, it does look like it in one of the photos. A little lean on the solder, but looks OK.

50-100mA from the CH340's 3.3V regulator is about the maximum to be expected, yes. 50mA should not be much of a problem; 100mA may be pushing it.

Should really not be a problem to get this from the 3.3V pin on a typical Nano clone.

May be different with

Yea the headers are soldered on there. I can try pulling all the pins up and checking their voltage to make sure they are working.

I’ve tried all 3 nanos that came with the pack, same issue with all 3.

I ordered a genuine Arduino nano to test with

next update. Genuine arduino nano every also doesn't work with the RFID. I realize that the every has a different chip than the normal nano, so tomorrow I'll test with a normal nano.

So far only working boards are ESP32 and Arduino Uno R4

You could power the RFID with the UNO's 3V - to troubleshoot that with.

Does that mean a genuine unit?

It was about time I learnt something about RFID. My AZ-Delivery MFC522 module arrived today, and tomorrow, Sunday, I will continue my attempt to get it working on a Uno. So far I think I have successfully identified the UIDs of both the key fob and card that accompanied the module. But attempting to use either in a sketch consistently failed with ‘Access denied!’.

There appear to be several similarly named libraries. Which are you using? And that sketch of yours seems far shorter and simpler than those I’ve been looking at. What is your use case? Do you not need to recognise a specific tag ID?

Hopefully, with the basics of RFID achieved on the UNO, I can then try the Nano.

Here is a clone Nano running a modified version of your sketch. It has been changed to allow more than one card read, and to output to an OLED display.

It uses an external 3.3V LDO regulator to take the 5V line down to 3.3V. Besides the regulator, 2 capacitors are required.

In addition, a 74AHC125 is used as a level shifter to translate the Nano's 5V level outputs to 3.3V levels to stay within what the the MFRC522 can handle.

And as you can see with your own eyes, when used with a proper 3.3V supply and level shifters, a Nano is perfectly capable of communicating with the MFRC522. But feel free to keep doing it your way. I'm done here.

#include <MFRC522.h>
#include <Adafruit_SSD1306.h>

// for ESP32 we use SS_PIN=5 and RST_PIN=22
#define SS_PIN 10
#define RST_PIN 9

MFRC522 rfid(SS_PIN, RST_PIN);

Adafruit_SSD1306 oled(128, 64);

const unsigned long clearDisplayTime = 20000;
unsigned long displayTime = 0;

void setup() {
   Serial.begin(115200);

   SPI.begin();
   rfid.PCD_Init();
   Serial.println("init");

   oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
   oled.setRotation(0);
   oled.setTextSize(2);
   oled.setTextColor(WHITE);
   oled.clearDisplay();
   oled.setCursor(0, 0);
   oled.println(F("Ready"));
   oled.display();
}

void loop() {
   if( rfid.PICC_IsNewCardPresent() ) {
      if( rfid.PICC_ReadCardSerial() ) {
         rfid.PICC_HaltA();

         displayTime = millis();
         oled.clearDisplay();
         oled.setCursor(0, 0);
         oled.println(F("I know\nthis card"));
         oled.display();

         Serial.println("\nI know this card!");
         delay(100);
      }
   }

   // clear display after timeout expires
   if( displayTime && millis() - displayTime > clearDisplayTime ) {
      oled.clearDisplay();
      oled.display();
      displayTime = 0;
   }
}

I've been trying various things in the sketch. Things that work on my other boards to try to figure out what it might be. My ending goal is actually using this library

NfcAdapter from GitHub - TheNitek/NDEF: NDEF Library for Arduino. Read and Write NDEF Messages to NFC tags with Arduino.

since I'm reading a record off the card. This sketch works correctly on my ESP32 and the Uno R4.

This sketch has my buttons, mp3player and the rfid. This all "works" on the ESP32, just not reliably, as the commands to the dfplayer are just ignored half the time with the esp32 setup. (separate thread on this forum)

#include "DFRobotDFPlayerMini.h"
#include <MFRC522.h>
#include <SPI.h>
#include <NfcAdapter.h>
#include <Regexp.h>
#include <Bounce2.h>

#define RXD2 16
#define TXD2 17
#define SIZE_BUFFER     18
#define MAX_SIZE_BLOCK  16
#define SS_PIN 21
#define RST_PIN 22
#define NDEF_USE_SERIAL true

int RFID_SDA = 21;
int RFID_RST = 22;
int RFID_SCK = 18;
int RFID_MOSI = 23;
int RFID_MISO = 19;

int bd = 115200;
int serial2_baud = 9600;
int playPauseButtonPin = 5;
int volumeButtonPin = 4;
int isPaused = 0;
int volume = 10;
int cmdDelay = 500;

MFRC522 mfrc522(RFID_SDA, RFID_RST);
NfcAdapter nfc = NfcAdapter(&mfrc522);
DFRobotDFPlayerMini myMP3;
MatchState ms;
Bounce2::Button playPauseButton = Bounce2::Button();
Bounce2::Button volumeButton = Bounce2::Button();

void setup() {
  Serial.begin(bd);
  while(!Serial);
  initButtons();
  initMp3Player();
  initNfcReader();
}

void loop() {
  buttonsLoop();
  nfcLoop();
}

void buttonsLoop() {
  playPauseButton.update();
  volumeButton.update();
  if (playPauseButton.pressed()) {
    handlePlayPauseButton();
  }
  if (volumeButton.pressed()) {
    handleVolumeButton();
  }
}

void handlePlayPauseButton() {
  Serial.println("handle play pause button");
  if (isPaused) {
    myMP3.start();
    delay(cmdDelay);
    Serial.println("resume");
    isPaused = 0;
  } else {
    myMP3.pause();
    delay(cmdDelay);
    Serial.println("pause");
    isPaused = 1;
  }
}

void handleVolumeButton() {
  Serial.println("handle volume");
  if (volume == 30) {
    Serial.println("dec volume");
    volume = 10;
  } else {
    volume = volume + 10;
    Serial.println("inc volume");
  }
  myMP3.volume(volume);
  delay(cmdDelay);
}

void initButtons() {
  playPauseButton.attach(playPauseButtonPin, INPUT_PULLUP);
  playPauseButton.interval(5); 
  playPauseButton.setPressedState(LOW); 
  volumeButton.attach(volumeButtonPin, INPUT_PULLUP);
  volumeButton.interval(5);
  volumeButton.setPressedState(LOW); 
}

void initNfcReader() {
  SPI.begin(RFID_SCK, RFID_MISO, RFID_MOSI, RFID_SDA);
  mfrc522.PCD_Init();
  nfc.begin(true);
  delay(4);
  Serial.println("RFID Ready");
}

void initMp3Player() {
  Serial2.begin(serial2_baud, SERIAL_8N1, RXD2, TXD2);
  while(!Serial2);
  myMP3.begin(Serial2, true, true);
  Serial.println("Mp3 ready");
  delay(2000);
  myMP3.setTimeOut(2000);
  myMP3.volume(volume);
  myMP3.playMp3Folder(1);
  delay(cmdDelay);
}

void nfcLoop() {

  if (nfc.tagPresent()) {

    // extract the NDEF text
    NfcTag tag = nfc.read();
    NdefMessage msg = tag.getNdefMessage();
    NdefRecord record = msg.getRecord(0);
    char* ndefText = (char*)record.getPayload();

    // extract the track number from the raw ndef text
    ms.Target(ndefText);
    char result = ms.Match("(%d+)");
    char buf [100];
    if (result == REGEXP_MATCHED) {
      String trackNumber = ms.GetMatch(buf);
      Serial.println("Playing: " + trackNumber);
      myMP3.playMp3Folder(trackNumber.toInt());
      delay(cmdDelay);
    }
  }
}

The Uno R4 is too big for my project, so I've been trying to get the nano working. If the only way to get the nano working with the RFID is the way that @van_der_decken said with a external 3.3V LDO regulator and 74AHC125 then I have a lot still to learn before moving from the ESP32 to the nano.

I know you said you're done here, so feel free to ignore these questions.

  1. What is an LDO regulator? I've searched around for this and can't really find anything definitive about what this is. I don't see something like that in your photo so I guess it's not pictured.

  2. You said 74AHC125 used as a level shifter. 74AHC125 says it's a QUADRUPLE 3-STATE BUFFER. So like, what is this thing? And is using it as a level shifter not it's primary purpose?

  3. You said 2 capacitors are required. Can you tell me why? So far in my projects a capacitor has only been used to "smooth things out" in terms of a consistent voltage to a source. But since you said it's required, how do you know that it's required? Said differently, how would I be able to find out that it's required?

  4. Your photo shows 5 capacitors not 2, I assume the other 3 are for the OLED then?

It looks like you have RST going to 2Y, then out 2A to pin 9. Then SS(SDA) going to 1Y then out 1A to pin 10. You've grounded 2OE and 1OE and 4OE and 3OE. MOSI is going in 3Y (not pictured) and out 3A to 11. And MOSI is going straight to 12.

  1. I've read the datasheet as best as I could, I don't see where it says 5v in provides 3.3v out. What in the datasheet indicates that would happen?

Lastly, If the UNO outputs 5v for RST, MOSI, SS and SDA, why is that fine with the RFID but when the Nano does it, it's not ok? You said earlier it's because the uno has a voltage regulator, but it's still 5v right? So why does 5v work from the uno but not the nano?

Thanks for your time.

Just to clarify:
image
On the bread board setup it's not visible what the 3.3V input on the RFID module in your setup connects to. I suspect it's connected underneath the module to the 3.3V rail that you fed with the 3.3V (1117?) TO92 regulator, yes?

Have you tried powering the RFID from the Nano's 3.3V supply to demonstrate whether that will indeed create problems as often said?

Longshot, but just in case... you haven't made the careless mistake I've made before and got the SPI pin orientation wrong?

So for the SPI pins I'm not using any of those top 6. I've got

SS(SDA) to pin 10
SCK to pin 13
MOSI to pin 11
MISO to pin 12
RST to 9