Getting the RFID-RC522 to work! [SOLVED]


#105

Thx your reply, @peekay123 , i am using the IDE, netbean.

Dont known why that the CPP file and H file should be combined into H file. If we make a separated files then the error will comes out .

below is the structure according to the Git:

|-core-firmware
|- build
|- inc -- which including h files.
|- linker
|- src -- for cpp files
|-
|-


#106

I am not sure what you mean by that. What I was mentioning is the PATH of the .h include files specified in the .cpp and .ino files not being correct. Your compiler needs to find them and this does not seem to be happening. smile


#107

@peekay123, I meant, i just merged CPP source code into the H file, then compiler found that.


#108

@yuanetking, it is a "crude" approach but since it works, good job stuck_out_tongue Hopefully things are working for you now (?)


#109

@peekay123, Thx your reply , smile, As my presentation above, my english,:( ..... ,
I just copyed CPP source code into the bottom of H file , then it work.


#110

@peekay123 i want to read data from uart and save it on sd card
how can i do this
help me please !


#111

@nooraqqad, I am not sure what you mean by reading from UART. The RC522 uses the SPI bus, not UART. Can you please explain?


#112

@peekay123 oky i wiil explain my project ,,
i want to make RFID attendance system , the only step i did was reading RFID tag and print its serial number on serial monitor of arduino ,
now i want to improve it , so i am thinking about making GUI for each teacher and at the begining of the school
the doctor will save a file on arduino which contains the RFID student number who are registered on his class
then when the student enroll his card , the arduino will compare his number with the file who had been saved
, if it is exist then arduino will save it as registered , if not then he will print on lcd not registerd
("i am so sorry for my language vut i am from palestine and my language is arabic ,, i am not so good in english language ,, i hope u understand what i wrote ")


#113

Hey Peekay123, your genius astounds me. I've been skimming this post for a few minutes and now have a better understanding of what's going on. Anyway, both for clarification of points you probably have already made, and to enlighten a rookie such as myself, I have a question or two. I'm trying to use an arduino to control three of these rfid readers which will, inturn, control three stepper motors. The stepper motors seem simple enough, but I was under the impression that an arduino could only handle one spi thingy at a time. Could I control three with one arduino? I know that the mega has 4 serial connections, but I'm not using the tx/rx pins now so how does that play together? Thanks for any knowledge you pass along, and I am seriously new to this so please be gentle.


#114

On a SPI bus, multiple slave devices are allowed with individual slave select lines.

In @peekay123's lovely adaptation, the standard select pin is SS (mapped to A2). To get your 3 readers running, connect them to the same MISO, MOSI and SCK lines, with each of their SS lines connected to different pins. When setting up their MFRC522 instances, specify the corresponding pins and all should be good to go wink


#115

Hi Peekay123,
thank you for the fantastic library. I still couldn't figure out how to write on a RFID tag. I guess I somehow have to use the "write" method, but I cannot make it work. Could you help me out on this?


#116

Heya @perucat, you are most welcome to reuse some code I recently implemented for the spark-bouncer

// Authenticate a block access
bool rfidAuth(int block) {
	MFRC522::MIFARE_Key key;
	
	// All Mifare chips have their factory default keys set to HIGH
	memset(&key, 0xFF, sizeof(key));

	byte status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid));
	if (status != MFRC522::STATUS_OK) {
		return false;
	}

	// All good!
	return true;
}
bool rfidWrite(int block, byte (&data)[16]) {
	if (mfrc522.MIFARE_Write(block, data, 16) != MFRC522::STATUS_OK) {
                return false;
	}
	return true;
}

How to use it:

byte buffer[16]; 
int block = 1;
...
if (rfidAuth(block))
    if (rfidWrite(block, buffer))
        ...  // SUCCESS

Take a look how its being used in the mentioned project to update a 16 byte key stored in the first RFID block: https://github.com/rastapasta/spark-bouncer/blob/master/application.cpp#L417-L457

Enjoy!


#117

Hello i'm new here, and i'm a noob. smile
i'm searching all over the internet about how to make this RC522 to work..
is there possible to make this work not using arduino or RaspberryPI..?
i mean , i have a school project using this RC522, ( just read and/or write the ID) and show it to 16x2 LCD..
if posibble, i want to try to make some communication with PC (what showed on LCD show it on PC too)..
i'm using atmega16A, and CodevisionAVR eval..

(i have made all the circuits needed to work with this RC522 including 3.3v supply and IC MAX232..)
i'm a beginner on coding,, and all code exist on the internet is for arduino

please help me.
what should i do first? at least for read the tag and show it to LCD
thanks smile


#118

Hi @Ozone123,

If you want to get the Rc522 working with an Arduino, there are lots of examples, here are a few:

http://playground.arduino.cc/Learning/MFRC522
https://sites.google.com/site/arduinomega2560projects/home/level-1/arduino-rfid-rc522
http://fritzing.org/projects/display-16x2-rfid-rc522

Thanks,
David


#119

@dave ,, thanks for the heads up it really help a bit smile

but for now i just want to make this RC522 could operates "without" Arduino modules..
rfid -> Atmega16a -> PC (via max232), (and a piece of LCD connected to Atmega16a)

first of all to anyone what do you think about my project? , considering that i'm a beginner on coding, does this possible? if not maybe i'll try to buy Arduino even though its expensive for me,
or at worst maybe i'll abandoned my project.. ( no way smile )


#120

If my understanding was right, after reading MFRC522 datasheet Rev.3.7 (26 March 2014)..
looks like that this RFID-RC522 can do Read and (maybe Write) using UART
(not only just SPI )..

as you can see :
PIN 24 = SDA, NSS, RX -> (NSS for SPI and RX for UART)
PIN 31 = D7, SCL, MISO, TX -> (MISO for SPI and TX for UART)

if that so, i think you can use this RFID at least for read the Tag with just connecting NSS and MISO (on RFID) direct to the PC using serial-to-USB cable (NSS to TX, MISO to RX) ..
no coding needed..
just open up Hyperterminal, and tap your tag to the reader, and the tag id must shown in hyperterminal
please... correct me if im wrong.. smile


#121

Does anyone have experience getting the RC522 to read Oyster contactless cards? These are MIFARE as I understand it but I'm not having any luck getting the reader to respond to them, despite it working with the supplied contactless card and keyfob.


#122

@henryaj, the MFRC522 specs say:

  • Supports ISO/IEC 14443 A/MIFE
  • Supports MF1xxS20, MF1xxS70 and MF1xxS50 encryption in Read/Writmode
  • Supports ISO/IEC 14443 A higher transfer speed communication up to 848 kBd

The Oyster cards, as described on Wikipedia say:

The Oyster card has a claimed proximity range of about 80 mm (3 inches). The card operates as a RFID system and is compatible with ISO/IEC 14443 types A and B. Oyster readers can also read other types of cards including Cubic Go-Cards. From its inception until January 2010, Oyster cards were based on NXP/Philips' MIFARE Classic 1k chips provided by Giesecke & Devrient, Gemalto and SchlumbergerSema.[13] Since December 2009 all new Oyster cards use MIFARE DESFire EV1 chips. From February 2010 MIFARE Classic-based Oyster cards were no longer issued.[14] MIFARE DESFire cards are now widely used as transport smartcards.

MIFARE Classic chips, on which the original Oyster card was based, are hard-wired logic smartcards, meaning that they have limited computing power designed for a specific task. The MIFARE DESFire chips used on the new Oyster card are CPUs with much more sophisticated security features and more complex computation power. They are activated only when they are in an electromagnetic field compatible with ISO/IEC 14443 type A, provided by Oyster readers. The readers read information from the cards, calculate whether to allow travel, assess any fare payable and write back information to the card. Some basic information about the MIFARE Classic or MIFARE DESFire chip can be read by any ISO/IEC 14443 type A compatible reader, but Oyster-specific information cannot be read without access to the encryption used for the Oyster system. While it has been suggested that a good reader could read personal details from a distance, there has been no evidence of anyone being able to decrypt Oyster information. By design the cards do not carry any personal information. Aluminium shielding has been suggested to prevent any personal data from being read.

Note the point about the onboard CPU and the Oyster-reader specific encryption. You will not be able to read these card fully unless you have an Oyster reader I suspect. frowning


Combined thermal printer and RFID shield
#123

i have a rc 522 module and theres so many code snippets on this site that i do not know what to try can you help me i am trying to see the new fob data on serial monitor using arduino nano so i can see what the code is so i can make it control access a door lock but just for now i need to read the data in serial monitor to move on but its not outputting anything not sure if its the reader or soldering job or the software, the pins are correct i know that much.


#124

@jamied_uk, I have to admit that I really don't understand what you are asking due to your grammar. Can you explain more clearly which libraries you tried and what it is you are trying to achieve?