What is NFC? An Introduction to NFC Tags, Cards, and Readers

NFC Introduction

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

  • |

Lesson Transcript

  • [00:00 - 00:11] Hello, in this lesson, I will give you a more detailed introduction to NFC. First thing first, what is NFC?

  • [00:12 - 00:18] NFC stands for Near Field Communication. It is a wireless communication protocol.

  • [00:19 - 00:33] A little about its history, it is rooted in RFID and funded by Sony, Philips and Nokia. The standard organization for NFC is called NFC Forum.

  • [00:34 - 00:48] And almost all NFC specifications are defined by NFC Forum. Being a wireless technology, NFC has a pretty short range, typically within 10 cm.

  • [00:49 - 01:04] It also has a relatively low bit rate, which is below 4-4Kbps. Let's compare NFC to other well-known wireless technologies, such as Bluetooth and Wi-Fi.

  • [01:05 - 01:22] As you can see, NFC has a much limited range and much slower speed. Typically, when we perform wireless technology comparison, we want them to have long distance and faster speed.

  • [01:23 - 01:31] However, when talks about NFC, these disadvantages actually become advantages. Why so?

  • [01:32 - 01:51] Because of the short range, NFC provides more privacy and security. Since the attackers cannot hack you from place too far, and because of the low bit rate, NFC is extremely effective for power consumption.

  • [01:52 - 02:04] As a mobile app developer, this basically told us the NFC won't drain the mobile phone's battery. This point also brings us to a unique feature regarding NFC.

  • [02:05 - 02:13] That is, the NFC tag doesn't need to carry a battery. This is pretty mind-blowing.

  • [02:14 - 02:31] In our common sense, almost any consumer electronics require batteries or other kind of power source, like an adapter plugged into a wall. NFC technology achieves this by an asymmetry design.

  • [02:32 - 02:54] On the left-hand side of this diagram, an NFC reader creates an electromagnetic field, and as we all know, electromagnetic fields can induce electricity. So, the NFC tag on the right-hand side couples its power, sorely from the reader.

  • [02:55 - 03:01] Let's also introduce some NFC terminologies. First is the device role.

  • [03:02 - 03:17] The NFC reader in our diagram is called an initiator, because it starts the entire communication process. On the other hand, the NFC tag is called a target.

  • [03:18 - 03:33] We also call the communication mode to be passive mode, because the target can only respond to the initiator's command passively. It cannot actively send any data to the initiator.

  • [03:34 - 03:45] Target devices without batteries usually use passive mode. Of course, we also have the so-called active communication mode.

  • [03:46 - 03:57] In this mode, the target must has its own power to send data actively to the initiator. Finally is the NFC operation mode.

  • [03:58 - 04:24] We call an NFC device, it's in reader mode, when it acts as an NFC reader. Besides reader mode, the NFC foreign also defines other operation modes, which are peer-to-peer mode, card emulation mode, as well as the latest wireless charging mode, which are not being widely adopted yet.

  • [04:25 - 04:49] The NFC reader mode allows the NFC device to read or write passive NFC tags and stickers. Most of the NFC applications we mentioned above is in this mode, such as the transportation or ticketing system, even the key card to open a Tesla's card or are all operated in this mode.

  • [04:50 - 05:07] The NFC card emulation mode allows the NFC device itself to act as an NFC card. The emulated NFC card can then be accessed by other NFC reader, such as a point -of-sale machine.

  • [05:08 - 05:20] The best example of this mode is Apple Pay. In this case, the iPhone becomes a contentless credit card, and we can then use it in merchant stores.

  • [05:21 - 05:30] Finally is the NFC peer-to-peer mode. It allows the NFC device to exchange data with another NFC peer.

  • [05:31 - 05:43] One example for this mode is the Android Bin feature, introduced by Google back to 2011. Besides that, this mode is not widely used in the real world.

  • [05:44 - 05:51] Let's take a look at the mobile platform support for NFC. Let's check Android first.

  • [05:52 - 06:09] The Android supports NFC quite early since API level 10. It supports all three operation modes originally, but Google has deprecated NFC peer-to-peer related API in API level 29.

  • [06:10 - 06:26] The iOS, on the other hand, supports NFC from iOS 13 and iPhone 7, and it only supports reader mode. The card emulation mode is only available for their own app, such as Apple Pay.

  • [06:27 - 06:37] That's why in this course, we will focus on reader mode applications. Next, let's see this NFC specification diagram.

  • [06:38 - 06:48] As you can see, this diagram groups related NFC specification vertically by the operation modes. It seems scary initially.

  • [06:49 - 07:03] However, as a native developer, we will focus on these two blocks. They are n-death and type 2 to type 5 tech specifications.

  • [07:04 - 07:11] Let's talk about n-death first. n-death stands for NFC Data Exchange Format.

  • [07:12 - 07:32] It's defined by NFC Forum and m to provide a tech-independent way to allow data exchange between NFC-enabled devices. It is often used to carry text-based data, such as URLs or contact info.

  • [07:33 - 07:47] n-death is well-supported by both iOS and Android, since most of the NFC tags contain n-death data. So, understanding it is very important for your NFC journey.

  • [07:48 - 08:01] We have a dedicated module discussing n-death. In the second app we are about to build, we will show you how to read and write n-death into NFC tags.

  • [08:02 - 08:16] And also explain how to use NFC tags to trigger deep linking. Another important block for us is the type 2 to type 5 specifications.

  • [08:17 - 08:26] Some people will refer to them as the NFC tag platform. Let's use the type 2 tag platform as an example.

  • [08:27 - 08:43] Oh, by the way, people in NFC demand often use T to T instead of the full type 2 tag platform. Again, NFC Forum defines what a type 2 tag should comply with.

  • [08:44 - 09:06] The specification covers the topics, such as the memory structure and the basic command set, such as read and writes, which allows us to directly communicate with the NFC tag. When we are designing an NFC application, sometimes using n-death is not enough .

  • [09:07 - 09:22] You will need to directly manipulate the NFC tags internal memory in order to use some advanced feature available for certain NFC tags. Let's see some real-world NFC tags and their feature to address this point.

  • [09:23 - 09:46] This table presents a feature summary for NXP and tag families, which are the most used NFC tags all over the world. Some feature listed in this table, such as AES or 32-bit password, must be configured using low-level tag platform commands rather than n-death writing.

  • [09:47 - 10:05] Being able to use these tag preparatory commands allows you to leverage the full power for your NFC tag hardware, so you can create unique NFC applications. We also have a dedicated module targeting type 2 tags.

  • [10:06 - 10:20] In the third app of this course, we will not only learn about the basic T2T commands, but also the more advanced password protection feature. Hope you are as excited as I do.

  • [10:21 - 10:31] In the next module, we will start our journey by creating our very first NFC app, tag countergamp. I will see you there.

