Published on 15 May 2015
RFID is often a good way to personalise a project as it allows you to assign a physical token some sort of programmatic action. RFID-type tokens are widely found, for example in London Oyster cards, door access entry tokens and increasingly bank payment cards. They're also wireless so there are opportunities to enable some magical interactions with them. For example, Libby's Podcast in a box.
Being able to reach for an RFID reader and quickly use it in a project is important so I've hacked together a couple of approaches.
The RFID reader I'm using is accessible over UART. This means to read from it you just have to open a serial connection and send the correct bytes. The reader will reply with an answer to your query.
The Espruino has a few UART pins and I'm using
Serial4 on the classic Espruino board. You can change the serial port to whatever you want and just replace all instances of
Serial4 in the code.
You open up the Espruino Web IDE, copy and paste the code and press send. The Espruino will now print the serial number of any cards to the console.
For other platforms, it's more convenient to have something that plugs in via USB. A USB-UART bridge is a fairly cheap solution. The code is verimgy similar and is doing exactly the same thing. I'm using node.js.
On Mac OS X, I had to install the drivers for the USB-UART chip. After that, it's a simple as figuring out which serial port you've plugged it into and specifying that as an environment variable for the script. This should also work on Linux so it's useful for the Raspberry Pi.