adafruit / Adafruit-Fingerprint-Sensor-Library

Arduino library for interfacing to the fingerprint sensor in the Adafruit shop
http://www.adafruit.com/products/751
Other
402 stars 335 forks source link

Function to send templates from your controller to the sensor #36

Open ricarduscat opened 6 years ago

ricarduscat commented 6 years ago
uint8_t Adafruit_Fingerprint::downloadModel(uint16_t id, uint8_t packet_1[], uint8_t packet_2[], uint8_t slot) {
  uint8_t packet[] = {FINGERPRINT_DOWNLOAD, slot};
  writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet);
  uint8_t len = getReply(recvPacket);

  if ((len != 1) && (recvPacket[0] != FINGERPRINT_ACKPACKET))
   return -1;
  if (recvPacket[1] == 0x00) {
    writePacket(theAddress, FINGERPRINT_DATAPACKET, 130, packet_1);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, 130, packet_2);
    return recvPacket[1];
  } else {
    return recvPacket[1];
  }
}

I made this with the latest version of the code. I need to put templates back to the sensor when I free the memory. The documention of the sensor says it's allowed, but not implemented in the library. This does not work, it will be fine to improve the library.

marianodato commented 6 years ago

This function worked for you? Did you find another solution?

ricarduscat commented 6 years ago

Yes, but I had to touch the fingerprint sensor packet size to adapt it to the datapackets I was sending

marianodato commented 6 years ago

@ricarduscat could you explain how to do that?

milindrc commented 5 years ago

@ricarduscat please explain the parameter you need to pass to this function.

sand007man commented 5 years ago

i am able to enroll ,search fingerprint but when i load show_fingperprint _template it is showing some "??" values in the serial monitor . even small help will be greatly appreciated . I am using this fingerprint with node_mcu esp 12e...i feel its something related to memory buffer !!

hanifizzudinrahman commented 5 years ago

recvPacket

what is "recvPacket"? the last packet, or what?

jimmygyl commented 5 years ago

i am able to enroll ,search fingerprint but when i load show_fingperprint _template it is showing some "??" values in the serial monitor . even small help will be greatly appreciated . I am using this fingerprint with node_mcu esp 12e...i feel its something related to memory buffer !!

Try using larger buffer for the software serial something like SoftwareSerial mySerial(D7, D8, false, 1024);

default is 64bytes packages of template are 128bytes+11bytes maybe it got overwritten

shreeramkulkarni commented 4 years ago
uint8_t Adafruit_Fingerprint::downloadModel(uint16_t id, uint8_t packet_1[], uint8_t packet_2[], uint8_t slot) {
  uint8_t packet[] = {FINGERPRINT_DOWNLOAD, slot};
  writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet);
  uint8_t len = getReply(recvPacket);

  if ((len != 1) && (recvPacket[0] != FINGERPRINT_ACKPACKET))
   return -1;
  if (recvPacket[1] == 0x00) {
    writePacket(theAddress, FINGERPRINT_DATAPACKET, 130, packet_1);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, 130, packet_2);
    return recvPacket[1];
  } else {
    return recvPacket[1];
  }
}

I made this with the latest version of the code. I need to put templates back to the sensor when I free the memory. The documention of the sensor says it's allowed, but not implemented in the library. This does not work, it will be fine to improve the library.

@ricarduscat If possible can you please expand on this code ?(What are the parameters..etc). Is there any other way where I can load the templates from one sensor to other sensor. BTW I am using R307.

hanifizzudinrahman commented 4 years ago
uint8_t Adafruit_Fingerprint::downloadModel(uint16_t id, uint8_t packet_1[], uint8_t packet_2[], uint8_t slot) {
  uint8_t packet[] = {FINGERPRINT_DOWNLOAD, slot};
  writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet);
  uint8_t len = getReply(recvPacket);

  if ((len != 1) && (recvPacket[0] != FINGERPRINT_ACKPACKET))
   return -1;
  if (recvPacket[1] == 0x00) {
    writePacket(theAddress, FINGERPRINT_DATAPACKET, 130, packet_1);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, 130, packet_2);
    return recvPacket[1];
  } else {
    return recvPacket[1];
  }
}

I made this with the latest version of the code. I need to put templates back to the sensor when I free the memory. The documention of the sensor says it's allowed, but not implemented in the library. This does not work, it will be fine to improve the library.

@ricarduscat If possible can you please expand on this code ?(What are the parameters..etc). Is there any other way where I can load the templates from one sensor to other sensor. BTW I am using R307.

i suggest you to read this post https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library/issues/9

i have written on there, how to send template fingerprint to module fingerprint

adityadate1997 commented 4 years ago

I want to download and store the template in my server datatabase, I am using NodeMCU and Php with mysql on server side. This function is not provided in the library. Can anybody please guide me on this?

hanifizzudinrahman commented 4 years ago

I want to download and store the template in my server datatabase, I am using NodeMCU and Php with mysql on server side. This function is not provided in the library. Can anybody please guide me on this?

of course, i can help you. NodeMCU i think can use as Arduino, so it can be work with module fingerprint R307 or DY50

adityadate1997 commented 4 years ago

I want to download and store the template in my server datatabase, I am using NodeMCU and Php with mysql on server side. This function is not provided in the library. Can anybody please guide me on this?

of course, i can help you. NodeMCU i think can use as Arduino, so it can be work with module fingerprint R307 or DY50

Can we connect through an email? I'll send in the required code for you to see.

hanifizzudinrahman commented 4 years ago

yes, you can see my profile to get my new phone number or email

adityadate1997 commented 4 years ago

Sir, we have downloaded the fingerprint template data from the module r305 using the show_finger_template library. It gives us an array of size 512....we want to compare this stored array on server side. What exactly do we need to do? We tried comparing the array byte by byte but it does not give proper output. Can you guide us on how to match these templates sir.

Thank you.

On Sat, 14 Mar 2020, 17:06 Hanif Izzudin Rahman, notifications@github.com wrote:

yes, you can see my profile to get my new phone number or email

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library/issues/36#issuecomment-599044581, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOKPALFHY4UX5XM4EOMG553RHNT2FANCNFSM4EIRSJTA .

rodrigotabsan commented 4 years ago

Hello adityadate1997,

You need to store the template into your fingerprint sensor and compare it with the fingerprint that the sensor is receiving from the user. Probably, you will need to store templates from a database to the database of the sensor to check the fingerprint that your sensor has received and compare it with the fingerprints of the database.

Good luck

shreeramkulkarni commented 4 years ago

@rodrigotabsan Are you able to get the templates out from the sensor and store those templates into another sensor's flash memory? If so what sensor are you using ? I'm also trying to achieve the same thing using NodeMCU and R307.

rodrigotabsan commented 4 years ago

@shreeramk1998 I didn't try that. I can't get the fingerprint template I have stored in an external database to match the one I put on the sensor. I'm not sure this can be done... I've been working on this for several months with no results.

