Windows PC Lock/Unlock Using RFID.

55K32273

Intro: Windows PC Lock/Unlock Using RFID.

Hi there!

How often have you felt tired of typing in the password to unlock your PC/laptop every time it got locked? I'm used to locking it down quite a number of times, everyday, and nothing is more annoying than typing the password/pin over and over again, every-time I want to unlock it. When the need for something becomes essential, you are forced to find ways of getting it. As the saying goes, "necessity is the mother of invention", the lazy mind in me started to think of an easy and a cheap way to unlock my personal Computer/Laptop every time I had to lock it. As I went through my stuff I found a RC522 RFID module. That's when I decided to make an RFID system.

RFID: Radio-frequency identification (RFID) is one of the oldest wireless technology. RFID chips are used to store information digitally, which can then be shared between objects through electromagnetic fields and radio waves. It may not be super-advanced, but many makers see real potential in the technology, no matter how old.

In this instructable I'll be explaining how to make a simple RFID system that can lock/unlock your windows computer with just a flick of an RFID card/tag. With this system in place no more hassles of unlocking your Laptop/PC every-time you lock it down.

STEP 1: Materials and Tools Required.

The heart of this project is the Arduino Pro Micro (or you can use Arduino Leonardo) with the ATmega32U4 chip. It is very important for this project to choose a development board with the ATmega32U4 chip. We can't use development boards like Arduino Uno, Mega 2560, Pro Mini or Arduino Nano for this application. The details are in the following steps.

Materials required :

  1. Arduino Pro Micro/Arduino Leonardo.
  2. MFRC-522 RFID module with RFID card.
  3. Male and female headers.
  4. Prototype PCB board.
  5. Wires.
  6. 10k ohm resistors - 3

Tools required :

  1. Soldering kit.
  2. Glue gun.
  3. Wire cutters

etc:

STEP 2: Building the Prototype.

I recommend you to build a prototype on the breadboard before soldering the circuit to a PCB. This will help you to get a better understanding of the connections and will allow you to fix any of the errors that occurs while linking connections. Building the prototype is not a hefty task considering this project. We've to only make a few connections and we're ready to upload the code. The connections are described below. On the Arduino many of the pins are not changeable. As this device uses the SPI bus, it does not allow switching pins, pins 14, 15 and 16 must remain as shown. RST and SDA are user specified.

  • The RC-522 RFID module is designed for an input voltage of just 3.3 volts. It is a very sensitive device, so any higher values may overheat and damage the module. The VCC out of Arduino Pro Micro will give you a 5 volts supply. Make a voltage divider as shown in the circuit diagram (or use a 5 V to 3.3 V step down module) to make a 3.3 volts supply voltage. Connect the 3.3 V supply to the VCC of RFID module.
  • RST to pin 5 of Arduino. (You can change this pin in the code.)
  • Connect the GND pin to the ground.
  • IRQ pin - Not Connected.
  • MISO to pin 14 of Arduino.
  • MOSI to pin 16 of Arduino.
  • SCK to pin 15 of Arduino.
  • SDA to pin 10 of Arduino. (This is also a user defined pin.)

That's all it is!, Simple and easy. Just plug the cable and we're ready to upload the code and test the device.

STEP 3: The Code.

The Arduino Leonardo/Micro with the ATmega32u4 chip has a built-in USB communication. This allows the Leonardo/Micro to appear to a connected computer as a mouse or a keyboard.

We use the keyboard.h core library to make the arduino send the keystrokes to a connected computer.

Download the code from here.

Download the MFRC522.h arduino library from here.

Download the Keyboard.h arduino library from here.

The working of the code is very simple.

  • The UID of your RFID card/tag and your windows password/PIN is stored in the code.
  • When the right card is shown to the RFID reader, the arduino will send keystrokes for locking the windows and your password for unlocking the windows simultaneously.
  • If the windows is in a locked state, the keystrokes for locking it won't have any effect and the command will unlock the locked computer.
  • Or else if the windows is already unlocked, the commands will lock it. (The unlock code is also coming simultaneously, but as there is only a pinch of a delay between the lock and unlock keystrokes, Windows goes into executing the lock command and will not read the unlock code command coming at that time.)

You have to make some small changes in the code I've provided to explore and use it for yourself.

  • Connect the prototype to the computer.
  • Launch the Arduino IDE and open the code I've given here.
  • From the toolbar go to tools -> Board and Select Arduino Leonardo for both Arduino Pro micro and Arduino Leonardo.
  • Check whether the COM port is selected.
  • Upload the code to the arduino.
  • Open the Serial Monitor ( Ctrl+Shift+M).
  • Scan your Card/tag.
  • The first line of the output shown in the serial monitor is the UID of your card/tag. Note down this value.
  • Now go back to the code editor and change the value of string "card1" to the UID you've just noted (In my code, you can find it in line 41).
  • Go to the last part of the code and you'll find a line which says "Keyboard.print("PASSWORD");" (Line number 80 in the code.). Change this value to your windows unlock code.
  • Now upload the modified code into the arduino.
  • Scan the card/tag to test the prototype.

This is a basic code for typing passwords in your computer using RFID tags. You can modify the code to add more cards/tags and set different passwords for each card for various applications.

STEP 4: Soldering.

This is a very small and simple circuit. It's better to solder this in to a prototyping PCB board than spend a lot of time to make a custom PCB.

Always use headers to connect the arduino and the RFID module, otherwise prolonged exposure to heat while soldering may damage these boards permanently.

