Need Help getting PN532 Module V3 to detect P2P

I am a new user to Arduino and I am trying to use the Elechouse PN532 V3 module as part of a project. My goal is to use the P2P functionality to have two PN532s (each running off an Arduino Uno) detect each other as part of a game, and I'm using this module because it's cheap and I need thirteen of them to make the game work.

I am following the example code laid out here (http://www.elechouse.com/elechouse/images/product/PN532_module_V3/PN532_%20Manual_V3.pdf) for the initiator and target code and it is not working. My serial monitor show the initiator and target are running, but when I bring the two NFC modules next to each other, neither detects the other.

I know that the I2c connection is generally working, because the tag reading example earlier in the manual works for both modules and displays the correct chip data in the serial monitor. The only thing i've done differently from the manual is comment out the typedef uint16_t u16 line in nfc.h because it conflicted with a declaration of u16 in Arduino.h, but otherwise I am simply running the examples displayed below.

/** @file nfc_p2p_target.ino @author www.elechouse.com @brief example of Peer to Peer communication for NFC_MODULE.

By this demo, target send "Hi, this message comes from NFC TARGET."

NOTE: this library only support MAX 50 bytes data packet, that is the tx_len must less than 50..

@section HISTORY

V1.0 initial version

Copyright (c) 2012 www.elechouse.com All right reserved. */

/** include library */

include "nfc.h"

/** define a nfc class */ NFC_Module nfc;

/** define RX and TX buffers, and length variable */ u8 tx_buf[50]="Hi, This message comes from NFC TARGET."; u8 tx_len; u8 rx_buf[50]; u8 rx_len;

void setup(void) { Serial.begin(115200); nfc.begin(); Serial.println("P2P Target Demo From Elechouse!");

uint32_t versiondata = nfc.get_version(); if (! versiondata) { Serial.println("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);

/** Set normal mode, and disable SAM */ nfc.SAMConfiguration(); }

void loop(void) { /** device is configured as Target / if(nfc.P2PTargetInit()){ /* send data with a length parameter and receive some data, tx_buf --- data send buffer tx_len --- data send legth rx_buf --- data recieve buffer, return by P2PTargetTxRx rx_len --- data receive length, return by P2PTargetTxRx */ Serial.println("Initiator is sensed."); tx_len = strlen((const char *)tx_buf); if(nfc.P2PTargetTxRx(tx_buf, tx_len, rx_buf, &rx_len)){ Serial.print("Data Received: "); Serial.write(rx_buf, rx_len); Serial.println(); } Serial.println(); } }

** @file nfc_p2p_initiator.ino @author www.elechouse.com @brief example of Peer to Peer communication for NFC_MODULE.

For this demo, initiator waiting for target proximity. As soon as the target sensed, the initiator exchange data with the target. By this demo, initiator sends "Hi, this message comes from NFC INITIATOR."

NOTE: this library only support MAX 50 bytes data packet, that is the tx_len must less than 50..

@section HISTORY

V1.0 initial version

Copyright (c) 2012 www.elechouse.com All right reserved. */

/** include library */

include "nfc.h"

/** define a nfc class / NFC_Module nfc; /* define RX and TX buffers, and length variable */ u8 tx_buf[50]="Hi, this message comes from NFC INITIATOR."; u8 tx_len; u8 rx_buf[50]; u8 rx_len;

void setup(void) { Serial.begin(115200); /** nfc initial */ nfc.begin(); Serial.println("P2P Initiator Demo BY ELECHOSUE!");

uint32_t versiondata = nfc.get_version(); if (! versiondata) { Serial.println("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);

/** Set normal mode, and disable SAM */ nfc.SAMConfiguration(); }

void loop(void) {

/** device is configured as Initiator */ if(nfc.P2PInitiatorInit()){ Serial.println("Target is sensed.");

/** send data with a length parameter and receive some data, tx_buf --- data send buffer tx_len --- data send legth rx_buf --- data recieve buffer, return by P2PInitiatorTxRx rx_len --- data receive length, return by P2PInitiatorTxRx / tx_len = strlen((const char)tx_buf); if(nfc.P2PInitiatorTxRx(tx_buf, tx_len, rx_buf, &rx_len)){ /** send and receive successfully */ Serial.print("Data Received: "); Serial.write(rx_buf, rx_len); Serial.println(); } Serial.println(); }

}

Can anyone help me with this issue? I've been trying to solve it for a week, and hours of Googling have gotten me nowhere. Thank you.

P.S.: I honestly don't want to use I2C for this project and I would rather go with SPI, but I can't even get that to detect the chip; I keep getting "Didn't find a PN53x" response in the serial monitor. If that's a more viable solution, I'm happy to hear it, but hours of experimentation has gotten me no progress there.

Dear Teacow2,

I'm facing same problem with the same hardware from elechouse. I used two boards to try p2p communication, but as you mentioned, it doesn't work. I tried with I2C using the libraries for arduino recomended by elechouse, but p2p is not working. Tried with other libraries for arduino working only with SPI, but not lucky.

I will return to this post if I will found a solution, but for the moment there is not so much info on the net about PN532 and P2P communication :(

Best regards,

JLB