
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
Driver for the PN532 NFC chip. Provides an event and promise-based API, and requires either:
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
npm install pn532
and npm install serialport or npm install i2c
var pn532 = require('pn532');
var SerialPort = require('serialport').SerialPort;
var serialPort = new SerialPort('/dev/tty.usbserial-AFWR836M', { baudrate: 115200 });
var rfid = new pn532.PN532(serialPort);
var pn532 = require('pn532');
var i2c = require('i2c');
var wire = new i2c(pn532.I2C_ADDRESS, {device: '/dev/i2c-1'});
var rfid = new pn532.PN532(wire);
rfid.on('ready', function() {
rfid.scanTag().then(function(tag) {
console.log('tag:', tag.uid);
});
});
rfid.on('ready', function() {
console.log('Listening for a tag scan...');
rfid.on('tag', function(tag) {
console.log('tag:', tag.uid);
});
});
rfid.on('ready', function() {
rfid.getFirmwareVersion().then(function(data) {
console.log('firmware: ', data);
});
});
Tested using NTAG203 tags. Should support other NTAG and Mifare Ultralight tags. Mifare Classic tags are currently NOT supported, but could be in the future.
rfid.on('ready', function() {
rfid.on('tag', function(tag) {
rfid.readNdefData().then(function(data) {
var records = ndef.decodeMessage(Array.from(data));
console.log(records);
});
});
});
rfid.on('ready', function() {
rfid.scanTag().then(function(tag) {
var messages = [
ndef.uriRecord('http://www.google.com'),
ndef.textRecord('test')
];
var data = ndef.encodeMessage(messages);
rfid.writeNdefData(data).then(function(response) {
console.log('Write successful');
});
});
});
Examples are available under the examples directory
PN532_LOGGING=debug node examples/card_scan.js
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:
core_freq=250 in the /boot/cmdline.txt/dev/ttyS0 instead of /dev/ttyAMA0For details on why these changes are needed, see here and here
FAQs
Library to run the PN532 RFID Reader
We found that pn532 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.