DEV Community

Cover image for Don't Fear Near Field Communication (NFC)
ccaldwell11
ccaldwell11

Posted on

Don't Fear Near Field Communication (NFC)

Introduction

In this modern age of technology, it is fairly common (if not expected) for devices to have some form of wireless connection compatibility. Many businesses have already begun their transition into the wireless communications market and, are currently striving to improve the existing technologies or discover innovative ways to incorporate them that have never been seen before. With Wi-Fi and Bluetooth being the more known data transfer methods between devices, NFC technology is a lesser-known one used by almost everyone. NFC tech can be found in credit cards, cell phones, and even some vehicles which are just a few examples to highlight how frequently used it is, but not many know what it is or how it works.

What is NFC?

NFC stands for Near Field Communication, as the name suggests, the technology uses proximity-based connectivity to establish a wireless connection. Specifically, a short-range distance of up to 4cm is essential for this type of wireless connection to be created and transfer or send data properly. Devices that use NFC connection communicate with other NFC-enabled devices by introducing one to another. Most people are familiar with this usage in the form of "tap to pay" when using Google Pay, compatible debit cards, or "toy-to-life" figurines such as Amiibo and Skylanders.

Image description

How does NFC work?

Near Field Communication uses high-frequency radio waves to send and receive data between NFC devices that are categorized into two categories referred to as active and passive. Passive NFC devices are responsible for sending data and aren't expected to receive anything in the exchange between the NFC components. This category of NFC devices also does not have a power source. Active NFC devices, on the other hand, can send and receive data while additionally requiring a power source. The passive device uses the active device's magnetic field as its power source similar to that of Radio Frequency Identification (RFID) technology eliminating the need of a passive device needing its own.

Image description

Communication Modes

NFC has three distinct connection modes that refer to the way that data is being exchanged: reader/writer, peer-to-peer, and card emulation. Reader/writer allows for a device to read data from or write data to an NFC tag. This is commonly seen in smart business cards and public transport passes/cards. Peer-to-peer connection allows for two devices to exchange data directly with each other, which means that data can be read and written back and forth. Smartphones that allow users to tap their phones together to share files are using peer-to-peer when performing that action. Lastly, card emulation mode. This mode allows an NFC-compatible device to behave similarly to a smart card which allows for users to make wireless purchases by tapping their phone to the card reader at places of business.

Image description

Limitations

Although NFC has proven to be fairly useful considering the number of use cases it has, it still has many limitations that make other wireless communication more applicable or better suited for certain tasks. The main limitation that sets NFC apart is the extremely short range it has before a connection is established. This may be viewed as inconvenient as there are other ways to establish a connection with less physical interaction. Other limitations include the minuscule maximum data storage size which some may desire to be larger and the slower data transfer speeds compared to Bluetooth or Wi-Fi.

Code

NFC does not have a programming language, but there are plenty of resources available that add compatibility to a select few of the modern (languages with some being in experimental phases). Android provides well-organized documents on how to implement NFC connectivity within an application.

The provided code snippet from their docs is an example of how to search for "intents", an object to request an action, within https://developer.android.com/index.html:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
   <data android:scheme="https"
              android:host="developer.android.com"
              android:pathPrefix="/index.html" />
</intent-filter>
Enter fullscreen mode Exit fullscreen mode

Image description

How an NFC tag is dispatched to the app

Conclusion

In conclusion, NFC technology proves to be very useful as it is viewed almost everywhere throughout our everyday lives without many people even knowing of its existence. It allows for the transfer of data from device to device and in some usages bi-directionally but at the cost of having to physically tap a device to another. This may sometimes feel like an intrusion of space at times, but near-field communication technology is truly one made for more personal interactions that happen to include text as the medium.

Sources:
https://www.pxl-vision.com/en/blog/nfc-near-field-communication-explained#:~:text=NFC%20technology%20works%20in%20three,exchange%20data%20with%20each%20other.

https://www.mdpi.com/sensors/sensors-15-13348/article_deploy/html/images/sensors-15-13348-g001-1024.png

https://developer.android.com/develop/connectivity/nfc/nfc

https://www.st.com/content/st_com/en/support/learning/essentials-and-insights/connectivity/nfc/nfc-chips.html#:~:text=RFID%20reader%20ICs-,The%20NFC%20tag%20chip,for%20example%2C%20a%20smartphone).

Top comments (0)