ljos / mfrc522 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from miguelbalboa/rfid
Arduino RFID Library for MFRC522
This project forked from miguelbalboa/rfid
Arduino RFID Library for MFRC522
Hi,
I am not sure if this is considered as an issue or not but I looked on internet and tried different solutions for 2 days and couldn't find any satisfactory result.
Can somebody please help me to find solution of the problem I am facing? I need to detect somehow if card is removed from RFID device.
In other RFID library (link given below), they found a solution for the problem i am facing. I applied same method here but Its not working.
Thanks and Regards,
Amit
Turning off encryption MUST happen after the command has been sent. Because of this the card is never halted...... this is what is causing the same card to be read over and over again in the example #program.
Please note that if the card is halted, the status returned will be ERR - the card it halted and so can not respond. so a timeout will occur. In this instance, this is the correct response.
I have reversed the commands, and it works as intended.
// Send command before turning off encryption.
status = commandTag(MFRC522_TRANSCEIVE, buffer, 4, buffer, &len);
clearBitMask(Status2Reg, 0x08); // turn off encryption
It is probably a register or something that gets set that we need to reset after authentication.
how to clear a crc error when it occurs ?
a soft/hard reset does not solve the problem.
Is it the same pin for Arduino Due as Mega2560?
wrong fork, , please close this. mu fault
in MFRC522.cpp line 294 it should read:
if(!(readFromRegister(ErrorReg) & 0x1D)) { // BufferOvfl Collerr CRCErr ProtocolErr
0x1D properly masks out the error bits in that register not 0x1B
0x1B caused problems with parity bit error that was not valid in the use case.
I've imported library MFRC522, but when I've tried compile examples/check_firmware.ino
, I received following errors. What I'm doing wrong?
Board: Arduino UNO R3
System: Ubuntu 16.04
Arduino IDE 1.8.5
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
/home/arkadiusz/Downloads/arduino-1.8.5/arduino-builder -dump-prefs -logger=machine -hardware /home/arkadiusz/Downloads/arduino-1.8.5/hardware -hardware /home/arkadiusz/.arduino15/packages -tools /home/arkadiusz/Downloads/arduino-1.8.5/tools-builder -tools /home/arkadiusz/Downloads/arduino-1.8.5/hardware/tools/avr -tools /home/arkadiusz/.arduino15/packages -built-in-libraries /home/arkadiusz/Downloads/arduino-1.8.5/libraries -libraries /home/arkadiusz/projects/personal/arduino-testing/libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path /tmp/arduino_build_556507 -warnings=none -build-cache /tmp/arduino_cache_645786 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.arduinoOTA.path=/home/arkadiusz/.arduino15/packages/arduino/tools/arduinoOTA/1.1.1 -prefs=runtime.tools.avrdude.path=/home/arkadiusz/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 -verbose /home/arkadiusz/Downloads/MFRC522-master/examples/check_firmware/check_firmware.ino
/home/arkadiusz/Downloads/arduino-1.8.5/arduino-builder -compile -logger=machine -hardware /home/arkadiusz/Downloads/arduino-1.8.5/hardware -hardware /home/arkadiusz/.arduino15/packages -tools /home/arkadiusz/Downloads/arduino-1.8.5/tools-builder -tools /home/arkadiusz/Downloads/arduino-1.8.5/hardware/tools/avr -tools /home/arkadiusz/.arduino15/packages -built-in-libraries /home/arkadiusz/Downloads/arduino-1.8.5/libraries -libraries /home/arkadiusz/projects/personal/arduino-testing/libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path /tmp/arduino_build_556507 -warnings=none -build-cache /tmp/arduino_cache_645786 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.arduinoOTA.path=/home/arkadiusz/.arduino15/packages/arduino/tools/arduinoOTA/1.1.1 -prefs=runtime.tools.avrdude.path=/home/arkadiusz/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9 -verbose /home/arkadiusz/Downloads/MFRC522-master/examples/check_firmware/check_firmware.ino
Using board 'uno' from platform in folder: /home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21
Using core 'arduino' from platform in folder: /home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21
Detecting libraries used...
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "/tmp/arduino_build_556507/sketch/check_firmware.ino.cpp" -o "/dev/null"
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "/tmp/arduino_build_556507/sketch/check_firmware.ino.cpp" -o "/dev/null"
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src" "/tmp/arduino_build_556507/sketch/check_firmware.ino.cpp" -o "/dev/null"
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src" "/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src/MFRC522.cpp" -o "/dev/null"
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src" "/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src/MFRC522Extended.cpp" -o "/dev/null"
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src" "/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src/SPI.cpp" -o "/dev/null"
Generating function prototypes...
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src" "/tmp/arduino_build_556507/sketch/check_firmware.ino.cpp" -o "/tmp/arduino_build_556507/preproc/ctags_target_for_gcc_minus_e.cpp"
"/home/arkadiusz/Downloads/arduino-1.8.5/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/arduino_build_556507/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/home/arkadiusz/.arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard" "-I/home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522/src" "-I/home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI/src" "/tmp/arduino_build_556507/sketch/check_firmware.ino.cpp" -o "/tmp/arduino_build_556507/sketch/check_firmware.ino.cpp.o"
/home/arkadiusz/Downloads/MFRC522-master/examples/check_firmware/check_firmware.ino: In function 'void setup()':
check_firmware:14: error: 'class MFRC522' has no member named 'begin'
nfc.begin();
^
check_firmware:16: error: 'class MFRC522' has no member named 'getFirmwareVersion'
uint8_t version = nfc.getFirmwareVersion();
^
check_firmware:27: error: 'class MFRC522' has no member named 'digitalSelfTestPass'
if (nfc.digitalSelfTestPass()) {
^
Using library MFRC522 at version 1.4.0 in folder: /home/arkadiusz/projects/personal/arduino-testing/libraries/MFRC522
Using library SPI at version 1.0 in folder: /home/arkadiusz/.arduino15/packages/arduino/hardware/avr/1.6.21/libraries/SPI
exit status 1
[Error] Exit with code=1
Hello, I got my Arduino and I’m trying to set up a MFRC52210 system to open an electromagnetic lock for a false bottom drawer. I’m having an issue because when I hit compile on my Arduino sketch it gives me a error code, “error compiling for board Arduino/genuine Uno”. I’m not sure what to do I would really love some help. I am a beginner at this so I’m probably doing something wrong.
The exact error code that gives me is
fork/exec /Users/mark2019/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++: no such file or directory
Error compiling for board Arduino/Genuino Uno.
This is the code I’m using----
/* Start of Code */
/* Simple RFID Arduino Sketch(RC522)
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
The MFRC522 Library used, was created by LJOS here: https://github.com/ljos/MFRC522
The FastLED Library used, was created by focalintent here: https://github.com/FastLED/FastLED/releases
*/
#include <MFRC522.h> // Include of the RC522 Library
#include "FastLED.h" // Include of the FastLED library
#include <SPI.h> // Used for communication via SPI with the Module
// WS2812 RGB Stick connection
#define led_pin 5 // Pin 5 connected to DIN of RGB Stick
#define NUM_LEDS 8 // # of WS2812 LEDs on stick
CRGB leds[NUM_LEDS]; // FastLED Library Init
#define SDAPIN 10 // RFID Module SDA Pin is connected to the UNO 10 Pin
#define RESETPIN 8 // RFID Module RST Pin is connected to the UNO 8 Pin
#define Buzzer 3 // Pin 3 connected to + pin of the Buzzer
byte FoundTag; // Variable used to check if Tag was found
byte ReadTag; // Variable used to store anti-collision value to read Tag information
byte TagData[MAX_LEN]; // Variable used to store Full Tag Data
byte TagSerialNumber[5]; // Variable used to store only Tag Serial Number
byte GoodTagSerialNumber[5] = {0x95, 0xEB, 0x17, 0x53}; // The Tag Serial number we are looking for
MFRC522 nfc(SDAPIN, RESETPIN); // Init of the library using the UNO pins declared above
void setup() {
pinMode(Buzzer, OUTPUT); // Set buzzer pin to an Output pin
digitalWrite(Buzzer, LOW); // Buzzer Off at startup
SPI.begin();
Serial.begin(115200);
FastLED.addLeds<NEOPIXEL,led_pin>(leds, NUM_LEDS); // Setup FastLED Library
FastLED.clear();
// Start to find an RFID Module
Serial.println("Looking for RFID Reader");
nfc.begin();
byte version = nfc.getFirmwareVersion(); // Variable to store Firmware version of the Module
// If can't find an RFID Module
if (! version) {
Serial.print("Didn't find RC522 board.");
while(1); //Wait until a RFID Module is found
}
// If found, print the information about the RFID Module
Serial.print("Found chip RC522 ");
Serial.print("Firmware version: 0x");
Serial.println(version, HEX);
Serial.println();
}
void loop() {
// Light up starting LED's
for (int x = 0; x < 8; x++) {
leds[x] = CRGB::Blue;
}
FastLED.setBrightness(50);
FastLED.show();
String GoodTag="False"; // Variable used to confirm good Tag Detected
// Check to see if a Tag was detected
// If yes, then the variable FoundTag will contain "MI_OK"
FoundTag = nfc.requestTag(MF1_REQIDL, TagData);
if (FoundTag == MI_OK) {
delay(200);
// Get anti-collision value to properly read information from the Tag
ReadTag = nfc.antiCollision(TagData);
memcpy(TagSerialNumber, TagData, 4); // Write the Tag information in the TagSerialNumber variable
Serial.println("Tag detected.");
Serial.print("Serial Number: ");
for (int i = 0; i < 4; i++) { // Loop to print serial number to serial monitor
Serial.print(TagSerialNumber[i], HEX);
Serial.print(", ");
}
Serial.println("");
Serial.println();
// Check if detected Tag has the right Serial number we are looking for
for(int i=0; i < 4; i++){
if (GoodTagSerialNumber[i] != TagSerialNumber[i]) {
break; // if not equal, then break out of the "for" loop
}
if (i == 3) { // if we made it to 4 loops then the Tag Serial numbers are matching
GoodTag="TRUE";
}
}
if (GoodTag == "TRUE"){
Serial.println("Success!!!!!!!");
Serial.println();
for(int x = 0; x < 8; x++) {
leds[x] = CRGB::Green;
}
FastLED.show();
for (int y = 0; y < 3; y++){
digitalWrite (Buzzer, HIGH) ;// Buzzer On
delay (50) ;// Delay 1ms
digitalWrite (Buzzer, LOW) ;// Buzzer Off
delay (50) ;// delay 1ms
}
delay(1500);
}
else {
Serial.println("TAG NOT ACCEPTED...... :(");
Serial.println();
for(int x = 0; x < 8; x++) {
leds[x] = CRGB::Red;
}
FastLED.show();
for (int y = 0; y < 3; y++){
digitalWrite (Buzzer, HIGH) ;// Buzzer On
delay (300) ;// Delay 1ms
digitalWrite (Buzzer, LOW) ;// Buzzer Off
delay (400) ;// delay 1ms
}
delay(500);
}
}
}
/* End of Code */
After connecting the pins as mentioned above still this output is coming
Looking for MFRC522.
Didn't find MFRC522 board.
Arduino Due
please help me
Hi, I already built successful solutions with unos and megas and your great library....
But now I got an arduino Leonardo ETH with integrated W5500 ethernet and I can not get it to work with the RC522 reader which Works fine with the UNO and the Standard-W5100 ethernetshield for example.
I also tried another board (http://tronixlabs.com/arduino/boards/ethernet/dfrobot-arduino-compatible-with-onboard-w5500-ethernet-and-poe-australia/) that seems to be somewhat similar.
Both boards Do Not recognize the RC522 reader during setup.
Even if I deactivate the CS from ethernet and SD, the reader can not be accessed.
There must be something general that Blocks the Icsp or so?
I have used the mosi, miso and sck from the 6 pin icsp header of the board because they do not have them on the GPIO Pins like the UNOs or Megas and also tried different Pins as the CS pin for the reader.
No success on getting the reader to respond.
Is there anything else I can try?
Thanks in advance and kind regards
Gerald
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.