How to use the AS608 Fingerprint sensor with Arduino

How to use the AS608 Fingerprint sensor with Arduino

Hello and welcome back! In this tutorial, we’ll learn how to use the AS608 Fingerprint sensor with Arduino. For that, I used the Arduino UNO board, LCD screen, LED bulb, and resistor, but you can use any other Arduino board. This tutorial is important because it can help you make biometric attendance and registration systems, Home security systems, door lock systems, safety boxes, and more, depending on your needs.

How to use the AS608 Fingerprint sensor with Arduino

AS608 Fingerprint sensor

The AS608 Fingerprint sensor is based on the AS608 chip. It captures fingerprints and sends the data to the microcontroller through serial communication. This sensor can store up to 255 fingerprint IDs, making it suitable for small projects. If you need to store more IDs, you can choose a different fingerprint module available in the market. We’ll cover more tutorials on the features of these sensors. Additionally, you can easily use this sensor with Arduino, ESP8266, and ESP32 development boards.

If you want to learn how does work fingerprint sensors deeply, please use these Wikipedia links.

How to use the AS608 Fingerprint sensor with Arduino

The working principle of this sensor

This fingerprint includes two processes. That is fingerprint registration and fingerprint matching. Also, this fingerprint matching consists of two more parts. That is fingerprint comparison (1:1) and fingerprint search (1:N). When checking fingerprints, the fingerprint image is captured by the sensor and compared with the fingerprint stored in the module. If it matches, it is called a fingerprint comparison (1:1). Otherwise, if multiple fingerprints match, it is called a fingerprint search (1:N).

Specifications of this sensor

  • Operation Voltage: 3.3v
  • Interface: TTL Serial.
  • Baud rate: (9600~57600) (default 57600).
  • Rated Current: ~120mA.
  • Fingerprint imaging time: <1.0 seconds.
  • Storage capacity: 255 templates.
  • Template file: 512 bytes.
  • False Acceptance Rate: <0.001% (Security level 3).
  • False Reject Rate: <1.0% (Security level 3).
  • Safety Level: 1~5 low to high safety.
  • Temperature: -20 – +50 degrees.
  • Sensing Window: (16×18) mm.
  • Dimension: (45.1×20.3×18.6) mm.

The wire structure of this sensor

  • Brown wire – No connection
  • Orange wire – No connection
  • White wire – No connection
  • Blue wire – No connection
  • Green wire – GND
  • Yellow wire – RXD(Serial Data Input)
  • Black wire – TXD(Serial Data Output)
  • Red wire – VCC (+3.3~5 V)

OK, let’s do it step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, let’s set up the sensor cable. It includes eight wires. But we need four wires for serial communication. (Red, Green, Black, Yellow) For that, I have soldered four Male-to-male jumper wires to it. Please use color jumper wires that match the sensor wire colors. Because you can easily identify.

Step 3

Thirdly, connect the fingerprint sensor and LCD screen(I soldered the I2C module to the LCD screen) to the Arduino UNO board. For that, use the circuit diagram below.

How to use the AS608 Fingerprint sensor with Arduino

Step 4

Next, place the LED bulb and resistor on the breadboard. Then connect it to the Arduino board.

Step 5

After that, connect the Arduino board to the computer.

How to use the AS608 Fingerprint sensor with Arduino

Step 6

Next, install the Fingerprint library. For that, follow the instructions below.

  • First, open the Arduino IDE and go to the Manage Libraries.
  • Then type “fingerprint” in the search bar and install the Adafruit Fingerprint Sensor Library file.

Step 7

OK, let’s enroll fingerprints. For that, follow the instructions below.

  • First, copy and paste the following program into the Arduino IDE. You must remember to install the I2C Liquid Crystal display library. Because I used an LCD screen.
  • I2C library — Download
  • Program and circuit diagram — Download
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Fingerprint.h>

LiquidCrystal_I2C dis(0x27, 16, 2);
SoftwareSerial mySerial(2, 3); // TX/RX
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

uint8_t id;

void setup() {
  Serial.begin(9600);
  dis.init();
  dis.backlight();
  dis.setCursor(0, 0);
  dis.print("Place finger");
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit Fingerprint sensor enrollment");

  // set the data rate for the sensor serial port
  finger.begin(57600);

  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) {
      delay(1);
    }
  }

  finger.getParameters();
}

uint8_t readnumber(void) {
  uint8_t num = 0;

  while (num == 0) {
    while (! Serial.available());
    num = Serial.parseInt();
  }
  return num;
}

