Example Code for Arduino-Delete Fingerprint

Delete Fingerprint

Hardware Preparation

  • DFRduino Leonardo (or similar) x 1
  • Capacitive Fingerprint Sensor - UART (FPC Connector) × 1
  • DuPont Wires

Software Preparation

Wiring Diagram

 Wiring Diagram

Sample Code

Run the codes, and press your finger on the sensor to delete your fingerprint.

/*!
 * @file fingerprintDeletion.ino
 * @brief Delete a specific fingerprint 
 * @n Experiment phenomenon:press your finger on the sensor, if this fingerprint is registered, delete it and LED lights up green.
                If it is unregistered or fingerprint collection fails, LED lights up red.
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (https://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author [Eddard]([email protected])
 * @version  V1.0
 * @date  2020-03-19
 * @get from https://www.dfrobot.com
 * @url https://github.com/DFRobot/DFRobot_ID809
*/
#include <DFRobot_ID809.h>

/*Use software serial when using UNO or NANO*/
#if ((defined ARDUINO_AVR_UNO) || (defined ARDUINO_AVR_NANO))
    #include <SoftwareSerial.h>
    SoftwareSerial Serial1(2, 3);  //RX, TX
    #define FPSerial Serial1
#else
    #define FPSerial Serial1
#endif

DFRobot_ID809 fingerprint;
//String desc;   //Error code information, enabling this function will consume much memory

void setup(){
  /*Initialize serial port for printing*/
  Serial.begin(9600);
  /*Initialize FPSerial*/
  FPSerial.begin(115200);
  /*Use FPSerial as communication serial port of module*/
  fingerprint.begin(FPSerial);
  /*Wait for Serial to open*/
  while(!Serial);
  /*Test whether device can communicate properly with mainboard,
    Return true or false
    */
  while(fingerprint.isConnected() == false){
    Serial.println("Communication with device failed, please check connection");
    /*Get error code information*/
    //desc = fingerprint.getErrorDescription();
    //Serial.println(desc);
    delay(1000);
  }
}

void loop(){
  uint8_t ret = 0;
  /*Set fingerprint LED ring mode, color, and number of blinks,
    Can be set as follows:
    Parameter 1:<LEDMode>
    eBreathing   eFastBlink   eKeepsOn    eNormalClose
    eFadeIn      eFadeOut     eSlowBlink   
    Parameter 2:<LEDColor>
    eLEDGreen  eLEDRed      eLEDYellow   eLEDBlue
    eLEDCyan   eLEDMagenta  eLEDWhite
    Parameter 3:<Number of blinks> 0 represents blinking all the time,
    This parameter will only be valid in mode eBreathing, eFastBlink, eSlowBlink
   */
  fingerprint.ctrlLED(/*LEDMode = */fingerprint.eBreathing, /*LEDColor = */fingerprint.eLEDBlue, /*blinkCount = */0);
  Serial.println("Please press the finger on the sensor to delete the fingerprint");
  /*Capture fingerprint image, 10s idle timeout, if timeout=0, disable the collection timeout function
    If succeed return 0, otherwise return ERR_ID809
   */
  if((fingerprint.collectionFingerprint(/*timeout=*/10)) != ERR_ID809){
    /*Compare the captured fingerprint with all the fingerprints in the fingerprint library,
      Return fingerprint ID(1-80) if succeed, return 0 when failed 
     */
    ret = fingerprint.search();
    /*Compare the captured fingerprint with a fingerprint of specific ID
      Return fingerprint ID(1-80) if succeed, return 0 when failed
     */
    if(ret != 0){
      /*Delete the fingerprint of this ID*/
      fingerprint.delFingerprint(/*Fingerprint ID = */ret);
      //fingerprint.delFingerprint(DELALL);  //Delete all fingerprints 
      Serial.print("delete successful,ID=");
      Serial.println(ret);
      /*Set fingerprint LED ring to always ON in green*/
      fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDGreen, /*blinkCount = */0);
    }else{
      Serial.println("Fingerprint is unregistered");
      /*Set fingerprint LED ring to always ON in red*/
      fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDRed, /*blinkCount = */0);
    }
  }else{
    Serial.println("Capturing fails");
    /*Get error code information*/
    //desc = fingerprint.getErrorDescription();
    //Serial.println(desc);
    /*Set fingerprint LED ring to always ON in red*/
    fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDRed, /*blinkCount = */0);
  }
  Serial.println("Please release your finger");
  /*Wait for finger to release
    Return 1 when finger is detected, otherwise return 0
   */
  while(fingerprint.detectFinger());

  /*Check whether the fingerprint ID has been registered
    Return 1 if registered, otherwise return 0
   */
//  if(fingerprint.getStatusID(/*Fingerprint ID = */FINGERPRINTID)){
//    Serial.println("ID has been registered");
//  }else{
//    Serial.println("ID is unregistered");
//  }
  Serial.println("-----------------------------");
  delay(1000);
}

Result

Result

Was this article helpful?

TOP