Using NFC Tools to Read/Write NFC tag
What is NFC?NFC Tools?
NFC (Near Field Communication)Tools is aan short-rangeapp wireless technology thatwhich allows two electronic devicesyou to communicateread, when they are within a few centimeters of each other. It’s most commonly used in contactless payments, digital keycards, smart tags,write and tap-to-shareprogram features.tasks on your NFC works by using magnetic field inductiontags and doesn’tother requirecompatible pairingNFC like Bluetooth — just a simple tap is enough to exchange data.chips.
InSimple thisand tutorial,intuitive, weNFC areTools usingcan anrecord iPhonestandard to tapinformation on theyour NTAG203NFC totags open up a link. This tutorial is more intensive andwhich will be morecompatible usefulwith ifany NFC device. For instance, you havecan othereasily interactive components instore your projectcontact involvingdetails, Arduino.an URL, a phone number, your social profile or even a location.
We have another tutorial which shows you how to read and write an NFC tag using the appArduino, NFCwhich tools.
Wiringmore intensive and Library
useful Weif will be using DFRobot PN532 module, please refer to this tutorial.
We will be using Adafruit_PN532 library, weyou have aother tutorialinteractive oncomponents howin toyour installproject ainvolving library here.Arduino..
Types of Tag
In this tutorial, we are using NTAG203, NTAG215 or NTAG216 should work fine as well. You cannot use MIFARE Classic tag or card.
CodeSteps
- Download the app, it is available for
WritingbothDataiPhoneand Android.
- Choose
.#includeWrite<Wire.h>#include - Add
#defineaSDA_PINrecord.A4#define -
A5 Adafruit_PN532 nfc(SDA_PIN, SCL_PIN); //your url const char *url = "youtube.com"; // Keep short dueURL/URI
to144openbytealimitlink,&thereomitare other functions that you can explore. - Put in your link.
- Hold the
"https://" part uint8_t urlPrefix = 0x01; // 0x01 = http://www. void setup(void) { Serial.begin(115200); Serial.println("Starting NFC writer with Adafruit PN532"); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (!versiondata) { Serial.println("Didn't find PN532 board"); while (1); } nfc.SAMConfig(); // configure board to read RFID Serial.println("Waiting for an NFC tag..."); } void loop(void) { uint8_t uid[] = { 0 }; uint8_t uidLength; if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength)) { Serial.println("Tag detected!"); // Build NDEF URI record uint8_t urlLength = strlen(url); uint8_t payloadLength = 1 + urlLength; // Prefix + URL uint8_t ndef[] = { 0xD1, // MB, ME, SR, TNF=0x01 (well-known) 0x01, // Type Length = 1 payloadLength, // Payload Length 0x55, // Type = 'U' urlPrefix // URL Prefix }; uint8_t messageLength = sizeof(ndef) + urlLength; uint8_t totalLength = messageLength + 3; // TLV: 0x03 len + msg + 0xFE uint8_t full[totalLength]; full[0] = 0x03; // NDEF Message TLVtagfull[1]near=yourmessageLength;phone//andLengthpressofWrite
.NDEFmessage