Connecting NFC/RFID tag to smartphone

Hi,

I have a SparkFun ST25DV64KC NFC/RFID tag and I'm having trouble understanding its documentation. I see example 5 polls for a connection, but I'm not sure how to secure the connection (ensuring only devices with permission or credentials can establish a connection). There is documentation on creating a password for reading/writing (example 2 and 3) but I'm not sure the purpose. When the documentation says reading/writing does that mean establishing the connection, or does that mean reading/writing to the Arduino or sensor after already establishing the connection? Any help or guidance would be greatly appreciated. Thank you.

Edit: To reiterate, I'm attempting to establish a connection between the Arduino board/NFC reader and a smartphone with NFC capabilities that, and secure the connection with credentials so that a device needs a password to connect to the reader.

Look at the last picture in the SparkFun link you gave. That picture will answer most of your questions about hooking the device up.

Thank you for your response. My apologies if I wasn't clear. I'm inquiring in regards to establishing a secured (password protected) wireless connection between the sensor and a smartphone device via NFC/RFID.

To reiterate what I mentioned in the OP, I know how to poll for a connection, but not how to secure it with a key or password.

Can you clarify your need and I didn't get where do you want to apply NFC/RFID card

I know how to poll for a connection to a mobile device, but I want to secure it programatically so that the mobile device needs a key or password to establish a connection to the NFC/RFID sensor.

I'll think you are asking the way to pass data through nfc/rfid card and only retrieve the data by giving password

My goal is to detect a device in range that has the proper credentials and then programmatically preform an output (such as turning on an LED) upon connecting. Below is a basic sketch that polls for a device in range:

/*
  ST25DV64KC Example
  By: Ricardo Ramos and Paul Clark
  SparkFun Electronics
  Date: July, 2022
  License: MIT. Please see the license file for more information but you can
  basically do whatever you want with this code.

  This example demonstrates how to detect when an RF field is present.
  
  Feel like supporting open source hardware?
  Buy a board from SparkFun!
  SparkFun Qwiic RFID Tag - ST25DV64KC : https://www.sparkfun.com/products/19035

  Hardware Connections:
  Plug a Qwiic cable into the Qwiic RFID Tag and a RedBoard
  If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
  Open the serial monitor at 115200 baud to see the output
*/

#include <SparkFun_ST25DV64KC_Arduino_Library.h> // Click here to get the library:  http://librarymanager/All#SparkFun_ST25DV64KC

SFE_ST25DV64KC tag;

void setup()
{
  delay(1000);

  Serial.begin(115200);
  Wire.begin();

  Serial.println(F("ST25DV64KC example."));

  if (!tag.begin(Wire))
  {
    Serial.println(F("ST25 not detected. Freezing..."));
    while (1) // Do nothing more
      ;
  }

  Serial.println(F("ST25 connected."));
}

void loop()
{
  bool value = tag.RFFieldDetected();
  if (value)
    Serial.println(F("RF field detected."));
  else
    Serial.println(F("RF field not detected."));

  delay(250);
}

I need logic like this:

if (value && devicePasswordIsValid) {
    digitalwrite(ledPin, HIGH);
}

I'm just unsure on how to utilize the library to check for a password from the mobile device attempting to connect to the NFC reader.

 uint8_t password[8] = {0x0}; // Default password is all zeros
  tag.openI2CSession(password);

this is how password is utilized there are diffrent type of protection in it like read protection write protection and connection protection and each has diffrent functions for that .So choose the function you need i think you will need tag.openI2CSession(password); and tag.readEEPROM

Example 3 from the documentation will give code you need

Thank you, and how do I set the password? Do I just set password[8] to a string of characters, or is that hex in the example you provided? And what is the parameter on the mobile device that is needed to store the password to establish a connection?

You need to use tag.programEEPROMWriteProtectionBit to enable writing and need to set password to enable i2c communication tag.writeI2CPassword(newPassword); You can write your password in hex in newPassword uint8_t newPassword[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };. I don't know much about nfc cards i never used it .But i think if you write the data using password so when the mobile scans nfc card they get the credentials

What is the code actually protecting by implementing an I2C password? Whether or not the device attempting to connect has valid credentials? Or is it protecting writing data to the I2C. If data is written to the I2C how would the Arduino board read it?

I'll think its protecting data it could only read if we open with password tag.openI2CSession(password); . This is used to read the data by opening I2C session

Okay, and how would one read/write data protected by the password? And where is the secured data located? Is it the tag's EEPROM? Thank you for the help thus far.

Edit: Example 2 explains how to read/write to memory, and example 3 explains how to secure it.

:+1: