1. I am using Uno, finger print module & Adafruit library.
2. With using all the library all the function works ok, like delete, scan but i have some issues in Enroll function.
3. Enroll function is below, it is same, except some minor changes & I had a small key_read function, in case user wants to exit. key_read is small non-blocking function, read a variable only, which get set/reset in ISR only, so minimal code there.
4. Problem is :
a) When first scan is done, it is ok.
b) next it ask for remove finger & place again.
c) now doing that & place finger again, code many times gives finger mismatch.
d) 9 out of 10 times it is giving mismatch . Although I am doing the same way every-time.
5. Same happens if I use En-roll example from Adafruit also.
6. What could be the error?
7. One possible error I think in Adafruit library there is variable "confidence", which check the matching level of both. Might be it is set to very high value, but in library I didn't find where to set it low.
uint8_t add_fingerprint_id(uint16_t id , uint8_t *r_key)
{
uint8_t point = 255U;
uint8_t key = no_key;
uint8_t breakloop;
uint8_t next = 0U;
lcd.setCursor(0 , 3);
lcd_string_const(add_place_str);
serial_string_nl_const(add_place_str);
/* clear key vars */
clear_key_vars();
breakloop = 0U;
while(0U == breakloop)
{
point = finger.getImage();
switch(point)
{
case FINGERPRINT_OK:
lcd.setCursor(0 , 3);
lcd_string_const(add_taken_str);
serial_string_nl_const(add_taken_str);
breakloop = 1U;
break;
case FINGERPRINT_NOFINGER:
lcd.setCursor(0 , 3);
lcd_string_const(add_no_finger_str);
serial_string_nl_const(add_no_finger_str);
break;
case FINGERPRINT_PACKETRECIEVEERR:
lcd.setCursor(0 , 3);
lcd_string_const(add_comm_err_str);
serial_string_nl_const(add_comm_err_str);
break;
case FINGERPRINT_IMAGEFAIL:
lcd.setCursor(0 , 3);
lcd_string_const(add_image_err_str);
serial_string_nl_const(add_image_err_str);
break;
default:
lcd.setCursor(0 , 3);
lcd_string_const(add_unknown_err_str);
serial_string_nl_const(add_unknown_err_str);
break;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
if(0U == next)
{
lcd.setCursor(0 , 3);
breakloop = 0U;
point = finger.image2Tz(1);
switch(point)
{
case FINGERPRINT_OK:
lcd_string_const(add_image_conv_str);
serial_string_nl_const(add_image_conv_str);
breakloop = 1U;
break;
case FINGERPRINT_IMAGEMESS:
lcd_string_const(add_image_messy_str);
serial_string_nl_const(add_image_messy_str);
next = 1U;
break;
case FINGERPRINT_PACKETRECIEVEERR:
lcd_string_const(add_comm_err_str);
serial_string_nl_const(add_comm_err_str);
next = 1U;
break;
case FINGERPRINT_FEATUREFAIL:
lcd_string_const(add_no_feature_str);
serial_string_nl_const(add_no_feature_str);
next = 1U;
break;
case FINGERPRINT_INVALIDIMAGE:
lcd_string_const(add_no_feature_str);
serial_string_nl_const(add_no_feature_str);
next = 1U;
break;
default:
lcd_string_const(add_unknown_err_str);
serial_string_nl_const(add_unknown_err_str);
next = 1U;
break;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
if(0U == next)
{
lcd.setCursor(0 , 3);
lcd_string_const(add_remove_str);
serial_string_nl_const(add_remove_str);
delay(2000);
point = 0U;
breakloop = 0U;
while(0U == breakloop)
{
point = finger.getImage();
if(FINGERPRINT_NOFINGER == point)
{
breakloop = 1U;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
}
if(0U == next)
{
lcd.setCursor(0 , 3);
lcd_string_const(add_again_str);
serial_string_nl_const(add_again_str);
point = 255U;
lcd.setCursor(0 , 3);
breakloop = 0U;
while(0U == breakloop)
{
point = finger.getImage();
switch(point)
{
case FINGERPRINT_OK:
lcd.setCursor(0 , 3);
lcd_string_const(add_taken_str);
serial_string_nl_const(add_taken_str);
breakloop = 1U;
break;
case FINGERPRINT_NOFINGER:
lcd.setCursor(0 , 3);
lcd_string_const(add_no_finger_str);
serial_string_nl_const(add_no_finger_str);
break;
case FINGERPRINT_PACKETRECIEVEERR:
lcd.setCursor(0 , 3);
lcd_string_const(add_comm_err_str);
serial_string_nl_const(add_comm_err_str);
break;
case FINGERPRINT_IMAGEFAIL:
lcd.setCursor(0 , 3);
lcd_string_const(add_image_err_str);
serial_string_nl_const(add_image_err_str);
break;
default:
lcd.setCursor(0 , 3);
lcd_string_const(add_unknown_err_str);
serial_string_nl_const(add_unknown_err_str);
break;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
}
if(0U == next)
{
lcd.setCursor(0 , 3);
breakloop = 0U;
point = finger.image2Tz(2);
switch(point)
{
case FINGERPRINT_OK:
lcd_string_const(add_image_conv_str);
serial_string_nl_const(add_image_conv_str);
breakloop = 1U;
break;
case FINGERPRINT_IMAGEMESS:
lcd_string_const(add_image_messy_str);
serial_string_nl_const(add_image_messy_str);
next = 1U;
break;
case FINGERPRINT_PACKETRECIEVEERR:
lcd_string_const(add_comm_err_str);
serial_string_nl_const(add_comm_err_str);
next = 1U;
break;
case FINGERPRINT_FEATUREFAIL:
lcd_string_const(add_no_feature_str);
serial_string_nl_const(add_no_feature_str);
next = 1U;
break;
case FINGERPRINT_INVALIDIMAGE:
lcd_string_const(add_no_feature_str);
serial_string_nl_const(add_no_feature_str);
next = 1U;
break;
default:
lcd_string_const(add_unknown_err_str);
serial_string_nl_const(add_unknown_err_str);
next = 1U;
break;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
if(0U == next)
{
lcd.setCursor(0 , 3);
lcd_string_const(add_create_str);
serial_string_nl_const(add_create_str);
lcd.setCursor(0 , 3);
point = finger.createModel();
if(FINGERPRINT_OK == point)
{
lcd_string_const(add_match_str);
serial_string_nl_const(add_match_str);
}
else if(FINGERPRINT_PACKETRECIEVEERR == point)
{
lcd_string_const(add_comm_err_str);
serial_string_nl_const(add_comm_err_str);
next = 1U;
}
else if(FINGERPRINT_ENROLLMISMATCH == point)
{
lcd_string_const(add_mismatch_str);
serial_string_nl_const(add_mismatch_str);
next = 1U;
}
else
{
lcd_string_const(add_unknown_err_str);
serial_string_nl_const(add_unknown_err_str);
next = 1U;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
if(0U == next)
{
lcd.setCursor(0 , 3);
point = finger.storeModel(id);
if(FINGERPRINT_OK == point)
{
lcd_string_const(add_store_str);
serial_string_nl_const(add_store_str);
}
else if(FINGERPRINT_PACKETRECIEVEERR == point)
{
lcd_string_const(add_comm_err_str);
serial_string_nl_const(add_comm_err_str);
next = 1U;
}
else if(FINGERPRINT_BADLOCATION == point)
{
lcd_string_const(add_not_store_str);
serial_string_nl_const(add_not_store_str);
next = 1U;
}
else if(FINGERPRINT_FLASHERR == point)
{
lcd_string_const(add_flash_err_str);
serial_string_nl_const(add_flash_err_str);
next = 1U;
}
else
{
lcd_string_const(add_unknown_err_str);
serial_string_nl_const(add_unknown_err_str);
next = 1U;
}
/* read the key */
key = key_read();
if(EXIT_KEY == key)
{
breakloop = 1U;
next = 1U;
}
}
if(EXIT_KEY == key)
{
*r_key = EXIT_KEY;
}
else
{
*r_key = no_key;
}
delay(2000);
return point;
} /* function ends here */