PN532
Driver for the PN532 NFC chip. Provides an event and promise-based API, and requires either:
- node-serialport
- node-i2c (WIP)
This implementation does not require libnfc, and should work on both X86 (32-bit or 64-bit) and ARM (RPi / Beaglebone) systems
Tested on a Mac OSX 10.9 system using a UART/FTDI cable to an Adafruit breakout board and on a BeagleBone using UART. I2C support is currently a WIP at the moment.
API is subject to change until the 1.0.0 release
Install
npm install pn532
and npm install serialport
or npm install i2c
Example
node-serialport)
UART (usingvar pn532 = ;var SerialPort = SerialPort; var serialPort = '/dev/tty.usbserial-AFWR836M' baudrate: 115200 ;var rfid = serialPort;
node-i2c)
I2C (usingvar pn532 = ;var i2c = ; var wire = pn532I2C_ADDRESS device: '/dev/i2c-1';var rfid = wire;
Scan a tag
rfid;
Poll for a tag
rfid;
Retrieve the firmware version
rfid;
ndef library)
Read and write tag data (usingTested using NTAG203 tags. Should support other NTAG and Mifare Ultralight tags. Mifare Classic tags are currently NOT supported, but could be in the future.
Read
rfid;
Write
rfid;
Examples
Examples are available under the examples
directory
Debug logging
PN532_LOGGING=debug node examples/card_scan.js
Note for using UART on a Raspberry Pi 3
If you are using this library on a Raspberry Pi 3, you will likely encounter an issue with the device sending or receiving data over UART due to some hardware and configuration changes with regards to the serial port.
TLDR workaround:
- Add
core_freq=250
in the/boot/cmdline.txt
- Use
/dev/ttyS0
instead of/dev/ttyAMA0
For details on why these changes are needed, see here and here