ESP32 Fingerprint based Biometric Door Lock & Home Automation

ESP32 Fingerprint:

ESP32 Fingerprint-based Biometric Door Lock & Home Automation– Until now, you may have seen many home automation systems, but the home automation system that I am going to present today is different from all of them because this system is based on the fingerprint sensor and this is never done before.

ESP32 Fingerprint based Biometric Door Lock & Home Automation

A fingerprint-based Biometric Door lock makes sense but a fingerprint-based Home automation, it sounds quite weird isn’t it? Well, you don’t have to control all your home appliances but you can secure certain loads that you don’t want anyone else to turn ON or turn OFF. Now, it could be a TV or a computer, or a Gaming machine; if you don’t want your kids to turn ON these things while you are not around. Anyway, it totally depends on you which loads you want to secure with a fingerprint sensor.

Anyway, first let me tell you about the hardware and then we will start the practical demonstration.

ESP32 Fingerprint based Biometric Door Lock & Home Automation practicla demonstration

As you can see, I am using my designed ESP32 WiFi + Bluetooth Module Development board, but it doesn’t matter if you don’t have this development board you can use a breadboard for the initial testing, and then you can use a Vero board for the final connections. But still if you want to make the same development board then you can download it’s Gerber files.

This board has 4 SPDT type relays. So, using these 4 relays I can control AC and DC loads both at the same time. If you want to control more AC or DC loads then go ahead and increase the number of relays. Don’t worry, I will explain the circuit diagram.

Anyway, this is the R557 Capacitive Fingerprint module and it has the ability to store 120 Fingerprints. You can read my getting started article on this fingerprint sensor if you want to know more about its technical specifications, wiring details, and lots of other things.

This is a 12V Electronic Door Lock and these are 220Vac Bulbs.  Now, let’s go ahead and start a practical demonstration.

ESP32 Fingerprint based Biometric Door Lock & Home Automation

I have powered up the entire system. When the 110/220Vac is ON never touch the relay contacts because it can be really dangerous. Wear protective gloves and it’s good to have someone on your side while working on such high-voltage projects. 

Anyway, for this project, I have registered a total of 4 fingers, and using my four fingers I am going to control these 4 loads.

ESP32 Fingerprint based Biometric Door Lock & Home Automation

Using my four fingers, I was able to control 3 Bulbs and one electronic Door Lock. For the step-by-step explanation and practical demonstration watch video tutorial given at the end of this article. I am sure by now, you might have got an idea of how does this system work. So, without any further delay let’s get started!!!

Amazon Links:

R557 Capacitive Fingerprint Module

12V Electronic Door Lock

ESP32 WiFi + Bluetooth Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

R557 Capacitive Biometric Sensor:

ESP32 Fingerprint based Biometric Door Lock & Home Automation

The R557 Fingerprint Sensor module is a compact and reliable biometric Sensor that can be used to secure doors or other access points. It can also be used in students and employees attendance systems. It’s a low-cost and low-power Fingerprint sensor.  It operates on a low voltage of 3.3V, making it ideal for battery-powered systems. It can be used with 5v and 3.3V compatible controller boards like Arduino, ESP32, STM32, ESP8266, Raspberry Pi Pico, and so on. With this Capacitive Fingerprint sensor, you can easily integrate biometric authentication into your projects.

R557 Technical specifications:

Technical parameter:

Supply voltage: DC 3.3V
Supply current:
Working current: 30mA (typ.)
Peak current: 40mA
Fingerprint image entry time: <0.3 seconds
Collection window area: 12.8mm in diameter
Image pixel: 160*160 pixel
Image Resolution: 508dpi
Match method:
Comparison method (1:1)
Search method (1:N)
Storage capacity: 120 pieces
Security level: five (from low to high: 1, 2, 3, 4, 5)
False Recognition Rate (FAR): <0.0001%
Authentic rejection rate (FRR): <1.0%
Search time: <0.3 seconds (1:1000, average)
Host computer interface: RS232 (TTL logic level, 3.3V)
Communication baud rate: (9600?N)bps where N=1~12 (default value N=6, ie 57600bps)

R557 Working environment:

Temperature: -20 to +45?
Relative humidity: 10%RH-85%RH (non-condensing)

There is an RGB Led inside this module. So, when the fingerprint sensor is ON it shows Blue light. When the Fingerprint scanning operation is successful it shows Green Light, and when the operation is failed, it shows Red light.