Solder all the connections as shown in the circuit diagram and connect the arduino and RFID module to the PCB board. I've connected the RFID module horizontally to the PCB board using a right angled female header for my convenience of making a case for it.

Always make sure to test the device for any possible loose connections or malfunctions after soldering.

STEP 5: Making an Enclosure.

Well with this invention you might have figured out that i'm too lazy to design and 3D print a case for this design, so i made a simple enclosure using cardboard boxes that i found in my garage. I made a stand for it using the same cardboard and cut out holes in the case for connecting the cable and for the LEDs in the arduino. Then i wrapped the whole setup with carbon-fiber textured sticker and put a semi-transparent dark sticker for the hole where the LEDs in the board is situated.

Making the case is completely up to your imagination. Post the pictures of your creative builds in the comments section below.!

Check out this neatly designed case by Alan Phan. Click here to view the design.

STEP 6: Making a Wearable RFID Tag.

I thought of an alternative method to replace the card as an unlock tool, because it's still hard to carry the card and pull it out every time to unlock the PC. The first thing that came to my mind was to make an RFID ring. The ring will always stay in our hand, so we don't have to remember to take it with us every time and there are no worries of losing it when compared to a card.

As you can see from the pictures, i am a noob in crafting these things, but I've tried my best to make it look nice in the hand. Please comment below your ideas for making a better looking wearable RFID tag.

I took out the RFID tag from an RFID key-chain. Be careful while breaking it or you might cut through the coil of the tag. I glued the tag to an old ring and wrapped it with tape and stickers. Now i can either use the ring or my RFID card to unlock my PC.

STEP 7: The Result.


Remember, this is just a simple hobby project and it does the work perfectly for a home user. Consider the potential security vulnerabilities before implementing this for your personal use. I can't guarantee any security.

There are numerous possibilities for applying RFID technology in our daily life. I made it for locking/unlocking my computer. What're you going to do? Let me know it in the comments below!

Hope you enjoyed reading this instructable. If you've any questions feel free to ask it here or send a mail to dream.code.make@gmail.com, I'll try my best to help you out.

Happy Making...!

Thank you...! :)

44 Comments

Hey, very nice project, I need this implemented but my usecase is a little different, at our company we have to lock our laptops if we are stepping away even for a couple of seconds, so it is a pain to remember to lock it each time, and the secuity team sees somone's system is not locked a world of pain would come in the persons way.

so I wanted to implement this a little different, like a proximity sensor, so I was thinking where to put the RFID tag and where to put the RFID module, and the device would initiate the system lock when the tag is not scannable on the Module. any Ideas How to tweak your design to get this?

Also using windows Dynamic Lock won't work in my case since that feature works within bluetooth range and that is at least a 10 meter radius which does not apply to my case.
Thanks again
I like the card idea but to slide it into a slot and leave it, once you pull the card it locks the computer
Maybe a bit too late but this can be achieved by using "mfrc522.PICC_IsHaltPresent" This will keep checking if the card is still present.
Could you please explain how to connect rfid with Leonardo using a detailed diagram
i tried it for many times, but it is not work. i used leonardo. is there anything to change in pc sitting? and the card is not read by arduino. i need some help.

Cool tutorial! I managed to recreate it using a arduino micro 5v, altough some pins were changed
I advise anybody to use this model as it provides 3.3v output as well
+-2 hours

i have arduino uno and it doesnt have pins 14, 15 & 16

Hi, go to an example of the MFRC522 library. There the settings for uno are explained. But uno is not working as keyboard! Scetch will not work.

BR

Hey there,

first thanks for the Idea. Was what I looked. Even when not secure system. Who can copy an RFID UID anyhow? My question:

Tried your code with a leonardo and nano. Both with same hardware canĀ“t identifie the tag in your example. Tried with different code (for unlocking a door) and it works. Ever encountered that problem and have a solution for me? The tag is shown in the serial console.

Best, Oskar

Hello,

I am using Ardunio UNO, I known need Ardunio Micro to control USB keyboard, however I just removed keyboard.h related, but still cannot detect my RFID card. (use example Dumpinfo is find)

Thanks

Hi there, wish you can provide me the circuit for Arduino Leonardo or explain how to connect them properly. Because I bought it instead of Arduino Pro Micro (out of stock) from local store. The pin numbering is in different orders and this is my first time trying computer's DIY. Thanks for considering my request.

Hi,

You can use any of those two boards for this project. Use the ICSP header pins ( The Pin numbers are the same 14 - MISO, 15 - SCLK, 16 - MOSI ) for Arduino Leonardo, but these numbers (14, 15, 16) are not printed in some Leonardo boards. You can use this diagram for your reference.

Thank you for replying, this is a very useful project. Nice work and thanks again.

Hi it's me again. So I mounted the all the pins referring to the provided pictures above, 6 of them to corresponding RC522 module and SDA into SDA of Arduino Leonardo. The board selected as Arduino Leonardo and port also successfully detected. But nothing came out on serial monitor when I tried to scan the RFID tag UID. Could you please identify what could be the problems here.

Note that Arduino Leonardo has a 3.3v voltage output. You don't have to make a voltage divider circuit.

Hi. Are you sure about the 3.3v supply to the RFID module. Seems like you haven't taken a V out from the voltage divider. The RC522 module is very sensitive to voltage. If you power it up with 5V, the board will get damaged.

Hi i just ordered a bunch of atmega328p boards not knowing about the need for the 32u4 chip i was wondering if there is a way to modify the code to work with these boards

Thanks in Advance

Just for clarity my UID code was

030eaa89 i had to ommit the zeros for the code to work.

3eaa89 worked for me

More Comments