Using RFID to Lock/Unlock a Windows PC

Parts and materials

  • Arduino Micro
  • RC-522 RFID Module
  • Resistor 10k ohm

Tools and machinery that are required

Soldering iron (generic)

Online services and applications

Arduino IDE

This project’s details

The Arduino Pro Micro (or Arduino Leonardo) with the ATmega32U4 processor is at the core of this project.

Choosing a development board with the ATmega32U4 processor is critical for this project.
For this application, we can’t utilise development boards like the Arduino Uno, Mega 2560, Pro Mini, or Nano.

The steps that follow provide further information.

Before attaching the circuit to a PCB, I propose building a prototype on a breadboard.

This will assist you in gaining a better understanding of the connections and allowing you to correct any problems that may occur while joining them.

In the context of this project, creating a prototype is not a difficult process.

We simply need to connect a few things before we can upload the code.

The links are explained further down.

Many of the pins on the Arduino are not programmable.

Because this device utilises the SPI bus, swapping pins is not possible, thus pins 14, 15, and 16 must stay as stated.

RST and SDA are user-defined parameters.

The RC-522 RFID module is intended to work with only 3.3 volts as an input voltage.

Because it is an extremely sensitive gadget, any higher numbers may cause the module to overheat and be damaged.

The Arduino Pro Micro’s VCC will provide you with a 5 volt supply.

To produce a 3.3 volts supply voltage, use a voltage divider as illustrated in the circuit design (or a 5 V to 3.3 V step down module).

Connect the 3.3 V power supply to the RFID module’s VCC.

  • RST to Arduino pin 5.
  • (This pin can be changed in the code.)
  • The GND pin should be connected to the ground.
  • The IRQ pin is unconnected.
  • MISO to Arduino pin 14.
  • MOSI to Arduino pin 16.
  • SCK to Arduino pin 15.
  • SDA to Arduino pin 10.(This is a user-defined pin as well.)

The ATmega32u4 chip in the Arduino Leonardo/Micro features built-in USB connection.

This enables the Leonardo/Micro to appear as a mouse or keyboard to a connected PC.

To have the Arduino communicate keystrokes to a connected computer, we utilise the keyboard.h core library.

RFID system circuit

The code’s operation is quite straightforward.

The code contains the UID of your RFID card/tag as well as your Windows password/PIN.

When the proper card is presented to the RFID reader, the Arduino sends keystrokes to lock the windows and your password to open them at the same time.

If Windows is locked, the keystrokes used to lock it will have no impact, and the command will unlock the locked machine.

Otherwise, the instructions will lock the window if it is already unlocked. (The unlock code is also arriving at the same moment, but because there is only a fraction of a second between the lock and unlock keystrokes, Windows executes the lock instruction first and ignores the unlock code command.)

To investigate and utilise it for yourself, you’ll need to make a few minor changes to the code I’ve shared.

Connect the computer to the prototype.

Open the Arduino IDE and paste the code I’ve provided into it.

Go to tools -> Board and choose Arduino Leonardo for both the Arduino Pro mini and Arduino Leonardo from the toolbar.

Check to see if the COM port is enabled.

Connect the arduino to the computer and upload the code.

Ctrl+Shift+M will bring up the Serial Monitor.

Scan the barcode on your card or tag.

The UID of your card/tag appears on the first line of the output shown in the serial monitor.

Make a note of this number.

Return to the code editor and replace the value of string “card1” with the UID you specified before (In my code, you can find it in line 41).

You’ll discover a line that reads “Keyboard.print(“PASSWORD”);” at the end of the code. (In the code, this is line 80.)

This value should be changed to your Windows unlock code.

Now you may upload the new code to the Arduino.

To test the prototype, scan the card/tag.

This is a rudimentary code for utilising RFID tags to type passwords into your computer.

You may change the code to add more cards/tags and different passwords for each card to use with other apps.

Soldering.

This is a modest and straightforward circuit. It’s preferable to assemble this to a prototype PCB board rather than wasting time making a bespoke PCB.

When connecting the arduino and the RFID module, always utilise headers; otherwise, extended heat exposure when soldering may permanently harm these boards.

Connect the arduino and RFID module to the PCB board by soldering all of the connections as indicated in the circuit diagram. For the sake of building a container for it, I’ve attached the RFID module horizontally to the PCB board using a right angled female header.

After soldering, be careful to test the gadget for any loose connections or faults.

Constructing an Enclosure

I created a basic enclosure out of cardboard boxes from my garage. I created a support for it out of the same cardboard and drilled holes in the case for the cord and the Arduino’s LEDs. Then I applied a carbon-fiber textured sticker to the entire system, as well as a semi-transparent dark sticker to the hole where the LEDs on the board are located.

Code :

#include <Keyboard.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 5
#define KEY_RETURN 0xB0                 //The hex value for the return key is 0xB0.
 
MFRC522 mfrc522 ( SS_PIN, RST_PIN ) ;
char Enter = KEY_RETURN;                //Return key is declared as Enter.
String readid;
String card1="48b45a10";                //Change this value to the UID of your card.
 
void setup( ) 
{
 Serial.begin(9600);
 Keyboard.begin();
 SPI.begin();
 mfrc522.PCD_Init();
}

void temp(byte *buffer, byte bufferSize)//function to store card uid as a string datatype.
{
  readid="";
  for(byte i = 0;i<bufferSize; i++)
  {
    readid=readid+String(buffer[i], HEX);
  }
}
void loop( ) 
{
 if(!mfrc522.PICC_IsNewCardPresent())
 {
  return;
 }
 if(!mfrc522.PICC_ReadCardSerial()) 
 {
  return;
 }
 mfrc522.PICC_DumpToSerial(&(mfrc522.uid));  // Display card details in serial Monitor.
 temp(mfrc522.uid.uidByte, mfrc522.uid.size);
 if(readid==card1)
 { 
  Keyboard.press(KEY_LEFT_GUI);              //Press the left windows key.
  Keyboard.press('l');                       //Press the "l" key.
  Keyboard.releaseAll();                     //Release all keys.
  delay (100);
  Keyboard.press(Enter);                     //Press the Enter key.
  Keyboard.release(Enter);                   //Release the Enter key.
  delay(100);
  Keyboard.print("PASSWORD");                    // Change this value to your Windows PIN/Password.
  Keyboard.releaseAll();
  delay(100);
  Keyboard.press(Enter);
  Keyboard.releaseAll();
 }
 else
 {
  return;
 } 
}

Same Stories, Different People, Different Places, Different Languages, Different Timing, Different Endings, Different Beginings, Different Techniques.

KP

“Success comes because you’ve taken on the right kind of capability and attitude within yourself, your body, and your mind. Afterall It’s better to have a daring adventures life than nothing” – KP

Helping Hands.

About the author

pondabrothers

You can download our apps and books for free..
Search - Incognito Inventions

View all posts

1 Comment

  • Я технічний ентузіаст мені сподобалося це. це економія часу і безпека. Мені це дуже подобається 😉

Leave a Reply

Your email address will not be published. Required fields are marked *