I was looking at this link on RFID I2C interface. I added the library to arduino, but in main.cpp, I see an error:

In function 'void setup()':

sketch_mar27a:16: error: no matching function for call to 'TwoWire::begin(int, int)'

Wire.begin(SDA_PIN, SCL_PIN); // Initialize I2C

I looked at Wire.cpp file and found that there is no such member function overloaded with two parameters.

How should I fix the problem? Even if I fix this one problem, I am not sure if this code is working code.

Where can I find working code with I2C interface? I have resource problem and SPI PORT cannot be used.

The code:

#include <Wire.h>

#include "MFRC522_I2C.h"

#define SDA_PIN 5
#define SCL_PIN 6
#define RST_PIN 3

MFRC522 mfrc522(0x28, RST_PIN);  // Create MFRC522 instance.

void ShowReaderDetails();

void setup() {
  Serial.begin(9600); // Initialize serial communications with the PC
  Wire.begin(SDA_PIN, SCL_PIN); // Initialize I2C
  mfrc522.PCD_Init();   // Init MFRC522
  ShowReaderDetails();  // 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()) {

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

  // Dump debug info about the card; PICC_HaltA() is automatically called

void ShowReaderDetails() {
  // Get the MFRC522 software version
  byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
  Serial.print(F("MFRC522 Software Version: 0x"));
  Serial.print(v, HEX);
  if (v == 0x91)
    Serial.print(F(" = v1.0"));
  else if (v == 0x92)
    Serial.print(F(" = v2.0"));
    Serial.print(F(" (unknown)"));
  // When 0x00 or 0xFF is returned, communication probably failed
  if ((v == 0x00) || (v == 0xFF)) {
    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
  • Please edit your answer and include the sketch "sketch_mar27a".
    – VE7JRO
    Commented Mar 27, 2018 at 1:42
  • the example code in that link is for nodemcu (i.e. ESP8266) - the ESP8266 wire library DOES have a void begin(int sda, int scl); - so it seems the library you are using is targeted to ESP8266 Commented Mar 27, 2018 at 7:37

1 Answer 1


SPI is a multi-slave bus. Unless you've run out of free pins to use for CS, or you have slaves that don't play nice, you can connect your RFID module to the SPI bus as well. Also your sketch will most likely compile if you only correct the offending line to simply Wire.begin(). Your library uses the standard Wire library but assumes the target is an ESP8266, whose version of Wire has an extended begin() method.

But this may all be no use since the MFRC522 you have (assuming it's the cheap blue module) is hardwired to use only the SPI interface. Unless you're ready to modify the PCB (cut traces, etc) as others have done.

  • Thanks for the info, I am not using any SPI devices and SP pins are used for other purpose and that is why I thought I will try I2C. I too have cheap china made blue module. So no meaning in trying I guess. But does UART interface works in this module?
    – Rajesh
    Commented Mar 27, 2018 at 6:48
  • @Rajesh No, UART doesn't work either, SPI is what it was made for. All the other NodeMCU pins are in use? If you really must use RFID, you're only concerned with each card's unique ID and you don't intend to store data on the card, you can try the cheap 125 kHz readers/cards like this: aliexpress.com/item/…. They use a UART interface and you only need an RX pin really since they're read-only. Commented Mar 27, 2018 at 20:19

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