This article shows how to read/write data to NFC/RFID tag using PHPoC.


NFC/RFID Tag at a glance

Before going into the design and source code. I briefly describe about memory of NFC/RFID tag.
Memory of NFC/RFID tag usually includes at least two memory types:
  • A memory portion to store the unique tag ID number by the manufacturer when the IC is manufactured. Typically, this memory portion cannot be changed.
  • User memory to store user data. This memory can be readable/writable, write-only, read-only, or write-once... It may contain information to restrict access such as secret key or access conditions. The secret key may be write-only and changeable. It is required to access memory. The access condition bits specify read/write possibility for a part of or whole memory. You can use these bits to lock memory.

Things Used In This Project
  • PHPoC Blue or Black
  • PN532 NFC/RFID controller (in my case, I used Adafruit PN532 RFID/NFC Breakout)
  • Some NFC/RFID tag (Mifare Classic tag)
  • PHPoC bread board (Optional)
  • Jumper wires‚Äč

Wiring Diagram between PHPoC and Adafruit PN532
Click image for larger version  Name:	nfc_rfid_Wiring.jpg Views:	1 Size:	148.6 KB ID:	569
  • PHPoC------------- Adafruit PN532
  • 3V----------------3.3V (Red wire)
  • SCK ----------------SCK (Yellow wire)
  • MISO---------------MISO (Green wire)
  • MOSI---------------MOSI (Blue wire)
  • 4 ------------------SSEL (White wire)
  • GND---------------GND (Gray wire)

Source Code

The image bellow shows the source code architecture. For other tag types and another NFC/RFID controllers, I hope that someone who is interested in this project can implement it and share it in this forum.
Click image for larger version  Name:	nfc_rfid_Source code architecture.png Views:	1 Size:	30.6 KB ID:	570

My code is reusable, including:
  • PN532 library
  • Mifare Classic Tag library
  • Examples:
    • read UID
    • read data
    • write data
    • change secret key.
    • Combine three first examples (as shown on demonstration video)

You can get the full source codes:

If you have any questions or something to discuss, leave a comment below.
Attached Files