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?
How much current does your RFID board require?
Is the answer to question #2 greater than the answer to question #1?
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.
The RFID chip requires 13-26ma
need to figure out 1 to answer this one
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 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.
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
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.
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
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.
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.
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?
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?
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.
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?
Just to clarify:
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?