How To Encode NFC Tags

0
7238
How to encode NFC Tags with an Android phone

This is a step by step tutorial to help you encode your first NFC tags with an Android phone.

NFC Tag encoding options

There are really two options for encoding NFC tags. The first is that you ask your supplier to encode them for you when you buy them or you can encode them yourself with a mobile phone.

Encoding tags yourself with a mobile is quick and easy. For small quantities of tags, perhaps up to a hundred or so, it can be no problem. If you are planning a large roll-out of tags and expect to be using many hundreds or thousands of NFC tags, then NFC.Today would suggest you get your tags encoded by your provider.

Can NFC Tags be encoded with an iPhone ?

No. The latest iOS11 software allows the most recent iPhones to read NFC tags but even with an App, the iPhone cannot write to NFC tags. Whether this will change in the near future is not known. Apple only recently opened up NFC tag scanning so it may be that they will wait a while before the next step.

Which mobile phones can encode NFC Tags ?

In short, almost any Android NFC enabled smartphone. You will need to download an App but the best encoding App is free, reliable and easy to use. Encoding your tags doesn’t require specialist knowledge or technical skills. You just need to know the web address you want to encode, download the App to your Android phone, tap a few buttons and then wave the phone over your tag. Done.

Which NFC tag to use ?

There’s two answers here. The first is which NFC chip do you need ? There’s a detailed breakdown of the different NFC chip types but to save you the read, buy yourself NFC tags with the NTAG213 chip. Unless you plan on encoding vCard contact details (which NFC.Today strongly suggest that you don’t), then the NTAG213 chip will do everything you will probably need. For the format of the tag, then plain stickers, printed stickers, keyfobs, hang tags or anything will probably work. If you are just experimenting, then a set of plain white (or clear) 22mm to 38mm size NTGA213 NFC tags will work just fine. If you are based in Europe, you can use Seritag to buy your NFC tags.

Step 1. Download the NFC App

There are a large number of NFC Apps available for Android users. However, the App we are going to recommend here is made by NXP, who make the chips that go into the majority of NFC tags you can buy. It’s reliable, free and comprehensive. Android users can download NXP Tagwriter from Google Play.

Step 2. Get your NFC Tags ready

Most NFC tags will not work on metal surfaces. There are tags that do, which are called ‘on-metal’ tags but normal NFC tags won’t. So, the first thing is to make sure you haven’t put your tag on a metal desk before you try to encode it !

There isn’t a front and back to the tag and you don’t need to remove the liner if it’s a sticker. Just place one on your desk. If this is your first time encoding tags then we would suggest cutting or removing a single tag from your reel or strip and use that. This is especially important if the tags are small because some phones have a small ‘hotspot’ on the back of the phone. If you have multiple small tags on a strip of tags then it can be quite easy to encode the next one rather than the one you were aiming for. It might not make much difference but it can be a little confusing when you are testing things.

Step 3. Open the App and start encoding

Tag Requirements

The iPhone will scan a wide variety of NFC tags including NFC Forum Type 2 tags. This includes the popular NTAG®, MIFARE® and ICODE® series chips. Without getting too technical, pretty much any NFC tag you purchase will work but we’d recommend you stick with an NTAG® based tag.

Tag Encoding

The iPhone is able to read NFC tags, including the tag’s Unique ID. However, at the moment, the iPhone cannot encode data onto tags. If you want to test, for example, opening a web address on a tag, you have two options. The first is to have the web address encoded onto the tags when you purchase them. Most NFC tag stores can do this for you. Alternatively, you can use an Android phone with NXP’s Tagwriter App.

The tags do need to be encoded with NDEF data. This means that the information is stored in a specific way to NFC Forum standards. You don’t need to worry. If you get your tags encoded by a good supplier, then they will be encoded correctly. If you use Tagwriter for Android, then again, it will all be encoded correctly.

Screen 1 : Install and open the App

First, download NXP Tagwriter from Google Play. The App is free to use and reliable. The App will enable you both to read NFC tags and encode NFC tags. It’s a full featured App but there’s no need to use all the features. On opening the App, you will be presented with an options screen. We are just going to undertake a simple encoding of a web address (URL) – ‘https://nfc.today‘. Tap on the ‘Write tags’ square to begin.

 

Screen 2 : Select your data source

The ‘Write tags’ screen presents you with options related to where to get the data to do your encoding. You can encode from a previous stored dataset, copy data from another tag or QR code or write using data from a CSV (excel spreadsheet) file. For this example, we are going to create a new dataset so tap on the ‘New dataset’ option.

Screen 3 : Select link encoding

Now we have to choose which type of data we are going to encode. The way that data is stored on an NFC tag is defined by certain standards. These require the data type to be defined clearly so that any other device reading the NFC tag can understand what type of data to expect.

In this example, we are going to store a web address ‘https://nfc.today‘ which is described in Tagwriter as a ‘Link’. So tap the ‘Link’ option and we can start adding data.

 

Screen 4 : Add your encoding data

This screen has a number of options but you don’t need to worry about them to do simple web link encoding. In the example here, we’ve added ‘https://nfc.today‘ and selected a URI type of URL. It’s important that you include either http:// or https:// in front of your normal web address. Use https:// if it’s a secure website (you have a padlock on your page) or http:// if it isn’t. If you aren’t sure, visit the page you want to link to in your browser and then copy and paste the address from the address bar at the top of the browser. Most browsers will copy the full link including https:// or http://. That’s all you need to do and then you can tap ‘Save & Write’. We’ve added details on what all the options do below the image. You don’t need to read these to finish this tutorial.

