Sunday, October 17, 2010

Real World Integration

As part of a new project, I'm playing with some RFID technology, and I decided to document my setup process here so I could duplicate it later if I needed to do it again on another computer. The idea? use active RFID tags to track people as they come and go from a building. Here are the steps for getting the tag processing up and running on my macbook pro:

0) buy RFID receiver and tags from http://cliste.sailwhatcom.com/

1) Download Mac OS X driver for the serial to usb adapter built into the receiver
http://www.prolific.com.tw/eng/downloads.asp?ID=31. run the downloaded pkg file from the unzipped DMG. (will restart your computer)

2) make sure the receiver is sending data. Plug it into a USB port, and you can use (on Mac OS X) "screen /dev/tty.usbserial 9600" to watch the port's data come across your screen. (BTW, I was only able to receive telemetry from my RFID receiver from the USB port on the left side of my Macbook Pro's body. When I hooked into the USB port to the right of the keyboard, I got nothing. No idea why, just something to play with if you have trouble here).

3) Make sure you are using ruby 1.8.7, 1.9.x does not appear to work for this next gem

4) install the ruby-serialport gem with "gem install ruby-serialport"

5) write some code to read from the port, something like this:


require 'rubygems'
require 'bundler/setup'
require 'serialport'

port = SerialPort.new("/dev/tty.usbserial",:baud=>9600,:data_bits=>8,:stop_bits=>1)

count = 0
while count < 1000
  printf("%c",port.getc)
  count += 1
end

port.close

There's a simple program that just reads the tag names as they come in range, along with their relative signal strengths, and prints them to the console one character at a time. Output when I have 2 Active RFID 20 meter transmitters sitting on the table next to the receiver looks something like this:

1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri86 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP78 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP78 1nri85 1nwP78 1nri85 1nwP79 1nri84 1nwP78 1nri84 1nwP79 1nri84 1nwP79 1nri85 1nwP79 1nri86 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri86 1nwP79 1nri86 1nwP79 1nri85 1nwP80 1nri86 1nwP80 1nri87 1nwP80 1nri86 1nwP80 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP81 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri86 1nwP79 1nri86 1nwP79 1nri85 1nwP79 1nri85 1nwP79 1nri85 1nwP80 1nri87 1nwP79 1nri88 1nwP79 1nri85 1nwP80 1nri85 1nwP80 1nri85 1nwP79 1nri86 1nwP80 1nri86 1nwP80 1nri86 1nwP78 1nri86 1nwP79 1nri85 1nwP79 1nri85 1nwP81 1nri85 1nwP79 1nri85 1nwP79 1nri86 1nwP78 1nri85 1nwP78 1nri85 1nwP78 1nri86 1nwP79 1nri85 1nwP78 1nri85 1nwP78 1nri85 1nwP78 1nri85 1nwP78 1nri85 1nwP78 1nri85 1nwP78 1nri86 1nwP79 1nri85 

Note: BE SURE TO CLOSE YOUR PORT! On a couple occasions I've terminated the program without closing the port object, it seems to leave it open and any future attempts to connect with that port get bounced with a "resource busy" message. Only a restart has solved that problem for me.

No comments: