Lesson plan

RFID and NFC lesson plan

MIFARE Classic and NTAG cards on an MFRC522 and a PN532: how a passive tag is powered, UIDs of four and seven bytes, sectors, keys and blocks, NTAG pages and NDEF, an access list with a master card, honest security (UIDs clone, Crypto1 is broken), and a spaceship crew airlock.

3 chapters, 7 lessons, about 6 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • How tags work, their UIDs, and the memory inside a MIFARE Classic.
  • NFC on the PN532, access lists, and the limits of card security.
  • A crew airlock that knows who is aboard.

Materials for the whole unit

  • Arduino Uno R3
  • Buzzer
  • Character LCD with I2C backpack
  • LED x 2
  • NFC reader, PN532
  • Resistor x 2
  • RFID reader, MFRC522

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 2 h 25 min

Cards and readers

How tags work, their UIDs, and the memory inside a MIFARE Classic.

LessonTimeWhat students do
How tags workA reader that powers the card it reads: the MFRC522’s 13.56 MHz field, a passive tag’s coil and chip, and the ATQA and SAK that tell a MIFARE Classic 1K from an NTAG213 before anything else is said.45 min
  1. Run it: a reader on SPI
  2. Tap a card
  3. The reader sees it
  4. A different kind of tag
  5. Low frequency and high frequency
MFRC522 UIDsEvery card’s UID, four bytes or seven, sent in the clear before anything secret; PICC_HaltA() makes a card held on the reader count once per tap; and the property that decides which UIDs the cards on this bench carry.45 min
  1. Run it: read a UID
  2. Seven bytes
  3. A UID is public
  4. Once per tap
  5. Cards of your own
Sectors and blocksInside a MIFARE Classic 1K: 16 sectors of four 16-byte blocks, keys and access bits in every sector trailer, the wrong key timing out, the transport key FF FF FF FF FF FF working, and a name written to block 4 and read back.55 min
  1. Run it: tap card 1
  2. The wrong key
  3. The sector trailer
  4. Write a block
  5. Read it back
  6. Your own data

Materials

  • Arduino Uno R3
  • RFID reader, MFRC522

Check for understanding

Each student finishes "Sectors and blocks" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your own data".

Chapter 2. About 2 h 35 min

Building with tags

NFC on the PN532, access lists, and the limits of card security.

LessonTimeWhat students do
PN532 and NFCThe PN532 NFC controller on I2C: firmware version 1.6, a card’s UID through command frames, an NTAG213’s capability container E1 10 12 00, and a page of user memory written and read back with no key.55 min
  1. Run it: a reader with firmware
  2. Tap the NTAG
  3. Pages, not blocks
  4. Write a page
  5. A Classic on the PN532
  6. Your own message
Access listsA door controller: an allow list of UIDs with names, a green lamp for Ana, a red lamp and a buzzer for a stranger, and a master card that enrolls the stranger as a guest, who then gets in.55 min
  1. Run it: a door with a list
  2. Ana
  3. A stranger
  4. The master card
  5. The guest gets in
  6. Add someone in code
Security limitsA door that trusts the UID lets in a card that only copies it. A door that gives each card a secret in a keyed sector and checks it on every tap refuses the copy. And why even that is not enough: MIFARE Classic’s Crypto1 has been broken since 2008.45 min
  1. Run it: a door that trusts the UID
  2. The clone
  3. Crypto1 is broken
  4. Check a secret
  5. Honest security

Materials

  • Arduino Uno R3
  • Buzzer
  • LED x 2
  • NFC reader, PN532
  • Resistor x 2
  • RFID reader, MFRC522

Check for understanding

Each student finishes "Security limits" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Honest security".

Chapter 3. About 55 min

Boss project

A crew airlock that knows who is aboard.

LessonTimeWhat students do
Boss: the crew airlockThe airlock of a deep-space ship: crew cards board and leave for spacewalks, the LCD keeps the count aboard, the outer door lamp cycles on every crossing, and an unknown card sounds the intruder alarm.55 min
  1. Run it: three crew aboard
  2. A spacewalk
  3. The screen
  4. Back aboard
  5. Intruder
  6. A new crew member

Materials

  • Arduino Uno R3
  • Buzzer
  • Character LCD with I2C backpack
  • LED x 2
  • Resistor x 2
  • RFID reader, MFRC522

Check for understanding

Each student finishes "Boss: the crew airlock" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A new crew member".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.