element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Ralph Yamamoto's Blog Reading and Writing RFID Tags
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 17 Dec 2018 6:18 AM Date Created
  • Views 4611 views
  • Likes 5 likes
  • Comments 19 comments
  • rfid_reader
  • rfid_tag
  • rc522
Related
Recommended

Reading and Writing RFID Tags

ralphjy
ralphjy
17 Dec 2018

I am going to start a project soon where I want to use RFID tags to enable user authentication and individual profiles for a home automation remote controller.  I haven't worked with RFID tags before, even though they are fairly ubiquitous at this point.  I imagine this is old hat to most folks, but I thought I'd share my learning.

 

I purchased an RC522 RFID Reader/Writer module and a set of RFID tags on Amazon.  The RC522 chip itself offers multiple interfaces (SPI, I2C, Serial UART), but I discovered that the board that I got was only set up for SPI.  I had wanted to use I2C, but decided it wasn't worth hacking up the board.  The Reader/Writer supports most of the standard Mifare card types (Mini, 1K, 4K, Ultralight, DESFire EV1, and Plus).  The tags that were included were Mifare 1K.

 

I had a breadboard already set up with a Sparkfun ESP8266 Thing Dev and a 128x64 OLED display, so I decided to use that for testing.

image

 

I've been using the Arduino IDE to program my Thing Dev and there is an MFRC522 library available so that worked out well.  Took a while adjusting the pin configurations to get the SPI and I2C to coexist nicely.

 

Been having fun reading stuff that I have lying around.  I had a Ventra ticket from a recent trip to Chicago and it happened to be an Ultralight card.

 

Then I moved on to testing the write capability using the example code that is in the library.

 

Here's the output:

 

  Card UID: 72 DF 5D 96

  PICC type: MIFARE 1KB

  Authenticating using key A...

  Current data in sector:

     1      7   00 00 00 00  00 00 FF 07  80 69 FF FF  FF FF FF FF  [ 0 0 1 ]

             6   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  [ 0 0 0 ]

             5   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  [ 0 0 0 ]

             4   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  [ 0 0 0 ]

 

  Reading data from block 4 ...

  Data in block 4:

   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

 

  Authenticating again using key B...

  Writing data into block 4 ...

   01 02 03 04 05 06 07 08 09 0A FF 0B 0C 0D 0E 0F

 

  Reading data from block 4 ...

  Data in block 4:

   01 02 03 04 05 06 07 08 09 0A FF 0B 0C 0D 0E 0F

  Checking result...

  Number of bytes that match = 16

  Success :-)

 

  Current data in sector:

     1      7   00 00 00 00  00 00 FF 07  80 69 FF FF  FF FF FF FF  [ 0 0 1 ]

             6   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  [ 0 0 0 ]

             5   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  [ 0 0 0 ]

             4   01 02 03 04  05 06 07 08  09 0A FF 0B  0C 0D 0E 0F  [ 0 0 0 ]

 

*************************************************************************************

 

The 1K card has 16 sectors of 4 blocks and each block has 16 bytes (16x4x16 = 1024 bytes).  The fourth block (sector trailer) in each sector contains the authentication keys.

In the example above I was writing Block 4 which is the first block in the second sector.  You can see the authentication key in Block 7.

The factory default is 0xFFFFFFFFFFFF.

 

Now I need to figure out what type of data keys I want to store for my application......

  • Sign in to reply

Top Comments

  • e14phil
    e14phil over 7 years ago +6
    Awesome Great work! I have had a play with this RFID kit before, its a really neat package with great arduino library support. The reason I have played with it is that I have an NFC/RFID chip implanted…
  • Fred27
    Fred27 over 7 years ago in reply to ralphjy +6
    The trouble with storing the acess groups on the card is that you have no way of revoking access if someone loses their card. If you just use the read-only ID then you retain control of who gets in. My…
  • Fred27
    Fred27 over 7 years ago +5
    I'm glad you're enjoying your first forays into the world of RFID and NFC. If you're doing some home automation you can probably limit your efforts to just reading the ID on the card and having a list…
Parents
  • e14phil
    e14phil over 7 years ago

    Awesome Great work!

     

    I have had a play with this RFID kit before, its a really neat package with great arduino library support.

    The reason I have played with it is that I have an NFC/RFID chip implanted in my hand. image

     

    Feel free to read my blog about it here: Life as a Cyborg - Day 0 - Implantation

     

    Keep up the good work! I cant wait to see what you do with it next.

    e14Phil 

    • Cancel
    • Vote Up +6 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • e14phil
    e14phil over 7 years ago

    Awesome Great work!

     

    I have had a play with this RFID kit before, its a really neat package with great arduino library support.

    The reason I have played with it is that I have an NFC/RFID chip implanted in my hand. image

     

    Feel free to read my blog about it here: Life as a Cyborg - Day 0 - Implantation

     

    Keep up the good work! I cant wait to see what you do with it next.

    e14Phil 

    • Cancel
    • Vote Up +6 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube