Arjan Scherpenisse

Interfacing RFID

A quickstart for using Mediamatic's RFID readers

At Mediamatic, two different kind of high-frequency USB-based RFID readers are in use. While it is perfectly possible to write your own interfacing software for communication, Mediamatic already has done that a couple of times, resulting in classes for Processing/Java, Python (using the twisted framework), simple commandline tools and an RFID-to-OSC gateway. So you don't need to reinvent the wheel. This article describes the inner workings of the readers and how to get them to work on your machine or on a Mediamatic laptop.

Vergroot

Ik-Tag -

You'll basically have 4 options: Using Processing/Java with a sonmicro reader, using Python+twisted with a sonmicro reader, using Python+twisted with a tikitag reader, or setup an rfid-to-OSC gateway to receive RFID signals in any OSC-capable program.

Using Processing/Java

The aricle 30367 contains the link to www.on-signal.org/projects/RFID_Processing, where documentation and download links can be found to get this working.

Using Python+twisted

We'll use the `fizzjik` library which contains an implementation of the Sonmicro serial protocol. Ask 22661 or 24879 about this! We're excited if you want to go this way: using twisted+python is a viable and very stable option for doing RFID interaction, and at Mediamatic we find it the preferred way of developing applications.

Programs that were made with python+twisted and which source code can be inspected (on request):

  • The IkPoll interactive polling stations.
  • The new IkCam application.
  • IkTag Registration Desk.
  • The IkDisplay realtime backchannel.

The RFID-to-OSC gateway

Quickstart

  • install the driver for the reader (if needed, see below)
  • compile the rfid2osc gateway
  • start the gateway and run the test program
  • start implementing your client program!

What is OSC? From wikipedia: "OpenSoundControl (OSC) is a protocol for communication among computers, sound synthesizers, and other multimedia devices that are optimized for modern networking technology." It is a protocol for which many libraries are available for almost any programming language imaginable. It is especially popular with new media artists and programmers, for its ease of implementation.

The gateway handles input of either of the two different rfid interfacing programs ('acr122' and 'sonmicro-mifare'), and interpret its output, converting it into OSC messages which make more sense to the programmer. The OSC client program listens on the port the gateway sends to, and thus receives messages about tags entering and exiting the RF-field of the reader. The nice thing is that you can run multiple gateways at once, which can then all talk to the same client. This way support for multiple readers is very easily established.

Compiling the gateway

On Mac, you'll need to install the liblo library, from liblo.sourceforge.net/
Installing is simply ./configure && make && sudo make install, which will install it in /usr/local.
After that, you can use 'make' in the rfid2osc folder to build the gateway.
Linux users: apt-get install liblo0-dev.

Example

The tools are located in the Picnic repository from the Mediamatic subversion. The example presumes that you have the programs compiled and the necesary requirements installed. The gateway connects to localhost on port 7007 by default.

To get a simple gateway up for a Sonmicro USB reader:

cd $HOME/src/picnic/tools/
rfidtools/sonmicro-mifare /dev/tty.usbserial-A3Q6MSXI | rfid2osc/rfid2osc

Testing the gateway:

cd $HOME/src/picnic/tools/rfid2osc
./osc_receive.py

To get a simple gateway for an ACR122 reader:

cd $HOME/src/picnic/tools/
rfidtools/acr122 | rfid2osc/rfid2osc

Note: there is no way (yet!) to identity multiple ACR122 readers!

Multiple readers:

cd $HOME/src/picnic/tools/
rfidtools/acr122 | rfid2osc/rfid2osc --id reader-A &
rfidtools/sonmicro-mifare | rfid2osc/rfid2osc --id reader-B &

Readers & Drivers

SonMicro reader

The sonmicro readers in use are SM-132 modules, which are basically the same as serial readers (the SM-130 module) but with a serial-to-usb converter chip in front of it. On linux, it "just works"; the device is recognized as /dev/ttyUSB<x>.

On mac, you need a driver for the FTDI chip, FTDIUSBSerialDriver_v2_2_8.dmg. After installation the reader shows up as a serial port, something like /dev/tty.usbserial-XXXXXX where the X'es are the reader's serial number.

On windows, you'll need a driver from www.ftdichip.com/FTDrivers.htm. After installation the reader shows up as a serial port, usually COM3.

Once the drivers are installed, you can execute the 'sonmicro-mifare' script in the picnic/tools/readmifare folder. The first argument to this program is the serial port where the module is located.

Note that the sonmicro-mifare script is a Perl script which requires the Device::SerialPort module.
You can get it here: docs.mediamatic.nl/picnic/hackerscamp-archive/camp07/Device-SerialPort-1.002.tar

ACR122 (Tikitag)

The ACR122 readers, provided by Tikitag, are shiny white boxes which act like smart card readers. On mac it works out of the box, but on Linux you'll need the pcscd daemon, which can easily be apt-get install'ed. Linux users need to install wine-dev libpcsclite-dev pcscd as well!!

After that you'll need our acr122 program, which is located in the tools/rfidtools folder in the Picnic repository. You can compile it using make -f Makefile.darwin on Mac, or make -f Makefile.linux on Linux. Windows is not supported at the moment.