Hello, in this lesson, I will give you a more detailed introduction to NFC. First thing first, what is NFC? NFC stands for Near Field Communication. It is a wireless communication protocol. A little about its history, it is rooted in RFID and funded by Sony, Philips and Nokia. The standard organization for NFC is called NFC Forum. And almost all NFC specifications are defined by NFC Forum. Being a wireless technology, NFC has a pretty short range, typically within 10 cm. It also has a relatively low bit rate, which is below 4-4Kbps. Let's compare NFC to other well-known wireless technologies, such as Bluetooth and Wi-Fi. As you can see, NFC has a much limited range and much slower speed. Typically, when we perform wireless technology comparison, we want them to have long distance and faster speed. However, when talks about NFC, these disadvantages actually become advantages. Why so? Because of the short range, NFC provides more privacy and security. Since the attackers cannot hack you from place too far, and because of the low bit rate, NFC is extremely effective for power consumption. As a mobile app developer, this basically told us the NFC won't drain the mobile phone's battery. This point also brings us to a unique feature regarding NFC. That is, the NFC tag doesn't need to carry a battery. This is pretty mind-blowing. In our common sense, almost any consumer electronics require batteries or other kind of power source, like an adapter plugged into a wall. NFC technology achieves this by an asymmetry design. On the left-hand side of this diagram, an NFC reader creates an electromagnetic field, and as we all know, electromagnetic fields can induce electricity. So, the NFC tag on the right-hand side couples its power, sorely from the reader. Let's also introduce some NFC terminologies. First is the device role. The NFC reader in our diagram is called an initiator, because it starts the entire communication process. On the other hand, the NFC tag is called a target. We also call the communication mode to be passive mode, because the target can only respond to the initiator's command passively. It cannot actively send any data to the initiator. Target devices without batteries usually use passive mode. Of course, we also have the so-called active communication mode. In this mode, the target must has its own power to send data actively to the initiator. Finally is the NFC operation mode. We call an NFC device, it's in reader mode, when it acts as an NFC reader. Besides reader mode, the NFC foreign also defines other operation modes, which are peer-to-peer mode, card emulation mode, as well as the latest wireless charging mode, which are not being widely adopted yet. The NFC reader mode allows the NFC device to read or write passive NFC tags and stickers. Most of the NFC applications we mentioned above is in this mode, such as the transportation or ticketing system, even the key card to open a Tesla's card or are all operated in this mode. The NFC card emulation mode allows the NFC device itself to act as an NFC card. The emulated NFC card can then be accessed by other NFC reader, such as a point -of-sale machine. The best example of this mode is Apple Pay. In this case, the iPhone becomes a contentless credit card, and we can then use it in merchant stores. Finally is the NFC peer-to-peer mode. It allows the NFC device to exchange data with another NFC peer. One example for this mode is the Android Bin feature, introduced by Google back to 2011. Besides that, this mode is not widely used in the real world. Let's take a look at the mobile platform support for NFC. Let's check Android first. The Android supports NFC quite early since API level 10. It supports all three operation modes originally, but Google has deprecated NFC peer-to-peer related API in API level 29. The iOS, on the other hand, supports NFC from iOS 13 and iPhone 7, and it only supports reader mode. The card emulation mode is only available for their own app, such as Apple Pay. That's why in this course, we will focus on reader mode applications. Next, let's see this NFC specification diagram. As you can see, this diagram groups related NFC specification vertically by the operation modes. It seems scary initially. However, as a native developer, we will focus on these two blocks. They are n-death and type 2 to type 5 tech specifications. Let's talk about n-death first. n-death stands for NFC Data Exchange Format. It's defined by NFC Forum and m to provide a tech-independent way to allow data exchange between NFC-enabled devices. It is often used to carry text-based data, such as URLs or contact info. n-death is well-supported by both iOS and Android, since most of the NFC tags contain n-death data. So, understanding it is very important for your NFC journey. We have a dedicated module discussing n-death. In the second app we are about to build, we will show you how to read and write n-death into NFC tags. And also explain how to use NFC tags to trigger deep linking. Another important block for us is the type 2 to type 5 specifications. Some people will refer to them as the NFC tag platform. Let's use the type 2 tag platform as an example. Oh, by the way, people in NFC demand often use T to T instead of the full type 2 tag platform. Again, NFC Forum defines what a type 2 tag should comply with. The specification covers the topics, such as the memory structure and the basic command set, such as read and writes, which allows us to directly communicate with the NFC tag. When we are designing an NFC application, sometimes using n-death is not enough . You will need to directly manipulate the NFC tags internal memory in order to use some advanced feature available for certain NFC tags. Let's see some real-world NFC tags and their feature to address this point. This table presents a feature summary for NXP and tag families, which are the most used NFC tags all over the world. Some feature listed in this table, such as AES or 32-bit password, must be configured using low-level tag platform commands rather than n-death writing. Being able to use these tag preparatory commands allows you to leverage the full power for your NFC tag hardware, so you can create unique NFC applications. We also have a dedicated module targeting type 2 tags. In the third app of this course, we will not only learn about the basic T2T commands, but also the more advanced password protection feature. Hope you are as excited as I do. In the next module, we will start our journey by creating our very first NFC app, tag countergamp. I will see you there. [BLANK_AUDIO]