Stufin
Home Quick Cart Profile

R307 Optical Fingerprint Sensor Module

Buy Now on Stufin

Sensor Type

Optical

Resolution

508 dpi

Scan Area

14.4 mm x 13.2 mm

Fingerprint Capacity

Up to 1000 templates

Recognition Speed

0.5 seconds

Power Consumption

60mA (average), 100mA (peak)

Operating Voltage

3.3V to 5V

Interface

UART, I2C, SPI

Dimensions

21.5 mm x 16.5 mm x 4.5 mm

Operating Temperature Range

-20C to 50C

Applications

The R307 Optical Fingerprint Sensor Module is suitable for a wide range of IoT applications, including

Access control systems

Smart home systems

Wearable devices

IoT devices with biometric authentication requirements

Security systems

Identity verification systems

Pin Configuration

  • R307 Optical Fingerprint Sensor Module Pinout and Connection Guide
  • The R307 Optical Fingerprint Sensor Module is a compact and high-performance fingerprint recognition module suitable for various IoT and security applications. The module features a 16-pin interface, which requires proper connection and configuration to ensure optimal performance. Below is a detailed explanation of each pin, along with a point-by-point guide on how to connect them.
  • Pinout Structure:
  • The R307 Optical Fingerprint Sensor Module has a 16-pin interface, with the following pinout structure:
  • Pin 1-4: VCC and GND
  • Pin 1: VCC (Power Supply): Connect to a 3.3V power source. Ensure a stable and regulated power supply to avoid any damage to the module.
  • Pin 2: GND (Ground): Connect to the ground pin of your microcontroller or power supply.
  • Pin 5-8: SPI Communication
  • Pin 5: SCK (Serial Clock): Connect to the clock pin of your microcontroller's SPI interface. This pin provides the clock signal for SPI communication.
  • Pin 6: MOSI (Master Out Slave In): Connect to the MOSI pin of your microcontroller's SPI interface. This pin transmits data from the microcontroller to the fingerprint sensor module.
  • Pin 7: MISO (Master In Slave Out): Connect to the MISO pin of your microcontroller's SPI interface. This pin receives data from the fingerprint sensor module and transmits it to the microcontroller.
  • Pin 8: CS (Chip Select): Connect to the CS pin of your microcontroller's SPI interface. This pin is used to select the fingerprint sensor module as the active device for SPI communication.
  • Pin 9-12: interrupts and reset
  • Pin 9: INT (Interrupt): Connect to an interrupt pin on your microcontroller. This pin generates an interrupt signal when a fingerprint is detected or when the module is ready for communication.
  • Pin 10: RST (Reset): Connect to a digital output pin on your microcontroller. This pin is used to reset the fingerprint sensor module.
  • Pin 11: NC (No Connection): Leave this pin unconnected.
  • Pin 12: NC (No Connection): Leave this pin unconnected.
  • Pin 13-16: LED indicators
  • Pin 13: LED1 (Red LED): Connect to a 3.3V power source through a current-limiting resistor (e.g., 1k). This LED indicates when the fingerprint sensor module is powered on.
  • Pin 14: LED2 (Green LED): Connect to a 3.3V power source through a current-limiting resistor (e.g., 1k). This LED indicates when a fingerprint is being scanned or recognized.
  • Pin 15: NC (No Connection): Leave this pin unconnected.
  • Pin 16: NC (No Connection): Leave this pin unconnected.
  • Connection Guide:
  • 1. Connect the VCC pin (Pin 1) to a 3.3V power source.
  • 2. Connect the GND pin (Pin 2) to the ground pin of your microcontroller or power supply.
  • 3. Connect the SCK pin (Pin 5) to the clock pin of your microcontroller's SPI interface.
  • 4. Connect the MOSI pin (Pin 6) to the MOSI pin of your microcontroller's SPI interface.
  • 5. Connect the MISO pin (Pin 7) to the MISO pin of your microcontroller's SPI interface.
  • 6. Connect the CS pin (Pin 8) to the CS pin of your microcontroller's SPI interface.
  • 7. Connect the INT pin (Pin 9) to an interrupt pin on your microcontroller.
  • 8. Connect the RST pin (Pin 10) to a digital output pin on your microcontroller.
  • 9. Connect the LED1 pin (Pin 13) to a 3.3V power source through a current-limiting resistor (e.g., 1k).
  • 10. Connect the LED2 pin (Pin 14) to a 3.3V power source through a current-limiting resistor (e.g., 1k).
  • Important Notes:
  • Ensure a stable and regulated 3.3V power supply to the module.
  • Use a logic level converter if your microcontroller operates at a voltage other than 3.3V.
  • The module requires a minimum of 10ms pulse width on the RST pin to perform a successful reset.
  • The SPI communication frequency should not exceed 1 MHz.
  • The module's SPI interface is not 5V tolerant, so ensure that your microcontroller's SPI interface operates at 3.3V or uses a logic level converter.

