Summary
Build an Arduino smart door lock using an R307 fingerprint sensor and a 12V linear actuator. This tutorial covers the components, sensor wiring, motor driver connections, fingerprint enrollment, and Arduino code for locking and unlocking. Learn how to add backup access and improve mechanical and electrical safety.
This smart door lock uses an R307 fingerprint sensor to verify a user, then an Arduino sends a control signal through a motor driver to operate a 12V door lock linear actuator. The actuator extends or retracts the locking mechanism. A separate 12V supply powers the actuator, while the Arduino handles authentication and control.
This tutorial covers the required components, wiring, fingerprint enrollment, Arduino code for locking and unlocking, mounting, and backup access options. It is intended for a prototype or lab project, not as a replacement for a certified door-locking system.
How the Smart Door Lock Works
The R307 fingerprint sensor scans a fingerprint and compares it with templates stored in its memory. When a match is found, it sends the result to the Arduino over serial communication. The Arduino then commands a motor driver to move the linear actuator and change the lock position.
The system follows this sequence:
-
The user places a finger on the R307 sensor.
-
The sensor captures the fingerprint and searches for a stored match.
-
If authentication succeeds, the Arduino activates the motor driver.
-
The driver powers the 12V actuator to extend or retract the lock.
-
The actuator stops when the movement finishes or the controller reaches its configured run-time limit.
A key design point is that the actuator must not be powered directly from an Arduino GPIO pin. It requires a suitable driver and a separate supply capable of handling its current demand.
Parts List for the Arduino Fingerprint Door Lock
Gather the components below before assembling the circuit. Choose the motor driver and power supply based on the actuator's actual operating and stall current, not just its nominal voltage.
|
Component |
Purpose |
|---|---|
|
Arduino Uno |
Reads fingerprint results and controls the actuator |
|
R307 fingerprint sensor |
Enrolls and matches fingerprints |
|
Moves the lock mechanism |
|
|
H-bridge motor driver |
Reverses actuator polarity to extend and retract it |
|
Regulated 12V DC supply |
Powers the actuator |
|
USB cable or suitable Arduino supply |
Powers the Arduino during development |
|
Jumper wires and connectors |
Connect the sensor, controller, and driver |
|
Mechanical lock bracket |
Couples the actuator to the locking mechanism |
|
Manual override |
Allows access if power or electronics fail |
The linked Robocraze actuator listing describes a 12V, two-wire door-lock actuator with approximately 20mm travel and a stated current consumption range of 0.15A to 2.22A. Actual current can vary with load, and startup or stall current is particularly important when choosing the driver.
Motor driver selection: The L298N is a common teaching option, but it has significant voltage drop and thermal limitations. Do not assume it can safely drive this actuator under all conditions. Check the driver's continuous and peak current ratings, thermal performance, and the actuator's stall current. If these exceed the driver's practical limits, use a suitable higher-current H-bridge.
Wiring the R307 Fingerprint Sensor to Arduino
The R307 communicates with the Arduino over UART serial communication. With an Arduino Uno, software serial pins 2 and 3 can keep the hardware USB serial port free for debugging.
|
R307 pin |
Arduino Uno pin |
|---|---|
|
VCC |
The voltage specified for your R307 module |
|
GND |
GND |
|
TX / TXD |
D2, software serial receive |
|
RX / RXD |
D3, software serial transmit |
The serial lines cross over: sensor TX connects to Arduino RX, and sensor RX connects to Arduino TX. The exact supply voltage depends on the sensor variant, so check its documentation before connecting VCC.
Install the Adafruit Fingerprint Sensor Library through the Arduino IDE Library Manager. The library includes example sketches for testing the sensor and enrolling fingerprints.
Wiring the 12V Linear Actuator Through a Motor Driver
A two-wire DC actuator moves in opposite directions when the polarity across its motor terminals is reversed. An H-bridge motor driver handles this reversal while allowing the Arduino to control the direction.
For a typical L298N module, the connections are:
|
L298N module |
Connection |
|---|---|
|
OUT1 and OUT2 |
Two actuator motor wires |
|
IN1 |
Arduino D8 |
|
IN2 |
Arduino D9 |
|
ENA |
Arduino D10, with the ENA jumper removed if required |
|
Motor supply input |
Regulated 12V supply, according to module documentation |
|
Logic supply |
As specified for the module |
|
GND |
Common ground with the Arduino and motor supply |
Connect the 12V supply positive and negative to the driver's motor power input as labelled. Connect the Arduino ground to the driver ground so the control signals have a common reference. Do not power the actuator from the Arduino's 5V pin.
For an H-bridge that uses different terminal names, follow its datasheet rather than copying the L298N pin labels. Confirm that the driver can handle the actuator's current before testing.
Important: A timer in software is not a reliable substitute for end-position feedback. If the actuator has internal limit switches, confirm that they operate correctly. If it does not, use suitable external limit switches or position sensing to prevent the mechanism from being driven against its end stops. Never keep a motor powered against a mechanical stop.
Arduino Code: Fingerprint Match, Unlock and Relock
This example checks for an enrolled fingerprint, moves the actuator in the unlock direction when a match is found, waits five seconds, and then moves it back toward the locked position.
Before uploading:
-
Install the Adafruit Fingerprint Sensor Library.
-
Run its enroll example to save at least one fingerprint in the R307 sensor.
-
Connect the R307 to pins D2 and D3, and connect the motor driver to D8, D9, and D10 as described above.
-
Verify the actuator's movement direction at a safe, unloaded or mechanically disconnected setup before attaching it to the lock.
#include <SoftwareSerial.h>
#include <Adafruit_Fingerprint.h>
// Arduino software serial: RX, TX
SoftwareSerial fingerSerial(2, 3);
Adafruit_Fingerprint finger(&fingerSerial);
// Motor driver pins
const int IN1 = 8;
const int IN2 = 9;
const int ENA = 10;
// Adjust after testing the actuator safely.
// These are example durations, not guaranteed travel times.
const unsigned long ACTUATOR_TIME_MS = 700;
const unsigned long UNLOCK_HOLD_MS = 5000;
void stopActuator() {
digitalWrite(ENA, LOW);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
}
void moveActuator(bool unlock) {
if (unlock) {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
} else {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
}
digitalWrite(ENA, HIGH);
delay(ACTUATOR_TIME_MS);
stopActuator();
}
bool checkFingerprint() {
if (finger.getImage() != FINGERPRINT_OK) {
return false;
}
if (finger.image2Tz() != FINGERPRINT_OK) {
return false;
}
if (finger.fingerFastSearch() != FINGERPRINT_OK) {
Serial.println("Fingerprint not recognised");
return false;
}
Serial.print("Fingerprint matched. ID: ");
Serial.println(finger.fingerID);
return true;
}
void setup() {
Serial.begin(9600);
fingerSerial.begin(57600);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
stopActuator();
finger.begin(57600);
if (!finger.verifyPassword()) {
Serial.println("Fingerprint sensor not detected.");
while (true) {
stopActuator();
delay(100);
}
}
Serial.println("Fingerprint door lock ready.");
}
void loop() {
if (checkFingerprint()) {
Serial.println("Unlocking...");
moveActuator(true);
delay(UNLOCK_HOLD_MS);
Serial.println("Locking...");
moveActuator(false);
// Pause to reduce repeated triggers from the same finger.
delay(1500);
}
delay(100);
}
The Adafruit library's standard workflow captures an image, converts it to a template, and searches for a match among enrolled fingerprints. Its example sketches are useful for confirming that the sensor works before adding motor control.
Important code adjustments
-
Actuator direction: If the actuator locks when the code says unlock, reverse the IN1 and IN2 logic or swap the two motor wires with power disconnected.
-
Travel time:
ACTUATOR_TIME_MSis only an example. Calibrate it carefully and use limit switches or position feedback wherever possible. Do not allow the actuator to remain powered against a hard stop. -
Serial baud rate:
57600is common for R307 modules, but some modules may use a different configured baud rate. If the sensor is not detected, check its settings and wiring. -
Repeated scans: The example uses a delay to reduce repeated activations. A more robust design should wait for the finger to be removed and track the lock's actual state.
-
Driver compatibility: The code assumes an L298N-style driver with IN1, IN2, and ENA. Adapt it to the actual driver module and its enable logic.
This example is a starting point for a prototype. It does not provide door-position feedback, jam detection, tamper protection, or a guaranteed fail-safe locking state.
Mounting the Actuator on a Door
The mechanical design is just as important as the electronics. The actuator must move the locking bolt or latch without bending the bracket, binding, or putting excessive load on the motor.
-
Measure the travel needed: The linked actuator listing specifies approximately 20mm of travel. Confirm that this is sufficient for the chosen latch before designing the bracket.
-
Mount the actuator securely: Use a rigid bracket and suitable fasteners. Avoid mounting it where the actuator body or rod can twist under load.
-
Align the rod with the lock mechanism: Side loading can cause binding and premature wear. Keep the actuator's motion aligned with the latch's travel.
-
Check both end positions: Test the locked and unlocked positions with the door open. Ensure the actuator reaches the required position without forcing the mechanism.
-
Test under realistic conditions: Check the lock with the door open first, then verify alignment and operation with the door closed while keeping the manual override accessible.
Do not rely only on the actuator's travel distance or the delay in the Arduino code to determine whether the door is securely locked. Add position feedback, such as limit switches, if the application needs confirmation of the actual lock state.
Adding a Keypad or RFID Backup
A fingerprint sensor is convenient, but every electronic access system should have a planned recovery method.
-
Keypad: Add a keypad to allow entry using a PIN. The Arduino should validate the PIN before commanding the motor driver.
-
RFID reader: Add a compatible RFID reader and validate authorised card IDs. Use a reader and access-control design appropriate to the security level required.
-
Mechanical key or manual release: Preserve a practical way to unlock the door if the Arduino, sensor, driver, or power supply fails.
-
Power-failure plan: Decide whether the lock should remain locked or allow safe egress during a power failure. This depends on the door's purpose and applicable safety requirements.
Fingerprint matching alone does not make a system secure. Templates, wiring, controller access, physical tampering, and emergency access all affect the overall design.
Common Problems and Troubleshooting
The R307 sensor is not detected
Check its power supply and ground, then confirm that the TX and RX wires are crossed correctly. Verify the baud rate and run the library's fingerprint sensor example before testing the complete lock.
A valid fingerprint is not recognised
Enroll the fingerprint again and ensure the finger is placed consistently on the sensor. Check that the enrollment process completed successfully and that the sensor has enough memory for the templates you need.
The actuator does not move
Check the 12V supply, motor-driver wiring, enable pin, and common ground. Disconnect the actuator from the mechanical lock and test it safely to determine whether the problem is electrical or mechanical. Never connect the actuator directly to an Arduino GPIO.
The motor driver becomes hot
The actuator may draw more current than the driver can handle, particularly during startup or when the mechanism binds. Check the driver's continuous and stall-current ratings, improve cooling where appropriate, and replace an undersized driver with a suitable higher-current model. The L298N has meaningful voltage-drop and thermal
The lock does not reach the correct position
The movement duration may be too short, the bracket may be misaligned, or the mechanism may be obstructed. Check the linkage and actuator travel. Use limit switches or position feedback rather than relying on a longer delay to overcome a mechanical problem.
Product Recommendations for the Smart Door Lock
The following components form the core of the prototype. Confirm each product's exact specifications and compatibility before connecting the system.
|
Product |
Role in the project |
|---|---|
|
Moves the locking mechanism |
|
|
Enrolls and matches fingerprints; the link is a tutorial rather than a product listing |
|
|
L298N motor driver |
Drives the actuator in both directions only if its current and thermal limits are suitable |
|
Compatible 12V SMPS |
Supplies the actuator with the required current |
For a complete kit, choose a motor driver based on the actuator's real current requirements, use a properly rated 12V supply, and include a mechanical override. The actuator and fingerprint sensor must both be compatible with the intended installation.
Conclusion
An Arduino fingerprint door lock combines biometric authentication with motorised locking. The R307 stores and matches fingerprint templates, the Arduino processes the match result, and an H-bridge driver controls the direction of the 12V linear actuator.
Start by testing fingerprint enrollment and matching independently, then verify actuator movement with the lock disconnected. Once both parts work, integrate the circuit and test the mechanical assembly, travel limits, and power supply. For a real door, include position feedback, a manual override, and a safe response to power or hardware failure.