Alert.png

Notice: This page contains information for the legacy Phidget21 Library.

Phidget21 is out of support. Bugfixes may be considered on a case by case basis.

Phidget21 does not support VINT Phidgets, or new USB Phidgets released after 2020. We maintain a selection of legacy devices for sale that are supported in Phidget21.

We recommend that new projects be developed against the Phidget22 Library.


Click on the 2phidget22.jpg button in the menu bar to go to the Phidget22 version of this page.

Alert.png

Access Control: Difference between revisions

From Phidgets Legacy Support
No edit summary
Line 51: Line 51:


==Setting it up==
==Setting it up==
The most difficult part with this project is installing all the components.  We are trying to mount hardware on both the exterior and interior of the wall, this can be tricky as cables will need to be run through the wall.  Since exterior walls have insulation in them, feeding wires through can be difficult.
The most difficult part with this project is installing all the components.  We are trying to mount hardware on both the exterior and interior of the wall, this can be tricky as cables will need to be run through the wall.  Since exterior walls have insulation in them, feeding wires through can be difficult.[[File:rfidusbpinout.png|right|thumb|310px|link=|Pinout of the RFID USB header as viewed from the top down (as if looking through the board).]]
#The first step is to cut a hole in the exterior wall that is large enough to fit the box you have gotten.
#The first step is to cut a hole in the exterior wall that is large enough to fit the box you have gotten.
#You will need to drill a hole through the interior side of the wall inline with this large hole.
#You will need to drill a hole through the interior side of the wall inline with this large hole.
Line 59: Line 59:
#The easiest thing to do now is to fasten the RFID reader to the faceplate via glue or foam tape.
#The easiest thing to do now is to fasten the RFID reader to the faceplate via glue or foam tape.
#Attach the faceplate to the electrical box and this part is finished.
#Attach the faceplate to the electrical box and this part is finished.
[[image:rfidusbpinout.png|thumb|310px|link=|Pinout of the RFID USB header as viewed from the top down (as if looking through the board).]]
If you find you are having trouble getting the USB plug to fit in the box you can always remove the plug and solder the wires directly to the pins on the underside of the RFID reader.  Depending on where you install the box it may also be a good idea to use some foam weather stripping to enhance the seal of the faceplate to the box.
If you find you are having trouble getting the USB plug to fit in the box you can always remove the plug and solder the wires directly to the pins on the underside of the RFID reader.  Depending on where you install the box it may also be a good idea to use some foam weather stripping to enhance the seal of the faceplate to the box.