It includes a storage capacity of up to 120 fingerprints, a fast recognition speed of under 1 second, and a high-resolution image sensor that captures clear and accurate fingerprints.

R557 Capacitive Biometric Sensor Pinout:


1 VT Finger detection

2 Out IRQ

3 VCC 3.3

4 TX 3.3 Logic level

5 RX 3.3 Logic level


ESP32 Fingerprint based Biometric Door Lock & Home Automation

1st wire is the VT. This is the Finger Detection power and this wire is connected with the 3.3V.

2nd wire is the IRQ. This is the Finger detection signal wire. When there is a finger, it outputs a high signal.

3rd wire is the VCC and it should be connected with 3.3V.

4th and 5th wires are TXD and RXD, both are 3.3V TTL logical level. And

6th wire is the GND and it should be connected with the ground.

Now, let’s go ahead and take a look at the circuit diagram.

ESP32 Fingerprint Circuit Diagram:

ESP32 Fingerprint based Biometric Door Lock & Home Automation circuit diagram

J1 is the female power jack and this is where we connect a 12v adaptor, battery or a solar panel. Two 470uf capacitors are connected at the input and output sides of the voltage regulator. The output of the voltage regulator is connected to the 5v pin of the ESP32 module.  The ground of the power supply is connected to the ground of the ESP32 module.

The R557 Capacitive Fingerprint module VT and VCC wires are connected with the 3.3V pin on the ESP32 module. The IRQ wire is not connected. The Green and Blue wires which are the TXD and RXD pins are connected with the GPIO pins 16 and 17. And the White wire is the GND wire and it’s connected to the GND pin of the ESP32 module.

These are 12v SPDT type relays and can’t be directly controlled using the ESP32 Module, So, that’s why we need a driver to control these relays. You can use a relay driver IC or you can use 2n2222 NPN transistors and 10k resistors. One pin of the relay coil is connected with the collector of the 2n2222 NPN transistor while the other pin of the relay coil is connected with the 12 volts. The emitter of the transistor is connected with the ground while the base is connected with the 10k ohm resistor.

Now to control these relays you simply need to connect these 10k resistors with the ESP32 I/O pins. In this project, I am using the GPIO pins 13, 12, 14, and 27.

The neutral wire from the 110/220Vac supply is connected with the neutral of all the lights. While the Live wire from the AC supply is connected with the lights through these relays.

ESP32 Fingerprint based Biometric Door Lock & Home Automation

Here is my ESP32 development board and as you can see right now only the Fingerprint module is connected. Now, the next step is to enroll in the fingerprints. But first, we are going to install the fingerprint library.

Fingerprint Library Installation:

For this, open the Arduino IDE. Click on the sketch Menu, go to Include Library, and then click on manage libraries.

ESP32 Fingerprint based Biometric Door Lock & Home Automation

Search for the Adafruit Fingerprint.

ESP32 Fingerprint based Biometric Door Lock & Home Automation adafruit finger print sensor library

Click on the install button.

ESP32 Fingerprint based Biometric Door Lock & Home Automation r577 fingerprint capacitive module

You can see my Adafruit Fingerprint Sensor Library is now installed.

Next, for the Fingerprint enrollment connect your ESP32 WiFi + Bluetooth module with the Laptop/PC and Upload this sketch.

Fingerprint Enrollment Code:

Code explanation:

The code begins by including two libraries: Adafruit_Fingerprint and HardwareSerial. These libraries provide the necessary functions for interfacing with the fingerprint sensor. The Adafruit_Fingerprint library is specifically designed for Adafruit fingerprint sensors.

An instance of the Adafruit_Fingerprint class is created and named finger. It is initialized with the Serial2 object, which represents the serial communication for the fingerprint sensor. The id variable is declared as an unsigned 8-bit integer.

The setup() function is called once at the beginning of the program. It performs the initialization of the fingerprint sensor and prints some information about the sensor.

The program starts the serial communication with a baud rate of 9600. Then, it waits for the serial connection to be established (the while (!Serial) loop is used for compatibility with certain boards like Yun, Leo, Micro, Zero, etc.).

The program initializes the fingerprint sensor by calling finger.begin(57600). This sets the data rate for the sensor’s serial port.

Next, it verifies the password for the fingerprint sensor using finger.verifyPassword(). If the password is verified, it indicates that the fingerprint sensor is found. Otherwise, it prints an error message and enters an infinite loop (while (1) { delay(1); }).

The program then reads various parameters from the sensor using finger.getParameters() and prints them out using Serial.print and Serial.println functions.

