Component: RFID (MFRC522) (Wireless): Difference between revisions
No edit summary |
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder"" |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 94: | Line 94: | ||
===AntennaOff=== | ===AntennaOff=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''AntennaOff''' | ||
|- | |- | ||
| colspan="2" | Switches off the RFID antenna to save power. The antenna must be switched on again before communicating with an RFID tag. | | colspan="2" | Switches off the RFID antenna to save power. The antenna must be switched on again before communicating with an RFID tag. | ||
| Line 108: | Line 108: | ||
===AntennaOn=== | ===AntennaOn=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''AntennaOn''' | ||
|- | |- | ||
| colspan="2" | Switches on the RFID antenna. Called as part of the Initialise macro. | | colspan="2" | Switches on the RFID antenna. Called as part of the Initialise macro. | ||
| Line 122: | Line 122: | ||
===Authenticate=== | ===Authenticate=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Authenticate''' | ||
|- | |- | ||
| colspan="2" | 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. | | colspan="2" | 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. | ||
| Line 151: | Line 151: | ||
===CompareUID=== | ===CompareUID=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''CompareUID''' | ||
|- | |- | ||
| colspan="2" | Compares the UID from the ReadCardSerial macro with 4 byte UID. Returns 0 if the addresses match. | | colspan="2" | Compares the UID from the ReadCardSerial macro with 4 byte UID. Returns 0 if the addresses match. | ||
| Line 185: | Line 185: | ||
===GetType=== | ===GetType=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''GetType''' | ||
|- | |- | ||
| colspan="2" | Translates the SAK (Select Acknowledge) to a PICC type | | colspan="2" | Translates the SAK (Select Acknowledge) to a PICC type | ||
| Line 204: | Line 204: | ||
===HaltA=== | ===HaltA=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''HaltA''' | ||
|- | |- | ||
| colspan="2" | Instructs a PICC in state ACTIVE(*) to go to state HALT | | colspan="2" | Instructs a PICC in state ACTIVE(*) to go to state HALT | ||
| Line 218: | Line 218: | ||
===Initialise=== | ===Initialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Initialise''' | ||
|- | |- | ||
| colspan="2" | Initialises the RFID module ready for interaction with RFID tags. | | colspan="2" | Initialises the RFID module ready for interaction with RFID tags. | ||
| Line 232: | Line 232: | ||
===IsNewCardPresent=== | ===IsNewCardPresent=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''IsNewCardPresent''' | ||
|- | |- | ||
| colspan="2" | Is there a card present for us to communicate with. Returns 0 for no card and 1 for valid card present. | | colspan="2" | Is there a card present for us to communicate with. Returns 0 for no card and 1 for valid card present. | ||
| Line 246: | Line 246: | ||
===MifareRead=== | ===MifareRead=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''MifareRead''' | ||
|- | |- | ||
| colspan="2" | Reads from a block of data on a MIFARE type tag | | colspan="2" | Reads from a block of data on a MIFARE type tag | ||
| Line 275: | Line 275: | ||
===MifareWrite=== | ===MifareWrite=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''MifareWrite''' | ||
|- | |- | ||
| colspan="2" | Writes to a block of data on a MIFARE type tag | | colspan="2" | Writes to a block of data on a MIFARE type tag | ||
| Line 304: | Line 304: | ||
===ReadCardSerial=== | ===ReadCardSerial=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadCardSerial''' | ||
|- | |- | ||
| colspan="2" | Simple wrapper around PICC_Select. Returns true if a UID could be read. Remember to call PICC_IsNewCardPresent(), PICC_RequestA() or PICC_WakeupA() first. The read UID is available in the class variable uid. | | colspan="2" | Simple wrapper around PICC_Select. Returns true if a UID could be read. Remember to call PICC_IsNewCardPresent(), PICC_RequestA() or PICC_WakeupA() first. The read UID is available in the class variable uid. | ||
| Line 318: | Line 318: | ||
===ReadUIDByte=== | ===ReadUIDByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadUIDByte''' | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
| Line 337: | Line 337: | ||
===Select=== | ===Select=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Select''' | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
| Line 356: | Line 356: | ||
===StopCrypto=== | ===StopCrypto=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''StopCrypto''' | ||
|- | |- | ||
| colspan="2" | Used to exit the PCD from its authenticated state. Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start. | | colspan="2" | Used to exit the PCD from its authenticated state. Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start. | ||
| Line 371: | Line 371: | ||
==Property reference== | ==Property reference== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Properties''' | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Connections | ||
|- | |- | ||
|- | |- | ||
| Line 416: | Line 416: | ||
| colspan="2" | MFRC522 Reset Pin | | colspan="2" | MFRC522 Reset Pin | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Simulation | ||
|- | |- | ||
|- | |- | ||
Latest revision as of 14:37, 13 July 2026
| Author | Ben Rowland and STibor |
| Version | 3.0 |
| Category | Wireless |
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.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_MFRC522.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_MFRC522.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Here is a basic example program that reads the UID from a Mifare RFID tag and displays on an LCD. If the UID matches the UID stored in memory then a solenoid will fire allowing a door to be unlocked etc.
Here is a basic example program to read and modify data stored on a Mifare RFID tag.
Macro reference
AntennaOff
| AntennaOff | |
| Switches off the RFID antenna to save power. The antenna must be switched on again before communicating with an RFID tag. | |
| Return | |
AntennaOn
| AntennaOn | |
| Switches on the RFID antenna. Called as part of the Initialise macro. | |
| Return | |
Authenticate
CompareUID
| CompareUID | |
| Compares the UID from the ReadCardSerial macro with 4 byte UID. Returns 0 if the addresses match. | |
| Add0 | |
| Add1 | |
| Add2 | |
| Add3 | |
| Return | |
GetType
| GetType | |
| Translates the SAK (Select Acknowledge) to a PICC type | |
| sak | |
| The SAK byte returned from PICC_Select | |
| Return | |
HaltA
| HaltA | |
| Instructs a PICC in state ACTIVE(*) to go to state HALT | |
| Return | |
Initialise
| Initialise | |
| Initialises the RFID module ready for interaction with RFID tags. | |
| Return | |
IsNewCardPresent
| IsNewCardPresent | |
| Is there a card present for us to communicate with. Returns 0 for no card and 1 for valid card present. | |
| Return | |
MifareRead
| MifareRead | |
| Reads from a block of data on a MIFARE type tag | |
| BlockAddress | |
| Buffer | |
| BufferSize | |
| Return | |
MifareWrite
| MifareWrite | |
| Writes to a block of data on a MIFARE type tag | |
| BlockAddress | |
| Buffer | |
| BufferSize | |
| Return | |
ReadCardSerial
ReadUIDByte
| ReadUIDByte | |
| Index | |
| 0-9 = UID Data Bytes, 10 = UID Length, 11 = UID SAK | |
| Return | |
Select
| Select | |
| ValidBits | |
| Return | |
StopCrypto
| StopCrypto | |
| Used to exit the PCD from its authenticated state. Remember to call this function after communicating with an authenticated PICC - otherwise no new communications can start. | |
| Return | |