I'm using a NodeMcu for my project and am running out of pins to use. I have a MFRC522 Module, IR Receiver, Buzzer and RGB LED connected. I am facing the problem that whenever I start scanning for RFID tags with the MFRC522 module, the onboard LED starts flashing very fast and the RGB LED changes to an undefined color.

I looked up the pin definitions of the NodeMcu, but couldn't quite find information on what pins I can use for this and which I can't, and why this only happens once I start up the RFID reader.

This is my wiring sketch: enter image description here

I found this pin layout image, as well as the datasheet.

The code shouldn't be really relevant since it works before starting the RFID reader, but here is the setup of the reader, just in case:

#define SS_PIN D4   // SPI - Slave Select Pin
#define RST_PIN D2  // SPI - Reset Pin - not actually connected

MFRC522 mfrc522(SS_PIN, RST_PIN);

// Initial setup for SPI and MFRC522
bool rfidSetupCompleted = false;
void setupReader()
  rfidSetupCompleted = true;

These are the pin definitions of the RGB LED:

#define LED_BLUE D8
#define LED_GREEN D3
#define LED_RED D2

Any help is highly appreciated! I'm assuming I am using a pin that is used for other purposes (such as maybe D8), but I can't figure out which, and why. I did try to change up the pins and switched D0 and D8 (buzzer and one LED pin), but without luck. I also tried disconnecting each LED pin separately, but didn't learn anything from that either.

  • what library for MFRC522 you use? I think you should set all SPI pins for the library, to set the correct SPI interface. Or if the library doesn't initialize SPI library, you should do it in setup()
    – Juraj
    Commented Oct 8, 2018 at 9:01
  • @Juraj I'm using this: github.com/miguelbalboa/rfid The library only takes those two parameters so I'm not sure if that is needed. And I do initialize the SPI library in my setup code. Commented Oct 8, 2018 at 9:04
  • @Juraj I have it in the setup method that I posted above. This is executed before I start using the MFRC522. I have it that way because I split up the code into several files. Commented Oct 8, 2018 at 9:09
  • then SPI looks OK, because D5, D6 and D7 are default SPI pins in SPI library
    – Juraj
    Commented Oct 8, 2018 at 9:09
  • @Juraj yeah exactly. I do have one wire attached to D8, which is "HCS" according to this image: pradeepsinghblog.files.wordpress.com/2016/04/… I'm not sure if this might cause issues Commented Oct 8, 2018 at 9:13

2 Answers 2


I fixed the issue by swapping pin D4 and D8, and then setting up the MFRC522 at the very start of the program. I originally set it up before I started using it, which caused the color to change during the first scan.


SPI.begin sets io15 (D8) mode even it is not used as SS pin for your device. It is better to use io15 (D8) as slave select pin for one of the slave devices. In your case for the one device you have on SPI bus.

Pins io 0 (D3) and io 2 (D4) have on-board pull-up, because they are boot configuration pins. Set them LOW right after setting pinMode for them, to not let current to LED RGB legs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.