Shared Phidgets Simple Example Using The RFID Reader

<< Back to the SharedPhidgets 3 page

What you will learn in this tutorial:

  • how to create a SharedPhidgets RFID object,
  • how to assign a specific serial number to this reader,
  • how to use the RFID skin and
  • how to get the retrieved RFID tags in your code with an event handler.

Download source:
The zip file contains the program code of all the Shared Phidgets programming examples. The source code of this example can be found in the 'RFIDExample' project.


The Phidget RFID Reader
The Phidget RFID Reader
  1. Create a new Shared Phidgets appliance with the template in VisualStudio.NET
  2. Create a RFID object
  3. Create a RFID skin and connect it to the RFID reader object
  4. Create a textbox on your form and display retrieved RFID tags
  5. Finished! Compile the application and enjoy to work with RFID tags!
  6. Some features of the RFID reader skin

Step-by-step Instructions

Preparation: Install the Shared Phidgets toolkit on all client machines, run the Connector software, and attach at least one Phidgets RFID reader to one of the client computers.

1) Open VisualStudio.NET 2005, click New Project, select a new C# Windows application, enter a name for the project, and confirm the dialog.

2) Doubleclick the 'ApplianceForm.cs' file in the project explorer on the right side of the screen:

The windows form for the appliance control will now be opened:

It is possible to change the appliance name, as well as the default address for the connection to the shared dictionary by changing properties of the main form:

3) Drag a SharedPhidget RFID component on your form

It is possible to change the serial number of the RFID reader. If you have only one RFID reader connected to your infrastructure, you don't need to add the serial number because the component will then connect to the only hardware device of this type that it will find.

4) Create a skin object for the RFID reader (RFIDSkin object): Just click on the entry in the toolbox and click-and-hold to create the control on the appliance form.

Change the RFID property of the RFIDSkin to the object of the created RFID reader, here this is rfid1:

5) Create a new TextBox object on your form, and select the Multiline property to true and the ScrollBars property to Vertical. Furthermore, set the value of the Text property to an empty string.

Select the 'rfid1' object, and select the event view:

Create a new eventhandler for the Tag and the TagLost event of the RFID object (rfid1):
just select the event in the list of events and press Enter (or Doubleclick there), and a new callback method will be created:

Just insert the following code line in this callback method: it will add the received (or lost) Tag (e.Tag) to the textbox and adds a new line.

private void rfid1_Tag(object sender, GroupLab.SharedPhidgets.RFIDTagEventArgs e)
  this.textBox1.Text = "Tag found: " + e.Tag +
    System.Environment.NewLine + this.textBox1.Text;

private void rfid1_TagLost(object sender, GroupLab.SharedPhidgets.RFIDTagEventArgs e)
  this.textBox1.Text = "Tag lost: " + e.Tag +
    System.Environment.NewLine + this.textBox1.Text;

6) Compile your application:

The following window will appear, where you can see the Skin for the RFID reader and the textbox with the received tags. Just place different tags near the reader, and you will see the ID of the tag in the RFID Reader skin and the textbox:

7) The RFID skin has three main sections that display information about the current status:

a) The last found or lost RFID tag.
b) You can see a history of received tags and also clear this history.
c) You can control the four binary outputs of the RFID reader: the 5V output, an internal LED on the RFID reader itself, an external LED, and finally the active state of the RFID itself (You always have to activate this flag to use the RFID reader to detect tags).

That's it,

you can now modify this application and enhance the functionality. You can simply use RFID tags to identify objects, and create software that can react dynamically to these detected objects/tags.