Additional encoding data options

Description
There are two basic ways of encoding a web link onto a tag. The first is a ‘Smart Poster’ type which typically stores the link and a title. The second is a URI type which just stores the link. There’s very little point in storing a title – it’s never* used under normal circumstances. *never means that NFC.Today have never come across a use case for it ever ! All it does it take up memeory space which, if you are using a smaller tag such as a MIFARE Ultralight®, may mean you run out of space. In short – don’t add a title.

URI type
Technically, a ‘link’ in this instance is not just a web link (generally defined as URL) which works over http(s)://. It can also mean any link protocol including mailto, ftp, etc. Additionally, it’s possible not to use a preset ‘URI identifier’ definition and enter an entire URI. In most instances, the NFC reader will understand the best it can. Which, in reality, in most cases other than a web address means that you will have no idea how it will react or if it will react at all. Note that mobile phones will (in all cases NFC.Today have experienced) understand a web address encoding without a URI identifer. There’s no real harm in encoding like this but you do need 7 or 8 additional memory bytes.

Add Tag UID (mirror)
Each NFC tag has a unique (if the tag is genuine) 7 byte ID hard coded into the memory. It can’t (on a genuine NXP chip) be changed. Some phones can’t actually scan this as they only can read – or perhaps more accurately present – the ‘user memory’ area. Therefore, in some cases, it makes sense to ‘mirror’ this UID into a URL. For example, if the UID was AABBCCDD112233 and your URL was https://nfc.today?tag=22, you could mirror the UID onto the URL such as ‘https://nfc.today?tag=22&uid=AABBCCDD112233‘. This may seem handy but, in reality, NFC.Today have never come across an application where this is actually that useful.

Add Interaction Counter (mirror)
Most newer NFC chips have an in-built counter which records how many times the tag has been scanned. This can be useful in a number of applications from security to marketing. The counter is stored in a part of the chip’s memory that some phones can’t readily get to without a specific App – and some phones don’t offer access at all. So, the count can be mirrored dynamically into the URL. For example, your URL might be ‘https://nfc.today?count=‘ and the count will be added to the end. First scan it would be count=1, then on the second scan it would be count=2 and so on. For developers, remember that this is the number of times the tag has been scanned, not the number of times the user has visited the link. The two are definately not the same.

Add NTAG213TT Message (mirror)
NXP recently released a new NFC chip called the NTAG213 Tag Tamper or NTAG213 TT. This is a clever little chip which has an extra couple of terminals on the chip. A loop of wire (seperate to the NFC antenna) can be attached and the chip can detect if the loop has been broken at any point. Very clever. This change in ‘status’ is recorded in the chips memory and can be accessed by a special App or, in the case of selecting this option, can be added to the URL. For example, an unbroken URL might show https://nfc.today?broken=00000000and a broken/tampered tag will magically change this URL to https://nfc.today?broken=FFFFFFFF. It’s a quick, simple way for anyone with an NFC phone to detect if a tag has been messed with. NFC.Today like it a lot.

Enable SUN Message
This is complicated. NXP launched a new tag recently called the NTAG413 DNA. It has a feature whereby each time the tag is tapped it can generate a new unique code – in a similar way to those online banking keycode generators. This code, ‘Secure Unique NFC’, can be added to a URL automatically each time the tag is scanned. This, essentially, enables a level of App free tag authentication. It’s extremely powerful and probably the best solution yet to open access (App free) NFC tag authentication. There aren’t that many NTAG413 DNA chips around at the moment but it’s a very strong step in the right direction.

Screen 5 : Confirm encoding options

This screen allows contains some additional options. You can leave all the settings as they are but if you are interested in what they do, we’ve added some notes below the image. To continue, tap on the ‘write’ button.

Write multiple NFC Tags
If you are encoding the same web link onto more than one tag, then this is how to do it. You simply check the ‘write multiple’ option and then you can tap your phone against a sequence of NFC tags and it will encode them all with the same data as the first.

Protection
NFC tags contain a ‘lock’ which prevents the data that you encode on the tag being changed. Until you lock a tag, anyone can change the data. After you lock it, nobody can change the data. There’s three options here but ignore the first ‘soft’ one. The third option is to ‘Lock’ the tag. This will prevent any further changes. If you are messing about and playing with encoding then don’t check this. Once the tag is locked, there’s no going back. If you are using the tags in a public place, then you really do need to lock. The second option is to password protect. Newer NFC tags have a password protection feature which means that reading and/or writing the data requires a password.

Screen 6 : Place phone over NFC tag

Now simply hold your phone within a few centimeters of your NFC tag. Note that the ‘hotspot’ on the phone is usually near the top but on some older phones it can be somewhere around the middle. If you wave the phone around slowly you will find it and then you will know ! The phone will respond with a sound and/or vibration when it finds the tag.

Screen 7 : Confirm that you want to overwrite

On the previous options screen (Screen 5), we left the ‘confirm overwrite’ option enabled. That’s this screen. If you uncheck that box then you do not need to provide confirmation of the encoding here – it will just go ahead an encode (if it can). Once you get started, you will uncheck that box pretty quickly. For now, just select ‘tap to confirm store’ holding your phone over the NFC tag.

Screen 8 : Encoding complete

If all has gone well, you should see a ‘Write successful’ page with further information of what has been encoded. That’s it – you have encoded your first NFC tag. If you now close the App and wave your phone over the NFC tag, your Android phone will (should) automatically launch your link.