Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

Fingerprint sensor with Arduino Mega2560
Moderators: adafruit_support_bill, adafruit

Fingerprint sensor with Arduino Mega2560

by mad76 on Sun Nov 18, 2012 5:32 pm

Hi guys,
I am wondering does anybody know if the fingerprint sensor (ID:751) works with the Arduino Mega2560. It works fine with my Arduino UNO but when i swap boards and upload the program it tells me it can't find the fingerprint sensor. any idea's ?
mad76
 
Posts: 3
Joined: Sun Nov 18, 2012 4:58 pm

Re: Fingerprint sensor with Arduino Mega2560

by franklin97355 on Sun Nov 18, 2012 7:01 pm

Have you made accomidations for the difference in pin numbers?
User avatar
franklin97355
 
Posts: 8219
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Fingerprint sensor with Arduino Mega2560

by mad76 on Sun Nov 18, 2012 7:11 pm

saw the earlier posts after putting mine up. All good now :lol:
Thanks for the reply.
mad76
 
Posts: 3
Joined: Sun Nov 18, 2012 4:58 pm

Re: Fingerprint sensor with Arduino Duemilanove

by shuhada natasha m on Mon Nov 19, 2012 4:02 pm

Hi may i ask how many ID can the fingerprint cater at one time?

and can it be reset?? cuz i enrol two different IDs (0 & 2) by placing my thumb twice .
It creates problem during matching. cuz sometimes it finds a match as 0 and sometimes as 2.

Btw im using arduino duemilanove =)
shuhada natasha m
 
Posts: 5
Joined: Thu Oct 18, 2012 10:49 pm

Re: Fingerprint sensor with Arduino Mega2560

by adafruit_support_bill on Tue Nov 20, 2012 6:49 am

The english version of the manual is available now here: http://www.adafruit.com/datasheets/ZFM% ... ualV15.pdf

adafruit_support_bill
 
Posts: 37547
Joined: Sat Feb 07, 2009 10:11 am

Re: Fingerprint sensor with Arduino Mega2560

by shuhada natasha m on Mon Dec 10, 2012 8:42 am

thanx for the manual =)

now im trying to interface the fingerprint with keypad... i wanted it to loop it and match the inserted ID with fingerprint (customKeypad == finger.fingerID) <------- i think..... but it seems there were some conflict between the fingerprint and keypad eventhough there were no errors during uploading... can somebody pls have a look at the program ive done below? i couldnt find the mistake

[Edit - moderator - please use the 'code' button when submitting code]

Code: Select all | TOGGLE FULL SIZE
void loop(){
    getFingerprintIDez();
    char customKey = customKeypad.getKey();
 
    if (customKey){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(customKey);
    lcd.setCursor(0,1);
    lcd.print("Now, fingertest");
  }

}




uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  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!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
 
}

// 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;
 



int getFingerprintIDez() {
  char customKey = customKeypad.getKey();

 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;
 
 

 if(customKey == finger.fingerID)
 {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Match ID #"); lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print("Successful");
  delay(1000);
 
  //return finger.fingerID;
 }
  else
  {
    lcd.setCursor(0,0);
    lcd.print("No Match");
    lcd.setCursor(0,1);
    lcd.print("Try Again");
   
 
   // return finger.fingerID;
  }
}
shuhada natasha m
 
Posts: 5
Joined: Thu Oct 18, 2012 10:49 pm

Re: Fingerprint sensor with Arduino Mega2560

by adafruit_support_bill on Mon Dec 10, 2012 9:02 am

What you posted does not compile. Post your entire sketch. (Use the 'code' button and paste your sketch between the tags)

adafruit_support_bill
 
Posts: 37547
Joined: Sat Feb 07, 2009 10:11 am

Re: Fingerprint sensor with Arduino Mega2560

by shuhada natasha m on Mon Dec 10, 2012 1:28 pm

heres the complete program... the numbers from keypad wouldnt appear instead the char. of lcd were juz blinking when i press the keypad... while for the thumbprint, i have actually enrolled an ID for my left thumbprint, but it didnt recognize..


Code: Select all | TOGGLE FULL SIZE
#include <Keypad.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif

#include <LiquidCrystal.h>

LiquidCrystal lcd(40, 42, 44, 46, 48, 50, 52);
int backLight = 13;

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(12, 13);
#else
NewSoftSerial mySerial(12, 13);
#endif

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','4','7','*'},
  {'2','5','8','0'},
  {'3','6','9','#'},
  {'A','B','C','D'}
};
byte rowPins[ROWS] = {31,33,35,37}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23,25,27,29}; //connect to the column pinouts of the keypad

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
  //Serial.begin(9600);
  finger.begin(57600);
   pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH);
  lcd.begin(16,2);             
  lcd.clear();                 
  lcd.setCursor(0,0);           
  lcd.print("Hello enter ID");
 // pinMode(6, OUTPUT); //RED LED
 // pinMode(7, OUTPUT); //GREEN LED
 // pinMode(13,OUTPUT); //SIREN
 
}
 
