Introduction: Windows PC Lock/Unlock Using RFID.

Picture of 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.

Picture of 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.

Picture of 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.

Picture of 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.

Picture of 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.

Picture of 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.!

Step 6: Making a Wearable RFID Tag.

Picture of 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...! :)

Comments

MartínT121 (author)2017-10-12

Hi, thanks for this instructable, i will defintly build one. good work :D!

jemuel sands (author)2017-10-11

awsome idea

sarmadgulzar (author)2017-10-11

Hi I have Arduino Nano which doesn't have pins 14, 15 and 16. Can it be used by modifying some code to work?

kksjunior (author)sarmadgulzar2017-10-11

Hello, you'll need an Atmega32U4 based development board. Arduino nano won't work with this code i've provided. Try Arduino Micro or Arduino Leonardo.

DeejayO1 (author)2017-10-09

How to do "control+alt+canc"? My laptop need it for unlock before to insert user and password

kksjunior (author)DeejayO12017-10-09

keys like cntrl, alt etc are modifier keys. They have a certain hexcode.

You can find the hexcodes for all the modifier keys from here : https://www.arduino.cc/en/Reference/KeyboardModifi...

Define the keys you need like i did for the return key in my code and send keystrokes in the order you want . Mail me on dream.code.make@gmail.com if you need any assistance. I'll be happy to help you!

DeejayO1 (author)2017-10-09

How to do "control+alt+canc"? My laptop need it for unlock before to insert user and password

RAJESH-MrX (author)2017-10-06

why uno is not compactible

kksjunior (author)RAJESH-MrX2017-10-06

Arduino Uno does not have a native USB support, It has a secondary chip to convert USB to serial commands. Arduino Leonardo and pro micro features a ATmega32u4 chip which has native USB support, there's no need of a secondary processor to covert the USB. So the Leonardo or Pro Micro can appear to a connected computer as a mouse and a keyboard. Thus we can use the keyboard emulation method to make this project work.

giig982 (author)kksjunior2017-10-09

Also Uno can be userd to emulate Mouse + Keyboard, but it's more complicated.

https://hackaday.com/2012/06/29/turning-an-arduino-into-a-usb-keyboard/

WannaDuino (author)2017-10-08

funny man,

i used it for more than 1 year now, and it still works. the pro mini leonardo board.

nice addition dude..And i run it with an 7 meter USB cable tru my man cave. and still works

WannaDuino STYLE

www.wannaduino.com

lukee1986 (author)2017-10-08

great thinking on this. this should be released with every computer the techs been there for a while now

EricL2 (author)2017-10-08

I like the card idea but to slide it into a slot and leave it, once you pull the card it locks the computer

hakk3r (author)2017-10-08

Awesome idea, thanks for sharing. If I may suggest and improvement. I can spot two relatively simple vectors of attack.

While you're away, someone could dump the arduino firmware and do a simple string search for your password and card ID. At the very least I suggest you encrypt the plain text password using something like DES encryption library with the the card identifier as the encryption key. Decryption should be done in run time and neither the card id nor the password should be stored in plain text.

Which leads me to my second suggestion for improvement. Add a hardware setup button which allows you to scan a badge and type in a password, which will save both the encrypted badge id and password into EEPROM. This will not only secure the system it will allow you to easily change the password when needed.

Again nice job!

kksjunior (author)hakk3r2017-10-08

That's a great suggestion. This one here is simple and basic. I was thinking of more ways to make it secure! Thank you so much for the comment. I'll definitely try it out!

DejayRezme (author)2017-10-08

Oh this is awesome. Brilliant idea!

But now I really want something like a ring, or a very flat wristband to unlock as soon as I get near my keyboard or phone. Far too lazy to take out a card every time I go near my computer ;)

A personal token could also make things like logging in to accounts easier. All the passwords are stored and encrypted on the token, and as long as you are near the keyboard / tablet / phone and set your token to auto login you don't have to bother again. And it would be something you can wear always.

kksjunior (author)DejayRezme2017-10-08

Thank you! We're thinking of the same idea brother! I'm now making a ring with an RFID tag to use with this system. As you've said a wearable tag is far better than pulling out a card every time we need to unlock the computer.! I'll soon update this instructable with the "ring unlock" system!

Henri.Lacoste (author)2017-10-05

This is really cool, nice project. Is there the possibility to do the same thing but with a Macintosh computer?

kksjunior (author)Henri.Lacoste2017-10-05

Thank you...! I've been using windows all my life but I guess we can do the same thing to unlock a mac too! As we're using the keyboard emulation method, you just need to modify the code and change the commands to keyboard shortcuts of a mac for locking and unlocking it! Note down which all keys needs to be pressed for locking and unlocking it.

In my case I've coded it as :

Windows key + Letter "l" -> Enter -> My Password -> Enter

Figure this out for the mac and modify the code! That's all it is!

Let me know when you get there!

Ardutronico (author)kksjunior2017-10-08

In Mac it's easier since you only have to press a key to wake the computer, wait until it's ready, enter your password and press enter. Also, in Mac it's better if it only enters the password and press enter, since it asks for your password more often (every time you must give root permission)

WarenGonzaga (author)2017-10-06

Great Job! Very nice instructables...

RAJESH-MrX (author)2017-10-06

nice one

kksjunior (author)RAJESH-MrX2017-10-06

Thank you!

vishnumaiea (author)2017-10-06

Cool project bro, you have my vote ;)

kksjunior (author)vishnumaiea2017-10-06

Thanks a lot bro...!