Fingerprint sensor problem

I have R305 fingerprint sensor connected with arduino uno. As i run enroll sketch on arduino, it successfully detects the scanner and ask for a #id. As i enter "#0" in the serial monitor, it says to show finger.. It scans it and ask for second scan for tye same finger. After scanning the finger for second time it says "unknown error". And on running the fingerprint sketch, it doesn't recognize the finger which i have enrolled... I think this is due to the error which was generated in enroll. Please help

Fix the sketch to display the error code. Find the error code in the list of error codes to see what the sketch should have said. Fix that error.

Thanks a lot john for reply. I have checked the code and got to know that error came at time of matching the two fingerprints. It should show “Prints matched!” and in place of this it is showing “Unknown error 5”. I don’t know much about these fingerprint modules, please help me out. Here is the code:-

/*************************************************** 
  This is an example sketch for our optical Fingerprint sensor

  Designed specifically to work with the Adafruit BMP085 Breakout 
  ----> http://www.adafruit.com/products/751

  These displays use TTL Serial to communicate, 2 pins are required to 
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

uint8_t id;

uint8_t getFingerprintEnroll();

// Software serial for when you dont have a hardware serial port
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
// On Leonardo/Micro/Yun, use pins 8 & 9. On Mega, just grab a hardware serialport 
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial1);


void setup()  
{
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(500);
  
  Serial.begin(9600);
  Serial.println("Adafruit 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);
  }
}

uint8_t readnumber(void) {
  uint8_t num = 0;
  boolean validnum = false; 
  while (1) {
    while (! Serial.available());
    char c = Serial.read();
    if (isdigit(c)) {
       num *= 10;
       num += c - '0';
       validnum = true;
    } else if (validnum) {
      return num;
    }
  }
}

void loop()                     // run over and over again
{
  Serial.println("Ready to enroll a fingerprint! Please Type in the ID # you want to save this finger as...");
  id = readnumber();
  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 1");
      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 2");
      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 3");
      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 4");
      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 5"); // THIS ONE
    return p;
  }   
  
  Serial.print("ID "); Serial.println(id);
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    Serial.println("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 6");
    return p;
  }   
}

I got “Unknown error 5”.

Anyone...? Please help me out because I got stuck.. and have no idea how to make this work.

In each step there is some function is called, according to which successes or errors will be shown. In my case the functions "finger.getImage()", "finger.image2Tz(1)", "finger.getImage()", "finger.image2Tz(2)", these all functions which are used one after another, works well i.e. without any error messages but just after there is "finger.createModel()" and here after this it shows unknown error.It means that there is problem related o creating model only. I have checked this function in library's files but haven't understand much.

Ok finally I got solution. This sketch not works on Arduino's latest ide. when I tried it on ide 1.6.6, it worked.

rishabh i got the same error when i used the code inbuilt in this software itself .so can you please elaborate how to fix that error or can you please tell me about changes you made in your program

I have R305 fingerprint sensor connected with arduino uno. As i run enroll sketch on arduino, it successfully detects the scanner and ask for a #id. As i enter "#0" in the serial monitor, it says to show finger.. It scans it and ask for second scan for tye same finger. After scanning the finger for second time it says "unknown error". And on running the fingerprint sketch, it doesn't recognize the finger which i have enrolled... I think this is due to the error which was generated in enroll. Please help

check this first: http://forum.arduino.cc/index.php?topic=424755.0 It doesn't need editing the library code, its just a fault of Arduino ide version. In my case Arduino ide 1.6.10 had shown error but when the same code uploaded with Arduino ide 1.6.6, it worked. I hope this will work for you, just change the Arduino ide.

Please guide me how did you make it work Kerr I'm trying to run it but when I connect r305 with 5v power there is just a single blink of led in it then it's on and when I connect with 3.3v led is on but serial monitor shoes there is no module

Try changing the rx tx pins. In uno?

Rishabh8721: Ok finally I got solution. This sketch not works on Arduino's latest ide. when I tried it on ide 1.6.6, it worked.

Thank You! You saved my life with this information! I hope God bless you!

I have secugen hfdu04 Fingerprint scanner. but its not connect

Pls find attachment " error at the time of Enroll"
Pls help

error1.txt (2.57 KB)

Is the code uploaded in arduino? It seems like there is some problem in importing library. Or are you talking about the runtime error? Please make sure the rx tx pins and the compatible arduino ide version, the basic cause of runtime errors as per this thread.

Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
enroll:36: error: 'Adafruit_Fingerprint' does not name a type
enroll.ino: In function 'void setup()':
enroll:44: error: 'finger' was not declared in this scope
enroll.ino: In function 'uint8_t getFingerprintEnroll(uint8_t)':
enroll:75: error: 'FINGERPRINT_OK' was not declared in this scope
enroll:76: error: 'finger' was not declared in this scope
enroll:78: error: 'FINGERPRINT_OK' cannot appear in a constant-expression

It looks like you failed to include the Adafruit_Fingerprint library. Try Sketch->Include Library->Adafruit Fingerprint Sensor Library

Is it compatible with CAMA-SM20 arduino?

HI! I am also facing the same problem. I did a quick search of the manufacturer's website and they have the source code, but the .zip files have a password. Any news update!

http://www.szcamabio.com/en/product/CAMA-SM20-optical-fingerprint-reader-module.html

http://www.szcamabio.cn