Skip to content
Rotzbua edited this page Jul 25, 2020 · 1 revision

Source: https://github.com/miguelbalboa/rfid/issues/197#issuecomment-325053383 Author: @leandre84

I'm able to write to NTAG 213/216 using MIFARE_Ultralight_Write() without any issues. You just need an 4x8 bit array to hold the data for each page to write. Have a look at the following code I use to write pages 4 and 5 with factory data according to the NTAG datasheet as an example:

int NTAGWriteDefaultUserPages() {
	int status = 0;
	byte page4[NTAG_PAGELENGTH];
	byte page5[NTAG_PAGELENGTH];

	#if (CARD_TYPE == 203)
	page4[0] = 0x01; page4[1] = 0x03; page4[2] = 0xA0; page4[3] = 0x0C;
	page5[0] = 0x34; page5[1] = 0x03; page5[2] = 0x00; page5[3] = 0xFE;
	#endif
	#if (CARD_TYPE == 206)
	page4[0] = 0x03; page4[1] = 0x00; page4[2] = 0xFE; page4[3] = 0x00;
	page5[0] = 0x00; page5[1] = 0x00; page5[2] = 0x00; page5[3] = 0x00;
	#endif
	status += mfrc522.MIFARE_Ultralight_Write(4, page4, NTAG_PAGELENGTH);
	status += mfrc522.MIFARE_Ultralight_Write(5, page5, NTAG_PAGELENGTH);

	return status;
}

(NTAG_PAGELENGTH is defined as 4)

Clone this wiki locally