kela910512
Published © GPL3+

Win10 login via MFRC522, HC06, OLED, HCSR04 (+Android security)

With this project, we can log in and out of our Windows 10 account with our own RFID card, with many convenience and security functions.

IntermediateFull instructions providedOver 1 day607
Win10 login via MFRC522, HC06, OLED, HCSR04 (+Android security)

Things used in this project

Hardware components

Arduino Micro
Arduino Micro
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
RFID MFRC522
×1
Blue OLED display - 128x32, 0.91 inch, I2C, SSD1306
×1
HC-06 Bluetooth Module
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Through Hole Resistor, 20 kohm
Through Hole Resistor, 20 kohm
For the 5V - 3.3V Voltage divider. (HC-06)
×1
Through Hole Resistor, 10 kohm
Through Hole Resistor, 10 kohm
For the 5V - 3.3V Voltage divider. (HC-06)
×1
Resistor 220 ohm
Resistor 220 ohm
For the led.
×1
Jumper wires (generic)
Jumper wires (generic)
×20
TP-LINK TL-SF1008D 8 port switch
For the case.
×1
HC-SR04-CLS
×1
Hobby glass
×1
Universal PCB
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

HC-06 (Fritzing file)

Bluetooth modul

HC-SR04 (Fritzing file)

Ultrasonic sensor

MFRC522 (Fritzing file)

RFID modul

D091-12832-I2C/BL (Fritzing file)

128x32 OLED Display

POTENTIOMETER (Fritzing file)

LED (Fritzing file)

5V AND GND OUTPUTS STRIPBOARD (Fritzing file)

5V AND GND OUTPUTS STRIPBOARD

Code

RFID_WIN10_LOGIN_SYSTEM.ino

C/C++
The main INO code.
#include <AnalogPin.h>
#include <Keyboard.h>
#include <SPI.h>
#include <Wire.h>
#include <MFRC522.h>
#include <SoftwareSerial.h>
#include <Ultrasonic.h>
#include <Adafruit_SSD1306.h>
#include <U8g2_for_Adafruit_GFX.h>

#define LED 13

AnalogPin Apin(A0);
U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
MFRC522 mfrc522(SS, 5);
MFRC522::MIFARE_Key key;
SoftwareSerial EEBlue(11, 10);
Ultrasonic ultrasonic(8, 7, 68000UL);
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire, 13, 400000UL, 100000UL);

const char card1[32] = "EB1CEFFC";
const long passwordExpireInterval = 3600000;
char str[32] = "";
String readid, password = "";
byte readCard[4];
byte distance, i, lastx, x = 0;
byte isLogged = 0;
unsigned long lastPasswordCheck, lastPotChange, start = 0;

void setup() {
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
   u8g2_for_adafruit_gfx.begin(display);
   display.clearDisplay();
   display.display();
   pinMode(LED, OUTPUT);
   pinMode(11, INPUT);
   pinMode(10, OUTPUT);
   digitalWrite(LED, HIGH);
   Serial.begin(57600);
   SPI.begin();
   Keyboard.begin();
   EEBlue.begin(9600);
   mfrc522.PCD_Init();
}
void setPassword() {
   if (EEBlue.available() > 0) {
      password = EEBlue.readStringUntil('\n');
   }
}
void resetPassword() {
   if ((millis() - lastPasswordCheck) >= passwordExpireInterval) {
      password = "";
      lastPasswordCheck = millis();
   }
}
void loginCommand() {
   delay(400);
   Keyboard.press(KEY_LEFT_CTRL);
   Keyboard.press('a');
   Keyboard.releaseAll();
   delay(400);
   Keyboard.print(password);
   Keyboard.releaseAll();
   delay(100);
   Keyboard.press(KEY_RETURN);
   Keyboard.release(KEY_RETURN);
   isLogged = 1;
   digitalWrite(LED, HIGH);
   message();
}
void winLock() {
   Keyboard.press(KEY_LEFT_GUI);
   Keyboard.press('l');
   Keyboard.releaseAll();
   isLogged = 0;
   digitalWrite(LED, LOW);
   message();
}
void message() {
   display.clearDisplay();
   u8g2_for_adafruit_gfx.setFont(u8g2_font_doomalpha04_tr);
   if (isLogged == 0) {
      u8g2_for_adafruit_gfx.drawStr(0, 32, "LOCKED");
   } else {
      u8g2_for_adafruit_gfx.drawStr(0, 32, "UNLOCKED");
   }
   display.display();
   delay(1000);
}
String arrayToString(byte array[], unsigned int len, char buffer[]) {
   for (unsigned int i = 0; i < len; i++) {
      byte nib1 = (array[i] >> 4) & 0x0F;
      byte nib2 = (array[i] >> 0) & 0x0F;
      buffer[i * 2 + 0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA;
      buffer[i * 2 + 1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA;
   }
   buffer[len * 2] = '\0';
   return buffer;
}
void getID() {
   if (!mfrc522.PICC_IsNewCardPresent()) {
      return;
   }
   if (!mfrc522.PICC_ReadCardSerial()) {
      return;
   }
   for (int i = 0; i < mfrc522.uid.size; i++) {
      readCard[i] = mfrc522.uid.uidByte[i];
   }
   mfrc522.PICC_HaltA();
}
void deleteCardInfo() {
   for (int i = 0; i < mfrc522.uid.size; i++) {
      readCard[i] = "";
   }
   readid = "";
}
byte readDistance() {
   return ultrasonic.read(CM);
}

void countDown() {
   if (start == 0 || i == 0) {
      start = millis();
      i = 11;
   }
   long last;
   while (i > 0 && distance > x) {
      last = millis();
      distance = readDistance();
      Apin.setNoiseThreshold(4);
      x = map(Apin.read(), 0, 1023, 30, 200);
      if (last - start >= 1500) {
         display.clearDisplay();
         u8g2_for_adafruit_gfx.setFont(u8g2_font_doomalpha04_tr);
         u8g2_for_adafruit_gfx.drawStr(0, 32, "LOCKING IN");
         u8g2_for_adafruit_gfx.setCursor(70, 32);
         u8g2_for_adafruit_gfx.print(i - 1);
         (i > 10) ? u8g2_for_adafruit_gfx.drawStr(85, 32, "sec") : u8g2_for_adafruit_gfx.drawStr(80, 32, "sec");
         display.display();
         i--;
         if (i == 0) {
            delay(1000);
            winLock();
            distance = 0;
            start = 0;
         }
         start += 1000;
         last = millis();
      }
   }
   distance = 0;
   start = 0;
   i = 0;
}
void loop() {
   Apin.setNoiseThreshold(5);
   x = map(Apin.read(), 0, 1023, 30, 200);
   distance = readDistance();
   if (distance > x && isLogged == 1) {
      countDown();
   } else {
      if (lastx == x && millis() - lastPotChange > 2000) {
         display.clearDisplay();
         u8g2_for_adafruit_gfx.setFont(u8g2_font_doomalpha04_tr);
         u8g2_for_adafruit_gfx.drawStr(0, 32, "STATUS OK");
      } else if (lastx != x) {
         display.clearDisplay();
         u8g2_for_adafruit_gfx.setFont(u8g2_font_open_iconic_embedded_2x_t);
         u8g2_for_adafruit_gfx.drawGlyph(0, 32, 0x0050);
         u8g2_for_adafruit_gfx.setFont(u8g2_font_doomalpha04_tr);
         u8g2_for_adafruit_gfx.setCursor(30, 31);
         u8g2_for_adafruit_gfx.print(x);
         if (x > 99) {
            u8g2_for_adafruit_gfx.drawStr(55, 32, "CM");
         } else {
            u8g2_for_adafruit_gfx.drawStr(50, 32, "CM");
         }
         lastx = x;
         lastPotChange = millis();
      }
      display.display();
   }
   getID();
   readid = arrayToString(readCard, 4, str);
   setPassword();
   resetPassword();
   if (password != "" && password.length() > 2 && readid == card1 && isLogged == 0) {
      loginCommand();
   } else if (readid == card1 && isLogged == 1) {
      winLock();
   }
   deleteCardInfo();
}

ANDROID APPLICATION

C#
For make bluetooth connection and sending your password.
No preview (download only).

GITHUB

Credits

kela910512

kela910512

0 projects • 0 followers

Comments