Line 66: Line 65:
Next we need to have a method for actually unlocking the door.  For this project we will be using an electric strike.  An electric strike is a device that replaces the hardware on the jamb of the door.  Electric strikes can be difficult to install, usually they are used in metal frame doors since the jambs tend to be hollow in these cases which makes running wires much easier.  However, there are strikes made specifically for wooden doors.  In general, you should follow the instructions that come with the strike for installation.   
Next we need to have a method for actually unlocking the door.  For this project we will be using an electric strike.  An electric strike is a device that replaces the hardware on the jamb of the door.  Electric strikes can be difficult to install, usually they are used in metal frame doors since the jambs tend to be hollow in these cases which makes running wires much easier.  However, there are strikes made specifically for wooden doors.  In general, you should follow the instructions that come with the strike for installation.   
{|
{|
|[[image:metaldoorjamb.jpg|thumb|left|500px|link=http://sl/wiki/images/3/3d/Metaldoorjamb.jpg|Metal door jamb with precut whole for a strike plate.  Note that since the frame is hollow wiring can be run through it fairly easily.]]||[[image:wooddoorjamb.jpg|thumb|left|500px|link=http://sl/wiki/images/a/af/Wooddoorjamb.jpg|Wood door jamb with traditional strike plate installed.  This needs to be removed, and a large hole cut out for the electric strike.]]
|[[File:metaldoorjamb.jpg|thumb|left|500px|link=http://sl/wiki/images/3/3d/Metaldoorjamb.jpg|Metal door jamb with precut whole for a strike plate.  Note that since the frame is hollow wiring can be run through it fairly easily.]]||[[File:wooddoorjamb.jpg|thumb|right|500px|link=http://sl/wiki/images/a/af/Wooddoorjamb.jpg|Wood door jamb with traditional strike plate installed.  This needs to be removed, and a large hole cut out for the electric strike.]]
|}
|}
While installing the strike keep in mind what you are going to need to do with the wires.  You need to run wires from the power supply to the relay and from the relay to the strike.   
While installing the strike keep in mind what you are going to need to do with the wires.  You need to run wires from the power supply to the relay and from the relay to the strike.   


The layout for the setup is as follows:
The layout for the setup is as follows:<br />
{|
[[File:doorlockblockdiagram.png|600px|link=http://sl/wiki/images/5/54/Doorlockblockdiagram.png]]
|[[image:doorunlockfull.png|700px|link=http://sl/wiki/images/a/aa/Doorunlockfull.png]]||[[image:doorlockblockdiagram.png|600px|link=http://sl/wiki/images/5/54/Doorlockblockdiagram.png]]
[[File:doorunlockfull.png|600px|link=http://sl/wiki/images/a/aa/Doorunlockfull.png]]
|}


==Software==
==Software==

Revision as of 17:05, 4 April 2012

This project will help you set up a keyless entry system for any door in your house, specifically we want to create a system that will unlock a door when a recognized RFID tag is detected. Keyless entry systems have been in use in large facilities for years so why not your house too? At the flash of a card or key-chain your door will automatically unlock, no need to fumble around with a set of keys to find the right key which inevitably takes a few tries.

Difficulty: Software Difficulty: Time Commitment: Awesome:


This project includes:

  • Some tricky wiring
  • Protecting your devices against the elements
What You're Going to Need for this Project
Phidgets Parts Tools
Qty Item
1 1023_1 - PhidgetRFID
1 1072_0 - PhidgetSBC2
1 3052_0 - SSR Relay Board
Qty Item
1 Double gang electrical box
1 Faceplate for the box

A selection of screwdrivers
Drill with a large bore drill bit
Fish tape
Exterior Caulk

Warning: Before you begin this project take note: We will be drilling holes in an exterior wall, make sure to check with local building codes to ensure the modifications you are making are legal.

Setting it up

The most difficult part with this project is installing all the components. We are trying to mount hardware on both the exterior and interior of the wall, this can be tricky as cables will need to be run through the wall. Since exterior walls have insulation in them, feeding wires through can be difficult.

Pinout of the RFID USB header as viewed from the top down (as if looking through the board).
  1. The first step is to cut a hole in the exterior wall that is large enough to fit the box you have gotten.
  2. You will need to drill a hole through the interior side of the wall inline with this large hole.
  3. Use your fish tape to feed the USB cable through the hole and then fish it through the electrical box.
  4. Insert the box into the hole you created and screw it in place.
  5. Use the exterior caulk to create a seal between the box and the wall.
  6. The easiest thing to do now is to fasten the RFID reader to the faceplate via glue or foam tape.
  7. Attach the faceplate to the electrical box and this part is finished.

If you find you are having trouble getting the USB plug to fit in the box you can always remove the plug and solder the wires directly to the pins on the underside of the RFID reader. Depending on where you install the box it may also be a good idea to use some foam weather stripping to enhance the seal of the faceplate to the box.

On the inside you will need to mount the SBC.

Next we need to have a method for actually unlocking the door. For this project we will be using an electric strike. An electric strike is a device that replaces the hardware on the jamb of the door. Electric strikes can be difficult to install, usually they are used in metal frame doors since the jambs tend to be hollow in these cases which makes running wires much easier. However, there are strikes made specifically for wooden doors. In general, you should follow the instructions that come with the strike for installation.

Metal door jamb with precut whole for a strike plate. Note that since the frame is hollow wiring can be run through it fairly easily.
Wood door jamb with traditional strike plate installed. This needs to be removed, and a large hole cut out for the electric strike.

While installing the strike keep in mind what you are going to need to do with the wires. You need to run wires from the power supply to the relay and from the relay to the strike.

The layout for the setup is as follows:
Doorlockblockdiagram.png Doorunlockfull.png

Software

We want the program to have the following structure:

We need to have code that checks RFID tag events against a list or database of accepted tags and if the tag is a recognized tag, switch power on to the electric strike.

rfid.addTagGainListener(new TagGainListener()
{
	public void tagGained(TagGainEvent oe)
	{
		String line = null;
		try{
			reader = new Scanner(inFile); // set the scanner to read in from the appropriate file
		}
		catch(Exception e){}
		while(reader.hasNextLine()){  // read through the entire file
			try{
				line = reader.nextLine(); //read in the current tag data
				if(line.equals(oe.toString())){ //does the active tag match this entry?
					ik.setOutputState(0,true); //if so activate the relay.
				}	
			}
			catch(Exception e){}	
		}
		reader.close();
	}
});

Where inFile is a File object set to the file in which the tag data is stored. The data can be read into a file off line prior to installing, or at will with the push of a button or the swipe of a master tag etc... depending on what you prefer. You can download the full file here. Note that this code has a mechanism for reading tags into a file though in practice you would want this system to be a bit more robust. Perhaps by using a database of some kind. This way you could also log who specifically was accessing the door etc...

When the tag is lost the door should relock, though we want to have a window in which the user can still open the door before it locks. This can be handled in our tag loss handler:

delay = new javax.swing.Timer(SHORTDELAY, new ActionListener(){  //SHORTDELAY is an arbitrary number of milliseconds
					public void actionPerformed(ActionEvent evt){
						try{
							ik.setOutputState(0,false);
						}
						catch(Exception e){}
						delay.stop();
					}
				});


rfid.addTagLossListener(new TagLossListener()
{
	public void tagLost(TagLossEvent oe)
	{
		try{
			if(ik.getOutputState(0) == true){
				delay.start();			//add a short delay so the user has time to open the door		
			}
		}
		catch(Exception e){}
	}
});