Topic: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

Hi,

I've asked in two or three forums, about getting this to work, as my attempts are not resulting in something useful:

I've made little edits to the driver, mainly the speed and delay, but nothing.


Someone got this Arduino Leonardo connected via I2C to the Pn532 chip working?

I would be happy to attempt to modify existing drivers to support this board, but if anybody has made some better advances than I did, would be great.

Thanks and hope to hear from you!

Transcript from the elecfreaks forum/viewtopic.php?f=4&t=2299 (since it appears that I'm not allowed to post links here):

It appears that most of the times, timeout occurs, but sometimes unexpected reply does. The serial monitor doesn't allow me to set the port to 921600 or 230400 bauds, and this speed is set in three different places:

  1. The .ino file

  2. The devices.d/pn532_via_uart2usb.conf file, and

  3. libnfc/libnfc/drivers/pn532_uart.c


The arduino serial monitor shows that two bursts of data are received, at an interval of a few seconds.

I followed these instructions:
nfc-tools.org /index.php?title=Libnfc:Arduino

And also:
code.google.com /p/mfocuino/wiki/buildingLibNfc

I tried with various settings and default speeds in

- libnfc/chips/pn53x.c
- /etc/nfc/devices.d/pn532_via_uart2usb.conf
- libnfc/drivers/pn532_uart.c
- libnfc/buses/uart.c
- etc.

Also tried with:

./configure --with-drivers=pn532_uart --enable-serial-autoprobe

But so far I get things like:

nfc-poll -v
/home/mop/Projects/Ingeniería/rfid/libnfc/examples/.libs/lt-nfc-poll uses libnfc libnfc-1.7.1
debug   libnfc.config   key: [allow_autoscan], value: [true]
debug   libnfc.config   key: [device.name], value: [Adafruit PN532 board via UART]
debug   libnfc.config   key: [device.connstring], value: [pn532_uart:/dev/ttyACM0:230400]
debug   libnfc.config   key: [device.allow_autoscan], value: [true]
info   libnfc.config   Unknown key in config line: device.allow_autoscan = true
debug   libnfc.config   key: [device.allow_intrusive_scan], value: [true]
info   libnfc.config   Unknown key in config line: device.allow_intrusive_scan = true
debug   libnfc.config   key: [device.log_level], value: [3]
info   libnfc.config   Unknown key in config line: device.log_level = 3
unknown   libnfc.general   log_level is set to 3
debug   libnfc.general   allow_autoscan is set to true
debug   libnfc.general   allow_intrusive_scan is set to false
debug   libnfc.general   1 device(s) defined by user
debug   libnfc.general     #0 name: "Adafruit PN532 board via UART", connstring: "pn532_uart:/dev/ttyACM0:230400"
debug   libnfc.driver.pn532_uart   Attempt to open: /dev/ttyACM0 at 230400 bauds.
debug   libnfc.bus.uart   Serial port speed requested to be set to 230400 bauds.
debug   libnfc.chip.pn53x   Diagnose
debug   libnfc.chip.pn53x   Timeout value: 500
debug   libnfc.bus.uart   TX: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00
debug   libnfc.chip.pn53x   SAMConfiguration
debug   libnfc.chip.pn53x   Timeout value: 1000
debug   libnfc.bus.uart   TX: 00 00 ff 03 fd d4 14 01 17 00
debug   libnfc.bus.uart   Timeout!
debug   libnfc.driver.pn532_uart   Unable to read ACK
error   libnfc.driver.pn532_uart   pn53x_check_communication error
debug   libnfc.chip.pn53x   InRelease
debug   libnfc.bus.uart   TX: 00 00 ff 03 fd d4 52 00 da 00
debug   libnfc.bus.uart   Timeout!
debug   libnfc.driver.pn532_uart   Unable to read ACK
debug   libnfc.general   Unable to open "pn532_uart:/dev/ttyACM0:230400".
lt-nfc-poll: ERROR nfc-poll.c:125
lt-nfc-poll:     Unable to open NFC device.


Or with nfc-list:

nfc-list -vdebug   libnfc.config   key: [allow_autoscan], value: [true]
debug   libnfc.config   key: [device.name], value: [Adafruit PN532 board via UART]
debug   libnfc.config   key: [device.connstring], value: [pn532_uart:/dev/ttyACM0:230400]
debug   libnfc.config   key: [device.allow_autoscan], value: [true]
info   libnfc.config   Unknown key in config line: device.allow_autoscan = true
debug   libnfc.config   key: [device.allow_intrusive_scan], value: [true]
info   libnfc.config   Unknown key in config line: device.allow_intrusive_scan = true
debug   libnfc.config   key: [device.log_level], value: [3]
info   libnfc.config   Unknown key in config line: device.log_level = 3
unknown   libnfc.general   log_level is set to 3
debug   libnfc.general   allow_autoscan is set to true
debug   libnfc.general   allow_intrusive_scan is set to false
debug   libnfc.general   1 device(s) defined by user
debug   libnfc.general     #0 name: "Adafruit PN532 board via UART", connstring: "pn532_uart:/dev/ttyACM0:230400"
nfc-list uses libnfc libnfc-1.7.1
debug   libnfc.driver.pn532_uart   Attempt to open: /dev/ttyACM0 at 230400 bauds.
debug   libnfc.bus.uart   Serial port speed requested to be set to 230400 bauds.
debug   libnfc.chip.pn53x   Diagnose
debug   libnfc.chip.pn53x   Timeout value: 500
debug   libnfc.bus.uart   TX: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00
debug   libnfc.chip.pn53x   SAMConfiguration
debug   libnfc.chip.pn53x   Timeout value: 1000
debug   libnfc.bus.uart   TX: 00 00 ff 03 fd d4 14 01 17 00
debug   libnfc.bus.uart   Timeout!
debug   libnfc.driver.pn532_uart   Unable to read ACK
error   libnfc.driver.pn532_uart   pn53x_check_communication error
debug   libnfc.chip.pn53x   InRelease
debug   libnfc.bus.uart   TX: 00 00 ff 03 fd d4 52 00 da 00
debug   libnfc.bus.uart   Timeout!
debug   libnfc.driver.pn532_uart   Unable to read ACK
debug   libnfc.general   Unable to open "pn532_uart:/dev/ttyACM0:230400".
nfc-list: ERROR nfc-list.c:149
nfc-list:     Unable to open NFC device: pn532_uart:/dev/ttyACM0:230400

Any suggestion?

Re: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

Hi,

At first, please fix your reported troubles :

info   libnfc.config   Unknown key in config line: device.allow_autoscan = true
Romuald Conty

Re: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

Hi,
Those are info messages... they have nothing to do with the actual problem.

However I removed those lines and the messages don't appear anymore.


As far I know, Arduino + Pn532 [SPI] + libnfc live happy togheter, but Arduino + Pn532 [I2C] + libnfc need a new driver, or .ino file, which is I would like to contribute, but don't have the time to investigate the current one and match with the different datasheets.

Regards,

Re: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

Hello,

If you have an Arduino in front of PN532, you can make a firmware for Arduino that handle UART (or serial over USB) just like the PN532 do when its connected directly to a UART->USB dongle.
There is no need for additional driver in libnfc in this case.

Romuald Conty

5 (edited by helpme 2015-05-28 11:30:17)

Re: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

rconty wrote:

Hello,

If you have an Arduino in front of PN532, you can make a firmware for Arduino that handle UART (or serial over USB) just like the PN532 do when its connected directly to a UART->USB dongle.
There is no need for additional driver in libnfc in this case.

Thanks for the good news. How do you compile the libnfc for Arduino? Do you use Arduino IDE to compile the libnfc? I read this link nfc-tools.org/index.php?title=Libnfc:Arduino and am getting confused. From the instructions, it seems that libnfc is compiled on a Linux PC. But how can the libnfc executable run on Arduino if it is compiled on a PC? So far, the related posts I found do not make things clearer, at least to me. Maybe the fault lies with me. How do I compile libnfc to get it working on Arduino?

Thank you.

Re: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

Its not possible to compile libnfc for Arduino.

Arduino do have a different code to forward instructions send from PC (by libnfc) to the connected PN532.

Romuald Conty

Re: Libnfc vs. Elecfreaks NFC Bridge (Arduino Leonardo I2C Pn532)

rconty wrote:

Its not possible to compile libnfc for Arduino.

Arduino do have a different code to forward instructions send from PC (by libnfc) to the connected PN532.

Ahh ... Things are much clearer now. I guess this approach works only for UART. The downside is that libnfc SPI and I2C will not be able to work.