If I'm just getting started with Arduino, what would I need to create a simple project that could be an NFC peer to my phone?
A starter kit + the NFC shield?
Thanks!
NFC project parts list...
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 3
- Joined: Mon May 13, 2013 12:38 pm
Re: NFC project parts list...
I'd like to place an order with adafruit... but still not sure which components I need. Anybody have an idea, or know a technical support # or email address for adafruit?
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: NFC project parts list...
An Arduino and the NFC shield will give you some basic tools to work with, but NFC is still a work in progress for us, especially when it comes to reading and writing NDEF data.
We know there are problems when it comes to communicating with Android and Win8 phones. Google and Microsoft have only chosen to support part of the NFC protocol, and they've focused on the NDEF stuff. We can't promise that our libraries will give you out-of-the-box support for communication with most phones.
We know there are problems when it comes to communicating with Android and Win8 phones. Google and Microsoft have only chosen to support part of the NFC protocol, and they've focused on the NDEF stuff. We can't promise that our libraries will give you out-of-the-box support for communication with most phones.
-
- Posts: 3
- Joined: Mon May 13, 2013 12:38 pm
Re: NFC project parts list...
Looks like I'm out of luck for the moment then... I have the HTC 8X running Windows Phone 8.
If things change in the future, please update this thread if you happen to remember.
Thanks!
If things change in the future, please update this thread if you happen to remember.
Thanks!
-
- Posts: 3
- Joined: Tue May 21, 2013 12:01 pm
Re: NFC project parts list...
Hiya,
I have the HTC Windows 8x and the break out NFC board from Adafruit. Mifare NFC tags work when written to NDEF first throught the board and then programmed as you wish. You might have to change the MEMDUMP code because that didn't work in terms of reprogramming the card. You could also just copy my code in, this works.
All the best,
I have the HTC Windows 8x and the break out NFC board from Adafruit. Mifare NFC tags work when written to NDEF first throught the board and then programmed as you wish. You might have to change the MEMDUMP code because that didn't work in terms of reprogramming the card. You could also just copy my code in, this works.
All the best,
Code: Select all
/**************************************************************************/
/*!
@file mifareclassic_formatndef.pde
@author Adafruit Industries
@license BSD (see license.txt)
This example attempts to format a Mifare Classic
card for NDEF Records and writes an NDEF URI Record
Note that you need the baud rate to be 115200 because we need to print
out the data and read from the card at the same time!
This is an example sketch for the Adafruit PN532 NFC/RFID breakout boards
This library works with the Adafruit NFC breakout
----> https://www.adafruit.com/products/364
Check out the links above for our tutorials and wiring diagrams
These chips use SPI to communicate, 4 required to interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
/**************************************************************************/
#include <Adafruit_PN532.h>
#define SCK (2)
#define MOSI (3)
#define SS (4)
#define MISO (5)
Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
const char * url = "benedictcopping.com";
uint8_t ndefprefix = NDEF_URIPREFIX_HTTP_WWWDOT;
// for an email address
//const char * url = "[email protected]";
//uint8_t ndefprefix = NDEF_URIPREFIX_MAILTO;
// for a phone number
//const char * url = "07889969473";
//uint8_t ndefprefix = NDEF_URIPREFIX_TEL;
void setup(void) {
Serial.begin(115200);
Serial.println("Looking for PN532...");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// configure board to read RFID tags
nfc.SAMConfig();
}
void loop(void) {
uint8_t success; // Flag to check if there was an error with the PN532
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
bool authenticated = false; // Flag to indicate if the sector is authenticated
// Use the default NDEF keys (these would have have set by mifareclassic_formatndef.pde!)
uint8_t keya[6] = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5 };
uint8_t keyb[6] = { 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7 };
Serial.println("Place your NDEF formatted Mifare Classic card on the reader to update the");
Serial.println("NDEF record and press any key to continue ...");
// Wait for user input before proceeding
while (!Serial.available());
// a key was pressed1
while (Serial.available()) Serial.read();
// Wait for an ISO14443A type card (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success)
{
// Display some basic information about the card
Serial.println("Found an ISO14443A card");
Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print(" UID Value: ");
nfc.PrintHex(uid, uidLength);
Serial.println("");
// Make sure this is a Mifare Classic card
if (uidLength != 4)
{
Serial.println("Ooops ... this doesn't seem to be a Mifare Classic card!");
return;
}
// We probably have a Mifare Classic card ...
Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
// Check if this is an NDEF card (using first block of sector 1 from mifareclassic_formatndef.pde)
// Must authenticate on the first key using 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7
success = nfc.mifareclassic_AuthenticateBlock (uid, uidLength, 4, 0, keyb);
if (!success)
{
Serial.println("Unable to authenticate block 4 ... is this card NDEF formatted?");
return;
}
Serial.println("Authentication succeeded (seems to be an NDEF/NFC Forum tag) ...");
// Authenticated seems to have worked
// Try to write an NDEF record to sector 1
// Use 0x01 for the URI Identifier Code to prepend "http://www."
// to the url (and save some space). For information on URI ID Codes
// see http://www.ladyada.net/wiki/private/articlestaging/nfc/ndef
if (strlen(url) > 38)
{
// The length is also checked in the WriteNDEFURI function, but lets
// warn users here just in case they change the value and it's bigger
// than it should be
Serial.println("URI is too long ... must be less than 38 characters!");
return;
}
Serial.println("Updating sector 1 with URI as NDEF Message");
// URI is within size limits ... write it to the card and report success/failure
success = nfc.mifareclassic_WriteNDEFURI(1, ndefprefix, url);
if (success)
{
Serial.println("NDEF URI Record written to sector 1");
Serial.println("");
}
else
{
Serial.println("NDEF Record creation failed! :(");
}
}
// Wait a bit before trying again
Serial.println("\n\nDone!");
Serial.flush();
while (!Serial.available());
Serial.flush();
}
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: NFC project parts list...
Thanks. I'll pass this along to the folks who are working on the NFC code.
- ktownsend
- Posts: 1447
- Joined: Thu Nov 05, 2009 2:18 am
Re: NFC project parts list...
As snowball mentionned, you are able to read and write to tags in NDEF format, and then read these cards on Android,, etc. There is already examples for this. What isn't supported at present is peer to peer comunication (with no card involved, only two NFC devices). This is mainly a memory problem since the Uno only has 2KB SRAM available, but the current code does support writing basic NDEF messages to Mifare Classic cards (the most common card type).
-
- Posts: 3
- Joined: Tue May 21, 2013 12:01 pm
Re: NFC project parts list...
But is there any way to program the MiFare cards with more than the three URI Prefixes in the examples (URL/tele/email)? I found you have the classes in the library for many more, but I don't know which ones do what and find little information that is digestable... I'm specifically looking to join a wifi network.
Cheers,
Cheers,
Please be positive and constructive with your questions and comments.