---
title: Touchatag RFID reader and Ubuntu Linux
canonical: https://0110.be/posts/Touchatag_RFID_reader_and_Ubuntu_Linux
markdown_url: https://0110.be/posts/Touchatag_RFID_reader_and_Ubuntu_Linux.md
id: 56
published_at: '2009-10-05T00:00:00Z'
updated_at: '2013-12-05T18:19:15Z'
author: Joren
tags:
- name: 0110.be
  markdown_url: https://0110.be/tags/0110.be.md
- name: Code
  markdown_url: https://0110.be/tags/Code.md
- name: Harde waren
  markdown_url: https://0110.be/tags/Harde%20waren.md
- name: Projecten
  markdown_url: https://0110.be/tags/Projecten.md
---

# Touchatag RFID reader and Ubuntu Linux

![Touchatag Logo](https://0110.be/files/attachments/56/touchatag_logo.png "Touchatag Logo")

This blog post is about how to use the [Touchatag](http://www.touchatag.com) RFID reader hardware on Ubuntu Linux without using the Touchatag web service.

An RFID reader with tags can used to fire events. With a bit of scripting the events can be handled to do practically any task.

Normally a Touchatag reader is used together with the [Touchatag web service](http://www.touchatag.com/developer/tools/advanced-http-application) but for some RFID applications the web service is just not practical. E.g. for embedded Linux devices without an Internet connection. In this tutorial I wil document how I got the Touchatag hardware working under Ubuntu Linux.

To follow this tutorial you will need:

-   Touchatag hardware: the USB reader and some tags

-   A Ubuntu Linux computer (I tested 9.10 Karmic Koala and 8.04 )

-   SVN to download source code from a repository

The touchatag USB reader works at 13.56MHz (High Frequency RFID) and has a readout distance of about 4 cm (1.5 inch) when used with the touchatag RFID tags. Internally it uses an ACS ACR122U reader with a SAM card. A Linux driver is readily available so when you plug it in `lsusb` you should get something like this:

\`\`\`ruby\
lsusb

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub\
Bus 005 Device 004: ID 072e:90dd Advanced Card Systems, Ltd\
\`\`\`

lsusb recognizes the device incorrectly but that's [not a problem](http://code.google.com/p/tageventor/wiki/SupportedReadersAndTags). To read RFID-tags and respond to events additional software is needed: [tagEventor](http://code.google.com/p/tageventor/) is a software library that does just that. It can be downloaded using an svn command:

\`\`\`ruby\
svn export http://tageventor.googlecode.com svn/trunk/ tageventor\
\`\`\`

To compile tagEventor a couple of other software packages or header files should be available on your system. Te [tagEventor software dependencies](http://code.google.com/p/tageventor/wiki/SoftwareDependencies) are described on the [tagEventor wiki](http://code.google.com/p/tageventor/w/list). On Ubuntu (and possibly other Debian based distro's the installation is simple:

\`\`\`ruby\
sudo aptitude install build-essential libpcsclite-dev build-essential pcscd libccid\
#if you need gnome support\
#sudo aptitude install libgtk2.0-dev\
\`\`\`

<del>
Now the tricky part. Two header files of the pcsclite package need to be modified</del> (update: this bug is fixed [see here](http://code.google.com/p/tageventor/issues/detail?id=2)). tagEventor builds and can be installed:

\`\`\`ruby\
cd tageventor\
make\
...\
tagEventor BUILT (./bin/Release/tagEventor)

sudo ./install.sh\
...\
\`\`\`

When tagEventor is correctly installed the only thing left is ... to build your application. When an event is fired tagEventor executes the `/etc/tageventor/generic` script with three parameters (see below). Using some kind of [IPC (Inter Process Communication)](http://en.wikipedia.org/wiki/Inter-process_communication) an application can react to events. A simple and flexible way to propagate events (inter-processes, over a network, platform and programming language independent) uses sockets. The code below is the `/etc/tageventor/generic` script (make sure it is executable), it communicates with the server: the second script. To run the server execute `ruby /name/of/server.rb`

\`\`\`ruby\
#!/usr/bin/ruby

1.  \$1 = SAM (unique ID of the SAM chip in the smart card reader if exists, "NoSAM" otherwise

2.  \$2 = UID (unique ID of the tag, as later we may use wildcard naming)

3.  \$3 = Event Type (IN for new tag placed on reader, OUT for tag removed from reader)

require 'socket'

data = ARGV.join('\|')\
puts data

streamSock = TCPSocket.new( "127.0.0.1", 20000 )\
streamSock.send(data, 0)\
streamSock.close\
\`\`\`

\`\`\`ruby\
require "socket"\
dts = TCPServer.new('localhost', 20000)\
loop do\
Thread.start(dts.accept) do \|s\|\
puts s.gets\
s.close\
end\
end\
\`\`\`

The tagEventor software is made by [the Autelic Association](http://www.autelic.org/) a Non-Profit association dedicated to making technology easier to use for all. I would like to thank Andrew Mackenzie, the founder and president of the association for creating the software and the support.


![Touchatag hardware](https://0110.be/files/photos/56/touchatag_hardware.jpg)
