MFRC522_I2C_Library icon indicating copy to clipboard operation
MFRC522_I2C_Library copied to clipboard

error: 'MFRC522' does not name a type

Open phantom101 opened this issue 4 years ago • 5 comments

Hello,

In Arduino IDE and Platformio IDE i get the following Error when i just want try the demo: MFRC522_i2c:9:1: error: 'MFRC522' does not name a type Thanks

phantom101 avatar Apr 27 '21 10:04 phantom101

Hey,

Could it be that you probably install it wrong on Arduino IDE?

semaf avatar Apr 30 '21 22:04 semaf

I am getting "Compilation error: 'MFRC522' does not name a type; did you mean 'MFRC522_I2C'?" No matter what example program I use as long as it is a MFRC522_I2C version it will not compile. I have updated the IDE and even installed from scratch on a new computer and installed the libraries correctly, MFRC522_I2C is broken. I am trying to use the RFID from Keystudio Smart House with ESP32 but I am stuck because of this error. Again, No matter what computer I use or version of IDE the I2C for the MFRC522 will not compile. For Giggles I tried to compile a Pin example version not I2C of MFRC522 and it compiled just fine.

PDKarber avatar Mar 17 '23 10:03 PDKarber

Can you give a try with this here please? We dont have any MFRC522 with I2C to test it now.

#include <Wire.h>
#include "MFRC522_I2C.h"

// I2C GPIOs
#define SDA  32          // internal
#define SCL  33          // internal

byte chipAddress = 0x28;

TwoWire i2cBusOne = Wire;

MFRC522 mfrc522(chipAddress, RST_PIN);

void setup() {
  byte version;
  byte value;
  Serial.begin(115200);           // Initialize serial communications with the PC
    Serial.println("TwoWire Bus 1 initiieren");
  i2cBusOne.begin(SDA, SCL, 40000);
    Serial.println("TwoWire Bus 2 initiieren");
  mfrc522.PCD_Init();
    Serial.println("MFRC522 Selbsttest");
}

void loop() {
  scanBus1();
  // scanBus2();
  ShowReaderDetails();            // Show details of PCD - MFRC522 Card Reader details
 if (mfrc522.PCD_PerformSelfTest()) {
    Serial.println("Selftest   OK");
 } else Serial.println("Selftest not  OK");
  delay(5000);
}

void scanBus1 () {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    i2cBusOne.beginTransmission(address);
    error = i2cBusOne.endTransmission();
    if (error == 0) {
      Serial.print("Bus1: I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
}

void scanBus2 () {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    i2cBusTwo.beginTransmission(address);
    error = i2cBusTwo.endTransmission();
    if (error == 0) {
      Serial.print("Bus2: I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
/*  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
    pinMode(RST_PIN, OUTPUT);
    if (digitalRead(RST_PIN) == LOW) { //The MFRC522 chip is in power down mode.
      digitalWrite(RST_PIN, HIGH);   // Exit power down mode. This triggers a hard reset.
      // Section 8.8.2 in the datasheet says the oscillator start-up time is the start up time of the crystal + 37,74�s. Let us be generous: 50ms.
      delay(200);
    }
  else {
    Serial.println("done\n");
  } 
  } */
}

void ShowReaderDetails() {
 byte version = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);

  switch (version) {
    case 0x88:  // Fudan Semiconductor FM17522 clone
      Serial.println("Fudan Semiconductor FM17522 clone");
      break;
    case 0x90:  // Version 0.0
      Serial.println("Version 0.0");
      break;
    case 0x91:  // Version 1.0
      Serial.println("Version 1.0");
      break;
    case 0x92:  // Version 2.0
      Serial.println("Version 2.0");
      break;
    default:  // Unknown version
      Serial.println("Unknown version");
  }
}

semaf avatar Apr 04 '23 00:04 semaf

I came across the RESET PIN solution on my own. It appears the library has been updated since your instructions were written. I put the pin as 0. Thank you for your response.

Paul

On Mon, Apr 3, 2023, 19:44 Semaf Electronics @.***> wrote:

Can you give a try here please? We dont have any MFRC522 with I2C to test it now.

#include <Wire.h> #include "MFRC522_I2C.h"

// I2C GPIOs #define SDA 32 // internal #define SCL 33 // internal

byte chipAddress = 0x28;

TwoWire i2cBusOne = Wire;

MFRC522 mfrc522(chipAddress, RST_PIN);

void setup() { byte version; byte value; Serial.begin(115200); // Initialize serial communications with the PC Serial.println("TwoWire Bus 1 initiieren"); i2cBusOne.begin(SDA, SCL, 40000); Serial.println("TwoWire Bus 2 initiieren"); mfrc522.PCD_Init(); Serial.println("MFRC522 Selbsttest"); }

void loop() { scanBus1(); // scanBus2(); ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details if (mfrc522.PCD_PerformSelfTest()) { Serial.println("Selftest OK"); } else Serial.println("Selftest not OK"); delay(5000); }

void scanBus1 () { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { i2cBusOne.beginTransmission(address); error = i2cBusOne.endTransmission(); if (error == 0) { Serial.print("Bus1: I2C device found at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); nDevices++; } else if (error==4) { Serial.print("Unknow error at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); } } if (nDevices == 0) { Serial.println("No I2C devices found\n"); } else { Serial.println("done\n"); } }

void scanBus2 () { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { i2cBusTwo.beginTransmission(address); error = i2cBusTwo.endTransmission(); if (error == 0) { Serial.print("Bus2: I2C device found at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); nDevices++; } else if (error==4) { Serial.print("Unknow error at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); } } /* if (nDevices == 0) { Serial.println("No I2C devices found\n"); pinMode(RST_PIN, OUTPUT); if (digitalRead(RST_PIN) == LOW) { //The MFRC522 chip is in power down mode. digitalWrite(RST_PIN, HIGH); // Exit power down mode. This triggers a hard reset. // Section 8.8.2 in the datasheet says the oscillator start-up time is the start up time of the crystal + 37,74�s. Let us be generous: 50ms. delay(200); } else { Serial.println("done\n"); } } */ }

void ShowReaderDetails() { byte version = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);

switch (version) { case 0x88: // Fudan Semiconductor FM17522 clone Serial.println("Fudan Semiconductor FM17522 clone"); break; case 0x90: // Version 0.0 Serial.println("Version 0.0"); break; case 0x91: // Version 1.0 Serial.println("Version 1.0"); break; case 0x92: // Version 2.0 Serial.println("Version 2.0"); break; default: // Unknown version Serial.println("Unknown version"); } }

— Reply to this email directly, view it on GitHub https://github.com/semaf/MFRC522_I2C_Library/issues/6#issuecomment-1495183965, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMHNQJBGHT66J346IWPBM53W7NVG7ANCNFSM43UXJMYA . You are receiving this because you commented.Message ID: @.***>

PDKarber avatar Apr 04 '23 04:04 PDKarber

Hi, I have exactly the same issue as Phantom 101 and PDKarber. I have tried everything that PDK has tried and I am still getting "Compilation error: 'MFRC522' does not name a type; did you mean 'MFRC522_I2C'?" Is there a line that is incorrect in the library? I see that the library refers to also including Wire in the arguments for MFRC522. Any help would be greatly appreciated!

Gavin

VitensenteretInnlandet avatar Dec 15 '23 12:12 VitensenteretInnlandet