6000850 commented 3 years ago

Hello This is the 3-finger pattern output stored in the module I have saved these templates in the server database. Can I restore these templates to another module (fingerprint) and be usable?

Attempting to load #1
Template 1 loaded
Attempting to get #1
Template 1 transferring:
534 bytes read.
Decoding packet...
FFFFFFFFFFFFFFFFFF09144BAE6B8A6845BEBE6E4D9D4272AA7B0C76BA77947A95EF9C7EB5E1A482ABC7D90DE993A30F54445703636883651396377E32A45E204D00EF0B091E0E7A7C98780A16A94E3047C3190CC0605F70DF82D390C61C921441F152FFBD1DDF57721022EA517970EE836D7086133DB05673935C1A141675D6504177F6000000003753EF01FFFFFFFF02008200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFD6EF01FFFFFFFF020082CB091455A6AB826425BE9E6E0D9D6272AA7B8C76BA77947A95EF9C7EB5E1A482ABC7590DEB973F378BC79A52D96E2F71B2907F7B42B8AD68EA6844BD85CE3C77C758AEEE5BA97F2ECAC12AD8CB7AFF74DDB03E1AA4F85C947949B472FE2C1F7F233F2D3C4A67EFCE93E63ECA302BB15A3516C04229C675D6C30F77F6000000004076EF01FFFFFFFF080082CB09144BAE6B8A6845BEBE6E4D9D4272AA7B0C76BA
done.
------------------------------------
Attempting to load #2
Template 2 loaded
Attempting to get #2
Template 2 transferring:
534 bytes read.
Decoding packet...
FFFFFFFFFFFFFFFFFF091852A1AA859405C6BE60CDAD0274AB5B0D74B937157556E72BC15598B7B4BA8439B2062970051716C200C3C9425E2D8D2AB7DFE33AD4A78F004DB69EA401FEF01FFFFFFFF020082DC95A39E80F4FAAE6BDCFEEE00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFAFEF01FFFFFFFF020082CB091B4FA26B826805B69E6E0D9D4272AA7B8C76BA77147A97EF1C7EB5E1A482ABC75909E9937B209045F75FF86F876003928D7C02A0445BA770BD45489EA73A5ED96F82C1797F80F8C38EEC44626FBC898E54BA20E0B59AAEC0722667BFB1E1B7DB3CC7D3EEFD5433683A26C94A6FCE05DA69D654287A3A06596BC785FCCBB74230EF01FFFFFFFF080082CB091852A1AA859405C6BE60CDAD0274AB5B0D74B9371578936F1D78B3E22584A7C95A11E7AB773FF847AE2C086D5A651390556E72BC1550EA68C44049DE07C1DB399AA64378E9D8CBC1DEC24E666D98B7B4BA8439FCF8
done.
Attempting to load #3
Template 3 loaded
Attempting to get #3
Template 3 transferring:
534 bytes read.
Decoding packet...
FFFFFFFFFFFFFFFFFF091A59BE4BFA6CC5A6FE6CCC8D8272A97B0D76B977157A93E5989C1802BC050F275855AF56A8FCBA692308EAB8C748CA430B384B17E3C87CF78BD7383E8629F68C2AE972222B5F230B8D5D634CCEFAEC69ADE5ABE1FFCFA41F0EF01FFFFFFFF0200825FFDFADD8565A01605E9A93E7318022FCED30C6F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFF8EEF01FFFFFFFF020082CB09175EAE2BBA6C45B6FE6CCD9D0272A97B0D76B977157A93EF1D7EB3E12582AFC55801EF9B3303F344E23D536F7E10239C541372B0B7746940F56E68EE7D3586992A6E9B2AA9504344DF464A68B8E2DF8E118CAA9432BECC28F79A804E3D83C738B80B3AE8FC1790407E70BB216FC28A564332FB3945BA191BDA4B669A54DE3D14EF01FFFFFFFF080082CB091A59BE4BFA6CC5A6FE6CCC8D8272A97B0D76B977157A93EF1D7CB3E02580A7C15A01E78B0F1F79C48608736FF63B95989C1802BC050F275854038
done.

please guide me Thanks

hanifizzudinrahman commented 3 years ago

Do it with example code "Upload", so the template will move to another module fingerprint

On Fri, Apr 16, 2021 at 12:43 AM 6000850 @.***> wrote:

Hello This is the 3-finger pattern output stored in the module I have saved these templates in the server database. Can I restore these templates to another module (fingerprint) and be usable?

Attempting to load #1 Template 1 loaded Attempting to get #1 Template 1 transferring: 534 bytes read. Decoding packet... FFFFFFFFFFFFFFFFFF09144BAE6B8A6845BEBE6E4D9D4272AA7B0C76BA77947A95EF9C7EB5E1A482ABC7D90DE993A30F54445703636883651396377E32A45E204D00EF0B091E0E7A7C98780A16A94E3047C3190CC0605F70DF82D390C61C921441F152FFBD1DDF57721022EA517970EE836D7086133DB05673935C1A141675D6504177F6000000003753EF01FFFFFFFF02008200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFD6EF01FFFFFFFF020082CB091455A6AB826425BE9E6E0D9D6272AA7B8C76BA77947A95EF9C7EB5E1A482ABC7590DEB973F378BC79A52D96E2F71B2907F7B42B8AD68EA6844BD85CE3C77C758AEEE5BA97F2ECAC12AD8CB7AFF74DDB03E1AA4F85C947949B472FE2C1F7F233F2D3C4A67EFCE93E63ECA302BB15A3516C04229C675D6C30F77F6000000004076EF01FFFFFFFF080082CB09144BAE6B8A6845BEBE6E4D9D4272AA7B0C76BA done.

