How to use a fingerprint sensor with Arduino
Hi guys, Nick again, welcome to educ8s.tv. today we are going to learn how to use a cheap fingerprint sensor with the Arduino. The procedure is very easy and it is an ideal project for both Arduino experts and beginners.
I always wanted to try a fingerprint sensor module in order to learn more about its technology and use it in some of my projects in order to add biometric security to them. While searching for a nice and low cost sensor, I discovered this sensor module on Gearbest.com, with a price tag of around 30$ and Gearbest.com was kind enough to send me a sample unit in order to test it and share my opinion about it with you.
The fingerprint sensor module is a very compact module with an advanced DSP (Digital Signal Processing) chips inside which is used by the sensor to process the image of fingers captured to detect if there is a match or not. When the sensor captures a new image, the image is rendered and some calculations are made to find the features of that finger after which the memory of the sensor is searched for a fingerprint with matching characteristics and the result of that session is sent to the microcontroller via serial communication. All this is done in less than a second. The module can store up to 1000 fingerprints in its memory and its false acceptance rate is less than 0.001% which makes it pretty secure!
In order to demonstrate a simple use of the sensor, we will be building a simple project with it. We will be using the sensor along with an Arduino Uno and a 1.44 inch colored TFT display. The Concept behind the project is simple, we want to build a security system that unlocks only when a registered fingerprint is placed on the sensor. The project will display a welcome message on the LCD when the correct finger is placed and display a locked message when there is no fingerprint match. It is a useful and fun project and you will learn enough to build your own door security system.
Required Parts and Where to Buy
The following parts/components are required to build this project and they can be bought via the link in front of each component.
- Fingerprint Sensor: https://educ8s.tv/part/FingerprintSensor
- Arduino Nano: https://educ8s.tv/part/ArduinoNano
- 1.44 Color TFT: https://educ8s.tv/part/LCD144
- Small Breadboard: https://educ8s.tv/part/SmallBreadboard
- Jumper Wires: https://educ8s.tv/part/JumperWires
- Power bank Xiaomi: https://educ8s.tv/part/Powerbank
Schematics
Connect the parts as shown in the circuit diagram below. As mentioned earlier, the fingerprint sensor communicates with the microcontroller over serial communication so we only need connect two wires from the sensor to the microcontroller asides from power and ground. Fritzing didnt have the exact fingerprint sensor Wanted, hence the makeshift representation for the sensor.
To make the connection easier to follow, it is further described below.
FINGERPRINT Sensor ——–ARDUINO NANO
Vcc——————————–5V
GND——————————GND
Tx———————————D2
Rx———————————D3
NOTE: The 1.44’ TFT display used in the schematic above is quite different from the one used in the video tutorial. Ensure you make use of the pin mapping shown above if you are making use of the display used in the video
TFT DISPLAY———ARDUINO NANO
Vin———————–5V
GND——————–GND
CS———————–D10
RST———————D9
A0———————–D8
SDA——————–D11
SCK——————–D13
LED——————-3.3V
Code
It’s time to finally write the Arduino sketch for the project. To develop the code sketch for this project, we will be using three main Arduino libraries which are listed below. One of the libraries is used to interface with the Finger print sensor while the other two libraries are required to use the TFT display for the project. The libraries can be downloaded from the links below.
——————–
LIBRARIES
——————–
https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/sumotoy/TFT_ILI9163C
With the libraries downloaded and installed you can now proceed with the code. As usual I will do a brief explanation of the code for the project and attach the complete code under the download section at the end of this tutorial.
As usual, we start the code by including the libraries that we will be using.
#include <SPI.h> #include <Adafruit_GFX.h> #include <TFT_ILI9163C.h> #include <Adafruit_Fingerprint.h> #include <SoftwareSerial.h> #include <avr/pgmspace.h>
Then we make color definitions for the colors that will be used by the display.
#define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF
To ensure the display looks nice, an icon was created. Thus the next thing is for us to initialize the icons that will be used and store their hex values in the program memory. We have covered how to create icons for this display in a previous tutorial on this website.
The next important line is the creation of a software serial instance to enable the arduino communicate with the finger print sensor. The hardware serial was not used because it is the same pins that is being used by the arduino to communicate with the computer.
SoftwareSerial mySerial(2, 3); Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
With that done, we move to the void setup() function where we start and initialize all the communications systems and display the lock screen.
void setup(void) { startFingerprintSensor(); display.begin(); displayLockScreen(); }
Next is the void loop function, we check for a finger every 50ms. If a finger is found, the module checks to see if the fingerprint is enrolled in its memory. If it is enrolled, it generates the fingerprintID and then then displays the name of the user. After a few seconds, the screen is locked again.
void loop() { fingerprintID = getFingerprintID(); delay(50); if(fingerprintID == 1) { display.drawBitmap(30,35,icon,60,60,GREEN); delay(2000); displayUnlockedScreen(); displayIoanna(); delay(5000); display.fillScreen(BLACK); displayLockScreen(); } if(fingerprintID == 2) { display.drawBitmap(30,35,icon,60,60,GREEN); delay(2000); displayUnlockedScreen(); displayNick(); delay(5000); display.fillScreen(BLACK); displayLockScreen(); } }
Enrolling a finger before uploading the code for this project is important and can be done by uploading the enroll example from the Adafruit fingerprint library to our Arduino board. We go to File-> Examples -> Adafruit Fingerprint Sensor Library -> Enroll. With this example program we can store fingerprints in the FLASH memory of the module. We upload the sketch and open the Serial Monitor. The program asks us to enter the ID to enroll. Then we place the finger on the sensor twice as we are instructed and the fingerprint is stored! You can store as many as 1000 fingerprints this way.
The complete code for this project can be downloaded from the link below.
——————–
CODE OF THE PROJECT
——————–
After enrolling, upload the code for this project onto your Arduino and try with different fingers, you should see the project work as described. A look at the final setup in action is shown in the image below.
Thanks for watching or reading today’s tutorial. You can leave whatever questions you have under the comment section of this project, I will be glad to provide answers to them as soon as possible. Don’t forget to subscribe to get informed about all new tutorials.
SUBSCRIBE ON YOUTUBE
——————–
Never miss a video: Subscribe to educ8s.tv
Super! Bravo!
Hello Nick,
My name is Dimitris, your project is awsome!
I am using an arduino oem (copy) and a fpm10 sensor . I have already upload a sketch to enroll figngerprints and i get en error massege during the proccess.
Image taken
Image converted
Remove finger
ID 1
Place same finger again
…………….Image taken
Image converted
Creating model for #1 (the problem is that is unable to create model and then store the fingerprint
Unknown error
Ready to enroll a fingerprint! Please Type in the ID # you want to save this finger as…
After the messege uknown error the loop is running normaly.
Do you have any idea why is unable to create a model?
Thanks in advance!
Γεια σου Δημήτρη! Μάλλον δεν δουλεύει καλά ο αισθητήρας που έχεις. Ίσως να είναι ελλατωματικός.
DId you find a solution to this problem? I am having the same problem. The model can’t be created I only get the “Unknown Error” message as well.
hi “Unknown Error” problem Did you solve the problem?
Solution;
ardiuno last version 1.6.12 is the problem.
ardiuno 1.6.6 version no problem
Did anyone find a solution for the “unknown error” message from the enrolling sketch?
I’ve tried running it on Arduino 1.6.6 and it says the same thing…
FINGERPRINT SCANNER IS NOT CONNECTED PROPERLY
what if i use Arduino UNO in place of Arduino NANO?
Unknown Error” problem Did you solve the problem?
Hello
i’m Hannes and i’m 17 years old.
I have bought a r308 optical fingerprint module.
But I don’t know how to connect it. And I don’t know where I can find a code.
because I know not much of programming process. I need this for a school project.
Can someone help me?
Hi,
Does anyone know how to use fingerprint + arduino + web sql?
Regards, Bruno
I have a weird problem.. the display starts drawing at about 1/8th to 1/4 down the screen and it appears to be upside down from what you have..(meaning top is where connectors are) its 1.44 tft v1.1.. it works but shows static in top portion of screen and cuts off the bottom.. like its not starting in the correct location.. any ideas? you had 2.1 module.. wonder if that makes a difference.
Hello Nick your video is great but I have a problem with my own sensor module.
Please can you tell me how to do an access Denieded with the sensor module?
Thanks!
I’m using a liquid crystal display.
hi nick.
I am a student in electronics engineering in kenya. i wanted to do a final year project on class signing in using a biometric fingerprint sensor module. i want a development board which can enroll different categories of students who can thereafter sign in different classes using the module. which development board do you think can work best? i was thinking about using Teensy 3.5 by pjrc.
Any microcontroller will do. The teensy will work fine. Even an Arduino Uno can do the job though.
Dear Nick,
I have create your project, but I have one problem. When I’m uploading final arduino code my TFT screen stay just white color, nothing is displayed on it. I have checked all wires connection, I have include all necessary libraries:
#include
#include
#include
#include
#include
#include
(SPI.h, TFT.h and Softwere.h) are in orange color other ar in black.
I hope that you can help me, if I have missed something.
Best regards,
Robert
Dear Nick,
I have discovered something:
when I have TFT display connected to arduino nano just with 5V, GND, SCK and LED it works, but when I connect any of CS, RST, A= or SCK display become white.
Do you have any suggestions how to solve the problem?
Regards,
Robert
I’m trying this out on a Mega 2560.
I’ve connected Green (TX) to Digital PIN 0 and White (RX) to Digital PIN 1 since these ports support Hardware Serial on the Mega.
I think the Adafruit Library needs a few tweaks for this to work but I haven’t figured out what to change exactly. My sensor also doesn’t seem to work with the ‘SFG Demo’ testing application for Windows.
Any thoughts on changes I need to make on the wiring or code to get it to enroll?
It simply blinks continuously which makes me think the device is OK but something has not been done right elsewhere!?
Hello,
I purchased the UNIROI ultimate Arduino starter kit, Adafruit 1.44 and optical Fingerprint reader sensor (Geekstory GR2904 ASIN-B07BQ9VNWR). I have successfully wired the Arduino Uno, Adafruit 1.44 and the fingerprint sensor to the breadboard. I receive proper power to the Uno board. I can use the libraries to run the following tests separately: Graphics test, blink test, enroll several finger prints, and verify several fingerprints. However, I can’t figure out the code to show a name with each fingerprint enrollment 1 through 10, display a reject for non enrolled finger prints and have these results displayed on the Adafruit screen. Can someone help? I can be reached at terwhite@bellsouth.net
how i can connect this fingerprint with Database MYSQL using Arduino uno