Code Examples

R307 Optical Fingerprint Sensor Module Documentation
Overview
The R307 Optical Fingerprint Sensor Module is a compact, high-performance fingerprint recognition module designed for various IoT applications. It features a high-resolution optical sensor, advanced image processing algorithms, and a built-in microcontroller for rapid fingerprint recognition. This module is ideal for applications requiring secure biometric authentication, such as smart locks, access control systems, and wearables.
Technical Specifications
Sensor Type: Optical Fingerprint Sensor
 Resolution: 508 dpi
 Image Area: 12.8mm x 18.2mm
 Fingerprint Recognition Speed: < 1 second
 False Acceptance Rate (FAR): < 0.001%
 False Rejection Rate (FRR): < 0.1%
 Operating Voltage: 3.3V - 5.5V
 Communication Interface: UART, I2C, SPI
Code Examples
### Example 1: Basic Fingerprint Enrollment and Verification using UART (Arduino)
In this example, we will demonstrate how to enroll a fingerprint and then verify it using the R307 module connected to an Arduino board.
Hardware Requirements:
R307 Optical Fingerprint Sensor Module
 Arduino Board (e.g., Arduino Uno)
 Breadboard and jumper wires
Software Requirements:
Arduino IDE (version 1.8.x or later)
Code:
```c++
#include <SoftwareSerial.h>
#define R307_RX 2
#define R307_TX 3
SoftwareSerial r307Serial(R307_RX, R307_TX);
void setup() {
  Serial.begin(9600);
  r307Serial.begin(9600);
}
void loop() {
  // Enroll a new fingerprint
  Serial.println("Place your finger on the sensor to enroll...");
  delay(2000);
  uint8_t enrollBuffer[256];
  int enrollSize = r307Serial.getBytes(enrollBuffer, 256);
  if (enrollSize > 0) {
    Serial.print("Enroll buffer: ");
    for (int i = 0; i < enrollSize; i++) {
      Serial.print(enrollBuffer[i], HEX);
      Serial.print(" ");
    }
    Serial.println();
  } else {
    Serial.println("Enroll failed!");
  }
// Verify the enrolled fingerprint
  Serial.println("Place your finger on the sensor to verify...");
  delay(2000);
  uint8_t verifyBuffer[256];
  int verifySize = r307Serial.getBytes(verifyBuffer, 256);
  if (verifySize > 0) {
    Serial.print("Verify buffer: ");
    for (int i = 0; i < verifySize; i++) {
      Serial.print(verifyBuffer[i], HEX);
      Serial.print(" ");
    }
    Serial.println();
    if (memcmp(enrollBuffer, verifyBuffer, enrollSize) == 0) {
      Serial.println("Fingerprint verified!");
    } else {
      Serial.println("Fingerprint verification failed!");
    }
  } else {
    Serial.println("Verify failed!");
  }
  delay(5000);
}
```
### Example 2: Fingerprint Recognition using I2C (Raspberry Pi)
In this example, we will demonstrate how to use the R307 module connected to a Raspberry Pi to recognize fingerprints.
Hardware Requirements:
R307 Optical Fingerprint Sensor Module
 Raspberry Pi (e.g., Raspberry Pi 3 or 4)
 Breadboard and jumper wires