Attempting to load #2 Template 2 loaded Attempting to get #2 Template 2 transferring: 534 bytes read. Decoding packet... FFFFFFFFFFFFFFFFFF091852A1AA859405C6BE60CDAD0274AB5B0D74B937157556E72BC15598B7B4BA8439B2062970051716C200C3C9425E2D8D2AB7DFE33AD4A78F004DB69EA401FEF01FFFFFFFF020082DC95A39E80F4FAAE6BDCFEEE00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFAFEF01FFFFFFFF020082CB091B4FA26B826805B69E6E0D9D4272AA7B8C76BA77147A97EF1C7EB5E1A482ABC75909E9937B209045F75FF86F876003928D7C02A0445BA770BD45489EA73A5ED96F82C1797F80F8C38EEC44626FBC898E54BA20E0B59AAEC0722667BFB1E1B7DB3CC7D3EEFD5433683A26C94A6FCE05DA69D654287A3A06596BC785FCCBB74230EF01FFFFFFFF080082CB091852A1AA859405C6BE60CDAD0274AB5B0D74B9371578936F1D78B3E22584A7C95A11E7AB773FF847AE2C086D5A651390556E72BC1550EA68C44049DE07C1DB399AA64378E9D8CBC1DEC24E666D98B7B4BA8439FCF8 done. Attempting to load #3 Template 3 loaded Attempting to get #3 Template 3 transferring: 534 bytes read. Decoding packet... FFFFFFFFFFFFFFFFFF091A59BE4BFA6CC5A6FE6CCC8D8272A97B0D76B977157A93E5989C1802BC050F275855AF56A8FCBA692308EAB8C748CA430B384B17E3C87CF78BD7383E8629F68C2AE972222B5F230B8D5D634CCEFAEC69ADE5ABE1FFCFA41F0EF01FFFFFFFF0200825FFDFADD8565A01605E9A93E7318022FCED30C6F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFF8EEF01FFFFFFFF020082CB09175EAE2BBA6C45B6FE6CCD9D0272A97B0D76B977157A93EF1D7EB3E12582AFC55801EF9B3303F344E23D536F7E10239C541372B0B7746940F56E68EE7D3586992A6E9B2AA9504344DF464A68B8E2DF8E118CAA9432BECC28F79A804E3D83C738B80B3AE8FC1790407E70BB216FC28A564332FB3945BA191BDA4B669A54DE3D14EF01FFFFFFFF080082CB091A59BE4BFA6CC5A6FE6CCC8D8272A97B0D76B977157A93EF1D7CB3E02580A7C15A01E78B0F1F79C48608736FF63B95989C1802BC050F275854038 done.

please guide me Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library/issues/36#issuecomment-820613492, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMXTE4WJMMNPT4HTXP26MDTI4QT5ANCNFSM4EIRSJTA .

a2br commented 3 years ago

I want to download and store the template in my server datatabase, I am using NodeMCU and Php with mysql on server side. This function is not provided in the library. Can anybody please guide me on this?

of course, i can help you. NodeMCU i think can use as Arduino, so it can be work with module fingerprint R307 or DY50

Can we connect through an email? I'll send in the required code for you to see.

I'd be really interested to find out how you did that. Could you please reach out to me or make what you learned public by any means?

mlinaje commented 2 years ago

After reading all the datasheets I have found. Does someone knows if the template/signature of the fingerprint format follows some kind of standard such as ISO, ANSI,...? Thanks in advance!

Dygear commented 2 years ago

So, I read the datasheet, looks like this uses the DownImage function documented here on page 19. You can also upload an image to the sensor with UpImage (found on page 18.)

The images themselves and the formatting used are documented on page 8 (under the title 4.1.1 Image Buffer) says that the captured images are 256x288 pixels in size.

When uploading or downloading images though the UART port, in order to speed up the speed, only the upper four bits of the pixel byte are used that is, 16-level grayscale is used, and each byte represents two pixels (the high four bits are one pixel, and the low four bits are the same. A pixel in the next adjacent column of the row, that is to pixels are combined into one byte and transmitted). Since the image is16 grayscale levels, uploaded to PC When displaying (corresponding to BMP format), the grayscale should be expanded (expanded to 256 grayscale, i.e. 8bit bitmap format.) Transmission though the USB port is a full 8-bit pixel, that is, 256 gray levels.

What I think is needed is for the image to tz function Img2Tz page 19 again, after capturing / sending two images with that function it stores the first image in CharBuffer1 and CharBuffer2. Then you can run the RegModel function (page 20) that takes the contents of CharBuffer1 and CharBuffer1 and tries to make a template model out of it.

On page 21 it looks like you can straight up take the template model (they are now calling it characteristics) and "upload" that to the host computer. On page 21 again it has the DownChar function that allows you to download into the characestirics buffers and then you can save them into the flash memory with the store function call.

I think the only functions you really need are the UpChar, DownChar and Store functions in order to sync a database across multiple devices and have it return the same position ID. If they became out of sync you can always delete the database and copy one fingerprint reader to another using the Empty function (documented on page 24).

Edit: I call all of these functions, but really they are called "Instructions" in the document parlance.

AsifKhan991 commented 2 years ago

I was also in need of such functionalities (to read, save and write back template data to similar sensor models) and thus came up with an update to the existing library. @Dygear what you said is correct. I have a pull request pending about this. Please checkout my repository about this update. Also checkout the changes I've made.

However, keep in mind that writing template data from one model to another won't serve the purpose as different sensor models might use different template matching algorithms.

Hope I was able to help!

Gitare420 commented 2 years ago

Hi, I'm having trouble pasting the template.

get.template gives me this

57,1,7E,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,F,0,2,0,83,0,0,30,C,F3,33,F3,CF,FF,FE,EF,FF,FB,FB,EE,EF,EA,AA,AA,A9,95,66,59,55,55,65,55,55,51,54,40,44,4,40,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,. 3E,8A,EC,DE,4E,8B,57,1E,33,9D,52,BE,58,21,3,7E,46,A3,42,9E,24,A7,50,1E,5B,AA,46,1E,2E,2C,4F,9E,33,B9,27,3E,33,C2,E,7E,3E,8F,0,FF,6B,14,19,5F,51,14,D7,9F,4D,A5,17,FF,21,B6,E5,3F,48,37,95,1F,67,BB,DD,BF,25,41,CE,7F,57,C2,C7,9F,40,C3,9,BF,4D,43,88,DF,3B,2B,52,FA,36,2C,69,78,26,C6,4F,1E,38,50,4D,3C,3E,C6,D,DA,2A,50,A4,18,4A,D1,7,78,3D,C9,4D,99,42,C9,C9,B9,5A,4B,8,B9,42,CE,C,39,. 46,51,9,99,59,CD,9F,F5,59,CE,8,55,2E,50,65,95,2E,D0,8E,D5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,. 3,3,56,17,0,1,20,1,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,F,0,2,0,77,0,0,30,C,F3,33,F3,CF,FF,FE,EF,FF,EF,BB,BA,AA,AA,AA,AA,65,55,55,95,55,55,45,51,10,44,4,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.

and I paste it in write_to_sensor like this

uint8_t fingerTemplate[512] = {3, 3, 58, 25, 14, 1, 57, 1, 7E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, F, 0, 2, 0, 83, 0, 0, 30, C, F3, 33, F3, CF, FF, FE, EF, FF, FB, FB, EE, EF, EA, AA, AA, A9, 95, 66, 59, 55, 55, 65, 55, 55, 51, 54, 40, 44, 4, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3E, 8A, EC, DE, 4E, 8B, 57, 1E, 33, 9D, 52, BE, 58, 21, 3, 7E, 46, A3, 42, 9E, 24, A7, 50, 1E, 5B, AA, 46, 1E, 2E, 2C, 4F, 9E, 33, B9, 27, 3E, 33, C2, E, 7E, 3E, 8F, 0, FF, 6B, 14, 19, 5F, 51, 14, D7, 9F, 4D, A5, 17, FF, 21, B6, E5, 3F, 48, 37, 95, 1F, 67, BB, DD, BF, 25, 41, CE, 7F, 57, C2, C7, 9F, 40, C3, 9, BF, 4D, 43, 88, DF, 3B, 2B, 52, FA, 36, 2C, 69, 78, 26, C6, 4F, 1E, 38, 50, 4D, 3C, 3E, C6, D, DA, 2A, 50, A4, 18, 4A, D1, 7, 78, 3D, C9, 4D, 99, 42, C9, C9, B9, 5A, 4B, 8, B9, 42, CE, C, 39, .46, 51, 9, 99, 59, CD, 9F, F5, 59, CE, 8, 55, 2E, 50, 65, 95, 2E, D0, 8E, D5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 56, 17, 0, 1, 20, 1, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, F, 0, 2, 0, 77, 0, 0, 30, C, F3, 33, F3, CF, FF, FE, EF, FF, EF, BB, BA, AA, AA, AA, AA, 65, 55, 55, 95, 55, 55, 45, 51, 10, 44, 4, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

and it throws me the error exponent has no digits

What can be? Thanks in advance :)