void loop() { // run over and over again
  Serial.println("Ready to enroll a fingerprint!");
  Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");
  id = readnumber();
  if (id == 0) {// ID #0 not allowed, try again!
    return;
  }
  Serial.print("Enrolling ID #");
  Serial.println(id);

  while (!  getFingerprintEnroll() );
}

uint8_t getFingerprintEnroll() {

  int p = -1;
  Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
      case FINGERPRINT_OK:
        Serial.println("Image taken");
        break;
      case FINGERPRINT_NOFINGER:
        //Serial.println(".");
        break;
      case FINGERPRINT_PACKETRECIEVEERR:
        Serial.println("Communication error");
        break;
      case FINGERPRINT_IMAGEFAIL:
        Serial.println("Imaging error");
        break;
      default:
        Serial.println("Unknown error");
        break;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  Serial.println("Remove finger");
  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }
  Serial.print("ID "); Serial.println(id);
  p = -1;
  Serial.println("Place same finger again");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
      case FINGERPRINT_OK:
        Serial.println("Image taken");
        break;
      case FINGERPRINT_NOFINGER:
        //Serial.print(".");
        break;
      case FINGERPRINT_PACKETRECIEVEERR:
        Serial.println("Communication error");
        break;
      case FINGERPRINT_IMAGEFAIL:
        Serial.println("Imaging error");
        break;
      default:
        Serial.println("Unknown error");
        break;
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK converted!
  Serial.print("Creating model for #");  Serial.println(id);

  p = finger.createModel();
  if (p == FINGERPRINT_OK) {
    Serial.println("Prints matched!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    Serial.println("Fingerprints did not match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }

  Serial.print("ID "); Serial.println(id);
  dis.setCursor(0, 1);
  dis.print("ID: ");
  dis.print(id);
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    Serial.println("Stored!");
    dis.print(" Stored!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not store in that location");
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }

  return true;
}
  • Now, select the board and port. After, click the upload button.
  • Next, open the serial monitor. Now you can see the Fingerprint sensor status.
  • Then, enter your ID as you like. The library file shows that only 1 to 127 can be entered. But you can enter 1 to 255 IDs.
  • I have entered 25.
  • Next, place any finger on the sensor window. Then, follow the instructions on the serial monitor. Finally, you can store your fingerprint ID on the module.

Step 8

OK, now set up the main program.

  • First, copy and paste the following program into the Arduino IDE.
  • I2C library — Download
  • Program and circuit diagram — Download
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Fingerprint.h>
#define LED 4

SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
LiquidCrystal_I2C dis(0x27, 16, 2);

byte ID = 25; // Enter your fingerprint ID
bool Switch = true;

void setup() {
  Serial.begin(9600);
  dis.init();
  dis.backlight();
  dis.setCursor(0, 0);
  dis.print("Place finger");
  pinMode(LED, OUTPUT);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit finger detect test");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  delay(5);
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) {
      delay(1);
    }
  }

  finger.getParameters();
  finger.getTemplateCount();
  if (finger.templateCount == 0) {
    Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example.");
  }
  else {
    Serial.println("Waiting for valid finger...");
    Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
  }
}

void loop() {
  int value = getFingerprintIDez();

  if (value == ID) {
    dis.setCursor(0, 1);
    dis.print("Thank you");
    if (Switch) {
      digitalWrite(LED, HIGH);
      Switch = false;
    } else if (Switch == false) {
      digitalWrite(LED, LOW);
      Switch = true;
    }
    delay(2000);
  } else {
    dis.setCursor(0, 1);
    dis.print("         ");
  }
  delay(50);
}


// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;

  return finger.fingerID;
}
  • Next, enter your fingerprint ID. I have entered my ID as 25.
How to use the AS608 Fingerprint sensor with Arduino
  • Finally, select the board and port. After, click the upload button.
  • If you want to delete the Fingerprint IDs. Please visit the fingerprint library example.

Now, you can turn on or off the LED bulb using your fingerprint. The full video guide is below. So, we hope to see you in the next project. Have a good day.

How to use the AS608 Fingerprint sensor with Arduino

Troubleshooting

  • Check all jumper wires.
  • Check the sensor wire colors.
  • Install the Fingerprint and I2C library files.
  • Enter the correct fingerprint ID.

How to use the AS608 Fingerprint sensor with Arduino

Leave a Comment

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

Shopping Cart
Select your currency
USD United States (US) dollar
EUR Euro
Scroll to Top