Background: When I first learned of RFID technology, I instantly began to ponder the multiple applications to which this technology could be applied. This technology is currently used extensively for security access control, inventory tracking, and item identification but even more applications are already in the works. I was anxious to learn about this technology myself and wanted to apply it to a useful function so I decided to build an RFID door opener for my apartment. This way I could easily gain access to my apartment without the need to find the right key, insert it in the lock properly, then open the door. Instead I would only need to hold my RFID key fob up to the door and it would be unlocked in less than one second. Admittedly this application may serve more of a "cool factor" than truly being helpful but nevertheless I can't help but smile every time I unlock my door now. Design: Because this project was still a learning experience for me, I selected components from Parallax that would simplify the design to a level which I could implement with a limited electronics and programming background. I choose a BOE development board with a BS2 microcontroller based upon my previous experience with the Parallax BOE Bot. I also selected the Parallax RFID serial reader because plenty of support documentation and example code can be found for this device further simplifying the design process. I also picked up a power supply so I wouldn't need to change batteries in the device and a pair of red and green LEDs to provide a visual indication of whether the RFID tag presented is valid or not.
My apartment door can be locked by pressing the door knob in and turning to the right. If you turn the door knob a few degrees to the left from the inside, the door is unlocked. This type of lock made it very easy to add RFID control to because all I needed to do was build a device that would pull on the door knob when a valid RFID tag was detected. I selected an HS-645MG standard sized servo to unlock the door. By attaching a small cable from the servo arm to the door knob, the servo could pull on the door knob thus unlocking the door from the inside when a valid RFID tag is presented outside. The cable system also allows the door lock to be operated the traditional way without interfering. I wanted to make sure I could still access my apartment even if my RFID opener stopped working. I purchased a medium sized project box from Radioshack to contain all of the components and used heavy-duty hook and look fastner to attach the device to my door. The pictures below shows the final design of the device. Code: Here is my code for the RFID door opener. It's primarily based upon sample code provided my Parallax with a few modifications for my specific design. Feel free to use this code in your own project. Just make sure to enter your own RFID tag numbers in the EEPROM Data section. ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' Reads tags from a Parallax RFID reader and compares to known tags (stored ' in EEPROM table). If tag is found, the program will disable a lock. ' -----[ I/O Definitions ]------------------------------------------------- Enable PIN 6 ' low = reader on RX PIN 2 ' serial from reader Green PIN 11 ' positive ID light Red PIN 15 ' negative ID light Servo PIN 12 ' servo for unlocking door ' -----[ Constants ]------------------------------------------------------- T2400 CON 396 SevenBit CON $2000 Inverted CON $4000 Open CON $8000 Baud CON T2400 TmAdj CON $100 ' x 1.0 (time adjust) FrAdj CON $100 ' x 1.0 (freq adjust) Number_of_Tags CON 3 ' -----[ Variables ]------------------------------------------------------- buf VAR Byte(10) ' RFID bytes buffer tagNum VAR Nib ' from EEPROM table idx VAR Byte ' tag byte index char VAR Byte ' character from table Counter VAR Word ' -----[ EEPROM Data ]----------------------------------------------------- Tag1 DATA "XXXXXXXXXX" ' valid tags Tag2 DATA "XXXXXXXXXX" Tag3 DATA "XXXXXXXXXX" Name0 DATA "Unauthorized", CR, 0 Name1 DATA "User1", CR, 0 Name2 DATA "User2", CR, 0 Name3 DATA "Spare", CR, 0 ' -----[ Initialization ]-------------------------------------------------- Reset: HIGH Enable ' turn off RFID reader FOR counter = 1 TO 50 ' adjust servo to starting position PULSOUT Servo, 1000 PAUSE 20 NEXT ' -----[ Program Code ]---------------------------------------------------- Main: LOW Enable ' activate the reader SERIN RX, T2400, [WAIT($0A), STR buf\10] ' wait for hdr + ID HIGH Enable ' deactivate reader Check_List: FOR tagNum = 1 TO Number_of_Tags ' scan through known tags FOR idx = 0 TO 9 ' scan bytes in tag READ (tagNum - 1 * 10 + idx), char ' get tag data from table IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table NEXT GOTO Tag_Found ' all bytes match! Bad_Char: ' try next tag NEXT Bad_Tag: tagNum = 0 HIGH Red GOSUB Show_Name ' print message PAUSE 1000 LOW RED GOTO Main Tag_Found: HIGH Green GOSUB Show_Name ' print name GOSUB Unlock ' open door LOW Green GOTO Main END ' -----[ Subroutines ]----------------------------------------------------- ' Prints name associated with RFID tag Show_Name: DEBUG DEC tagNum, ": " LOOKUP tagNum, [Name0, Name1, Name2, Name3], idx ' point to first character DO READ idx, char ' read character from name IF (char = 0) THEN EXIT ' if 0, we're done DEBUG char ' otherwise print it idx = idx + 1 ' point to next character LOOP RETURN Unlock: FOR counter = 1 TO 30 PULSOUT Servo, 500 PAUSE 20 NEXT |



