Introduction: RFID Access Control System

About: We are a new 10,000 sq. ft. makerspace in Portland, OR at 7600 N. Interstate Ave with a wood shop, craft lab, hackerspace, tiny home, garden, and electronics lab for the community.

This Instructable is for a Rasberry Pi Access Control System, which uses an RFID tag system for automatic entry through a door. We use this system for members to access our makerspace and maintain secure access.

For this project, you will need a raspberry pi and the included parts list. The power supply is a self-contained unit, and its function is to control the strike by shorting PUSH to GND, and also provide 12V power. You can be creative when it comes to layout and interface (the spring terminals, etc., are only a suggestion) but all of the modules - or equivalent functionality - are required. For example, if you leave out the level shifter, you *will* fry your pi.

The theory of operation is actually very simple. connect four leads from the pi to the level shifter. Connect B4 to the S pin of the relay, and the green and white wires from the RFID reader go to B2 and B3, respectively. I used GPIO pins 24 and 26 for the RFID reader, and pin 25 for the relay. The 3.3V voltage goes to the LV pin of the level shifter. All of the rest is a simple matter of wiring.

The relay shorts out the PUSH and GND terminals from the power supply. The strike goes to COM+ and COM-. The 12V - 5V Dc-DC converter downsteps the 12V coming out of the supply to 5V that the pi can use.

Use the spring terminals for connecting up the power, and the wires to the rfid reader.

The relay contains all of the appropriate logic for driving the relay, including transistor, flyback diode, etc. The level shifter is also self contained. There are no required discrete components as currently designed, though some are optional.

MATERIALS:

- Power supply

http://www.amazon.com/IMAGE%C2%AE-110-240V-Access-...

- 12V door strike

- Raspberry Pi B+

- Raspberry Pi B+ downgrade cable http://www.adafruit.com/products/1986

- Half sized proto board http://www.adafruit.com/products/1148

- 4 channel level shifter http://www.adafruit.com/products/757 (though you may be able to get away without i2c compatibility and save a few cents)

- Relay http://www.amazon.com/Arduino-Module-Development-...

- Spring terminals http://www.adafruit.com/products/1074 (you can use two of these three pin ones, or one six pin one)

- HID RFID reader http://www.amazon.com/Black-Plastic-Weigand-Proxi... (this is a cheap knockoff and I wouldn't trust it, but this is similar to what is needed)

- 12V to 5V DC-DC converter http://www.amazon.com/SMAKN-Converter-Power-Suppl...

- HID 125KHz cards

- an LED to suit, perhaps a diode to prevent reverse biasing the pi (I haven't added that to my project), etc.

- Large plastic box

Step 1: Assembly

The code for the pi is located here:
https://github.com/duskglow/accesscontrol/tree/mas...

First, you will need to assemble the level shifter and permaboard. When soldering the level shifter, it might be helpful to use a breadboard to put the headers in, so that you are guaranteed a good fit to the permaboard.

Now find a good spot on the permaboard for all of the parts. You will need a three pin header for the relay, and sufficient space for the spring terminals and level shifter. Once you have a good layout, solder everything on. You may want to use female headers for the level shfiter so that you can replace it if needed.

Now, do the wiring. Connect 3.3v from the pi to the LV terminal of the level shifter. Wire 5V and GND to the HV side of the level shifter and relay (it might be helpful to cross-bridge the rails on each side of the permaboard for easy access). Also be sure that the RPI has at least one 5V and GND wire connected (pins 4 and 6 are good candidates). DO NOT REVERSE BIAS THE PI. You may want to include a diode to prevent any possibility of this happening. It is not required, but the peace of mind may justify spending the extra few cents. If you include the diode, mind the polarity - you only want to block current flowing the wrong direction.

Connect the S terminal of the relay header to one of the outputs of the level shifter.

Wire up the appropriate GPIO pins from the pi to the LV site of the level shifter. Note that wiringpi uses a different gpio schema than python. You may want to use the suggested GPIO pins, but if you are willing to modify the software appropriately, you can use whichever pins strike your fancy. We used 23 and 25 for the RFID, and 24 for the relay.

Wire +5V and GND to two spring terminals. Wire +5V and GND to two more spring terminals (this is for the RFID reader). Wire two more spring terminals to two high-side pins of the level shifter. Wire everything up and test it. First, you might want to check that there are no shorts - check that there is an open circuit between +5V and GND before plugging anything in. Wire the green and white wires from the RFID reader to the spring terminals you've connected to the two high-side outputs of the level shifter.

Program the pi and use the access.py script found on github. Make sure that the GPIO in the weigand.c file is correct, and run "mkwiegand" - this will create a program in the directory called "weigand". You will need to install python-pip and the daemon module, and also wiringpi. Test the weigand by starting the weigand program on its own and try to read a card. If you get a 26 bit result, you have wired everything correctly. Now make sure the config files in the conf directory are correct (you will need to edit zone.conf and users.conf) for the user and card you're using, and start the script. If you've done everything right, presenting the card will cause the relay to trigger.

If you have made this work, you have completed the logic, now you just have to wire it up.

It also helps to use masking tape on the wires so they don't fall out when flipping over to solder.

Step 2: Install in to a Door

Find a place to mount your reader. Find a way to run the wires inside to the control mechanism (do NOT make it accessible to the outside - if you have access to the power supply the system is trivially subverted). We used hook-up wires, plastic conduit, and shrink tubing. For the control mechanism, we used two small project boxes, one for the power supply and one for the mechanism itself, mounted to the door jamb using double sided tape. You can do this any way you want, the way we did it is unique to our setup and is only a suggestion.

We mounted everything in the boxes using double sided foam stickies, and drilled holes so that the wires can enter and exit. The power supply needs 120V AC, we used a standard IEC connector. It can be hardwired using conduit, if you choose this route, be sure you know what you're doing or hire a competent electrician. Wire the 12V and GND from the power supply to the 5V DC-DC converter, and use the output from the converter to power your board, from the spring terminal that you wired earlier. MIND YOUR POLARITY - getting this wrong will likely fry something. Wire the NO terminals of the relay to PUSH and GND from the power supply. Wire the strike to NC and COM on the power supply.

To install the strike, use a vibrosaw or other similar tool to cut out a notch, and just put it in. Make sure that you don't screw it in too tight, it will bind the solenoid. Power it up, make sure the pi has started access.py (it should be configured to start automatically on boot) and make sure everything works. Feel free to hack on the access.py, but please send us your changes so that others can use them. Notes and gotchas: You can use other weigand systems too, the one we used is not a requirement, as long as it's a 26 bit system it should work.

The card reader we used apparently does not always like freezing weather - use wisdom in cold climes. There is one 5V GPIO slot available for an LED or something similar - feel free to make use of it. The proxpass reader has wires available for controlling the buzzer and LED. We did not make use of these. If you wish to use an 8 bit level shifter instead of the 4 bit one we used, you can probably do something with those. Shrink tube or otherwise electrically isolate all unused wires on the reader. If security from internal threats is important, place in a physically secure location. Subverting the mechanism with access to the pi or power supply is easier than trivial. Access to the wires and reader, though, is completely safe, the system is not easily subverted in that way. The strikes that are predominantly available through amazon and ebay will unlock when there is no power. Take care that you get the strike that is right for your application. If you get one that will fail closed, make sure you are using the correct lead from the power supply. The software has code for a locker application. This will be a separate instructable, but the hardware is actually very similar. Feel free to dink with it.

CONGRATULATIONS!! You made an RFID access control system!

On a Budget Contest

Participated in the
On a Budget Contest

Protected Contest

Participated in the
Protected Contest