Can't decode NFC Shield

Arduino, Seeeduino Serials and mutants. Share your problems and experence on arduino compatible board such as seeeduino/stalker, etc.

Moderators: lily.li, violet, salmanfarisvp

Post Reply
lesmortsvivants
Pre-kindergarten
Pre-kindergarten
Posts: 5
Joined: Wed Mar 16, 2016 9:51 pm

Can't decode NFC Shield

Post by lesmortsvivants » Tue Mar 22, 2016 5:43 am

Hello, this is my second topic !
Sorry for my english..

so, i have a problem with NFC shield V2.1 !
"http://www.seeedstudio.com/wiki/NFC_Shield_V2.0"

So, i want to READ a TAG, it's impossible...

Look screen :
Scan TAG NFC.PNG
I use "NFC Tool" on Play store !
We can write and Read a tag..
Look.
Screenshot_13.png
It's an application FR
For example, " SIN" this is the TAG writter NFC
I want that NFC shield decode my message and Read..
For example in the website NFC Shield, HE CAN READ..
Example-6-read-ndef-message.png

i hope, u understand my problem..
Just one question, NFC shield can READ the tag writter by an application on Play store "Android" ???
just read.. this is possible or not ?

I use this code

Code: Select all

#include <SPI.h>
#include "PN532_SPI.h"
#include "PN532.h"
#include "NfcAdapter.h"

PN532_SPI interface(SPI, 10); // create a SPI interface for the shield with the SPI CS terminal at digital pin 10

NfcAdapter nfc = NfcAdapter(interface); // create an NFC adapter object
 
void setup(void) 
{
    Serial.begin(115200); // start serial comm
    Serial.println("NDEF Reader");
    nfc.begin(); // begin NFC comm
}

void loop(void) 
{
  Serial.println("\nScan an NFC tag\n");
  if (nfc.tagPresent()) // Do an NFC scan to see if an NFC tag is present
  {
      NfcTag tag = nfc.read(); // read the NFC tag
      if(tag.hasNdefMessage())
      {
        NdefMessage message = tag.getNdefMessage();
        for(int i=0;i<message.getRecordCount();i++)
        {
          NdefRecord record = message.getRecord(i);
          int payloadLength = record.getPayloadLength();
          byte payload[payloadLength];
          record.getPayload(payload);
          Serial.write(payload,payloadLength);
        }
      }
  }
  delay(500); // wait half a second (500ms) before scanning again (you may increment or decrement the wait time)
} 
Thanks,

viswa
Staff
Staff
Posts: 168
Joined: Tue Jan 25, 2011 11:16 am
Are you a staff member of seeedstudio?: no
Which products/projects are your favorite?: Seeeduino Film,Motion Frame,UartSbee

Re: Can't decode NFC Shield

Post by viswa » Thu Mar 24, 2016 5:59 pm

Hello,

Could you please post more information about the tag that is being read. Please check if it is compatible with NFC Shield (i.e PN532 chip datasheet provides the NFC standards that are supported)

Thanks and Warm Regards

lesmortsvivants
Pre-kindergarten
Pre-kindergarten
Posts: 5
Joined: Wed Mar 16, 2016 9:51 pm

Re: Can't decode NFC Shield

Post by lesmortsvivants » Thu Apr 14, 2016 12:01 am

Hey,
I test with an other code "Emulated TAG NDEF"

Code: Select all

#include "SPI.h"
#include "PN532_SPI.h"
#include "emulatetag.h"
#include "NdefMessage.h"

PN532_SPI pn532spi(SPI, 10);
EmulateTag nfc(pn532spi);

uint8_t ndefBuf[120];
NdefMessage message;
int messageSize;

uint8_t uid[3] = { 0x12, 0x34, 0x56 };

void setup()
{
  Serial.begin(9600);
  Serial.println("------- Emulate Tag --------");
  
  message = NdefMessage();
  message.addUriRecord("http://www.seeedstudio.com");
  messageSize = message.getEncodedSize();
  if (messageSize > sizeof(ndefBuf)) {
      Serial.println("ndefBuf is too small");
      while (1) { }
  }
  
  Serial.print("Ndef encoded message size: ");
  Serial.println(messageSize);

  message.encode(ndefBuf);
  
  // comment out this command for no ndef message
  nfc.setNdefFile(ndefBuf, messageSize);
  
  // uid must be 3 bytes!
  nfc.setUid(uid);
  
  nfc.init();
}

void loop(){
    // uncomment for overriding ndef in case a write to this tag occured
    //nfc.setNdefFile(ndefBuf, messageSize); 
    
    // start emulation (blocks)
    nfc.emulate();
        
    // or start emulation with timeout
    /*if(!nfc.emulate(1000)){ // timeout 1 second
      Serial.println("timed out");
    }*/
    
    // deny writing to the tag
    // nfc.setTagWriteable(false);
    
    if(nfc.writeOccured()){
       Serial.println("\nWrite occured !");
       uint8_t* tag_buf;
       uint16_t length;
       
       nfc.getContent(&tag_buf, &length);
       NdefMessage msg = NdefMessage(tag_buf, length);
       msg.print();
       
       
    }
    

    delay(1000);
}
with the application "NFC TOOL" i'll write "TestWrite" "16bytes"
and write is occured..

Look : here this is my text on my application
textwrite.PNG
i put the smartphone on the antenna, and he can read

Look screen :
screen 2.png

But when i want to use a simple program to read...

Code: Select all

#if 1
#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(void) {
    Serial.begin(9600);
    Serial.println("NDEF Reader");
    nfc.begin();
}

void loop(void) {
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        tag.print();
    }
    delay(5000);
}
but he can't read, why ??
screen 3.png
i don't understand, i want that he read...

lesmortsvivants
Pre-kindergarten
Pre-kindergarten
Posts: 5
Joined: Wed Mar 16, 2016 9:51 pm

Re: Can't decode NFC Shield

Post by lesmortsvivants » Sun Apr 17, 2016 6:45 am

pls help???

Post Reply