Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: 'MFRC522' does not name a type #6

Open
phantom101 opened this issue Apr 27, 2021 · 5 comments
Open

error: 'MFRC522' does not name a type #6

phantom101 opened this issue Apr 27, 2021 · 5 comments

Comments

@phantom101
Copy link

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

@semaf
Copy link
Owner

semaf commented Apr 30, 2021

Hey,

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

@PDKarber
Copy link

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.

@semaf
Copy link
Owner

semaf commented Apr 4, 2023

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");
  }
}

@PDKarber
Copy link

PDKarber commented Apr 4, 2023 via email

@VitensenteretInnlandet
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants