Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

R307 Fingerprint Sensor with Arduino: Wiring & Code

R307 Fingerprint Sensor with Arduino: Wiring & Code
P
Written By Pranay Agarwal
📅 Updated on 16 Oct 2026
✨ Summarize with AI
✅ Prompt copied

Summary

Learn how to connect the R307 fingerprint sensor to Arduino Uno, install the Adafruit library, enrol fingerprints, match stored IDs and troubleshoot common wiring and communication errors.

How to Use the R307 Fingerprint Sensor with Arduino (Wiring and Code)

The R307 fingerprint sensor can store fingerprint templates and identify a finger by comparing a scanned print with enrolled templates. To use it with Arduino, connect the sensor's power and UART pins, install a compatible fingerprint library, enrol a fingerprint, and run a matching example. The sensor can store up to 1,000 templates, depending on the module's specifications.

This guide covers the R307 pinout, Arduino wiring, library installation, fingerprint enrolment, matching, troubleshooting and a simple attendance or door-lock project.

What Is the R307 Fingerprint Sensor?

The R307 is an optical fingerprint recognition module that captures a fingerprint image, processes it and stores a template for later comparison. Its onboard processing allows a microcontroller such as an Arduino Uno to communicate with it over a serial UART connection instead of processing the fingerprint image itself.

Typical applications include:

  • Fingerprint-based attendance systems

  • Access control and electronic door locks

  • Student embedded-systems projects

  • Personal identification prototypes

  • Arduino security and automation projects

The sensor handles fingerprint capture and template matching internally. Arduino sends commands and receives responses, such as whether a fingerprint matches a stored template.

For the specific R307 module, verify the supplied datasheet for the supported voltage range, storage capacity, baud rate and connector pinout before wiring.

Components and Supplies

R307 Optical Fingerprint Sensor – Optical fingerprint sensor -Fingerprint Sensor -Biomedical Sensor -RobocrazeR307 Optical Fingerprint Sensor – Optical fingerprint sensor -Fingerprint Sensor -Biomedical Sensor -Robocraze

    R307 Optical Fingerprint Sensor Module

    R307 Optical Fingerprint Sensor Module The R307 Optical Fingerprint Reader makes fingerprint scanning straightforward. It connects easily to microcontrollers or PCs using a TTL UART interface or through a MAX232/USB-Serial adapter. You can store fingerprints on the device and set it to recognize individuals...
    Rs 999/-
    Rs 999/-
    Rs 1,299/-
    Save Rs 300/-
    Original Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -RobocrazeOriginal Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -Robocraze

      Arduino Uno R3 Original

      Arduino UNO R3 Original The Arduino Uno R3 is a microcontroller board based on the ATmega328P chip and is widely recognized as the best original Arduino Uno board for beginners and projects. This board has 14 digital I/O pins (6 support PWM), 6 analog...
      Rs 2,750/-
      Rs 2,750/-
      Rs 3,499/-
      Save Rs 749/-
      1.3" I2C OLED Display 4pin Blue – OLED screen for Arduino, ESP32 & projects -OLED Display -Robocraze1.3" I2C OLED Display 4pin Blue – OLED screen for Arduino, ESP32 & projects -OLED Display -Robocraze

        1.3 Inch I2C OLED Display Module 128×64 4-Pin Blue

        1.3 Inch I2C OLED Display Module 128×64 4-Pin Blue The 1.3 Inch I2C OLED Display Module is a compact blue OLED display designed for Arduino, IoT, robotics, embedded systems, and DIY electronics projects. With a 128×64 pixel resolution and high-contrast OLED technology, it provides...
        Rs 339/-
        Rs 339/-
        Rs 449/-
        Save Rs 110/-
        GL12 840 Points Solderless Breadboard for Large Prototyping - Electronic Components -RobocrazeGL12 840 Points Solderless Breadboard for Large Prototyping - Electronic Components -Robocraze

          GL12 840 Points Solderless Breadboard

          GL12 MB102 840 Points Solderless Breadboard Introducing the GL12 840 Points Breadboard at Robocraze! This solderless breadboard is an essential tool for any electronics engineer or hobbyist. It allows you to make temporary prototypes for your electronics projects, making it perfect for experimenting with...
          Rs 69/-
          Rs 69/-
          Rs 90/-
          Save Rs 21/-
          Jumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - RobocrazeJumper Wire Set - M2M, M2F, F2F (40 pcs each) – Ideal for Arduino & prototyping. Electronic Components - Robocraze

            Jumper Wire Set - M2M, M2F, F2F (40 pcs each)

            Jumper Wire Set - M2M, M2F, F2F (40 pcs each) These DuPont jumper wires for electronics is a premium quality wire manufactured by using quality assured material and advanced techniques, which make them up to the standard in this highly challenging field. This 120pcs...
            Rs 145/-
            Rs 145/-
            Rs 169/-
            Save Rs 24/-

            R307 Fingerprint Sensor Pinout

            Fingerprint identification module (R307)




            Many R307 modules use a six-pin connector. The exact pin order can vary between boards or cable assemblies, so confirm the labels or documentation for your particular sensor before applying power.

            Sensor pin

            Function

            Arduino connection

            VCC

            Sensor power

            Supply voltage supported by your module

            GND

            Ground

            GND

            TX

            Serial data transmitted by sensor

            Arduino RX pin

            RX

            Serial data received by sensor

            Arduino TX pin

            Touch / Wake

            Optional touch or wake signal on some versions

            Optional digital input, if supported

            Additional pin

            May vary by module

            Confirm with the module's pinout

            Important: TX and RX cross over. The sensor's TX connects to the Arduino's RX, and the sensor's RX connects to the Arduino's TX. Do not rely on the physical pin order in a generic diagram if your module's markings differ.

            Components Required

            Before wiring the circuit, gather these components:

            The R307 communicates with Arduino using UART serial communication. The Arduino runs the application code, while the fingerprint module handles image capture, fingerprint-template creation and matching.

            GitHub
            +1

             

            R307 Fingerprint Sensor Wiring with Arduino Uno

            For an Arduino Uno, use software serial on digital pins 2 and 3 so that the USB serial connection remains available for the Serial Monitor.

            Wiring Table

            R307 pin

            Arduino Uno pin

            Purpose

            VCC

            5V, if supported by your module

            Sensor power

            GND

            GND

            Common ground

            TX / TXD

            D2

            Sensor transmits data to Arduino

            RX / RXD

            D3

            Arduino transmits data to sensor

            Touch

            Leave disconnected for basic testing

            Optional finger-detection signal

            Additional pin

            Leave disconnected unless required

            Check the module documentation

            The UART connections must cross over: sensor TX goes to Arduino D2, and sensor RX goes to Arduino D3. The library's software-serial constructor uses the order (Arduino RX, Arduino TX).

             

            Power warning: Many R307 modules specify a supply around 4.2–6V, but module variants can differ. Verify the voltage and pin labels for your exact sensor. Do not connect an unidentified pin to 5V based only on its position or wire colour.

            Installing the Adafruit Fingerprint Library

            The Adafruit Fingerprint Sensor Library provides functions for communicating with compatible UART fingerprint modules, enrolling fingerprints and searching stored templates.

             

            Follow these steps:

            1. Open the Arduino IDE.

            2. Select Sketch → Include Library → Manage Libraries.

            3. Search for Adafruit Fingerprint Sensor Library.

            4. Install the library by Adafruit.

            5. Connect the Arduino Uno to your computer using USB.

            6. Select the correct board and port from the Tools menu.

            You can also review the library's official repository: Adafruit Fingerprint Sensor Library.

            Before uploading the enrolment or matching program, test the connection using the library's example sketch if you are unsure whether the wiring is correct.

            Enrolling a Fingerprint with Arduino

            Enrolment stores a fingerprint template in the sensor's memory. The same finger is scanned twice so the module can compare the two captures and create a template.

            This example stores a fingerprint under ID 1. Install the Adafruit library first, then upload the sketch and open the Serial Monitor at 9600 baud.

            Arduino Code: Fingerprint Enrolment

            #include <Adafruit_Fingerprint.h>
            #include <SoftwareSerial.h>
            
            // Arduino RX, TX
            SoftwareSerial fingerSerial(2, 3);
            Adafruit_Fingerprint finger(&fingerSerial);
            
            const uint16_t fingerprintID = 1;
            
            bool waitForImage() {
              while (true) {
                uint8_t result = finger.getImage();
            
                if (result == FINGERPRINT_OK) {
                  return true;
                }
            
                if (result != FINGERPRINT_NOFINGER) {
                  Serial.print("Image capture error: ");
                  Serial.println(result);
                  return false;
                }
            
                delay(100);
              }
            }
            
            void waitForFingerRemoval() {
              Serial.println("Remove your finger.");
            
              while (finger.getImage() != FINGERPRINT_NOFINGER) {
                delay(100);
              }
            }
            
            bool enrollFingerprint() {
              Serial.println("Place your finger on the sensor.");
            
              if (!waitForImage()) return false;
            
              if (finger.image2Tz(1) != FINGERPRINT_OK) {
                Serial.println("Could not process first scan.");
                return false;
              }
            
              waitForFingerRemoval();
              delay(500);
            
              Serial.println("Place the same finger again.");
            
              if (!waitForImage()) return false;
            
              if (finger.image2Tz(2) != FINGERPRINT_OK) {
                Serial.println("Could not process second scan.");
                return false;
              }
            
              if (finger.createModel() != FINGERPRINT_OK) {
                Serial.println("Scans did not match. Try again.");
                return false;
              }
            
              if (finger.storeModel(fingerprintID) != FINGERPRINT_OK) {
                Serial.println("Could not save fingerprint.");
                return false;
              }
            
              Serial.println("Fingerprint enrolled successfully!");
              Serial.print("Stored under ID: ");
              Serial.println(fingerprintID);
            
              return true;
            }
            
            void setup() {
              Serial.begin(9600);
              finger.begin(57600);
            
              if (!finger.verifyPassword()) {
                Serial.println("Sensor not found. Check wiring and baud rate.");
                while (true) delay(100);
              }
            
              Serial.println("R307 fingerprint sensor detected.");
            
              while (!enrollFingerprint()) {
                Serial.println("Enrolment failed. Starting again...");
                delay(1000);
              }
            }
            
            void loop() {
              // Enrolment runs during setup.
            }

            How the Enrolment Code Works

            1. The Arduino checks whether the fingerprint sensor responds.

            2. The user places a finger on the scanner for the first capture.

            3. The sensor converts the captured image into fingerprint features.

            4. The user removes the finger and places the same finger again.

            5. The sensor compares the captures and creates a model if they match.

            6. The Arduino asks the sensor to store the model under ID 1.

            Note: This is a basic teaching example. If you run it again, it attempts to enrol ID 1 again, potentially replacing the existing template. Use a unique ID for each enrolled person in a multi-user project. The enrolment loop waits for a finger and may need a reset if communication fails during capture.

            Matching a Fingerprint with Arduino

            After enrolment, upload this separate sketch to search for the stored fingerprint. It continuously scans for a finger and reports whether the sensor finds a matching template.

            Arduino Code: Fingerprint Matching

            #include <Adafruit_Fingerprint.h>
            #include <SoftwareSerial.h>
            
            // Arduino RX, TX
            SoftwareSerial fingerSerial(2, 3);
            Adafruit_Fingerprint finger(&fingerSerial);
            
            void setup() {
              Serial.begin(9600);
              finger.begin(57600);
            
              if (!finger.verifyPassword()) {
                Serial.println("Sensor not found. Check wiring and baud rate.");
                while (true) delay(100);
              }
            
              Serial.println("Fingerprint matching is ready.");
            }
            
            void loop() {
              uint8_t result = finger.getImage();
            
              if (result == FINGERPRINT_NOFINGER) {
                delay(100);
                return;
              }
            
              if (result != FINGERPRINT_OK) {
                Serial.println("Could not capture fingerprint.");
                delay(300);
                return;
              }
            
              result = finger.image2Tz();
            
              if (result != FINGERPRINT_OK) {
                Serial.println("Could not process fingerprint.");
                delay(500);
                return;
              }
            
              result = finger.fingerFastSearch();
            
              if (result == FINGERPRINT_OK) {
                Serial.println("Fingerprint matched!");
                Serial.print("Stored ID: ");
                Serial.println(finger.fingerID);
            
                Serial.print("Match confidence: ");
                Serial.println(finger.confidence);
              } else if (result == FINGERPRINT_NOTFOUND) {
                Serial.println("No matching fingerprint found.");
              } else {
                Serial.print("Search error: ");
                Serial.println(result);
              }
            
              delay(800);
            }

            Expected Output

            When the sensor finds a stored fingerprint, the Serial Monitor displays output similar to this:

            Fingerprint matching is ready.
            Fingerprint matched!
            Stored ID: 1
            Match confidence: 120

            The ID and confidence score are examples; actual values depend on the enrolled template and scan. If the sensor cannot find a match, it reports that no matching fingerprint was found.

            The confidence value is a sensor-reported matching score, not a percentage probability of identity. Do not treat it as a standalone security guarantee.

            Troubleshooting R307 Fingerprint Sensor with Arduino

            If the sensor does not detect a finger or the Arduino cannot communicate with it, check the wiring, supply voltage, serial settings and fingerprint enrolment.

            Problem

            Possible cause

            What to do

            Did not find fingerprint sensor

            Incorrect wiring, wrong baud rate or insufficient power

            Check VCC and GND, swap TX/RX if needed, and verify the sensor's configured baud rate

            Fingerprint not detected

            Finger is not positioned correctly or the sensor window is dirty

            Clean the scanner window gently and place the finger flat over the sensing area

            Fingerprint scans but does not match

            Finger moved between scans, poor image quality or no template enrolled

            Re-enrol the same finger and ensure both captures are clear

            Communication errors

            Loose connections, unsuitable serial pins or unreliable software serial communication

            Check connections and use a supported serial interface; confirm the baud rate

            Sensor resets or behaves inconsistently

            Unstable supply or wiring

            Check the specified supply voltage and provide a stable power source

            Fingerprint ID is not found

            The template was not saved or the wrong ID was used

            Run enrolment again and confirm that the sensor reports successful storage

            The Adafruit library documentation recommends checking wiring and the TX/RX connections when the sensor is not detected. Its example sketches also report sensor parameters, including capacity and baud rate, which can help with diagnosis.

             

            Quick Checks Before Re-uploading Code

            1. Confirm the sensor's VCC and GND connections.

            2. Check that sensor TX connects to Arduino D2 and sensor RX connects to D3 for the wiring used in these examples.

            3. Set the Serial Monitor to 9600 baud.

            4. Confirm the sensor UART baud rate matches finger.begin(57600).

            5. Upload the enrolment sketch before testing fingerprint matching.

            6. If the problem persists, run the library's sensor test example to verify communication.

            R307 Fingerprint Sensor Project Ideas

            Once the sensor is communicating correctly with Arduino, you can extend the project beyond enrolment and matching.

            1. Fingerprint Attendance System

            Assign each enrolled fingerprint an ID and record the ID with a timestamp. To build a useful attendance system, add a real-time clock module or another reliable time source, and store records using an SD card or connected computer.

            2. Fingerprint-Based Door Lock

            Use a successful fingerprint match to trigger a relay or a suitable driver connected to a lock mechanism. Include a safe default state, a timeout and a manual override. Choose the switching hardware based on the lock's voltage and current requirements.

            3. Fingerprint-Controlled Locker

            Use a matched fingerprint to operate a low-voltage locking mechanism. Add status LEDs or a display to indicate whether access was granted or denied.

            4. Fingerprint Access with Raspberry Pi

            A Raspberry Pi can communicate with a compatible UART fingerprint sensor through a suitable serial interface. Software can then log events or integrate the reader into a larger access-control prototype.

            Security consideration: These projects are educational prototypes, not automatically secure access-control systems. A fingerprint match alone does not prevent every spoofing or hardware attack. Do not rely on a basic R307-and-Arduino setup as the sole security mechanism for high-risk doors, valuable assets or sensitive personal data.

             

            Conclusion

            The R307 fingerprint sensor makes it possible to add fingerprint enrolment and matching to Arduino projects without implementing fingerprint-image processing from scratch. Connect its UART pins correctly, install the Adafruit Fingerprint Sensor Library, enrol a template and then test matching using the returned fingerprint ID.

            Start with the R307 Optical Fingerprint Sensor Module, an Arduino Uno and a Jumper Wire Set. Once the basic setup works, you can expand it into an attendance logger, a locker prototype or a low-voltage access-control project.

            Excerpt

            Connect the R307 fingerprint sensor to Arduino: pinout, wiring, Adafruit library, enrolment and matching code, plus fixes for common errors.

            Frequently Asked Questions

            Frequently Asked Questions

            1. How many fingerprints can an R307 sensor store?

            The R307 is commonly specified with storage for up to 1,000 fingerprint templates, but capacity should be confirmed against the exact module's datasheet and reported sensor parameters. The number of people supported in a project also depends on how many templates you assign per person.

            2. Does the R307 work with ESP32?

            The R307 communicates over UART, so it can generally be used with an ESP32 when the power supply, UART wiring and logic-level requirements are compatible. Use an available hardware UART on the ESP32 where possible, and check the exact sensor and board specifications before connecting their pins.

            3. R307 vs R305: What is the difference?

            R307 and R305 are names used for optical fingerprint modules in the same general category. Their exact specifications, connector arrangements, firmware behaviour and compatibility can vary by manufacturer and revision. Compare the actual datasheets rather than assuming that the pinout or library settings are interchangeable.

            4. Why does it say “Did not find fingerprint sensor”?

            The message means the Arduino library could not verify communication with the sensor. Common causes include crossed or incorrect UART wiring, a missing ground connection, unsuitable power, or a mismatch between the configured and actual baud rates. Check the connections first, then run the library's sensor test sketch.

            5. Can I build an attendance system with the R307?

            Yes. Enrol each person under a unique fingerprint ID, run matching, and log the returned ID with a timestamp. An RTC module, display and storage device can extend the project. For real attendance records, include access controls, a way to correct errors and appropriate protection for biometric data.

            Prev Post
            Next Post

            Leave a comment

            Please note, comments need to be approved before they are published.

            Thanks for subscribing!

            This email has been registered!

            Shop the look

            Choose Options

            Edit Option
            Back In Stock Notification
            Compare
            Product SKU Description Collection Availability Product Type Other Details

            Choose Options

            this is just a warning
            Login
            Shopping Cart
            0 items
            FREE SHIPPING!
            ₹100 OFF
            ₹200 OFF
            ₹999
            ₹2500
            ₹4900
            WhatsApp Chat Chat