We are proud to announce the latest addition to the Omega2 family, the RFID & NFC Expansion. This Expansion brings contact-less RFID and NFC communication to the Omega ecosystem. It supports reading and writing with several NFC and RFID protocols at 13.56 MHz. The Expansion is based on the popular
PN532 NFC Chip and communicates with the Omega serially via
We’ll guide you through the installation process and the hardware setup. Then we’ll jump into reading and writing to the included Mifare Ultralight RFID Tag.
So, let’s get started!
Installation of the tools
In order to use the RFID /NFC Expansion, we’ll need to install the
opkg update opkg install nfc-exp
This package also installs the
xxd utility that we’ll use later on. When the installation is done, the following utilities will be installed:
These programs can be accessed from the command line and you can use them to control your RFID/NFC Expansion. You can also see the usage of those programs by running them with just a
-h argument. Today, we’ll guide you through using these commands to work with the included Mifare Ultralight tags!
The RFID & NFC Expansion features a 13.56 MHz stripline antenna and an Expansion Header, so other expansions are stackable on top. In order to use it, plug the Expansion into a Dock that has Expansion Header pins (Expansion Dock, Power Dock 2, Arduino Dock R2) and you are all set to go!
Please note: During the boot process, the Expansion draws a lot of current. We recommend connecting it to a Dock while the Omega is powered off. If the Omega is powered on, the large current draw may cause the Omega to reboot.
Scanning for Nearby Tags
We’ll start from the command
nfc-list that is used to scan for the tag to find out the type of the tag and its UID (Unique Identification Number). So, tap your tag to the Expansion and run the
From the output, we can see that the UID consists of 7 Bytes. Since its a unique ID, we can use this to identify cards for access control systems or to trigger different actions.
Reading Data from the Included Mifare Ultralight Cards
The RFID tag that comes with the Expansion is a Mifare Ultralight card. It has 64 Bytes of EEPROM Memory that includes 7 Bytes of UID, 4 Bytes of One Time Programmable Memory, 1 Byte of Internal Memory, 2 Bytes of Lock Bytes and 48 Bytes of Used Defined Data. Tap the card to the Expansion and issue the following command:
# nfc-mfultralight r dump.mfd
If the tag was in range, you should see the something like the following:
This will write the contents of the card to the
dump.mfd file in a binary format. You can see the contents of the
.mfd binary file using the
Here is comes, first row is called
Manufacturer Block that consists of 16 Bytes of manufacturer data and other 3 blocks (next 3 rows) holds the programmable data.
Modifying the Data and Writing it Back to the Card
Now we can modify the data that we just read and write this back to the card. So here’s the deal:
- Convert the
.mfdbinary into hex that’s easier to edit
- Edit the hex using any code editor (e.g vim, nano, etc)
- Convert the hex back to the
- Write the new
.mfdbinary to the card
Again, we’ll use the
xxd utility to convert the
xxd dump.mfd > dump.hex
Now, open the
dump.hex file with any text editor that you’d like (e.g. Vim, Nano, etc.). We’ll be modifying the user blocks (2nd, 3rd and 4th blocks of the card). For example, you can convert any text to hex format and place it in the data blocks. Let’s write “Hello World!” to our card. The hex value of that text is as follows:
4865 6c6c 6f20 576f 726c 6421 0a
Just replace the text that is written in the 2nd block (starts with 0000010:) with the given text, save it, and convert back to the
xxd -r dump.hex dump.mfd
The last step is to write the updated data to the card. Use the following command to do so:
yes N | nfc-mfultralight w dump.mfd
The first part of this command will automatically answer No to all questions posed by the utility:
Write OTP bytes ? [yN] Write Lock bytes ? [yN] Write UID bytes (only for special writeable UID cards) ? [yN]
If you read the card again, you’ll see that it now holds the data we just wrote:
Isn’t that just great?
You can find more info about the Expansion Hardware and more details on Using the Expansion in our Documentation. And the Expansion is now available on the Onion Online Store as well as from our retailers! Now it’s your turn to make some awesome NFC and RFID projects!