Oct 13

I had originally wanted to build this project with my Parallax RFID reader, but since I can’t interface it with the Make Controller until Liam at MakingThings fixes the serial BLOB implementation fixed in mchelper 2.0, I decided to complete a proof-of-concept with a Phidgets RFID reader. The application is pretty straightforward - it consists of an RFID tag embedded in a cell phone that is read for its unique ID, prompts a user to enter some data and then remembers their personal data when they return. While the premise is simple, there are a few moving parts required to stitch it together.


But first, before an explanation, here’s a demo of the application:

The Phidgets RFID Reader
PhidgetRFID is a EM4102 125Khz protocol reader. This means that it does not have the capability to write to RFID tags, only read from them. While this is just fine, I point it out so that you are aware of this fact if you are new to RFID. It should also be noted that RFID readers like these usually fit into a larger architecture that consists of a database of some sort. This allows RFID tag IDs to be stored along with additional metadata.

This particular reader is nice in that you can connect it directly to a computer (Mac, Windows and Linux support) via USB and simply run a web service that provide connectivity to the board. In this example, that process is abstracted away in the AS3 classes that Phidgets provides (they also have a .SWC if you prefer that), so connecting to it and reading tags from it is really quite easy.

After installing the software from Phidgets, I set up an alias in my bash profile set up to make it easy to fire up the web service: alias phidget=’/usr/bin/phidgetwebservice21′. That way, I just type phidget into a terminal window and it starts. After plugging the RFID reader into an open USB port, it’s ready to communicate. That’s really all there is to setting it up since there is no microcontroller involved.

Flex Builder 3 and AIR
I opted to build this as an AIR application because an application like this is most applicable in a kiosk scenario, rather than as a web application. Anyway, connecting to the RFID reader using Flex is quite easy and a majority of the code is devoted to setting up event handlers:

<mx:application xmlns:mx="http://www.adobe.com/2006/mxml">
 
creationcomplete="onCreationComplete()"&gt;
 
<mx:script>
 
<!--[CDATA[
 
import com.phidgets.*;
 
import com.phidgets.events.*;
 
private var devRFID:PhidgetRFID;
 
private function onCreationComplete():void {
 
devRFID = new PhidgetRFID();
 
devRFID.addEventListener(PhidgetEvent.DETACH, onDetach);
 
devRFID.addEventListener(PhidgetEvent.ATTACH, onAttach);
 
devRFID.addEventListener(PhidgetErrorEvent.ERROR, onError);
 
devRFID.addEventListener(PhidgetDataEvent.TAG, onTag);
 
devRFID.addEventListener(PhidgetDataEvent.TAG_LOST, onTagLoss);
 
devRFID.open("localhost", 5001, "1234");
 
}
 
private function onAttach(pdeEvent:PhidgetEvent):void{
 
trace(pdeEvent);
 
devRFID.Antenna = true;
 
devRFID.LED = true;
 
}
 
private function onDetach(pdeEvent:PhidgetEvent):void{
 
trace(pdeEvent);
 
}
 
private function onTag(pdeEvent:PhidgetDataEvent):void {
 
&nbsp;	trace(pdeEvent);
 
//This is where all of the good stuff goes...
 
}
 
private function onTagLoss(pdeEvent:PhidgetDataEvent):void {
 
trace(pdeEvent);
 
}
 
private function onError(pdeEvent:PhidgetErrorEvent):void {
 
trace(pdeEvent);
 
}
 
]]-->
 
</mx:script>
 
</mx:application>

If you’re interested in the rest of the code, download the source. Also, a quick disclaimer that this was just a quick proof-of-concept and is all in a single MXML file for simplicity rather than encapsulating objects and creating components.

AMFPHP Remoting
For server/Flash Player communication, I generally opt for remoting due to its ease of implementation and speed, especially if dynamic, database-driven calls are required for the application. In this case, PHP and MySQL will handle user data and authentication as well as consuming SMS services. I could write an entire article about AMFPHP and Flex 3, and probably will, but for now, I’ll just mention it and note that it in the source code.

SMS
In the demo version (I’m not releasing this portion publicly), I’ve also rigged up some PHP classes to send SMS messages. I found a service called Clickatell that provides SMS gateway services to a bunch of giant corporations like BBC, Vodafone and Oracle. However, they do actually offer services to substantially smaller entities such as myself, which is pretty cool. Not only that, but they offer a free trial of their services.

I’d recommend them if you only need to send outgoing SMS messages. If you are interested in two-way messaging, be prepared to pony up a large amount of cash for short codes (somewhere in the neighborhood of $1200/month) and message routing. The other alternative is to set up your own SMS gateway. However, keep in mind that while setting up your own gateway is easy, it is not cost effective for sending large numbers of text messages using a normal consumer account. It will end up being cheaper using a bulk service like Clickatell.

Source
Click here to download the source for the AIR source and installer, PHP code and MySQL schema.



3 Responses

  1. noah Says:

    That is very, very, very cool indeed.

    I can already think of about 20 different implementations for this…

    Thanks for the demo!

  2. Ben Arent Says:

    this is great stuff. I’m going to be working on a very similar project soon. I’m desiging a social communication project for the eldery, keep an eye on my blog. Thanks for sharing.

  3. Hans Says:

    this is, so SO cool.
    How did you get the text/dialogue to happen on your computer?

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.