This is a project I made for my microprocessor programming laboratory at my university. The project goals were to log in and out of my PC using RFID card or fingerprint scan.
I value privacy a lot, so ability to log in and out in mere seconds, without typing password is a life saver for me. This interface is fully open source, you can use it and modify as you please.
Two very important things here:
You can use this project with only RFID reader with absolutely no changes in code, but using it with only fingerprint scanner require full code rebuild.
Wiring, despite how it looks is very simple, and explained below. Most important notes:
- Most of RC522 modules are powered with 3, 3 V supply, and are very sensitive, so make ABSOLUTELY SURE, you are connecting it with correct voltage, Leonardo has dedicated pin, prividing 3, 3 V
- On your RC522 you leave 2 pins not connected to anything - IRQ and RST
- You connect your LCD's LED anode to Arduino digital pin, instead of 5 V supply
Arduino Leonardo pinout for this project:
- D0 (RX) - TD pin of Z70
- D1 (TX) - RD pin of Z70
- D2 - RS pin of LCD
- D3 - Enable pin of LCD
- D4-D7 - Data 4-7 pins of LCD
- D8 - LCD anode
- D9 - blank
- D10 - SDA/NSS pin of RC522
- D11 - log out/LCD on button
- ICSP SCK (9) - SCK pin of RC522
- ICSP MOSI (10) - MOSI pin of RC522
- ICSP MISO (11) - MISO pin of RC522
- 3, 3 V out - supply for RC522
- 5 V out - supply for LCD, button and Z70 sensor
CODE -before you begin
Before anything, you need to add 5 libraries to your Arduino IDE (if you don't have them yet):
- Keyboard.h
- SPI.h
- MFRC522.h
- LiquidCrystal.h
- Adafruit_Fingerprint.h
You do this in libraries manager, accessed by Ctrl+Shift+I. Then copy this project code to your IDE.
Next you want to go to line 128 and comment out logOut() function callout (so you don't log out of your system during debugging), and do the same with passwd() function callout in line 190.
Just don't forget to uncomment these, when you're finished, or you won't be able to log in or out!
Last thing is to set your password in code, so Arduino can write it down when logging in. You do that in line 23, changing password string variable.
So first thing to do is to determine your RFID card ID. To do that connect everything as shown below, and open this project's code in IDE. In line 184 you have commented out debug line, that dumps readed card ID to Serial monitor. Just uncomment that, upload to Arduino, open Serial monitor and move card close to reader.
Readed ID copy to "logCard" string variable in line 22.
If you use only RFID reader, comment out line 184, uncomment lines 128 and 190, upload code to Arduino, and you are done. If you're using fingerprint reader, only comment out line 184, and keep reading.
CODE - with Z70 fingerprint reader (or any, that is supported by Adafruit_Fingerprint library)
So now you need to save your finger(s) to Z70 memory. To do that open new project in IDE, and from File -> Examples -> Adafruit Fingerprint Sensor Library open "enroll" example. Upload it to Arduino, open Serial monitor, and do as it says. The example is quite self-explanatory, and will walk you through adding as many fingerprint scans as you like, assigning them to IDs from 1 to 999.
After you added your finger, go back to this project's code. Now you have two options:
- leave it as it is, every finger you saved to Z70's memory will unlock your PC
- make some changes in code, to let only particular finger IDs unlock PC
CODE - unlock PC with only specific finger
Okay, so you let your sister, mother, father, grandma and dog save their fingers to sensor, and don't want to empty whole it's memory, you also want only your finger to be able to unlock the PC. Great, so you need to dig some more in the code. In lines 47 and 48 (in FingerID() function) there are some more commented out debug options, you want to uncomment. These dump ID of readed finger to Serial monitor. Pretty much like with RFID card ID, uncomment these, upload, place your finger, and read its ID from Serial monitor.
Now you go all the way down to switch, that starts in line 176. In there you have "case 0", that unlocks your PC with RFID and "default", that unlocks it with any finger in Z70's memory. What you want to do is add another case, with ID of your finger (read from Serial monitor), like "case 1:", copy contents of "default" to it, and empty out the "default".
You can add as many new cases, as you want, with personalized LCD message, for every person's login, like "Hello mum!", "Hi dad!", "Get out you little piece of...
Anyway, now comment back out lines 47 and 48, and you are pretty much done with this project.
CODE - tweaks, tips, and do what you forgot to do, despite I reminded it many times
First of all - make sure lines 128 and 190 are UNCOMMENTED, and lines 47, 48, 184 are COMMENTED OUT!
Now to less important tweaks. My PC boots up fairly long, so I added a 7 second delay before first loop starts. It is located in setup(), in lines 110 and 116. You can change it of course, if your system boots up longer or shorter. Keep in mind, it only logs you up to Windows 10, after your lock screen appears (if you place card/finger during boot, you have to click button and try again).
Another tweak. To save a bit the LCD and not drive me crazy with fingerprint scanner flashing LED the screen and Z70 turns off after 15 seconds. When that happen you can still unlock with RFID card, but to use finger, you need to press the button to activate sensor.
You can change how long it takes to turn them off, by tweaking if statement in line 147. To measure perfectly, you want to go to line 160, uncomment it, and just look how high gets the number after desired time (each iteration number on screen will increment, so for me it is 90 after 15 seconds). When you have your number, you just paste it in line 147 instead of 90, and comment back out line 160.
3D PRINTED CASE
Here is a link to Thingiverse, containing STLs to print my case. To assemble it you need cyanoacrylate glue (like super glue) and four tiny furniture screws. And a lot of patience, it takes FOREVER to print, and then cure the glue. Also you want to put the glue only INSIDE of the case, becouse CA glue leaves nasty white thing on PLA.
https://www.thingiverse.com/thing:4677132
I printed it on Tevo Tarantula Pro, on glass heated bed. Here are parameters (they are also on Thingiverse):
Front, front elements (pins and fingerprint/button slots) and top:
Extruder/Bed temperatures 200/50; layer 0.2 mm; infill 10% Honeycomb; Ironing off; speed 60 mm/s; Z hop on
Bottom, back, sides:
Extruder/Bed temperatures 200/50; layer 0.3 mm; infill 10% Honeycomb; Ironing off; speed 60 mm/s; Z hop on
It took me over 14 hours to print it all.
Also after you put everything together, it won't hurt to place a drop of hot glue on each pin behind LCD, RFID reader and button, to hold them in place. You can lock fingerprint sensor in place with zip tie or also hot glue.
So that's it, thank you for reading this and I hope you manage to make it on your own!
Comments