Software Requirements:
Raspbian OS (latest version)
 Python 3.x
Code:
```python
import smbus
import time
# I2C bus number (Raspberry Pi 3 or 4)
I2C_BUS = 1
# R307 I2C address
R307_ADDRESS = 0x28
# Create an I2C bus object
bus = smbus.SMBus(I2C_BUS)
def read_fingerprint():
  # Send a command to read a fingerprint
  bus.write_byte(R307_ADDRESS, 0x01)
  time.sleep(0.5)
  # Read the fingerprint data
  fingerprint_data = bus.read_i2c_block_data(R307_ADDRESS, 0x02, 256)
  return fingerprint_data
def recognize_fingerprint(fingerprint_data):
  # Send a command to recognize a fingerprint
  bus.write_byte(R307_ADDRESS, 0x03)
  time.sleep(0.5)
  # Read the recognition result
  result = bus.read_byte(R307_ADDRESS)
  return result == 0x00
while True:
  print("Place your finger on the sensor...")
  time.sleep(2)
  fingerprint_data = read_fingerprint()
  if recognize_fingerprint(fingerprint_data):
    print("Fingerprint recognized!")
  else:
    print("Fingerprint recognition failed!")
  time.sleep(5)
```
### Example 3: Integrating with a Microcontroller (STM32) using SPI
In this example, we will demonstrate how to use the R307 module connected to an STM32 microcontroller to recognize fingerprints.
Hardware Requirements:
R307 Optical Fingerprint Sensor Module
 STM32 Microcontroller Board (e.g., STM32F103)
 Breadboard and jumper wires
Software Requirements:
Keil Vision IDE (version 5.x or later)
 STM32CubeMX (version 5.x or later)
Code:
```c
#include "stm32f1xx_hal.h"
#include "r307_spi.h"
#define R307_SPI_PORT SPI1
int main(void) {
  // Initialize the SPI port
  MX_SPI1_Init();
// Initialize the R307 module
  r307_spi_init(R307_SPI_PORT);
while (1) {
    // Read a fingerprint
    uint8_t fingerprint_data[256];
    r307_spi_read_fingerprint(R307_SPI_PORT, fingerprint_data, 256);
// Recognize the fingerprint
    uint8_t result = r307_spi_recognize_fingerprint(R307_SPI_PORT, fingerprint_data);
if (result == 0x00) {
      printf("Fingerprint recognized!
");
    } else {
      printf("Fingerprint recognition failed!
");
    }
// Wait for 5 seconds
    HAL_Delay(5000);
  }
  return 0;
}
void r307_spi_init(SPI_HandleTypeDef hspi) {
  // Initialize the SPI pins
  hspi->Instance->CR1 |= SPI_CR1_CPHA | SPI_CR1_CPOL;
  hspi->Instance->CR2 |= SPI_CR2_FRXTH;
  hspi->Instance->CR2 |= SPI_CR2_DS;
  hspi->Instance->CR2 |= SPI_CR2_FRF;
  hspi->Instance->CR2 |= SPI_CR2_LSBFIRST;
}
void r307_spi_read_fingerprint(SPI_HandleTypeDef hspi, uint8_t buffer, uint16_t length) {
  // Send a command to read a fingerprint
  uint8_t command[2] = { 0x01, 0x00 };
  HAL_SPI_Transmit(hspi, command, 2, 100);
// Read the fingerprint data
  HAL_SPI_Receive(hspi, buffer, length, 100);
}
uint8_t r307_spi_recognize_fingerprint(SPI_HandleTypeDef hspi, uint8_t buffer) {
  // Send a command to recognize a fingerprint
  uint8_t command[2] = { 0x03, 0x00 };
  HAL_SPI_Transmit(hspi, command, 2, 100);
// Read the recognition result
  uint8_t result;
  HAL_SPI_Receive(hspi, &result, 1, 100);
  return result;
}
```
These examples demonstrate how to use the R307 Optical Fingerprint Sensor Module in various contexts, including Arduino, Raspberry Pi, and STM32 microcontrollers. Note that the code may require modifications to suit your specific application and hardware setup.