In this guide we set up an Adafruit Optical Fingerprint Scanner to enroll fingerprints to be recognised. Then we will use our fingerprints to control the attached hardware (LED and Solenoid). We will even produce digital images of the enrolled fingerprints!


Hey gang, Tim here at Core Electronics and today we set up this scanner to register fingerprints to be recognized then we'll use fingerprints to control attached hardware. We will even produce digital images of the enrolled fingerprints, so let's crack on in.

When this Adafruit Optical Fingerprint Scanner captures a fingerprint, it's going to return a confidence value if it finds a matching enrolled fingerprint. Remarkably, this small module can store 300 unique fingerprints in its non-volatile flash memory. This means that even if you completely depower this system, this scanner is still going to remember all your enrolled fingerprints.

Today, I'm using a Raspberry Pi 4 Model B with this Adafruit Fingerprint Scanner and on screen now is everything you will need to follow along. We will assume you know how to run a Raspberry Pi as a desktop computer and that you have all the hardware to do so. Check the main written article for resources on this if you need, link down below.

First, connect the breakout cable to the scanner. Be careful and don't force it as the connectors are quite delicate. Observe here that the lead may not lie completely flat against the board. Now make sure your Raspberry Pi is unpowered.

For this next bit, we're going to connect the red wire to the 3.3 Power Pin on the Raspberry Pi. Connect the black wire to any ground pin. These next two are for the UART. Connect the white wire to GPIO14 and the yellow wire to GPIO50. Four of these wires will remain unconnected from the optical scanner.

A note here: this Adafruit Fingerprint Scanner will break if you connect it to five volts, so be sure to double check all the connections before powering up the system.

With that double check done, let's power up the Raspberry. finger I'm going to enter the number one

Pi communication with the scanner is all handled by a two-wire UART connection. The buyer's UART port is disabled by default, but will need to be available for this scanner to work. To do this, click the top left menu button, go down to Preferences, and then click on the Raspberry Pi Configuration. Under the Interfaces tab, make sure that Serial Port is turned on. You're also going to want to disable the Serial Console. Having done this, press OK and restart your system.

Now open up a new terminal window to install the fingerprint scanner packages. In the article, find the Software Setup section and copy these commands one by one into a new terminal. Enter 'y' if prompted. The first command will install some Python driver packages and the second and third commands will download helpful example scripts.

With that complete, we are ready to begin scanning fingerprints. From here, we will open up Thonny IDE. Click on the Application Menu (this is that Raspberry Pi symbol on the top left of the screen) and hover over the Programming tab. There you'll find Thonny IDE. Click the Open button and navigate to our freshly downloaded examples. Find them by jumping through these directories: Home > Pi > Out of Roots > Circuit Python > Fingerprint Examples. Then choose the Simple Example:

Now this script we're going to need to modify slightly so that it will use our UART port. Comment out this line 14 by adding a hash symbol to the front of it, and uncomment line 17 by deleting the hash symbol. Make sure to save your script after doing this.

With that done, we can now press the big green Run button. This will spit out some information to the Shell offering us several options. Let's start by enrolling a new finger into this system. To do this, type in 'enter e'. We are being prompted for an ID and, as this is my first finger, I'm going to enter the number one. the LED will turn on and when you scan an unenrolled fingerprint it will turn off

We will enter one fingerprint scanner and the lights will come on. We are instructed to place a finger on the sensor and press it onto the scanner two separate times to lock it in. We can then check whether it has been correctly enrolled by testing our system type and entering 'f'. As you can see, it is detecting my fingerprint perfectly. Written in the Shell, it states 'Detected Number One' and it has provided a confidence value of 273. The confidence value is from 0 to 500, with higher values meaning higher confidence. As a note on incorporating confident scores into your projects, it only really makes sense for higher security applications. If the scanner confirms a detection, you can feel pretty self-reassured about it. To make sure, I'm going to try scanning an unenrolled pinky finger and it's working as it should.

If you want to remove all captured fingerprints from this device, simply press 'R' and enter. We can now control some GPIO with our fingerprints utilizing the breadboard. I have added an LED and resistor in series to GPIO 21 and a ground pin on the Raspberry Pi singleboard computer. The end goal here is to turn on the LED based on our correctly identified fingerprint. Full schematics can be found on the written article. If you need, GPIO pins are the gateway to the rest of the world. This LED is simply a placeholder to represent whatever hardware you want to connect to.

In the article, find the next example and copy and paste this code into a new script. I have saved mine as 'LED Fingerprint Control'. Having pressed run, I'm going to place my fingertip onto the scanner and it lit up exactly how we wanted it to. Beautiful! Now when you scan an enrolled fingerprint like this, the LED will turn on and when you scan an unenrolled fingerprint, it will turn off.

One right here, it's going to turn the LED on for a second. Nice and of course, unenrolled fingerprints are ignored, no light and no match bound. This script that I've created here is just a remix on one of the examples that we've already downloaded.

Jumping into the script, you can see where I have initialized GPIO 21 as the output pin. That is the PIN that's driving the LED. I've also imported the GPIO pins to this script so that way we have all our GPIO functionality. I've set the extrenuous warnings to be false so that way it won't give us warnings all the time and I've set pin, which in this case is pin 21, to be an output pin. When you set up a GPIO pin like this, it defaults to low voltage.

Now when we recognize the enrolled fingerprint, we toggle the LED on with a brief delay. Scrolling down a little bit further, we can see this else statement. This else statement is only ever reached by the python interpreter when an index finger is detected. This is why we can see that I then set our LED to toggle on, sleep for one second, and then toggle off. And that is how we get our beautiful light turning on and off just like so.

I hooked up a 12 volt solenoid to our Raspberry Pi system which can act as a door lock. This is the makings of a home brew access control system based on biometrics. Boom! I have a guide on hooking up 12 volt solenoids with a Raspberry Pi system so check the description for assembly and code tips. We could also modify this script to get different uses for different enrolled fingerprints. We could also make the script so it runs infinitely so that way it will constantly be searching for new fingerprints.

Naturally, I had to 3D print a mount for this scanner. I downloaded this super swell mountable case linked to it down below in the description and I printed it using TPU on the Audi maker.

With just three steps behind me, I was eager to see what my fingerprint would look like through the fingerprint scanner. The script can be found in the 'Where to Now' section of my written guide, and you can copy, paste, save, and run it in the same way as before. When you run the script using the Thonny IDE and press your finger onto the scanner, it will export a BMP image of your fingerprint. It takes about 10 seconds to do so, but it's worth the wait.

Now, you can take this concept to wherever your imagination desires with your biometrics as the control lever. The sky is the limit, and if you want to further your biometric controls with Raspberry Pi, we have a video on facial recognition. Check out the link down below.

We also have a forum where you can directly contact us if you ever need a hand with any of your projects. Unlike YouTube comments, you can attach photos to your questions so we can troubleshoot for you even faster. We are full-time makers and we are here to help, so until next time, staycode!



Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.