void loop(){
  getFingerprintIDez();
  digitalWrite(6,HIGH);
  digitalWrite(13,LOW);
  char customKey = customKeypad.getKey();
 
    if (customKey){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(customKey);
    lcd.setCursor(0,1);
    lcd.print("Now, fingertest");
  }
}


uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      lcd.print("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      lcd.clear();
      lcd.print("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.clear();
      lcd.print("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      lcd.clear();
      lcd.print("Imaging error");
      return p;
    default:
      lcd.clear();
      lcd.print("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      lcd.clear();
      lcd.print("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      lcd.clear();
      lcd.print("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.clear();
      lcd.print("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      lcd.clear();
      lcd.print("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      lcd.clear();
      lcd.print("Could not find fingerprint features");
      return p;
    default:
      lcd.clear();
      lcd.print("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    lcd.clear();
    lcd.print("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    lcd.clear();
    lcd.print("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    lcd.clear();
    lcd.print("Did not find a match");
    return p;
  } else {
    lcd.clear();
    lcd.print("Unknown error");
    return p;
  }   
 
  // found a match!
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Found ID #"); lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print(" with confidence of "); lcd.print(finger.confidence);
}



int getFingerprintIDez() {
  char customKey = customKeypad.getKey();

 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;
 
 

 if(customKey == finger.fingerID)
 {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Match ID #"); lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print("Successful");
  //digitalWrite(6,LOW);   //red led off
  //digitalWrite(7,HIGH);  // green led on
  //delay(1000);
 
  //return finger.fingerID;
 }
  else
  {
    lcd.setCursor(0,0);
    lcd.print("No Match      ");
    lcd.setCursor(0,1);
    lcd.print("Try Again");
   // digitalWrite(7,LOW);
    //digitalWrite(6,HIGH);
    //digitalWrite(13,HIGH);
    //delay(1000);
 
   // return finger.fingerID;
  }
}



 
 
shuhada natasha m
 
Posts: 5
Joined: Thu Oct 18, 2012 10:49 pm

Re: Fingerprint sensor with Arduino Mega2560

by adafruit_support_bill on Mon Dec 10, 2012 1:54 pm

You are reading the keypad in two places. Remove all the modifications to getFingerprintIDez() and put all your keypad and comparison logic in loop().

adafruit_support_bill
 
Posts: 37547
Joined: Sat Feb 07, 2009 10:11 am

Re: Fingerprint sensor with Arduino Mega2560

by shuhada natasha m on Mon Dec 10, 2012 9:02 pm

u mean like this???

Code: Select all | TOGGLE FULL SIZE
#include <Keypad.h>
#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif

#include <LiquidCrystal.h>

LiquidCrystal lcd(40, 42, 44, 46, 48, 50, 52);
int backLight = 13;

int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(12, 13);
#else
NewSoftSerial mySerial(12, 13);
#endif

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1','4','7','*'},
  {'2','5','8','0'},
  {'3','6','9','#'},
  {'A','B','C','D'}
};
byte rowPins[ROWS] = {31,33,35,37}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23,25,27,29}; //connect to the column pinouts of the keypad

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);


/******************************************************************/
void setup(){
  //Serial.begin(9600);
  finger.begin(57600);
   pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH);
  lcd.begin(16,2);             
  lcd.clear();                 
  lcd.setCursor(0,0);           
  lcd.print("Hello enter ID");
// pinMode(6, OUTPUT); //RED LED
// pinMode(7, OUTPUT); //GREEN LED
// pinMode(13,OUTPUT); //SIREN

}


/********************************************************************/ 


void loop(){
  //getFingerprintIDez();
 // digitalWrite(6,HIGH);
  //digitalWrite(13,LOW);
  char customKey = customKeypad.getKey();
 
    /*if (customKey){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(customKey);
    lcd.setCursor(0,1);
    lcd.print("Now, fingertest");
  }*/
 
  if(customKey == finger.fingerID)
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Match ID #"); lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print("Successful");
  //digitalWrite(6,LOW);   //red led off
  //digitalWrite(7,HIGH);  // green led on
  //delay(1000);
 
  //return finger.fingerID;
}
  else
  {
    lcd.setCursor(0,0);
    lcd.print("No Match      ");
    lcd.setCursor(0,1);
    lcd.print("Try Again");
   // digitalWrite(7,LOW);
    //digitalWrite(6,HIGH);
    //digitalWrite(13,HIGH);
    //delay(1000);
 
   // return finger.fingerID;
  }
}

/*****************************************************************/

/************************************************************************************/


int getFingerprintIDez() {
 

 uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      lcd.print("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      lcd.clear();
      lcd.print("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.clear();
      lcd.print("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      lcd.clear();
      lcd.print("Imaging error");
      return p;
    default:
      lcd.clear();
      lcd.print("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      lcd.clear();
      lcd.print("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      lcd.clear();
      lcd.print("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      lcd.clear();
      lcd.print("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      lcd.clear();
      lcd.print("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      lcd.clear();
      lcd.print("Could not find fingerprint features");
      return p;
    default:
      lcd.clear();
      lcd.print("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    lcd.clear();
    lcd.print("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    lcd.clear();
    lcd.print("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    lcd.clear();
    lcd.print("Did not find a match");
    return p;
  } else {
    lcd.clear();
    lcd.print("Unknown error");
    return p;
  }   
 
  // found a match!
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Found ID #"); lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print(" with confidence of "); lcd.print(finger.confidence);
}
 
 






 
 
shuhada natasha m
 
Posts: 5
Joined: Thu Oct 18, 2012 10:49 pm

Re: Fingerprint sensor with Arduino Mega2560

by adafruit_support_bill on Tue Dec 11, 2012 7:21 am

You still have to call getFingerprintIDez() in your loop to read the fingerprint.

adafruit_support_bill
 
Posts: 37547
Joined: Sat Feb 07, 2009 10:11 am

Re: Fingerprint sensor with Arduino Mega2560

by shuhada natasha m on Tue Dec 18, 2012 9:49 pm

hi i think i've got it... im trying to call the fingerprint sensor after entering password.
the problem is juz that after i break the password using * key, the sensor illuminates <1.0sec.
how do i get it illuminate in a longer time, without pressing the * button many times.
here;s my new code

Code: Select all | TOGGLE FULL SIZE
#include <Password.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(40, 42, 44, 46, 48, 50, 52);

#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif

Password password = Password( "C141516" );

const byte ROWS = 4; // Four rows
const byte COLS = 4; //  columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','4','7','*'},
  {'2','5','8','0'},
  {'3','6','9','#'},
  {'A','B','C','D'}
};

byte rowPins[ROWS] = {31,33,35,37}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {23,25,27,29}; //connect to the column pinouts of the keypad


// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int alarm_var = 0;


int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
#if ARDUINO >= 100
SoftwareSerial mySerial(12, 13);
#else
NewSoftSerial mySerial(12, 13);
#endif

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
/*SETUP****************************************************************************************/

void setup()
{
  lcd.begin(16, 2);
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
  lcd.clear();
  lcd.print("Password:");
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(9,OUTPUT);
  finger.begin(57600);
  //digitalWrite(11,HIGH);
}

/************************************************************************************/

void loop()
{
  //digitalWrite(11,HIGH);
  //digitalWrite(9,LOW);
  if (digitalRead(11)==LOW)
  {
    digitalWrite(9,HIGH);
    lcd.clear();
    lcd.print("INTRUDER!!");
    delay(1000000);
    digitalWrite(9,LOW);
  }
   
  if(alarm_var < 3)
  {
    keypad.getKey();
  }
 
}



/************************************************************************/

//take care of some special events
void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
    case PRESSED:
       
   //lcd.print("");
   lcd.print(eKey);
   switch (eKey){
     case '*': checkPassword(); break;
     case '#': password.reset(); break;
     default: password.append(eKey);
     }
  }
}

void checkPassword(){
  if (password.evaluate()){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Success!");
    lcd.setCursor(0,1);
    lcd.print("Now scan finger ");
   
   getFingerprintIDez();
    //delay(1000);
  }
  else{
    alarm_var = alarm_var + 1;
   //for (i=0; i>3; i++);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Wrong");
    if (alarm_var >= 3)
    {
      lcd.setCursor(0,0);
      lcd.print("Wrong 3 times");
      lcd.setCursor(0,1);
      lcd.print("Alarm Activated");
      digitalWrite(9,HIGH);
     
      //alarm_var = 0;
    }
    else
    {
      delay(1000);
      lcd.clear();
      lcd.print("Password:");
      password.reset();
    }
  }
 
}

 
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;
 
  // found a match!
  digitalWrite(11,LOW); // switch OFF red LED
  digitalWrite(10, HIGH); //switch ON green LED
  delay(1000);
  digitalWrite(10,LOW);// switch OFF green LED
  digitalWrite(9,HIGH); // switch ON alarm
  delay(100);
  digitalWrite(9,LOW);
 
 
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Match ID #");
  lcd.print(finger.fingerID);
  lcd.setCursor(0,1);
  lcd.print("Accepted ");
  return finger.fingerID;
  //delay(100);
}
shuhada natasha m
 
Posts: 5
Joined: Thu Oct 18, 2012 10:49 pm

Re: Fingerprint sensor with Arduino Mega2560

by adafruit_support_bill on Wed Dec 19, 2012 7:23 am

Code: Select all | TOGGLE FULL SIZE
    while(getFingerprintIDez() == -1)
    {
    }

Will loop until it gets a valid fingerprint reading.

adafruit_support_bill
 
Posts: 37547
Joined: Sat Feb 07, 2009 10:11 am