UPDATE:
Write 04-06 with 0 doesn’t work. You need to write this
[04] 03 03 D0 00
[05] 00 FE 00 00
aka command
A2040303D000
A20500FE0000
What does it mean:
A2 Writes one 4 byte page
04 page:
03 indicate it's NDEF format
03 length of record (3 bytes)
D0 NDEF record header
00 type length(0)
05 page:
00 payload length(0)
FE end of the NDEF message
if you have Arduino, here are the scripts. I’m only posting the loop function, as setup is easy to find anywhere.
Read raw data for debugging purpose
void loop() {
Serial.println("=====Reading Start=====");
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
Serial.print("Card UID:");
dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
Serial.println();
Serial.println("Card Data:");
for (byte block = 0; block < 255; block++) {
byte buffer[18];
byte size = sizeof(buffer);
byte status = mfrc522.MIFARE_Read(block, buffer, &size);
if (status != MFRC522_I2C::STATUS_OK) {
Serial.print("MIFARE_Read() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
break;
}
Serial.print("[");
if (block < 16) {
Serial.print("0");
}
Serial.print(block, HEX);
Serial.print("] ");
dump_byte_array(buffer, 4);
Serial.println();
}
Serial.println("=====Reading End=====");
delay(1000);
}
void dump_byte_array(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
Serial.print(" |");
for (byte i = 0; i < bufferSize; i++) {
if (buffer[i] >= 32 && buffer[i] <= 126) {
Serial.print((char)buffer[i]);
} else {
Serial.print('.');
}
}
Serial.print('|');
}
Fix your NDEF format, only when apps don’t work!
void loop() {
Serial.println("=====Writing Start=====");
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
// load your bytes here, starts at 0x04
byte bufferArray[][4] = {
{ 0x03, 0x03, 0xD0, 0x00 },
{ 0x00, 0xFE, 0x00, 0x00 },
};
byte size = sizeof(bufferArray[0]);
for (byte i = 0x04; i <= 0x04 + sizeof(bufferArray) / sizeof(bufferArray[0]) - 1; i++) {
byte status = mfrc522.MIFARE_Ultralight_Write(i, bufferArray[i - 0x04], size);
if (status != MFRC522_I2C::STATUS_OK) {
Serial.print("MIFARE_Ultralight_Write() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
break;
}
dump_byte_array(&i, 1);
dump_byte_array(bufferArray[i - 0x04], 4);
Serial.println(mfrc522.GetStatusCodeName(status));
}
Serial.println("=====Writing End=====");
delay(1000);
}
references:
Also, chatGPT can help you explaining your NDEF raw data! Just copy your hex code with page number and ask it to explain byte by byte! Super neat.
Now with a NDEF (start at page 04), NDEF lib can load it without any issue! I can finally be a cyber cat meow!