RFID shield slouží k obousměrné komunikaci s NFC zařízení (RFID nálepky, karty, ..). Shield má integrovanou anténu a využívá obvod NXP MFRC522. Tento čip podporuje práci se zařízeními fungujících na identifikačních protokolech
MIFARE Mini
MIFARE 1K
MIFARE 4K
MIFARE Ultralight
MIFARE DESFire EV1
MIFARE Plus
Hardware
Zapojení X konektoru
X01
X03
X05
X07
X09
X11
X13
X15
USR
VBUS
SDA
X00
X02
X04
X06
X08
X10
X12
X14
3V3
GND
SCL
3.3 V
GND
SDA a SCL - I2C komunikace s MFRC522
3V - detekce napětí 3,3 V
Konfigurace a zapojení
Shield nevyžaduje žádnou další komunikaci.
Schéma
Software
#include"byzance.h"#include"MFRC522.h"// third arument is optionalMFRC522RfChip(X07,X06,X15);#defineBYZANCE_OVER_USB0#ifBYZANCE_OVER_USBUSBSerialusb(0x1f00,0x2012,0x0001,false);#elseSerialpc(SERIAL_TX,SERIAL_RX); // tx, rx#endifvoidto_computer(constchar* format, ...);int rc =0;voidinit(){#if!BYZANCE_OVER_USBpc.baud(115200);#endifto_computer("Compiled on %02d. %02d. %04d - %02d:%02d:%02d\n", __BUILD_DAY__, __BUILD_MONTH__, __BUILD_YEAR_LEN4__, __BUILD_HOUR__, __BUILD_MINUTE__, __BUILD_SECOND__);to_computer("Waiting for init...\n");to_computer("ARM GCC NONEABI = %s.%s.%s\n",TOSTRING(__GNUC__),TOSTRING(__GNUC_MINOR__),TOSTRING(__GNUC_PATCHLEVEL__)); rc =RfChip.PCD_Init();if(rc){to_computer("*******************\n");to_computer("* RFchip init failed\n");to_computer("*******************\n"); } else {to_computer("RFchip init done\n"); // Get the MFRC522 software versionuint8_t v =RfChip.PCD_ReadRegister(RfChip.VersionReg);to_computer("MFRC522 Software Version: 0x%02X", v);if (v ==0x91){to_computer(" = v1.0"); } elseif (v ==0x92){to_computer(" = v2.0"); } else {to_computer(" (unknown)"); }to_computer("\n"); // When 0x00 or 0xFF is returned, communication probably failedif ((v ==0x00) || (v ==0xFF)) {to_computer("WARNING: Communication failure, is the MFRC522 properly connected?"); } }}voidloop(){ // Look for new cardsif (RfChip.PICC_IsNewCardPresent()){to_computer("card is present\n"); // Select one of the cardsif (RfChip.PICC_ReadCardSerial()){ // Print Card UIDto_computer("Card UID: ");for (uint8_t i =0; i <RfChip.uid.size; i++){to_computer("%02X",RfChip.uid.uidByte[i]); }to_computer("\n"); } // Print Card typeuint8_t piccType =RfChip.PICC_GetType(RfChip.uid.sak);to_computer("PICC Type: %s \n\r",RfChip.PICC_GetTypeName(piccType)); } else {to_computer("card isn't present\n"); } Thread::wait(1000);}voidto_computer(constchar* format, ...){charbuffer[256]; va_list arg;va_start (arg, format);vsnprintf(buffer,256, format, arg);va_end (arg);#ifBYZANCE_OVER_USBusb.printf(buffer); #elsepc.printf(buffer); #endif}