Fingerprint Scanner
Last updated
Last updated
A fingerprint scanner can add encoded fingerprint images to a database and then read a fingerprint to compare it against the stored fingerprints for identification purposes.
The GT-511C3 fingerprint scanner can store up to 200 different fingerprints in its onboard database.
This fingerprint scanner comes with a 4-wire connector (1 black wire + 3 white wires). Insert the wires into different numbered rows on a breadboard. Then use jumper wires to connect these rows to the Photon.
If the fingerprint scanner wires were numbered left to right as 1-4 (with the black wire being Wire 1), the jumper wire connections would be:
Fingerprint Scanner | Photon Pin |
Wire 1 (Black) = TX | RX |
Wire 2 (White) = RX | TX |
Wire 3 (White) = GND | GND |
Wire 4 (White) = VCC | V-USB (5V) |
The fingerprint scanner will transfer data with the Photon board over a serial data connection using the Photon RX and TX pins.
NOTE: For serial data connections, the RX pin of one device connects to the TX pin of the other device. (RX = receive, TX = transmit)
TIP: The fingerprint scanner has a small built-in green LED. If the Photon device is powered on and you have correctly wired the fingerprint scanner, this green LED should be on.
Your Photon app must include a code library with special functions that will allow you to control the fingerprint reader.
In Particle Build, click on the bookmark icon to open the Libraries sidebar.
Type "fingerprint" into the search field. Select the result called: FINGERPRINT_FPS_GT511C3
Click the button to "Include in Project"
Select the name of your Photon app, and then click the "Confirm" button
Particle Build will automatically insert an #include
statement at the top of your app code
In your global variables, you need to declare an FPS_GT511C3 object variable that you will use to run the special functions in the library. The example below declares an object variable called "fps" (but you could use a different variable name).
You will probably also want to declare an integer variable to store a fingerprint ID number (such as the ID of the detected fingerprint, etc.). This will make it easier to do something with this ID. The example below declares a variable called "fingerprintID" (but you could use a different variable name).
You need to include a statement within the setup()
function to start a serial data connection (which will activate both the RX and TX pins on the Photon). This will allow the Photon and the fingerprint scanner to send and receive data between each other. The fingerprint scanner communicates at a baud rate of 9600 bps.
You also need to include statements to start ("open") the fingerprint scanner and to turn on the LED inside the scanner.
You can use the following temporary code to test whether your fingerprint scanner is wired correctly and able to communicate with your Photon. It will simply turn the scanner's internal LED on and off in a blinking pattern. Once you've verified this works, you can remove this code from the loop()
function.
You can do the following tasks with the fingerprint scanner:
Check If Finger Pressed
Add Fingerprint
Delete Fingerprint
Verify Fingerprint Against Specific ID
Verify Fingerprint Against All Stored IDs
This code will most likely be placed within the loop()
function or within custom functions.
RECOMMENDATION: Use the speaker and/or LEDs to provide feedback on whether a fingerprint was verified or not. For example, if the fingerprint is verified, you could turn on a green LED and/or play a short medium-pitched sound. If the fingerprint is not recognized, you could turn on a red LED and/or play a longer low-pitched sound.
You can check whether a finger is being pressed against the scanner using a fps.IsPressFinger()
statement, which will return either true or false.
For example, if a finger is pressed against the scanner, you could have your code verify whether the fingerprint is already stored in the database, etc.
Before you can verify a fingerprint, you will obviously need to have at least one fingerprint added to the scanner database.
The fingerprint scanner can store up to 200 different fingerprints in its onboard database. Each fingerprint is given a unique ID number from 0-199. The fingerprints stored in the database will be retained even when the scanner is powered off.
Adding a new fingerprint is a process called "enrollment" which consists of capturing high-quality images of the same fingerprint 3 times in a row for comparison. This 3-step enrollment verifies the scanner is able to read and identify the fingerprint accurately and consistently.
During fingerprint enrollment, the person presses their finger on the scanner for the first capture, and then lifts the finger. The same finger is pressed down again for a second capture, and lifted again. Finally, the finger is pressed for a third capture, which will ideally complete the process. However, the enrollment process can fail at any of these 3 steps.
TIP: Be patient, as enrollment may take more than one try. However, once a fingerprint is successfully enrolled, verifying that fingerprint in the future is usually fast and accurate.
It is important to have some type of clear feedback during the enrollment process to know when to press and lift the finger, as well as to know whether the enrollment steps were successful or failed. This feedback could be provided through the OLED display screen, red & green LED lights, the web app, etc.
IMPORTANT: The code example below uses the Micro OLED display screen. You will need to wire the OLED screen to your Photon, and include other necessary code (library, global variables, etc.) for the OLED display.
You could use this code to enroll one or more fingerprints. Then you could remove the addFingerprint()
statement from the loop()
function, and replace it with your primary app code (to verify a fingerprint against the database and then do something with the result).
TIP: Once you are done enrolling fingerprints, you can still keep the code for the addFingerprint()
custom function in your app, even if you are no longer calling it in the loop()
. This will make it easier for you to add more fingerprints later, if necessary.
RECOMMENDATION: If you will need your Photon app (or web app) to know which fingerprint ID is assigned to which person, it may be easier to record this ID number immediately after successfully enrolling the finger. If a person (such as yourself) is going to register multiple fingers, then record the ID number for each specific finger (right index, left thumb, etc.) that you enroll. Then later, you can use this information to have your Photon app (or web app) make different decisions based on which specific fingerprint ID is detected by the scanner.
That's a lot of code compared to what's been needed for other parts. Luckily, the other fingerprint scanner tasks only require a few lines of code at most.
If necessary, you can delete a specific fingerprint from the scanner database by providing its ID (0-199) either as a number or as an integer variable.
If necessary, you can also delete all the fingerprint images from the scanner database. Be careful using this statement – there is no "undo" if you delete all the stored fingerprints.
You can use the fps.Verify1_1()
statement to verify whether a finger matches a specific fingerprint ID by providing the ID (0-199) to check against. The ID can be provided as a number or as an integer variable.
First, you need to capture an image of the finger being pressed. For faster identification, a lower-resolution image is captured.
If the captured fingerprint matches the specific fingerprint ID stored in the database, the fps.Verify1_1()
statement will return true. Otherwise, it will return false.
In most cases, you will want to use the fps.Identify1_N()
statement to verify whether a fingerprint matches any of the fingerprints stored in the database – and if so, identify which fingerprint ID matches.
First, you need to capture an image of the finger being pressed. For faster identification, a lower-resolution image is captured.
If the fingerprint matches an ID stored in the database, the fps.Identify1_N()
statement will return the matching ID number (0-199). Otherwise, it returns a value of 200 if the fingerprint isn't in the database.