don/NDEF

PN532 Arduino

Ecosmos opened this issue · 5 comments

Hello
I have two questions regarding this post, is it possible to use the code to have two PN532 arduino communicate with eachother? Because whenever I try sending a message I always get a failure notification.

The second thing is it possible to have the communication established through I2C as well ?

don commented

Theoretically 2 Arduinos should be able to send data to each other using Peer to Peer. You can try using 2 Seeed Studio NFC shields and the P2P_Send and P2P_Receive sketches.

By default the Adafruit NFC shield uses I2C and the Seeed Studio NFC shield uses SPI. The Peer to Peer functions require SPI. (I can't remember the exact reason but I think it's due to a buffer size in the I2C code). The Adafruit NFC shield can run in SPI mode if you solder a few jumpers, I don't know if this code works. I only run I2C with the Adafruit hardware.

Note that for P2P, this library is only used for generating and parsing NDEF messages. All SNEP functions are handled by the PN532 driver.

Would it be possible to break up the packet to make I2C work?
I am using the Grove NFC that only supports I2C and UART.

Breaking up the packet will not work. You can modify Arduino's I2C library to increase its buffer (at least 44 bytes) to make p2p work with I2C. The default buffer length is 32 bytes.

Hi Don,
I got hold of your book, downloaded the code and bought an Adafruit Arduino NFC shield. Things like reading NFC cards worked fine until I tried the NDEC functions. I discovered the problem lies with the I2C interface. Unfortunately, I cannot use SPI for some reason. I tried increasing the i2c buffer size but it did not help. In fact, raising the buffer size caused the Arduino code to hang. Are there any clues how to get your NDEC code to work with I2C?

@xiongyihui: I tried increasing the buffer size to 44 bytes. It is still too small. When I raised it to around 80 bytes, the code hangs. I am at a loss.

Has anyone got it working before? Maybe I did something wrong. It will be great if those who got it working can post the code. Thanks a lot.

don commented

@helpme1 it would be better if you create a new issue for this, rather than adding to a closed issue.

With the Adafruit Shield, you use I2C by default. You need to solder some jumpers for the shield to do SPI with that hardware.

The Adafruit Shield and I2C work for reading and writing NDEF data to NFC tags. You should not need to increase the I2C buffer size for read and write. @xiongyihui's comment about the I2C buffer is required for peer-to-peer (LLCP, SNEP). When the Arduino hangs, I find it usually in out of memory, try a smaller buffer and smaller NDEF messages.

See if you can get the ReadTag, ReadTagExtended, and WriteTag examples working with the Adafruit shield and I2C. If not please create a new issue with details about the problem and some code.