Skip to content

Instantly share code, notes, and snippets.

@rogeriochaves
Created November 6, 2014 12:44
Show Gist options
  • Save rogeriochaves/a778b13a42cf2fd18003 to your computer and use it in GitHub Desktop.
Save rogeriochaves/a778b13a42cf2fd18003 to your computer and use it in GitHub Desktop.
Using Arduino Elechouse's NFC to create vCard
#if 0
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);
#else
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
#endif
void setup() {
Serial.begin(9600);
Serial.println("NDEF Writer");
nfc.begin();
}
void loop() {
Serial.println("\nPlace a formatted Mifare Classic NFC tag on the reader.");
if (nfc.tagPresent()) {
NdefMessage message = NdefMessage();
message.addMimeMediaRecord("text/vcard", "BEGIN:VCARD\nVERSION:4.0\nFN:Oseias Arnaldo\nORG:React\nPHOTO;MEDIATYPE=image/png:http://react.ag/logo.png\nTEL;TYPE=work,voice;VALUE=uri:33432779\nEMAIL:oseia@react.ag\nREV:20080424T195243Z\nEND:VCARD");
bool success = nfc.write(message);
if (success) {
Serial.println("Success. Try reading this tag with your phone.");
} else {
Serial.println("Write failed.");
}
delay(1000);
digitalWrite(13, LOW);
}
delay(200);
}
@rogeriochaves
Copy link
Author

Instead of printing lots of business cards, you can lend over your NFC Card with vCard data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment