/************************************************************************************************* PROGRAMMINFO ************************************************************************************************** Funktion: RFID-Shield Test ************************************************************************************************** Version: 16.11.2022 ************************************************************************************************** Board: UNO ************************************************************************************************** Libraries: https://github.com/espressif/arduino-esp32/tree/master/libraries C:\Users\User\Documents\Arduino D:\gittemp\Arduino II\A156_Wetterdaten_V3 ************************************************************************************************** C++ Arduino IDE V1.8.19 ************************************************************************************************** Einstellungen: https://dl.espressif.com/dl/package_esp32_index.json http://dan.drown.org/stm32duino/package_STM32duino_index.json http://arduino.esp8266.com/stable/package_esp8266com_index.json It uses SPI communication. Connect SCK, MI, MO and NSS on the shield with jumper cap. Then slide SET0 to L, SET1 to H. There are two slide switches on the shield for you to select the interface mode: SET0 SET1 UART L L SPI L H IIC H L **************************************************************************************************/ #include #include /*Chip select pin can be connected to D10 or D9 which is hareware optional*/ /*if you the version of NFC Shield from SeeedStudio is v2.0.*/ #define PN532_CS 10 PN532 nfc(PN532_CS); #define NFC_DEMO_DEBUG 1 void setup(void) { #ifdef NFC_DEMO_DEBUG Serial.begin(115200); Serial.println("Hello!"); #endif nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { #ifdef NFC_DEMO_DEBUG Serial.print("Didn't find PN53x board"); #endif while (1); // halt } #ifdef NFC_DEMO_DEBUG // Got ok data, print it out! Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC); Serial.print("Supports "); Serial.println(versiondata & 0xFF, HEX); #endif // configure board to read RFID tags and cards nfc.SAMConfig(); } void loop(void) { uint32_t id; // look for MiFare type cards id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A); if (id != 0) { #ifdef NFC_DEMO_DEBUG Serial.println(" "); Serial.println("Read card #"); Serial.println(id); #endif uint8_t keys[]= { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF }; if(nfc.authenticateBlock(1, id ,0x08,KEY_A,keys)) //authenticate block 0x08 { //if authentication successful uint8_t block[16]; //read memory block 0x08 if(nfc.readMemoryBlock(1,0x08,block)) { #ifdef NFC_DEMO_DEBUG //if read operation is successful for(uint8_t i=0;i<16;i++) { //print memory block Serial.print(block[i],HEX); Serial.print(" "); } Serial.println(); #endif } } } delay(500); }