AsifKhan991 commented 2 years ago

Hi, I'm having trouble pasting the template.

get.template gives me this

57,1,7E,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,F,0,2,0,83,0,0,30,C,F3,33,F3,CF,FF,FE,EF,FF,FB,FB,EE,EF,EA,AA,AA,A9,95,66,59,55,55,65,55,55,51,54,40,44,4,40,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,. 3E,8A,EC,DE,4E,8B,57,1E,33,9D,52,BE,58,21,3,7E,46,A3,42,9E,24,A7,50,1E,5B,AA,46,1E,2E,2C,4F,9E,33,B9,27,3E,33,C2,E,7E,3E,8F,0,FF,6B,14,19,5F,51,14,D7,9F,4D,A5,17,FF,21,B6,E5,3F,48,37,95,1F,67,BB,DD,BF,25,41,CE,7F,57,C2,C7,9F,40,C3,9,BF,4D,43,88,DF,3B,2B,52,FA,36,2C,69,78,26,C6,4F,1E,38,50,4D,3C,3E,C6,D,DA,2A,50,A4,18,4A,D1,7,78,3D,C9,4D,99,42,C9,C9,B9,5A,4B,8,B9,42,CE,C,39,. 46,51,9,99,59,CD,9F,F5,59,CE,8,55,2E,50,65,95,2E,D0,8E,D5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,. 3,3,56,17,0,1,20,1,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,F,0,2,0,77,0,0,30,C,F3,33,F3,CF,FF,FE,EF,FF,EF,BB,BA,AA,AA,AA,AA,65,55,55,95,55,55,45,51,10,44,4,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.

and I paste it in write_to_sensor like this

uint8_t fingerTemplate[512] = {3, 3, 58, 25, 14, 1, 57, 1, 7E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, F, 0, 2, 0, 83, 0, 0, 30, C, F3, 33, F3, CF, FF, FE, EF, FF, FB, FB, EE, EF, EA, AA, AA, A9, 95, 66, 59, 55, 55, 65, 55, 55, 51, 54, 40, 44, 4, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3E, 8A, EC, DE, 4E, 8B, 57, 1E, 33, 9D, 52, BE, 58, 21, 3, 7E, 46, A3, 42, 9E, 24, A7, 50, 1E, 5B, AA, 46, 1E, 2E, 2C, 4F, 9E, 33, B9, 27, 3E, 33, C2, E, 7E, 3E, 8F, 0, FF, 6B, 14, 19, 5F, 51, 14, D7, 9F, 4D, A5, 17, FF, 21, B6, E5, 3F, 48, 37, 95, 1F, 67, BB, DD, BF, 25, 41, CE, 7F, 57, C2, C7, 9F, 40, C3, 9, BF, 4D, 43, 88, DF, 3B, 2B, 52, FA, 36, 2C, 69, 78, 26, C6, 4F, 1E, 38, 50, 4D, 3C, 3E, C6, D, DA, 2A, 50, A4, 18, 4A, D1, 7, 78, 3D, C9, 4D, 99, 42, C9, C9, B9, 5A, 4B, 8, B9, 42, CE, C, 39, .46, 51, 9, 99, 59, CD, 9F, F5, 59, CE, 8, 55, 2E, 50, 65, 95, 2E, D0, 8E, D5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 56, 17, 0, 1, 20, 1, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, F, 0, 2, 0, 77, 0, 0, 30, C, F3, 33, F3, CF, FF, FE, EF, FF, EF, BB, BA, AA, AA, AA, AA, 65, 55, 55, 95, 55, 55, 45, 51, 10, 44, 4, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

and it throws me the error exponent has no digits

What can be? Thanks in advance :)

These are actually hex values. You need to put '0x' before the hex values. Like this: 0xFE

@Gitare420 check this repo again after 4hrs (busy with other stuffs) , I will update the get template example to show hex values with '0x'. I know it's hard to put '0x' before 512 values.

Gitare420 commented 2 years ago

Thanks for answering, it was easy to put the 0x using the replace tool of the notepad, I stay like this

uint8_t fingerTemplate[512] = {0x3, 0x3, 0x59, 0x16, 0x0, 0x1, 0x20, 0x1, 0x7D, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x11, 0x0, 0x3, 0x0, 0x6D, 0x0, 0xC, 0x33, 0xCC, 0xFC, 0xCF, 0xFF, 0xFF, 0xFF, 0xBB, 0xEE, 0xFE, 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0x11, 0x54, 0x41, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};

Then I used the write function and it uploaded without problems, but when using the fingerprint scheme to read it tells me

"Image taken Image converted Did not find a match"

Did I do something wrong?

AsifKhan991 commented 2 years ago

@Gitare420 Did you use the same sensor for reading the template from and writing to back it? What is the model pf the sensor? Also what id you enrolled against?

Gitare420 commented 2 years ago

use the same model 071405 finger to read and write, with the id 1

Gitare420 commented 2 years ago

I am attaching my codes, I am using the example ones that the library brings, sorry for my bad English, I am using google translator, greetings from Chile :)

//////////////////////////////////// get_template ////////////////////////////////////

include

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);

uint8_t f_buf[512]; //here is where the template data is sotred

void setup() { // put your setup code here, to run once: Serial.begin(9600); finger.begin(57600); while (!Serial); // For Yun/Leo/Micro/Zero/... delay(100); Serial.println("\n\nAdafruit finger detect test");

if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1) { delay(1); } } store_template_to_buf(); }

