Hi,
I recently got a NFC shield V1.0 from Seedstudio. I’m super happy with the wiki (seeedstudio.com/wiki/index.p … NFC_Shield); however, I am unable to read/write to my Mifare Ultralight C NFC stickers. It seems that nfc.authenticateBlock fails for me. The NFC shield successfully picks up the ID of each ultralight C but it then does not succeed in reading or writing to any given block on the tag.
Here is the line that I think may be of trouble. Any thought on what I may be doing wrong?
uint8_t keys[]= {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // default key of a fresh card
if(nfc.authenticateBlock( 1 /*1 or 2*/,
id /*Card NUID*/,
10/*0 to 63*/,
KEY_A /*Either KEY_A or KEY_B */,
keys)) { ...}
I am also including my entire code for more detail. Please let me know if you need more information. Thanks!
#include "PN532.h"
#define SCK 13
#define MOSI 11
#define SS 10
#define MISO 12
PN532 nfc(SCK, MISO, MOSI, SS);
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// 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);
// 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)
{
Serial.print("Read card #");
Serial.println(id);
Serial.println();
uint8_t keys[]= {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // default key of a fresh card
if(nfc.authenticateBlock( 1 /*1 or 2*/,
id /*Card NUID*/,
10/*0 to 63*/,
KEY_A /*Either KEY_A or KEY_B */,
keys))
{
Serial.println("authenticated!");
}
else {
Serial.println("failed to authenticate");
}
}
delay(2000);
}