Hello everyone, I have a problem. I want to make a peer-to-peer communication between two Arduinos using PN532. I'm using this NDEF code, but not work

// Receive a NDEF message from a Peer
// Requires SPI. Tested with Seeed Studio NFC Shield v2

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

PN532_SPI pn532spi(SPI, 10);
SNEP nfc(pn532spi);
uint8_t ndefBuf[128];

void setup() {
Serial.begin(9600);
Serial.println("NFC Peer to Peer Example - Receive Message");
}

void loop() {
Serial.println("Waiting for message from Peer");
int msgSize = nfc.read(ndefBuf, sizeof(ndefBuf));
if (msgSize > 0) {
NdefMessage msg = NdefMessage(ndefBuf, msgSize);
msg.print();
Serial.println("\nSuccess");
} else {
Serial.println("Failed");
}
delay(3000);
}

saisissez ou collez du code ici

Welcome to the forum

As your topic does not relate the the Arduino project itself it has been moved to the Programming category of the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your full sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

It is also helpful to post error messages in code tags as it makes it easier to scroll through them and copy them for examination

Did you have a question?

Yes how do peer to peer communication of 2arduino with 2 pn532

Communicate 2 PN532 with each other using SPI protocol

Using Tools / Auto Format makes the code readable. Posting in code tags makes code easily copyable, so we can test.
Perhaps you did not read the pinned post re 'How to get the most from the forum'
Since there are several ways for two Arduinos to communicate and I am sure you googled that, maybe save us some time and tell us what you ruled out and why.

WAIT, didn't you just answer yourself in the following (#5) post????

Non this code not work showing faild faild faild

BTW, that is my last choice for a wired solution.

iI do it with several Nano's, I simply use CAN and Cory's Fowlers mcp-can library, it works great. Currently I have 9 nodes.

I want to use SPI because i want speed Reading

I want wireless communication not wireled ,so SPI give me speed and its wireless

11 posts, you're still giving info in bits and pieces, and no code tags yet. Have fun.

I have two arduino and two module pn532 i want to one been reciver and one been sender >>>communication in one direction no problem ,must important a message send by pn532 and reciver by other

Hint: Both use SPI, pn532 max 424 kbit/s CAN 1 Mbps, reliability of communications ???

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.