Irantha Jayasekara
Irantha Jayasekara
Digital Products & Solution Provider

Drink A Coffee With Me Today


Follow Me On Instagram

alt text alt text alt text alt text alt text alt text
Available For Freelance
August 13, 2014

Read and Write to NFC Card with ACR122u Reader in C#

By Irantha
C# Programming

Hello Again,
From from the previous post: ACR122u NFC Card reader application development with C# we have learned how to get UID (universal Identification) of the NFC card. In this post, I'm going to guide you on how to write custom data into an NFC card and read them back.

Before we start, let me get your attention to several things;

  • Please go through the previous post and create the project as it explains. You will need classes and functions we declared there.
  • In an NFC tag, there are several memory locations that we can store/ save our data. We use MiFare 1K tags and they can store 16 characters in a single block.
  • We will write our test data into Block number 5.
  • Please make sure you do not write data into these Authentication Blocks 0,3,7,11,15.
  • If you want to write more than 16 characters, you need to write to two or more blocks, so you have to make and custom mechanism that will divide your string into 16 characters strings and write them on different blocks.
  • Please note that I have only tried with Mifare 1K cards, Other card types might have different APDU commands.

Lets Start!

Write data to the NFC tag

Check interface below that we created from the previous post;

ACR122u C# Development

You can see, on the main window there is a textbox to enter your data. When clicking on “Write data to the card” button we are writing data on the 5th block of the NFC tag. Use below code;

Read written data from the NFC tag

Now we are going to retrieve what we wrote on 5th block of the NFC tag. Refer the code below;

Hope this helps you. Please comment your thoughts. If you have a problem ask here, I'll try my best to help you. Or we can discuss each other.
Author Details
Irantha Jayasekara
Irantha Jayasekara

Software Developer, Web Developer, Freelancer, Project Manager & Google Apps Scripts and API expert

Share Post