Component: RFID (MFRC522) (Wireless)

From Flowcode Help
Revision as of 15:46, 16 February 2017 by BenR (talk | contribs) (XML import BR)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


Author Ben Rowland and STibor
Version 2.0 (Release)
Category Wireless


Image RFID (MFRC522) component

Functions designed to work with the MFRC522 contactless reader IC. The MFRC522 supports all variants of the MIFARE Mini, MIFARE 1K, MIFARE 4K, MIFARE Ultralight, MIFARE DESFire EV1 and MIFARE Plus RF identification protocols.

Examples

Here is a basic example program that shows various ways the MFRC522 RFID reader can be used.

A switch is connected to pin A0, when the switch is active the program will read the ID of the RFID tag and display it on the LCD.

When the switch is not active the program will check the ID of a RFID tag with a pre-programmed ID, if the ID bytes match then the LCD will display a Welcome message and the LED connected to pin A1 will light for two seconds. This pin could then be used to drive a solenoid and open a security door. FC6 Icon.png MFRC522 Example

Downloadable macro reference

WriteBlock

Writes the contents of the 16-byte data buffer to the RFID block.

The data comes from the DataBuffer which can be set using the

WriteDataBuffer macro.

Returns 0 for a succesful write.

Parameters

BYTE BlockAddress


Return value

BYTE


ReadDataBuffer

Reads a byte from the receive data buffer.

ID locations are 0-4

Data locations are 0-15

Parameters

BYTE Index
Locations 0-15


Return value

BYTE


AntennaOff

Switches off the RFID antenna to save power.

The antenna must be switched on again before communicating with an RFID tag.

Parameters

This macro has no parameters


Return value

This call does not return a value


ReadBlock

Reads the contents of the 16-byte data buffer block on the RFID.

The receive data is stored in the data buffer and read back using the ReadDataBuffer macro.

Returns 0 for a succesful read.

Parameters

BYTE BlockAddress


Return value

BYTE


SelectTag

No additional information


Parameters

BYTE Ser0
BYTE Ser1
BYTE Ser2
BYTE Ser3
BYTE Ser4


Return value

BYTE


WriteDataBuffer

Writes a value to the 16-byte data buffer

ID locations are 0-4

Data locations are 0-15

Parameters

BYTE Index
0-15
BYTE Data


Return value

This call does not return a value


Auth

This command manages MIFARE authentication to enable a secure communication to any MIFARE Mini, MIFARE 1K and MIFARE 4K card.

All keys are set to FFFFFFFFFFFFh at chip delivery.

The authentication is described in the MFRC522 datasheet section 10.3.1.9.

Parameters

BYTE AuthMode
PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B
BYTE BlockAddress
The block number
BYTE Key0
Crypteo key to use - Byte 0
BYTE Key1
Crypteo key to use - Byte 1
BYTE Key2
Crypteo key to use - Byte 2
BYTE Key3
Crypteo key to use - Byte 3
BYTE Key4
Crypteo key to use - Byte 4
BYTE Key5
Crypteo key to use - Byte 5
BYTE Ser0
UID Byte 0
BYTE Ser1
UID Byte 1
BYTE Ser2
UID Byte 2
BYTE Ser3
UID Byte 3


Return value

BYTE


AuthOff

Resets the authentication allowing a new communications tasks to work.

Parameters

This macro has no parameters


Return value

This call does not return a value


AntennaOn

Switches on the RFID antenna.

Called as part of the Initialise macro.

Parameters

This macro has no parameters


Return value

This call does not return a value


Compare

Compares the read address from the Check macro with a fixed 5 bytes address.

Returns 0 if the addresses match.

Parameters

BYTE Add0
BYTE Add1
BYTE Add2
BYTE Add3
BYTE Add4


Return value

BYTE


Initialise

Initialises the RFID module ready for interaction with RFID tags.

Parameters

This macro has no parameters


Return value

This call does not return a value


Check

Checks to see if a RFID tag is present.

Returns 255 if RFID tag responds to the request.

Returns 0 for no response.

Parameters

This macro has no parameters


Return value

BYTE


Simulation macro reference

This component does not contain any simulation macros


Property reference

Channel

This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.

No additional information


MISO / SDI

This property is of type Single digital pin and can be referenced with the variable name MISO.

SPI Data In Pin

MOSI / SDO

This property is of type Single digital pin and can be referenced with the variable name MOSI.

SPI Data Out Pin

SCK

This property is of type Single digital pin and can be referenced with the variable name CLK.

SPI Serial Clock Pin

SS

This property is of type Single digital pin and can be referenced with the variable name CS.

SPI Chip Select Pin

Reset

This property is of type Single digital pin and can be referenced with the variable name reset.

MFRC522 Reset Pin