You need to be much more specific than saying "Adafruit example from IDE". It's unacceptable to be so vague. It makes it more difficult for the people trying to help you and it makes it less likely that you'll get an answer to your question. So it hurts everyone. Help us to help you.
You know exactly how you got that example but the rest of us aren't psychic so you need to tell us. Sure, I can do some Google searching and make some guesses and maybe get it right, but why should I have to do all that just because you were too lazy to provide me the information I need?
pert:
You need to be much more specific than saying "Adafruit example from IDE". It's unacceptable to be so vague. It makes it more difficult for the people trying to help you and it makes it less likely that you'll get an answer to your question. So it hurts everyone. Help us to help you.
You know exactly how you got that example but the rest of us aren't psychic so you need to tell us. Sure, I can do some Google searching and make some guesses and maybe get it right, but why should I have to do all that just because you were too lazy to provide me the information I need?
dear bert Thanks for the advice. Why would I be lazy or mysterious and I need help? ( Adafruit example) is famous example in the library " Adafruit_Fingerprint.h " for any one he use this sensor so I did not see that repeating the code again would be useful but no problem this is the Example
// using UNO
#include <Adafruit_Fingerprint.h>
// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1
// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
// comment these two lines if using hardware serial
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
uint8_t id;
void setup()
{
Serial.begin(9600);
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); }
}
}
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);
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");
return p;
}
}
ahmed_abdelsattar:
Why would I be lazy or mysterious and I need help?
How would I know?
ahmed_abdelsattar:
( Adafruit example) is famous example in the library " Adafruit_Fingerprint.h " for any one he use this sensor
So you only want help from the people who have used the sensor? And still you're playing your game of being vague for no reason. Why is it so hard for you to say "it's the example sketch named enroll"?
If you look at the documentation for the library, you will see that it was intended to be used with the fingerprint sensor sold on the Adafruit store, which is not the R307 you're using. The library documentation says:
You can also enroll new fingers directly - up to 162 finger prints can be stored in the onboard FLASH memory.
So it's unclear to me whether your fingerprint sensor can be used with this library and, if so, whether the library can be used to store the entire 1000 fingerprint capacity of your sensor.
ahmed_abdelsattar:
this is the Example
I do notice an immediate problem in the example sketch. Each data type has a limited range of values it can hold. The data type the example sketch author chose for the function that takes the fingerprint ID number from Serial Monitor is uint8_t. That is an unsigned 8 bit integer. It can store values from 0 to 255. For a sensor that can store 1000 fingerprints, that is not a suitable choice of data type. It is necessary to use an unsigned 16 bit integer data type for this application. You could use uint16_t to follow the example of the sketch, but in the Arduino world we are more familiar with the data type unsigned int, which can easily hold the range of 1 to 1000 needed for this purpose. So to make the sketch support fingerprint IDs from 1 to 1000 you need to change line 31 from:
uint8_t id;
to:
unsigned int id;
Change line 51 from:
uint8_t readnumber(void) {
to:
unsigned int readnumber(void) {
Change line 52 from:
uint8_t num = 0;
to:
unsigned int num = 0;
I didn't take a close look through all the library code to see if there are any similar limitations there, but those are at least some easy changes to make and then give a try.