The readnumber() function is a helper function used to read a number from the serial input. It waits for the serial input to be available (while (!Serial.available())) and then reads an integer using Serial.parseInt(). It returns the read number as an 8-bit unsigned integer (uint8_t).

The loop() function is called repeatedly in an infinite loop. It prompts the user to enter an ID number for enrolling a fingerprint.

It first prints some messages to the serial monitor to guide the user. It calls the readnumber() function to read the ID number entered by the user and stores it in the id variable.

If the entered ID is 0, it returns from the loop() function, effectively restarting the loop to prompt the user for a valid ID.

If a non-zero ID is entered, it prints a message indicating the ID being enrolled and enters a while loop, repeatedly calling the getFingerprintEnroll() function until the enrollment process is completed.

This line indicates that the function is expecting an id value to be available. However, the value of id is not defined in the provided code snippet.

This while loop waits until a valid finger image is obtained by calling finger.getImage(). The value returned by finger.getImage() is stored in p, and the code inside the switch statement handles different cases based on the value of p. For example, if p is FINGERPRINT_OK, it means an image has been successfully captured and the message “Image taken” is printed. Other cases include FINGERPRINT_NOFINGER (indicating that no finger is detected), FINGERPRINT_PACKETRECIEVEERR (communication error), and FINGERPRINT_IMAGEFAIL (imaging error).

Once a valid image is obtained, it is converted into a fingerprint template using finger.image2Tz(1). The returned value is stored in p, and the switch statement handles different cases based on the value of p. If p is FINGERPRINT_OK, it means the image was successfully converted into a template, and the message “Image converted” is printed. Other cases include FINGERPRINT_IMAGEMESS (indicating that the image is too messy), FINGERPRINT_PACKETRECIEVEERR (communication error), FINGERPRINT_FEATUREFAIL (failure to find fingerprint features), and FINGERPRINT_INVALIDIMAGE (failure to find fingerprint features).

The code prompts the user to remove their finger and waits for 2 seconds (delay(2000)) before attempting to capture an image again. The while loop keeps checking for the absence of a finger (FINGERPRINT_NOFINGER) by calling finger.getImage() until it detects no finger.

Once the finger is removed, the code prompts the user to place the same finger on the sensor again. It then enters another loop, similar to the previous one, to capture the image of the finger. The switch statement handles different cases based on the value of p as explained earlier.

After capturing the second image, it is again converted into a fingerprint template using finger.image2Tz(2). The switch statement handles different cases based on the value of p as explained earlier.

After converting the second image, the code attempts to create a fingerprint model using finger.createModel(). If p is FINGERPRINT_OK, it means the model was created successfully, and the message “Prints matched!” is printed. Other cases include FINGERPRINT_PACKETRECIEVEERR (communication error) and FINGERPRINT_ENROLLMISMATCH (indicating that the fingerprints did not match).

Finally, the code attempts to store the created model using finger.storeModel(id). If the return value p is FINGERPRINT_OK, it means the model was successfully stored, and the message “Stored!” is printed. Other cases include FINGERPRINT_PACKETRECIEVEERR (communication error), FINGERPRINT_BADLOCATION (indicating that the model could not be stored in that location), and FINGERPRINT_FLASHERR (error writing to flash memory).

The function returns true if the execution reaches this point without encountering any errors.

After uploading this code; next open the serial monitor and follow the instructions. If you find it difficult to enroll your fingers then you can follow my video tutorial given at the end of this article. Anyway, I enrolled 4 fingers “the forefinger, middle finger, ringer finger, and small finger” I assigned 3 as an ID to the forefinger, 4 as an ID to my Middle finger, 5, and 6 to the ringer finger and small finger respectively.

Altium Designer + Altium 365 + Octopart:

Arduino LoRa Free SMS

Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.

Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.

After, enrolling all the fingers. Next, download the following code, and replace my finger ids with yours.

ESP32 Fingerprint Programming:

This is the Final Code that I use to lock and unlock the Electronic Door Lock and to control other appliances or loads. If this is your first time using the ESP32 WiFi + Bluetooth module then you will also need to install the ESP32 board in the Arduino IDE. And for this, you can watch my video on the ESP32. Anyway, Let me show you, how I used the IDs.

If finger.fingerID == 3 then turn ON or turn OFF the Relay1. First, it reads the status of the relay1 pin. If it’s OFF then it will be turned ON and if its ON then it will be turned OFF. As you can see I am doing it the same way for the remaining IDs and relays.

Watch Video Tutorial:


Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button