Step 1

Make a directory inside your "tessel-code" folder: enter mkdir rfid into your command line, then change directory into that folder: cd rfid

Step 2

Plug the RFID module into Tessel port A with the hexagon/icon side down and the electrical components on the top, then plug Tessel into your computer via USB.

Step 3

Install by typing npm install rfid-pn532 into the command line.

Step 4

Save this code in a text file called rfid.js:

// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

/*********************************************
This basic RFID example listens for an RFID
device to come within range of the module,
then logs its UID to the console.
*********************************************/

var tessel = require('tessel');
var rfidlib = require('rfid-pn532');

var rfid = rfidlib.use(tessel.port['A']); 

rfid.on('ready', function (version) {
  console.log('Ready to read RFID card');

  rfid.on('data', function(card) {
    console.log('UID:', card.uid.toString('hex'));
  });
});

rfid.on('error', function (err) {
  console.error(err);
});

Step 5

In your command line, tessel run rfid.js
Tap the included RFID card on the reader to get its UID!

Bonus: Change the polling rate of the RFID module so that it only checks for a card once every three seconds. (Hint: you may need to check the docs.)

To see what else you can do with the RFID module, see the module docs here.

Step 6

What else can you do with a RFID module? Try a community-created project.


What are you making? Share your invention!

If you run into any issues you can check out the RFID forums.

Choose another module

Or if you're all set, move on to Wifi.

Fork on Github