void store_template_to_buf(){

Serial.println("Waiting for valid finger...."); while (finger.getImage() != FINGERPRINT_OK) { // press down a finger take 1st image } Serial.println("Image taken");

if (finger.image2Tz(1) == FINGERPRINT_OK) { //creating the charecter file for 1st image Serial.println("Image converted"); } else { Serial.println("Conversion error"); return; }

Serial.println("Remove finger"); delay(2000); uint8_t p = 0; while (p != FINGERPRINT_NOFINGER) { p = finger.getImage(); }

Serial.println("Place same finger again, waiting...."); while (finger.getImage() != FINGERPRINT_OK) { // press the same finger again to take 2nd image } Serial.println("Image taken");

if (finger.image2Tz(2) == FINGERPRINT_OK) { //creating the charecter file for 2nd image Serial.println("Image converted"); } else { Serial.println("Conversion error"); return; }

Serial.println("Creating model...");

if (finger.createModel() == FINGERPRINT_OK) { //creating the template from the 2 charecter files and saving it to char buffer 1 Serial.println("Prints matched!"); Serial.println("Template created"); } else { Serial.println("Template not build"); return; }

Serial.println("Attempting to get template..."); if (finger.getModel() == FINGERPRINT_OK) { //requesting sensor to transfer the template data to upper computer (this microcontroller) Serial.println("Transferring Template...."); } else { Serial.println("Failed to transfer template"); return; }

if (finger.get_template_buffer(512, f_buf) == FINGERPRINT_OK) { //read the template data from sensor and save it to buffer f_buf Serial.println("Template data (comma sperated HEX):"); for (int k = 0; k < (512/finger.packet_len); k++) { //printing out the template data in seperate rows, where row-length = packet_length for (int l = 0; l < finger.packet_len; l++) { Serial.print(f_buf[(k * finger.packet_len) + l], HEX); Serial.print(","); } Serial.println("."); } }

}

void loop() {} //////////////////////////////////// get_template ////////////////////////////////////

//////////////////////////////////// write_to_sensor ////////////////////////////////////

include

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);

void setup() { Serial.begin(115200); finger.begin(57600); //set your sensor's baudrate if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1); } write_template_data_to_sensor(); }

uint8_t readnumber(void) { uint8_t num = 0;

while (num == 0) { while (! Serial.available()); num = Serial.parseInt(); } return num; }

void write_template_data_to_sensor() { uint8_t fingerTemplate[512] = {0x3, 0x3, 0x59, 0x1A, 0x8, 0x1, 0x28, 0x1, 0x81, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0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, 0x3C, 0xF3, 0xCF, 0xFF, 0xFF, 0xFE, 0xFB, 0xFE, 0xEF, 0xBA, 0xEB, 0xAA, 0xAA, 0xAA, 0xA9, 0x99, 0x56, 0x65, 0x55, 0x95, 0x55, 0x15, 0x54, 0x45, 0x51, 0x11, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; memset(fingerTemplate, 0xff, 512);

Serial.println("Ready to write template to sensor..."); Serial.println("Enter the id to enroll against, i.e id (1 to 127)"); int id = readnumber(); if (id == 0) {// ID #0 not allowed, try again! return; } Serial.print("Writing template against ID #"); Serial.println(id);

if (finger.write_template_to_sensor(fingerTemplate)) { //telling the sensor to download the template data to it's char buffer from upper computer (this microcontroller's "fingerTemplate" buffer) Serial.println("now writing to sensor..."); } else { Serial.println("writing to sensor failed"); return; }

Serial.print("ID "); Serial.println(id); if (finger.storeModel(id) == FINGERPRINT_OK) { //saving the template against the ID you entered or manually set Serial.print("Successfully stored against ID#"); Serial.println(id); } else { Serial.println("Storing error"); return ; } }

void loop() {} //////////////////////////////////// write_to_sensor ////////////////////////////////////

//////////////////////////////////// fingerprint ////////////////////////////////////

include

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);

void setup() { Serial.begin(115200); while (!Serial); // For Yun/Leo/Micro/Zero/... delay(100); Serial.println("\n\nAdafruit finger detect test");

// set the data rate for the sensor serial port finger.begin(57600); delay(5); if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1) { delay(1); } }

Serial.println(F("Reading sensor parameters")); finger.getParameters(); Serial.print(F("Status: 0x")); Serial.println(finger.status_reg, HEX); Serial.print(F("Sys ID: 0x")); Serial.println(finger.system_id, HEX); Serial.print(F("Capacity: ")); Serial.println(finger.capacity); Serial.print(F("Security level: ")); Serial.println(finger.security_level); Serial.print(F("Device address: ")); Serial.println(finger.device_addr, HEX); Serial.print(F("Packet len: ")); Serial.println(finger.packet_len); Serial.print(F("Baud rate: ")); Serial.println(finger.baud_rate);

finger.getTemplateCount();

if (finger.templateCount == 0) { Serial.print("Sensor doesn't contain any fingerprint data. Please run the 'enroll' example."); } else { Serial.println("Waiting for valid finger..."); Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates"); } }

void loop() // run over and over again { getFingerprintID(); delay(50); //don't ned to run this at full speed. }

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.fingerSearch(); 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; }

// found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence);

return finger.fingerID; }

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

// found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence); return finger.fingerID; } //////////////////////////////////// fingerprint ////////////////////////////////////

AsifKhan991 commented 2 years ago

@Gitare420 in the "write_to_sensor" example you have to comment out or delete the line "memset(fingerTemplate, 0xff, 512);" if you've manually put the template data in the array buffer before this line. (as you have done). This line was simply done to initiate the array buffer when it was previously empty. So comment out his line and let me know if it works or not. IMG_20220906_185054.jpg

Gitare420 commented 2 years ago

I made the change and left everything as it is and it still doesn't work, it reads the template and uploads it without problems, but when reading the fingerprint it can't find it in the database.

It occurs to me perhaps to filter the data that is not necessary and save the template in a string, and when reading it see the percentage of coincidence, and if it is greater than 80%, for example, I would take it as good. I'm going to sleep for a while and when I wake up I'll do that test and let you know how it goes, thanks for answering :)

hanifizzudinrahman commented 2 years ago

I was also in need of such functionalities (to read, save and write back template data to similar sensor models) and thus came up with an update to the existing library. @Dygear what you said is correct. I have a pull request pending about this. Please checkout my repository about this update. Also checkout the changes I've made.

However, keep in mind that writing template data from one model to another won't serve the purpose as different sensor models might use different template matching algorithms.

Hope I was able to help!

yap, that's right

AsifKhan991 commented 2 years ago

@Gitare420 @hanifizzudinrahman I made some changes in the write_template_to_sensor() function. Check if it works now. Also currently I don't have access to the modules. Tomorrow I will have them and check again thoroughly.

Gitare420 commented 2 years ago

Hello, I updated the library and it's still the same, from what I've seen my model 071405 is the least used, it may be the reason why it doesn't work, these are the data that the fingerprint example gives me:

Reading sensor parameters Status: 0x0 SysID: 0x0 Capacity: 300 Security level: 3 Device address: FFFFFFFF Packet length: 128 Baud rate: 57600 Waiting for valid finger... Sensor contains 1 templates

I think I'll buy the 307 model through AliExpress (it doesn't exist in Chile) and I'll keep trying there so as not to waste my time, I'll be attentive to the updates, thank you very much :)

Gitare420 commented 2 years ago

I leave the last test I did in case it helps someone :)

//////////////////////////////////// write_to_sensor ////////////////////////////////////

include

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);

void setup() { Serial.begin(115200); finger.begin(57600); //set your sensor's baudrate if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1); } write_template_data_to_sensor(); }

uint8_t readnumber(void) { uint8_t num = 0;

while (num == 0) { while (! Serial.available()); num = Serial.parseInt(); } return num; }

void write_template_data_to_sensor() { uint8_t fingerTemplate[512] = {0x3, 0x3, 0x50, 0x16, 0x0, 0x1, 0x20, 0x1, 0x7F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x12, 0x0, 0x1, 0x0, 0x71, 0x0, 0x33, 0x33, 0x33, 0xC3, 0xFF, 0xF, 0xFF, 0xFB, 0xEF, 0xFB, 0xFF, 0xFE, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x59, 0x95, 0x55, 0x45, 0x55, 0x11, 0x51, 0x44, 0x10, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4C, 0x94, 0xC4, 0x5E, 0x50, 0x1E, 0x6, 0x7E, 0x28, 0xA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x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, 0x50, 0x17, 0x0, 0x1, 0x20, 0x1, 0x81, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x3, 0x0, 0x6D, 0x0, 0x33, 0xCC, 0x3F, 0x3, 0xFC, 0x3F, 0xFF, 0xEF, 0xFF, 0xFE, 0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xA9, 0x95, 0x55, 0x55, 0x54, 0x55, 0x51, 0x51, 0x54, 0x40, 0x4, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};

Serial.println("Ready to write template to sensor..."); Serial.println("Enter the id to enroll against, i.e id (1 to 127)"); int id = readnumber(); if (id == 0) {// ID #0 not allowed, try again! return; } Serial.print("Writing template against ID #"); Serial.println(id);

if (finger.write_template_to_sensor(fingerTemplate)) { //telling the sensor to download the template data to it's char buffer from upper computer (this microcontroller's "fingerTemplate" buffer) Serial.println("now writing to sensor..."); } else { Serial.println("writing to sensor failed"); return; }

Serial.print("ID "); Serial.println(id); if (finger.storeModel(id) == FINGERPRINT_OK) { //saving the template against the ID you entered or manually set Serial.print("Successfully stored against ID#"); Serial.println(id); } else { Serial.println("Storing error"); return ; } }

void loop() {}

//////////////////////////////////// write_to_sensor ////////////////////////////////////

AsifKhan991 commented 2 years ago

There were indeed some issues with template buffer size. Those are now fixed. @Gitare420 sorry to bother, but will you please let me know if the issue is now solved or not? (use the new "get_direct_template.ino" example to get the template)

Gitare420 commented 2 years ago

WORKS!!!!! Thank you very much, I have searched everywhere and your library was the best that worked for me, very simple and intuitive everything, really thank you very much, you are a genius, I enclose my code in case it helps someone

////////////////////////////////////////write_to_sensor////////////////////////////////////////

include

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);

void setup() { Serial.begin(115200); finger.begin(57600); //set your sensor's baudrate if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1); } write_template_data_to_sensor(); }

uint8_t readnumber(void) { uint8_t num = 0;

while (num == 0) { while (! Serial.available()); num = Serial.parseInt(); } return num; }

void write_template_data_to_sensor() { int template_buf_size = 512; //usually hobby grade sensors have 512 byte template data, watch datasheet to know the info

uint8_t fingerTemplate[512] = {0x3, 0x3, 0x53, 0x1A, 0x0, 0x1, 0x20, 0x1, 0x79, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x7, 0x0, 0x73, 0x0, 0x0, 0xC3, 0x3, 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 0xAA, 0xAA, 0x65, 0x54, 0x51, 0x51, 0x45, 0x44, 0x51, 0x4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };

Serial.println("Ready to write template to sensor..."); Serial.println("Enter the id to enroll against, i.e id (1 to 127)"); int id = readnumber(); if (id == 0) {// ID #0 not allowed, try again! return; } Serial.print("Writing template against ID #"); Serial.println(id);

if (finger.write_template_to_sensor(template_buf_size, fingerTemplate)) { //telling the sensor to download the template data to it's char buffer from upper computer (this microcontroller's "fingerTemplate" buffer) Serial.println("now writing to sensor..."); } else { Serial.println("writing to sensor failed"); return; }

Serial.print("ID "); Serial.println(id); if (finger.storeModel(id) == FINGERPRINT_OK) { //saving the template against the ID you entered or manually set Serial.print("Successfully stored against ID#"); Serial.println(id); } else { Serial.println("Storing error"); return ; } }

void loop() {}

////////////////////////////////////////write_to_sensor////////////////////////////////////////

AsifKhan991 commented 2 years ago

Create an example to add fingerprints and get the templates at the same time. I use an esp32.

////////////////////////////////////////enrol+get_direct_template////////////////////////////////////////

include

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);

uint8_t f_buf[512]; //here is where the template data is sotred uint8_t id = 6; char Button; int Condition_Read_Finger = '1';

void store_template_to_buf() {

Serial.println("Waiting for valid finger...."); while (finger.getImage() != FINGERPRINT_OK) { // press down a finger take 1st image } Serial.println("Image taken");

if (finger.image2Tz(1) == FINGERPRINT_OK) { //creating the charecter file for 1st image Serial.println("Image converted"); } else { Serial.println("Conversion error"); return; } Serial.println("Remove finger"); delay(2000); uint8_t p = 0; while (p != FINGERPRINT_NOFINGER) { p = finger.getImage(); }

Serial.println("Place same finger again, waiting...."); while (finger.getImage() != FINGERPRINT_OK) { // press the same finger again to take 2nd image } Serial.println("Image taken");

if (finger.image2Tz(2) == FINGERPRINT_OK) { //creating the charecter file for 2nd image Serial.println("Image converted"); } else { Serial.println("Conversion error"); return; }

Serial.println("Creating model..."); if (finger.createModel() == FINGERPRINT_OK) { //creating the template from the 2 charecter files and saving it to char buffer 1 Serial.println("Prints matched!"); Serial.println("Template created"); } else { Serial.println("Template not build"); return; }

Serial.print("ID "); Serial.println(id); if (finger.storeModel(id) == FINGERPRINT_OK) { p = finger.storeModel(id); if (p == FINGERPRINT_OK) { Serial.println("Stored!"); } else { Serial.println("Unknown error"); return; }

Serial.println("Attempting to get template...");
if (finger.getModel() == FINGERPRINT_OK) {  //requesting sensor to transfer the template data to upper computer (this microcontroller)
  Serial.println("Transferring Template....");
} else {
  Serial.println("Failed to transfer template");
  return;
}

if (finger.get_template_buffer(512, f_buf) == FINGERPRINT_OK) { //read the template data from sensor and save it to buffer f_buf
  Serial.println("Template data (comma sperated HEX):");
  for (int k = 0; k < (512 / finger.packet_len); k++) { //printing out the template data in seperate rows, where row-length = packet_length
    for (int l = 0; l < finger.packet_len; l++) {
      Serial.print("0x");
      Serial.print(f_buf[(k * finger.packet_len) + l], HEX);
      Serial.print(",");
    }
  }
}
delay(2000);
Condition_Read_Finger = '1';

} }

void setup() { Serial.begin(115200); finger.begin(57600); //set your sensor's baudrate if (finger.verifyPassword()) { Serial.println("Found fingerprint sensor!"); } else { Serial.println("Did not find fingerprint sensor :("); while (1); }

Serial.print("write 't' to the serial monitor followed by the 'id' "); Serial.println("EXAMPLE 't21' for id 21");

Serial.println("write 'Y' in the serial monitor to delete all fingerprints"); }

void loop() { if (Condition_Read_Finger == '1') { getFingerprintID(); delay(50); //don't ned to run this at full speed. }

if (Serial.available() != 0) { Button = Serial.read();

if (Button == 't') {
  Condition_Read_Finger = '0';
  id = Serial.parseInt();
  Serial.print("Enrolling ID #");
  Serial.println(id);
  store_template_to_buf();
}

if (Button == 'Y') {
  finger.emptyDatabase();
  Serial.println("Now database is empty :)");
}

} }

uint8_t getFingerprintID() { uint8_t p = finger.getImage(); switch (p) { case FINGERPRINT_OK: Serial.println("Image taken"); break; case FINGERPRINT_NOFINGER: return p; }

// OK success!

p = finger.image2Tz(); switch (p) { case FINGERPRINT_OK: Serial.println("Image converted"); break; }

// OK converted! p = finger.fingerSearch(); if (p == FINGERPRINT_OK) { Serial.println("Found a print match!"); } else if (p == FINGERPRINT_NOTFOUND) { Serial.println("Did not find a match"); return p; } else { Serial.println("Unknown error"); return p; }

// found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence);

return finger.fingerID; }

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

// found a match! Serial.print("Found ID #"); Serial.print(finger.fingerID); Serial.print(" with confidence of "); Serial.println(finger.confidence); return finger.fingerID; } ////////////////////////////////////////enrol+get_direct_template////////////////////////////////////////

it's better to keep your work in your repository and share the repository link in the comment section.

Gitare420 commented 2 years ago

Sorry, I made an account here 4 days ago and I'm learning how this works :)

Gitare420 commented 2 years ago

Hello, sorry for so many doubts, this is the last one hahaha, how can I write the templates from an sd card? I use an esp32 and the libraries:

include "FS.h"

include "SD.h"

include "SPI.h"

I have a txt that stores only 1 template:

0x3, 0x3, 0x5B, 0x16, 0x14, 0x1, 0x3C, 0x1, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 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0x7D, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0xCC, 0xC, 0xF3, 0xF3, 0xFF, 0xFF, 0xEF, 0xFF, 0xBF, 0xBE, 0xBA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xA9, 0x95, 0x55, 0x55, 0x55, 0x54, 0x55, 0x54, 0x11, 0x54, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,

How can I write all that in the function

uint8_t fingerTemplate[512]={0x03,0x0E,....your template data.....};

As I understand memset(fingerTemplate, 0xff, 512); has something to do with it.

Thank you very much in advance :)

dody3030 commented 2 years ago

Hello everybody, I'm confused about the template size, I got R503 fingerprint when I read the datasheet I noticed that the template size is 768 bytes not 512, is there is anything I need to change in AssifKhan991's libraries. Thanks in advance

AsifKhan991 commented 2 years ago

@dody3030 just change the array buffer size to 768. I.e : finger.get_template_buffer(768,your_arr_buff) to get the template data and finger.write_template_to_sensor(768, your_arr_buff) to write template back to sensor.

dody3030 commented 2 years ago

write_template_to_sensor

@AsifKhan991 what about the memset(ref_buf, 0xff, 512) in Adafruit_Fingerprint.cpp

AsifKhan991 commented 2 years ago

write_template_to_sensor

@AsifKhan991 what about the memset(ref_buf, 0xff, 512) in Adafruit_Fingerprint.cpp

Updated this to take value from 'bufsize' variable

dody3030 commented 2 years ago

The controller get crash and reboot immediately after successfully store the model finger.storeModel, so the finger is stored successfully, then the model is loaded successfully, getModel(), the crash start after calling the function finger.get_template_buffer ` Serial.print("ID "); Serial.println(id); s = finger.storeModel(id); if (s == FINGERPRINT_OK) { //id = (finger.templateCount + 1); Serial.println("Stored!"); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_BLUE, 20); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_ON, 200, FINGERPRINT_LED_BLUE); delay(2000); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_OFF, 200, FINGERPRINT_LED_BLUE); delay(2000); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_ON, 200, FINGERPRINT_LED_BLUE); delay(2000); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_OFF, 200, FINGERPRINT_LED_BLUE); delay(2000); } else if (s == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return s; } else if (s == FINGERPRINT_BADLOCATION) { Serial.println("Could not store in that location"); return s; } else if (s == FINGERPRINT_FLASHERR) { Serial.println("Error writing to flash"); return s; } else { Serial.println("Unknown error"); return s; }

// Try to get the template // Serial.println("Attempting to get template..."); if (finger.getModel() == FINGERPRINT_OK) { //requesting sensor to transfer the template data to upper computer (this microcontroller) Serial.println("Transferring Template...."); } else { Serial.println("Failed to transfer template"); return s; }

if (finger.get_template_buffer(768, f_buf) == FINGERPRINT_OK) { //read the template data from sensor and save it to buffer f_buf Serial.println("Template data (comma sperated HEX):"); for (int k = 0; k < (512 / finger.packet_len); k++) { //printing out the template data in seperate rows, where row-length = packet_length for (int l = 0; l < finger.packet_len; l++) { Serial.print("0x"); Serial.print(f_buf[(k * finger.packet_len) + l], HEX); Serial.print(","); } } }`

ID 2 Stored! Attempting to get template... Transferring Template....

User exception (panic/abort/assert) --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Panic core_esp8266_main.cpp:215 loop_task

stack>>>

ctx: sys sp: 3fffeee0 end: 3fffffb0 offset: 0000 3fffeee0: 4020d968 00009ba3 3ffeefa4 4020d99b
3fffeef0: 000000fe 00000000 00000000 00000000
3fffef00: 00000000 00000000 00000000 3ffeea78
3fffef10: 3ffeea98 3ffeea98 3ffee450 3ffeea34
3fffef20: 3fffdad0 00000000 3ffe85e4 40203f02
3fffef30: 40236b02 3fffdab0 00000000 40203f6f
3fffef40: 00000000 3fffdad0 3ffeea34 402038fc
3fffef50: 40000f49 40000f49 3fffdab0 40000f49
3fffef60: 40000e19 00044f11 00000000 00000005
3fffef70: 00000000 aa55aa55 000000d4 40105951
3fffef80: 40105957 00000000 00000005 40100f08
3fffef90: 4010000d 30602020 00044f11 401000ac
3fffefa0: 40226e40 3fffef3c 40226df9 3ffffd28
3fffefb0: 3fffffc0 00000000 00000000 feefeffe
3fffefc0: feefeffe feefeffe feefeffe feefeffe
3fffefd0: feefeffe feefeffe feefeffe feefeffe
3fffefe0: feefeffe feefeffe feefeffe feefeffe
3fffeff0: feefeffe feefeffe feefeffe feefeffe
3ffff000: feefeffe feefeffe feefeffe feefeffe
3ffff010: feefeffe feefeffe feefeffe feefeffe
3ffff020: feefeffe feefeffe feefeffe feefeffe
3ffff030: feefeffe feefeffe feefeffe feefeffe
3ffff040: feefeffe feefeffe feefeffe feefeffe
3ffff050: feefeffe feefeffe feefeffe feefeffe
3ffff060: feefeffe feefeffe feefeffe feefeffe
3ffff070: feefeffe feefeffe feefeffe feefeffe
3ffff080: feefeffe feefeffe feefeffe feefeffe
3ffff090: feefeffe feefeffe feefeffe feefeffe
3ffff0a0: feefeffe feefeffe feefeffe feefeffe
3ffff0b0: feefeffe feefeffe feefeffe feefeffe
3ffff0c0: feefeffe feefeffe feef --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Panic core_esp8266_main.cpp:215 loop_task

stack>>>

AsifKhan991 commented 2 years ago

@dody3030 need to see your code

dody3030 commented 2 years ago

@AsifKhan991 I'm using the default example, I just added the changes at the end of the function. and added uint8_t f_buf[512]; at the beginning.

> uint8_t getFingerprintEnroll() {

uint8_t f_buf[512]; //here is where the template data is sotred int s = -1; Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_PURPLE, 0); while (s != FINGERPRINT_OK) { s = finger.getImage(); switch (s) { case FINGERPRINT_OK: Serial.println("Image taken"); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_PURPLE, 1); delay(2000); 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!

s = finger.image2Tz(1); switch (s) { case FINGERPRINT_OK: Serial.println("Image converted"); break; case FINGERPRINT_IMAGEMESS: Serial.println("Image too messy"); return s; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return s; case FINGERPRINT_FEATUREFAIL: Serial.println("Could not find fingerprint features"); return s; case FINGERPRINT_INVALIDIMAGE: Serial.println("Could not find fingerprint features"); return s; default: Serial.println("Unknown error"); return s; }

Serial.println("Remove finger"); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_BLUE, 0); //////////////// delay(2000); s = 0; while (s != FINGERPRINT_NOFINGER) { s = finger.getImage(); } Serial.print("ID "); Serial.println(id); s = -1; Serial.println("Place same finger again"); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_PURPLE, 0); while (s != FINGERPRINT_OK) { s = finger.getImage(); switch (s) { case FINGERPRINT_OK: Serial.println("Image taken"); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_PURPLE, 1); 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!

s = finger.image2Tz(2); switch (s) { case FINGERPRINT_OK: Serial.println("Image converted"); break; case FINGERPRINT_IMAGEMESS: Serial.println("Image too messy"); return s; case FINGERPRINT_PACKETRECIEVEERR: Serial.println("Communication error"); return s; case FINGERPRINT_FEATUREFAIL: Serial.println("Could not find fingerprint features"); return s; case FINGERPRINT_INVALIDIMAGE: Serial.println("Could not find fingerprint features"); return s; default: Serial.println("Unknown error"); return s; }

// OK converted! Serial.print("Creating model for #"); Serial.println(id);

s = finger.createModel(); if (s == FINGERPRINT_OK) { Serial.println("Prints matched!"); } else if (s == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return s; } else if (s == FINGERPRINT_ENROLLMISMATCH) { Serial.println("Fingerprints did not match"); newfingerprint() ; // return s; } else { Serial.println("Unknown error"); return s; }

Serial.print("ID "); Serial.println(id); s = finger.storeModel(id); if (s == FINGERPRINT_OK) { //id = (finger.templateCount + 1); Serial.println("Stored!"); finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 25, FINGERPRINT_LED_BLUE, 20); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_ON, 200, FINGERPRINT_LED_BLUE); delay(2000); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_OFF, 200, FINGERPRINT_LED_BLUE); delay(2000); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_ON, 200, FINGERPRINT_LED_BLUE); delay(2000); finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_OFF, 200, FINGERPRINT_LED_BLUE); delay(2000); } else if (s == FINGERPRINT_PACKETRECIEVEERR) { Serial.println("Communication error"); return s; } else if (s == FINGERPRINT_BADLOCATION) { Serial.println("Could not store in that location"); return s; } else if (s == FINGERPRINT_FLASHERR) { Serial.println("Error writing to flash"); return s; } else { Serial.println("Unknown error"); return s; }

// Try to get the template // Serial.println("Attempting to get template..."); if (finger.getModel() == FINGERPRINT_OK) { //requesting sensor to transfer the template data to upper computer (this microcontroller) Serial.println("Transferring Template...."); } else { Serial.println("Failed to transfer template"); return s; }

if (finger.get_template_buffer(768, f_buf) == FINGERPRINT_OK) { //read the template data from sensor and save it to buffer f_buf Serial.println("Template data (comma sperated HEX):"); for (int k = 0; k < (512 / finger.packet_len); k++) { //printing out the template data in seperate rows, where row-length = packet_length for (int l = 0; l < finger.packet_len; l++) { Serial.print("0x"); Serial.print(f_buf[(k * finger.packet_len) + l], HEX); Serial.print(","); } } } // End getting template. delay(2000); return true; }

AsifKhan991 commented 2 years ago

@dody3030 issues with your code:

1) You are using f_buf[512] when you mentioned your template size is 768 bytes. So replace all 512 to 768 in your code

2) Did not call the finger.loadModel(id) before calling finger.getModel(). Refer to "show_saved_template.ino" example.

dody3030 commented 2 years ago

@dody3030 issues with your code:

1. You are using `f_buf[512]` when you mentioned your template size is 768 bytes. So replace all 512 to 768 in your code

2. Did not call the `finger.loadModel(id)` before calling `finger.getModel()`. Refer to "show_saved_template.ino" example.

Actually am trying to get the hex values during the enrollment, so do I need to loadModel() before I getModel?? I checked your previous code examples trying to understand in which stage exactly I have to get the hex, taking into account the template size is different, I will use your example get_direct_template. thank you for your replies really appreciated.

AsifKhan991 commented 2 years ago

Actually am trying to get the hex values during the enrollment, so do I need to loadModel() before I getModel??

Usually the template remains on the char buffer if no other operation's done after enrollment. But it might be otherwise due to model variation. So yeah, safe to do so.