Introduction: Simple Internet Gizmo
The gizmo works by placing a RFID tag on the top of the gizmo. The gizmo then reads the RFID tag and sends the tag number via USB to a program running on a PC. The program looks up the tag number and the associated web site and then invokes the default web browser to open a new tab to display the web page.
The Simple Internet Gizmo is fun to use, makes an excellent desk toy, and sure beats using a mouse and keyboard to load your favorite web sites.
This video demonstrates the Simple Internet Gizmo:
I made this at TechShop.
Step 1: How It Works
The Simple Internet Gizmo consists of a Sparkfun RFID card reader mounted in a plastic single gang electrical outlet box connected to a PC using a USB cable as shown in the diagram. When a RFID card when it is placed near the reader, the reader sends the unique tag number on the card to the PC via USB. On the PC, a Python program is running in a loop waiting for data from the RFID card reader. When it receives the RFID card id from the reader, it looks up the RFID card ID in a table to see what web site is associated with that card. If it finds the card in the table, it opens a new tab in the default web browser for the computer and loads the web site. If the RFID card ID is not in the table, the Python program creates a simple HTML page with an error message and the RFID card ID and displays the information in a new tab in the browser.
Details on how the software works is covered in step 10.
Step 2: Parts
- Sparkfun RFID Card Reader (Sparkfun part number RTL-09875)
- 3 foot or longer USB cable with type A male plug and a mini-USB male plug on the ends.
- Single gang plastic electrical outlet box (I used a Carlon 1 Gang Handy Box B112HBR from Home Depot)
- Electrical plastic outlet box cover that matches the outlet box (I used a Carlon 1 Gang Handy Box Cover HB1BL from Home Depot)
- Four #4-40 1.5" machine screws
- Twelve #4-40 nuts
- Eight #4 washers
- Bunch of 50mm round RFID tags (Parallax part 28142)
- Self adhesive labels suitable for use in a color printer
- Phillips head screw driver
- Flat head screw driver
- Color printer (laser or inkjet)
- Goo Gone or similar adhesive remover
- Electric drill
- 7/64" Drill bit
- 7/32" Drill bit
- Sharpie permanent marker
Step 3: Prepare the RFID Reader
- The Sparkfun RFID reader comes with packaged with the board and the RFID reader chip as two components as shown in the first photo.
- Carefully plug the chip into the board as shown in the second and third photos.
- Put the four #4-40 machine bolts into the mounting holes on RFID reader board and secure with the #4-40 nuts as shown in the third photo.
Step 4: Mount the RFID Reader
- Place the RFID card reader on the top of the box cover and mark where the machine screws touch the cover with a marker as shown in the first photo. The RFID card reader should be mounted so that the chip will be right under the knock-out hole in the outlet/switch box.
- Using a 7/64" drill bit drill holes at the marked places on the cover as shown in the second photo.
- Put nuts on each of the machine screws approximately 1/4" from the end as shown in the third photo.
- Place the RFID reader on the cover using washers between the nuts and the cover as shown in the fourth and fifth photos. Make sure the USB plug on the reader is facing inwards.
- Secure the RFID reader to the bottom of the base using washers and nuts as shown in the last photo.
Step 5: Prepare the Top of the Case
- Using a flat head screw driver and a hammer carefully break the tabs holding the knock-out plug in place on the top of the outlet box as shown in the first photo.
- Remove any stickers on the box. Goo Gone (or a similar product) may be needed to remove any residue adhesive from the box to make it look nice and neat like the second photo.
- Using a 7/32" drill bit, drill holes in the box on the opposite end of the knock-out hole to make an opening as shown in the third and fourth photos. This hole will be used for the USB cable.
Step 6: Prepare the USB Cable
Tie a knot in the USB cable as shown in the second photo. The knot will prevent the USB cable from coming unplugged from the reader if the cable is pulled too hard.
Step 7: Assemble the Gizmo
- Plug the USB cable into the reader as shown in the first photo.
- Carefully place the cover onto the base as shown in the second photo. Make sure the knot in the USB cable is inside the outlet box and the cable is aligned with the drilled hole in the end of the box.
- Secure the outlet box to the bottom using the screws that came with the bottom cover as shown in the third photo.
Step 8: Label the RFID Tags
- Find artwork that you want to use to represent the web site you want to associate with tag.
- Using your favorite software, print the artwork onto the labels (I used Avery labels and their online label printing software.)
- Cut out the labels and stick them on the tags as shown in the second photo. You can put the sticker on either side of the tag.
Step 9: Install the Software
Python is used to run the program that will monitor the USB port for data from the Sparkfun RFID card reader in the Gizmo. I used Python version 2.7.2 for this program. Any version of Python 2.7.x should work fine. I have not tested the Simple Internet Gizmo on Python 3.2.x.
- To install Python 2.7.x, download the Python 2.7.x Windows installer software from http://www.python.org/download/.
- After the download is complete, run the installer. The installer asks where you want to install Python - I had it install it at c:\Python27. All of the following instructions assume that's where it's installed. You can install it in a different folder, but you will need to adjust the instructions accordingly.
pySerial is a library for Python that allows it communicate over a serial communication link like USB. Install pySerial as follows:
- Download pySerial from http://pypi.python.org/pypi/pyserial - click on pyserial-2.6.tar.gz to download the library.
- Download and install 7-Zip from http://www.7-zip.org/. This software is required to open the pyserial tar.gz file.
- Run 7-Zip (Start -> All Programs -> 7-Zip -> 7-Zip File Manager).
- Open the pyserial-2.6.tar.gz file with 7-Zip (File -> Open).
- Double click the "dist" folder.
- Single click on the "pyserial-2.6.tar" file and click the "Extract" button at the top of the window. When asked where to put the file, specify c:\Python27\Lib\site-packages\pyserial-2.6
- Exit from 7-Zip
Now that you have downloaded pySerial, install it:
- Open a command window (Start -> All Programs -> Accessories -> Command Prompt) and type into the command line: cd c:\Python27\Lib\site-packages-\pyserial-2.6
- Install pySerial by typing this command: c:\Python27\python.exe setup.py install
Note: this program was written for the Sparkfun RFID card reader. If you are building a Simple Internet Gizmo using the Parallax USB RFID card reader, you should use the python program "simple-internet-gizmo v1 for Parallax.py" attached to this step. The Sparkfun RFID card reader only sends tag information once when the tag is in range. The Parallax reader will send tag information multiple times when the tag is in range so additional logic is needed in the program to eliminate the duplicate readings.
Step 10: How the Software Works
- Lines 15 - 17 import the libraries for creating and writing to files, communicating with the RFID reader, parsing the data sent from the RFID reader, and controlling the web browser.
- Lines 22 - 36 are the table (dictionary in Python terms) used to associate the tag IDs with web sites. Each line has the ten character RFID tag ID and a HTTP link to the web site. Note that the first tag has "quit" for the web address. If this tag is read, then the program will end. New tags can be added by duplicating the last line and replacing the tag ID with the new tag and putting in the web site you want for the tag.
- Line 39 defines what COM port the program will use to communicate with the RFID reader. You should change this to match your system. The Quickstart guide for RFID reader on the Sparkfun site shows to determine what COM port is being used by the RFID reader.
- Line 44 is the name of the file that the program creates when an unknown tag is read. This file is created in the directory where you installed Python. In my case, it was "c:\Python27".
- Lines 47 - 55 use the pySerial library to connect to the RFID reader. Messages will be displayed in the Python window indicating whether the connection was made or not.
- Line 58 checks to see whether the connection was successful. If the connection was made, processing will continue otherwise the program will end.
- Lines 62 - 63 use the "pySerial" library to read the data from the RFID reader.
- Line 66 checks to see if data has been read.
- Line 68 extracts just the RFID tag number from the data that was read. The Sparkfun RFID reader sends a few bytes of additional data that need to be removed.
- Line 69 prints the tag number just read in the python command window.
- Line 72-73 calls a function to lookup the web site based on the tag ID. The tag ID and web site in the Python are displayed in the Python console window for debugging purposes.
- Lines 76 - 77 check to see if this is the special tag used to stop the program and if so, the program exits the loop and the program ends.
- Line 79 uses the "webbrowser" library to start the browser if not running and then open a new tab for the web site.
Lines 82 - 95 are the function that is used to lookup the web sites associated with the tag ID:
- Line 84 checks to see if the tag ID is in the dictionary
- Line 85 returns the web site if the tag ID was in the dictionary.
- Lines 89 - 91 build the HTML for the error message for the unknown tag.
- Lines 92 - 94 use the "sys" library to create a HTML file, write the HTML to the file, and close the file. If the file happens to already exist, the HTML in the file is overwritten with the new HTML.
- Line 95 returns the name of the file. Back in the main program, the web browser will open this file rather than a web site and display the error message.
- Lines 98 - 102 allow you run this program from the command line and pass in the name of the COM port as a parameter rather than modifying the program.
Step 11: Operating the Gizmo
Plug the USB cable from the Gizmo into your PC. If you get messages about the driver not being found, follow the instructions at the Sparkfun web site here.
Start the Python program on the PC:
- Open a command prompt: Start -> All Programs -> Accessories -> Command Prompt
- Change the directory to the Python directory: type cd c:\Python27
- Start the program by typing: python.exe simple_internet_gizmo_v1.py
- The program will connect to the gizmo and you should see the messages indicating the Sparkfun RFID reader was connected like in the first photo. If you get an error message that the program can't connect, you are most likely using the wrong COM port. The Quickstart guide for RFID reader on the Sparkfun site shows to determine what COM port is being used by the RFID reader. Double check and try again. If you're using a different COM port than the one in the Python program, you can either change line 39 in the program or specify the COM port when you run the program like this: python.exe simple_internet_gizmo_v1.py COM6
- Read a tag and when you get the error message in the browser about an unknown tag, copy the tag ID, paste it into the table in the python program and update the associated web site. The second photo shows an example of an unknown tag error page.
- Repeat this for all of your tags. Don't forget to use one of your tags as the "quit" tag.
- Restart the python program for the changes to take effect.
The third photo shows what is displayed by the Python program in the command window when tags are read. The first line for each tag is the data read from RFID reader and the second line is the tag and associated web site.
Enjoy your Simple Internet Gizmo!
We have a be nice policy.
Please be positive and constructive.