Using Grove NFC with Photon in I2C

Hi, I want to use a Grove NFC board with my Photon with I2C (All the hardware modifications on the board is done) and all the libraries and threads I find are hard to follow and every one I flashed on my board couldn’t find the chip. I just want to read a tag and send it’s information to the cloud.

The first step when experiencing I2C issues would be running an I2C scanner app to see whether the communication is working at all.

Here is one such scanner app.

I ran the scanner and it found the device at 0x24 I2C Scan and when I try a firware that tries to read a tag from the board it detects the chip but not the tag.

#define SYSTEM_THREAD(ENABLED)
#include <Adafruit_PN532.h>
#define PN532_I2C_MODE
// #include <Wire.h>
// #define PN532_MODE (PN532_I2C_MODE)
// #define PN532_READY                         (0x01)
// #define IRQ_PIN  (D0) // This is how the PN532 Shield gets ready status in I2C mode
// #define RST_PIN  (D1) // Necessary for I2C mode

Adafruit_PN532 nfc(D0,D1);


void setup(void) {
  Serial.begin(115200); // Make sure your serial terminal is closed before power the Core.
  
   
  Serial.println("Hello!");

  nfc.begin();

  uint32_t versiondata;
  
  do {
    versiondata = nfc.getFirmwareVersion();
    if (!versiondata) {
      Serial.print("Didn't find PN53x board\n");
      delay(1000);
      Particle.process();
    }
    Particle.process();
    
    
  }while(!versiondata);
  
  

  // Got ok data, print it out!
  Serial.print("Found chip PN5\n"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. \n"); 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) {

  Particle.process();
  Serial.println("Waiting for an ISO14443A Card ...\n");
  delay(1000);
  
  
  uint8_t success;
  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)
    
  // Wait for an ISO14443A type cards (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);
    
    if (uidLength == 4)
    {
      // We probably have a Mifare Classic card ... 
      uint32_t cardid = uid[0];
      cardid <<= 8;
      cardid |= uid[1];
      cardid <<= 8;
      cardid |= uid[2];  
      cardid <<= 8;
      cardid |= uid[3]; 
      Serial.print("Seems to be a Mifare Classic card #");
      Serial.println(cardid);
    }
    Serial.println("");
 
  }  else {
    Serial.println("nfc.readPassiveTarget Failed\n");
    
    }
}

D0 is the I2C data pin and D1 is the I2C clock pin, so you cannot use them as IRQ and RST pin too.
You need other pins for IRQ and RST

Alright that makes sense, but I don’t know what those pins are. The board has only power and SCL,SDA (That code is probably for another board Il’l admit it) And what I have found for the Grove board is just people saying they adapted the original arduino library but that thing has like 10 interdependent files.

I found a way to read it, I just need to find a way to interpret that data.

I found a way to read it, I just need to find a way to interpret that data.

The example code above you are using tells you that the UID (card/tag ID) is either 4 bytes or 7 bytes. the 4 bytes (32 bit) can be converted into an unsigned long number and the 7 bytes into an 8 byte (64 bit) number. Alternatively, they can be kept as byte arrays and compared byte to byte.
How else did you want to interpret the data?

Yeah so I used another code (a modified library of the board’s maker) and now I can red the payload on my tags.

Can you share the code you’re using?

That’s the library I used with the ReadTagExtended example. I had a couple of problems in the workbench with my includes but if you use this kind of synthax it should work fine

#include "../lib/Seeed_Arduino_NFC-master/src/NfcAdapter.h"
#include "../lib/Seeed_Arduino_NFC-master/src/PN532/PN532/PN532.h"
#include <Wire.h>
#include "../lib/Seeed_Arduino_NFC-master/src/PN532/PN532_I2C/PN532_I2C.h"