NFC Tag

The Adafruit ST25DV16K is an I²C EEPROM that doubles as an NFC tag. Your sketch can write NDEF records (text, URLs, SMS, email, contacts, and geo coordinates) to the tag over I²C; a phone can then read them wirelessly via NFC. See the Adafruit learn guide for wiring and hardware details.

Connection

Call startNFCTag() inside preload(). The device is ready to use by the time setup() runs.

let tag;

function preload() {
  tag = startNFCTag();
}

Methods

readGeoLocation() Promise<GeoLocation>

Reads the current NDEF record as a geo location. Returns an object with latitude, longitude, and information fields.

readEmail() Promise<EmailMessage>

Reads the current NDEF record as an email. Returns email, subject, message, and information fields.

readSms() Promise<ShortMessage>

Reads the current NDEF record as an SMS. Returns phoneNumber, message, and information fields.

readText() Promise<string>

Reads the current NDEF record as plain UTF-8 text.

readUnabridgedUri() Promise<string>

Reads the current NDEF record as a full URI string.

readUri() Promise<string>

Reads the current NDEF record as a URI with protocol prefix prepended.

readVcard() Promise<VCard>

Reads the current NDEF record as a vCard contact.

writeEmail(email, subject, message, information?) Promise<boolean>

Writes an email NDEF record. Also accepts an EmailMessage object as the first argument. Resolves to true on success.

writeGeoLocation(latitude, longitude, information?) Promise<boolean>

Writes a geo location NDEF record. Also accepts a GeoLocation object as the first argument.

writeSms(phoneNumber, message, information?) Promise<boolean>

Writes an SMS NDEF record. Also accepts a ShortMessage object as the first argument.

writeText(text, language?) Promise<boolean>

Writes a plain UTF-8 text NDEF record. language defaults to "en".

writeUnabridgedUri(uri, information?) Promise<boolean>

Writes a full URI as an NDEF record (no protocol prefix abbreviation).

writeUri(protocol, uri, information?) Promise<boolean>

Writes a URI NDEF record with an abridged protocol prefix (e.g. "https://").

writeVcard(vcard) Promise<boolean>

Writes a vCard contact NDEF record. Accepts a partial VCard object — only the fields you provide are written.

await tag.writeVcard({
  firstName: "Ada",
  name: "Lovelace",
  email: "ada@example.com",
  url: "https://example.com",
});

Methods (BaseDevice)

connect() Promise<Response>

Opens the USB connection and sends the start command to the firmware. Calling it multiple times is safe — subsequent calls return the same promise. In p5.js you do not need to call this manually; startXxx() calls it for you inside preload().

Properties

Properties (BaseDevice)

id { type, address }

Identifies the device. type is the DeviceType enum value, address is the I2C address the device was started with.

isConnected boolean

true once the USB connection has been established and the firmware has acknowledged the device. In p5.js this is always true by the time setup() runs, because startXxx() waits for the connection inside preload().