Skip to content

Instantly share code, notes, and snippets.

Last active April 2, 2021 02:29
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Reading out the contents of an NTAG203 NFC tag using an Adafruit PN532 shield for Arduino. This sketch reads and prints to the serial console all 42 pages of memory on the tag.
Dump the memory on a NTAG203 NFC tag using the Adafruit PN532 RFID/NFC Shield
This sketch requires the installation of the Adafruit I2C library for the shield,
which can be found at
The datasheet and other info for the NTAG203 can be found at
NTAG203 NFC chips are available from
#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>
#define IRQ (2)
#define RESET (3)
Adafruit_NFCShield_I2C nfc(IRQ, RESET);
void setup(){
Serial.println("Starting NFC...");
uint32_t card = nfc.getFirmwareVersion();
if (! card) {
Serial.print("Card fail! I die now...");
while(1); // DIE!
Serial.println("Waiting for a tag...");
void loop(){
uint8_t success;
uint8_t uid[] = {0, 0, 0, 0, 0, 0, 0, 0};
uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
The NTAG203 has a 7 byte UID, so I'll assume that if this tag does, it is the
right type of tag. But this isn't a fool-proof assumption, since Mifare Ultralight
tags also use a 7 byte UID. This code will still work with those tags, but it will
only read out the first 42 pages (out of 64) on the tag.
I don't know enough about the NFC card structure to know if there's a reliable
method to determine the NFC tag type.
if (uidLength == 7) {
uint8_t data[32];
Note that the tag must remain in range of the reader while the loop is running
for all of the pages to be read out. If the tag moves out of range, the page
printing will just stop at whatever point it was at.
for (uint8_t i = 0; i < 42; i++) {
success = nfc.mifareultralight_ReadPage(i, data);
if (success) {
Serial.print("Page ");Serial.print(i);Serial.print(": ");
nfc.PrintHexChar(data, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment