Can't upload sketch for MFRC522

I went to upload my sketch (see below) for the MFRC522 to the UNO R3 on my chromeOS chromebook but I keep getting these error messages.

ERROR CODE

/usr/local/bin/arduino-cli compile --fqbn arduino:avr:uno --build-cache-path /tmp --output-dir /tmp/2226048840/build --build-path /tmp/arduino-build-DC19FE70F4113185265B477A0A61F183 --library /mnt/create-efs/webide/65/e5/65e523c25be7ae3682a5232c0d63e290:cool_cat3275/libraries_v2/MFRC522 /tmp/2226048840/rfid_read_personal_data_-UPDATED-

/tmp/ccSpl5kV.ltrans0.ltrans.o: In function global constructors keyed to 65535_0_rfid_read_personal_data__UPDATED_.ino.cpp.o.1828': <artificial>:(.text.startup+0x60): undefined reference to MFRC522::MFRC522(unsigned char, unsigned char)'
/tmp/ccSpl5kV.ltrans0.ltrans.o: In function setup': /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:40: undefined reference to MFRC522::PCD_Init()'
/tmp/ccSpl5kV.ltrans0.ltrans.o: In function loop': /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:59: undefined reference to MFRC522::PICC_IsNewCardPresent()'
/tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:64: undefined reference to MFRC522::PICC_ReadCardSerial()' /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:72: undefined reference to MFRC522::PICC_DumpDetailsToSerial(MFRC522::Uid*)'
/tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:85: undefined reference to MFRC522::PCD_Authenticate(unsigned char, unsigned char, MFRC522::MIFARE_Key*, MFRC522::Uid*)' /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:92: undefined reference to MFRC522::MIFARE_Read(unsigned char, unsigned char*, unsigned char*)'
/tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:114: undefined reference to MFRC522::PCD_Authenticate(unsigned char, unsigned char, MFRC522::MIFARE_Key*, MFRC522::Uid*)' /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:121: undefined reference to MFRC522::MIFARE_Read(unsigned char, unsigned char*, unsigned char*)'
/tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:141: undefined reference to MFRC522::PCD_Authenticate(unsigned char, unsigned char, MFRC522::MIFARE_Key*, MFRC522::Uid*)' /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:148: undefined reference to MFRC522::MIFARE_Read(unsigned char, unsigned char*, unsigned char*)'
/tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:151: undefined reference to MFRC522::GetStatusCodeName(MFRC522::StatusCode)' /tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:172: undefined reference to MFRC522::PICC_HaltA()'
/tmp/2226048840/rfid_read_personal_data_-UPDATED-/rfid_read_personal_data_-UPDATED-.ino:173: undefined reference to `MFRC522::PCD_StopCrypto1()'
collect2: error: ld returned 1 exit status
Multiple libraries were found for "SPI.h"
Used: /home/builder/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/SPI
Not used: /home/builder/opt/libraries/eventethernet_1_0_0
Multiple libraries were found for "MFRC522.h"
Used: /mnt/create-efs/webide/65/e5/65e523c25be7ae3682a5232c0d63e290:cool_cat3275/libraries_v2/MFRC522
Not used: /home/builder/opt/libraries/mfrc522_pn512_1_4_12
Not used: /home/builder/opt/libraries/mfrc522_spi_i2c_uart_async_1_5_1
Not used: /home/builder/opt/libraries/mfrc522_1_4_11
Error during build: exit status 1

Code

#include <MFRC522.h>
#include <MFRC522Extended.h>
#include <deprecated.h>
#include <require_cpp11.h>

/*

#include <SPI.h>

int RST_PIN = 9; // Configurable, see typical pin layout above
int SS_PIN = 10; // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

//*****************************************************************************************//
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println(F("Read personal data on a MIFARE PICC:")); //shows in serial that it is ready to read
}

//*****************************************************************************************//
void loop() {

// Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
MFRC522::MIFARE_Key key;
for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;

//some variables we need
byte block;
byte len;
MFRC522::StatusCode status;

//-------------------------------------------

// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

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

Serial.println(F("Card Detected:"));

//-------------------------------------------

mfrc522.PICC_DumpDetailsToSerial(&(mfrc522.uid)); //dump some details about the card

//mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); //uncomment this to see all blocks in hex

//-------------------------------------------
Serial.print(F("Name: "));

byte buffer1[18];

block = 4;
len = 18;

//------------------------------------------- GET FIRST NAME
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 4, &key, &(mfrc522.uid)); //line 834 of MFRC522.cpp file
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Authentication failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

status = mfrc522.MIFARE_Read(block, buffer1, &len);
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Reading failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

//PRINT FIRST NAME
for (uint8_t i = 0; i < 16; i++)
{
if (buffer1[i] != 32)
{
Serial.write(buffer1[i]);
}
}
Serial.print(" ");

//---------------------------------------- GET LAST NAME

byte buffer2[18];
block = 1;

status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 1, &key, &mfrc522.uid); //line 834
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Authentication failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

status = mfrc522.MIFARE_Read(block, buffer2, &len);
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Reading failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

//PRINT LAST NAME
for (uint8_t i = 0; i < 16; i++) {
Serial.write(buffer2[i] );
}

Serial.print("\n");

byte buffer3[18];

block = 5;
len = 18;

//------------------------------------------- GET AGE
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, 4, &key, &(mfrc522.uid)); //line 834 of MFRC522.cpp file
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Authentication failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

status = mfrc522.MIFARE_Read(block, buffer3, &len);
if (status != MFRC522::STATUS_OK) {
Serial.print(F("Reading failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

//PRINT AGE
for (uint8_t i = 0; i < 16; i++)
{
if (buffer3[i] != 32)
{
Serial.write(buffer3[i]);
}
}
Serial.print(" ");

//----------------------------------------

//----------------------------------------
Serial.println(F("\nEnd Reading\n"));

delay(1000); //change value if you want to read cards faster

mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
//*****************************************************************************************//

I'm sorry but I can't print it in code format.

I think the issue is due to wrong library .It shows multiple library for MFRC522 .Use this Library and remove the duplicate ones if you don't need other

I use the cloud editor so there are no duplicates and if there is I can't delete them.

The code compiles fine in IDE .Check the settings in cloud editor

The cloud editor has THOUSANDS of preloaded librarys. Therefore, it finds multiple.
BTW, It is not a library problem. If you have a problem in your code ex. missing semicolin. It gives you the library error with a bunch of other errors regarding variables not defined. So there is probably ONE ERROR disgised as 1,000 errors.

By the way which editor do you use .I tried with Arduino cloud it worked fine with me

https://app.arduino.cc/sketches/fdcfc7e0-eefc-4f7f-95b7-39a7bc9da4dd?view-mode=preview

/usr/local/bin/arduino-cli compile --fqbn arduino:avr:uno --build-cache-path /tmp --output-dir /tmp/2824457128/build --build-path /tmp/arduino-build-82B4B8338FC9BEEA456CDF5F8F3A7DEE  /tmp/2824457128/rfid_read_personal_data_-UPDATED-_copy-1
[info] Sketch uses 6796 bytes (21%) of program storage space. Maximum is 32256 bytes.
[info] Global variables use 281 bytes (13%) of dynamic memory, leaving 1767 bytes for local variables. Maximum is 2048 bytes.

This is the output i am getting

/usr/local/bin/arduino-cli compile --fqbn arduino:avr:uno --build-cache-path /tmp --output-dir /tmp/3584149668/build --build-path /tmp/arduino-build-82B4B8338FC9BEEA456CDF5F8F3A7DEE  /tmp/3584149668/rfid_read_personal_data_-UPDATED-_copy-1
[info] Sketch uses 6796 bytes (21%) of program storage space. Maximum is 32256 bytes.
[info] Global variables use 281 bytes (13%) of dynamic memory, leaving 1767 bytes for local variables. Maximum is 2048 bytes.

Flashing with command:C:/Users/user/.arduino-create/arduino/avrdude/6.3.0-arduino17/bin/avrdude.exe -CC:/Users/user/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:/Users/user/AppData/Local/Temp/arduino-create-agent992079312/rfid_read_personal_data_-UPDATED-_copy-1.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:/Users/user/.arduino-create/arduino/avrdude/6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "C:/Users/user/AppData/Local/Temp/arduino-create-agent992079312/rfid_read_personal_data_-UPDATED-_copy-1.hex"
avrdude: writing flash (6796 bytes):

Writing | ################################################## | 100% 0.95s

avrdude: 6796 bytes of flash written
avrdude: verifying flash memory against C:/Users/user/AppData/Local/Temp/arduino-create-agent992079312/rfid_read_personal_data_-UPDATED-_copy-1.hex:
avrdude: load data flash data from input file C:/Users/user/AppData/Local/Temp/arduino-create-agent992079312/rfid_read_personal_data_-UPDATED-_copy-1.hex:
avrdude: input file C:/Users/user/AppData/Local/Temp/arduino-create-agent992079312/rfid_read_personal_data_-UPDATED-_copy-1.hex contains 6796 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.71s

avrdude: verifying ...
avrdude: 6796 bytes of flash verified

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

Ok

After upload

Did you add any custom libraries to the cloud can you check

1 Like

...

I have one with the exact same name and when I deleted it it worked. Thanks @AresXT

:smile: :+1:t6:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.