Fingerprint question

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
madmike89
 
Posts: 1
Joined: Fri Feb 02, 2018 5:47 am

Re: Fingerprint question

Post by madmike89 »

Hi was wondering if there is a way to copy the data from one fingerprint reader to another?

User avatar
Felix_Jochems
 
Posts: 1
Joined: Tue May 22, 2018 1:29 pm

Re: Fingerprint question

Post by Felix_Jochems »

I finally got a reliable way to download, convert and upload templates to the sensor.
I'll update my post in a couple of days with a working library

User avatar
axelchita
 
Posts: 2
Joined: Tue Jun 12, 2018 5:58 pm

Re: Fingerprint question

Post by axelchita »

"Felix_Jochems", do you have a solucion to download, convert and upload templates to the sensor???


Thank you, so much

User avatar
foobarjls
 
Posts: 1
Joined: Tue Jun 26, 2018 2:42 pm

Re: Fingerprint question

Post by foobarjls »

yes I also think its an overflow. so I did the following (removed Serial.prints, delays, yields, mySerial->reads, and instead used mySerial->readBytes) and it works.
I also compiled the code in Release mode. And Once I got the packets in a buffer then I processed the information as I needed.

Code: Select all

{
		uint8_t bytesReceived[973]; // 7 data packets of 139 uint8_t
		memset(bytesReceived, 0xff, 973);

		uint32_t starttime = millis();
		int i = 0;
		while (i < 973 && (millis() - starttime) < 2000) {
			int n;
			if (n = finger.mySerial->available()) {
				finger.mySerial->readBytes(bytesReceived + i, n);
				i += n;
			}

}

User avatar
COLLINZ
 
Posts: 1
Joined: Mon Jul 09, 2018 5:32 am

Re: Fingerprint question

Post by COLLINZ »

Hello all,
i am working on a project and i am required to scan the fingerprints on the adafruit fingerprint module
and store them in the mysql because the module has a limited range of templates it can store,
i then have to write code to match a scanned fingerprint with the ones in mysql;

i have tried using SFG demo to scan and store in the database but it gets stuck on place your finger and does nothings,
i am now forced to write code that can extract the fingerprint in the buffer and send it to mysql, i will be glad if someone can give me help

on the part of matching, i am following DON Jerome's idea and here is the code, i would appreciate any help on the part of parsing the char file to mysl
Attachments
fingerprint_match_concept.rar
here is the arduino code and mysql code
(5 KiB) Downloaded 197 times

User avatar
luiscarlos1974
 
Posts: 3
Joined: Tue Dec 29, 2015 10:01 pm

Re: Fingerprint question

Post by luiscarlos1974 »

Felix_Jochems wrote:I finally got a reliable way to download, convert and upload templates to the sensor.
I'll update my post in a couple of days with a working library

download sample please?

User avatar
axelchita
 
Posts: 2
Joined: Tue Jun 12, 2018 5:58 pm

Re: Fingerprint question

Post by axelchita »

Felix_Jochems... can you post your code?????

User avatar
EEEEmdadulIslam
 
Posts: 1
Joined: Mon Sep 17, 2018 2:00 am

Re: Fingerprint question

Post by EEEEmdadulIslam »

Hello Everyone,
I have been using dy50_main_v3 fingerprint module and adafruit fingerprint module since one month. There was no problem in enroll system. But from yesterday during enrollment the module is taking picture automatically thought there is no finger. it shows like the picture .
cap.PNG
cap.PNG (13.35 KiB) Viewed 1508 times

User avatar
Hanif_Izzudin_Rahman
 
Posts: 2
Joined: Wed Feb 13, 2019 5:25 am

Re: Fingerprint question

Post by Hanif_Izzudin_Rahman »

Hello, I'm Hanif, a collage student in BANNED :D

I've learn this problem, maybe for 1 month and from now, i only get this
[ This is abaout upload templete from computer to Char Buffer (1/2) using DownChar (look at datasheet, this use 0x09) ]
[ SO, this i check i upload my finger templete to Char Buffer and i dwonload again and put out again in Serial Monitor, to check, is all right when i upload the templete? ]

in my header there is

Code: Select all

 #ifndef ADAFRUIT_FINGERPRINT_H
#define ADAFRUIT_FINGERPRINT_H

/***************************************************
  This is a library for our optical Fingerprint sensor

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

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

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

#include "Arduino.h"
#if defined(__AVR__) || defined(ESP8266)
  #include <SoftwareSerial.h>
#elif defined(FREEDOM_E300_HIFIVE1)
  #include <SoftwareSerial32.h>
  #define SoftwareSerial SoftwareSerial32
#endif

#define FINGERPRINT_OK 0x00
#define FINGERPRINT_PACKETRECIEVEERR 0x01
#define FINGERPRINT_NOFINGER 0x02
#define FINGERPRINT_IMAGEFAIL 0x03
#define FINGERPRINT_IMAGEMESS 0x06
#define FINGERPRINT_FEATUREFAIL 0x07
#define FINGERPRINT_NOMATCH 0x08
#define FINGERPRINT_NOTFOUND 0x09
#define FINGERPRINT_ENROLLMISMATCH 0x0A
#define FINGERPRINT_BADLOCATION 0x0B
#define FINGERPRINT_DBRANGEFAIL 0x0C
#define FINGERPRINT_UPLOADFEATUREFAIL 0x0D
#define FINGERPRINT_PACKETRESPONSEFAIL 0x0E
#define FINGERPRINT_UPLOADFAIL 0x0F
#define FINGERPRINT_DELETEFAIL 0x10
#define FINGERPRINT_DBCLEARFAIL 0x11
#define FINGERPRINT_PASSFAIL 0x13
#define FINGERPRINT_INVALIDIMAGE 0x15
#define FINGERPRINT_FLASHERR 0x18
#define FINGERPRINT_INVALIDREG 0x1A
#define FINGERPRINT_ADDRCODE 0x20
#define FINGERPRINT_PASSVERIFY 0x21

#define FINGERPRINT_STARTCODE 0xEF01

#define FINGERPRINT_COMMANDPACKET 0x1
#define FINGERPRINT_DATAPACKET 0x2
#define FINGERPRINT_ACKPACKET 0x7
#define FINGERPRINT_ENDDATAPACKET 0x8

#define FINGERPRINT_TIMEOUT 0xFF
#define FINGERPRINT_BADPACKET 0xFE

#define FINGERPRINT_GETIMAGE 0x01
#define FINGERPRINT_IMAGE2TZ 0x02
#define FINGERPRINT_REGMODEL 0x05
#define FINGERPRINT_STORE 0x06
#define FINGERPRINT_LOAD 0x07
#define FINGERPRINT_UPLOAD 0x08
//---------------------------------------------------
#define FINGERPRINT_DOWNLOAD 0x09
#define FINGERPRINT_MATCH 0x03
//---------------------------------------------------
#define FINGERPRINT_DELETE 0x0C
#define FINGERPRINT_EMPTY 0x0D
#define FINGERPRINT_SETPASSWORD 0x12
#define FINGERPRINT_VERIFYPASSWORD 0x13
#define FINGERPRINT_HISPEEDSEARCH 0x1B
#define FINGERPRINT_TEMPLATECOUNT 0x1D

//#define FINGERPRINT_DEBUG

#define DEFAULTTIMEOUT 1000  ///< UART reading timeout in milliseconds

///! Helper class to craft UART packets
struct Adafruit_Fingerprint_Packet {

/**************************************************************************/
/*!
    @brief   Create a new UART-borne packet
    @param   type Command, data, ack type packet
    @param   length Size of payload
    @param   data Pointer to bytes of size length we will memcopy into the internal buffer
*/
/**************************************************************************/

  Adafruit_Fingerprint_Packet(uint8_t type, uint16_t length, uint8_t * data) {
    this->start_code = FINGERPRINT_STARTCODE;
    this->type = type;
    this->length = length;
    address[0] = 0xFF; address[1] = 0xFF;
    address[2] = 0xFF; address[3] = 0xFF;
    if(length<64)
      memcpy(this->data, data, length);
    else
      memcpy(this->data, data, 64);
  }
  uint16_t start_code;      ///< "Wakeup" code for packet detection
  uint8_t address[4];       ///< 32-bit Fingerprint sensor address
  uint8_t type;             ///< Type of packet
  uint16_t length;          ///< Length of packet
  uint8_t data[64];         ///< The raw buffer for packet payload
};

///! Helper class to communicate with and keep state for fingerprint sensors
class Adafruit_Fingerprint {
 public:
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  Adafruit_Fingerprint(SoftwareSerial *ss, uint32_t password = 0x0);
#endif
  Adafruit_Fingerprint(HardwareSerial *hs, uint32_t password = 0x0);

  void begin(uint32_t baud);

  boolean verifyPassword(void);
  uint8_t getImage(void);
  uint8_t image2Tz(uint8_t slot = 1);
  uint8_t createModel(void);

  uint8_t emptyDatabase(void);
  uint8_t storeModel(uint16_t id);
  uint8_t loadModel(uint16_t id);
  uint8_t loadModeltwo(uint16_t id);
  uint8_t getModel(void);
  uint8_t getModel2(void);
  uint8_t uploadModel(void);
  uint8_t deleteModel(uint16_t id);
  uint8_t fingerFastSearch(void);
  uint8_t getTemplateCount(void);
  //----------------------------------------------------
  void writePacket(uint32_t addr, uint8_t packettype, uint16_t len, uint8_t *packet);
  uint8_t getReply(uint8_t packet[], uint16_t timeout=DEFAULTTIMEOUT);
  uint8_t getMatch(void);
  //----------------------------------------------------
  uint8_t setPassword(uint32_t password);
  void writeStructuredPacket(const Adafruit_Fingerprint_Packet & p);
  uint8_t getStructuredPacket(Adafruit_Fingerprint_Packet * p, uint16_t timeout=DEFAULTTIMEOUT);

  /// The matching location that is set by fingerFastSearch()
  uint16_t fingerID;
  /// The confidence of the fingerFastSearch() match, higher numbers are more confidents
  uint16_t confidence;
  /// The number of stored templates in the sensor, set by getTemplateCount()
  uint16_t templateCount;

 private:
  uint8_t checkPassword(void);
  uint32_t thePassword;
  uint32_t theAddress;
    uint8_t recvPacket[20];

  Stream *mySerial;
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  SoftwareSerial *swSerial;
#endif
  HardwareSerial *hwSerial;
};

#endif
and this is file library in .cpp

Code: Select all

/***************************************************
  This is a library for our optical Fingerprint sensor

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

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

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

#include "Adafruit_Fingerprint.h"

//#define FINGERPRINT_DEBUG

#if ARDUINO >= 100
  #define SERIAL_WRITE(...) mySerial->write(__VA_ARGS__)
#else
  #define SERIAL_WRITE(...) mySerial->write(__VA_ARGS__, BYTE)
#endif

#define SERIAL_WRITE_U16(v) SERIAL_WRITE((uint8_t)(v>>8)); SERIAL_WRITE((uint8_t)(v & 0xFF));

#define GET_CMD_PACKET(...) \
  uint8_t data[] = {__VA_ARGS__}; \ 
  Adafruit_Fingerprint_Packet packet(FINGERPRINT_COMMANDPACKET, sizeof(data), data); \
  writeStructuredPacket(packet); \
  if (getStructuredPacket(&packet) != FINGERPRINT_OK) return FINGERPRINT_PACKETRECIEVEERR; \
  if (packet.type != FINGERPRINT_ACKPACKET) return FINGERPRINT_PACKETRECIEVEERR;

#define SEND_CMD_PACKET(...) GET_CMD_PACKET(__VA_ARGS__); return packet.data[0];

/***************************************************************************
 PUBLIC FUNCTIONS
 ***************************************************************************/


#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
/**************************************************************************/
/*!
    @brief  Instantiates sensor with Software Serial
    @param  ss Pointer to SoftwareSerial object
    @param  password 32-bit integer password (default is 0)
*/
/**************************************************************************/
Adafruit_Fingerprint::Adafruit_Fingerprint(SoftwareSerial *ss, uint32_t password) {
  thePassword = password;
  theAddress = 0xFFFFFFFF;

  hwSerial = NULL;
  swSerial = ss;
  mySerial = swSerial;
}
#endif

/**************************************************************************/
/*!
    @brief  Instantiates sensor with Hardware Serial
    @param  hs Pointer to HardwareSerial object
    @param  password 32-bit integer password (default is 0)

*/
/**************************************************************************/
Adafruit_Fingerprint::Adafruit_Fingerprint(HardwareSerial *hs, uint32_t password) {
  thePassword = password;
  theAddress = 0xFFFFFFFF;

#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  swSerial = NULL;
#endif
  hwSerial = hs;
  mySerial = hwSerial;
}

/**************************************************************************/
/*!
    @brief  Initializes serial interface and baud rate
    @param  baudrate Sensor's UART baud rate (usually 57600, 9600 or 115200)
*/
/**************************************************************************/
void Adafruit_Fingerprint::begin(uint32_t baudrate) {
  delay(1000);  // one second delay to let the sensor 'boot up'

  if (hwSerial) hwSerial->begin(baudrate);
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  if (swSerial) swSerial->begin(baudrate);
#endif
}

/**************************************************************************/
/*!
    @brief  Verifies the sensors' access password (default password is 0x0000000). A good way to also check if the sensors is active and responding
    @returns True if password is correct
*/
/**************************************************************************/
boolean Adafruit_Fingerprint::verifyPassword(void) {
  return checkPassword() == FINGERPRINT_OK;
}

uint8_t Adafruit_Fingerprint::checkPassword(void) {
  GET_CMD_PACKET(FINGERPRINT_VERIFYPASSWORD,
                  (uint8_t)(thePassword >> 24), (uint8_t)(thePassword >> 16),
                  (uint8_t)(thePassword >> 8), (uint8_t)(thePassword & 0xFF));
  if (packet.data[0] == FINGERPRINT_OK)
    return FINGERPRINT_OK;
  else
    return FINGERPRINT_PACKETRECIEVEERR;
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to take an image of the finger pressed on surface
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_NOFINGER</code> if no finger detected
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
    @returns <code>FINGERPRINT_IMAGEFAIL</code> on imaging error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::getImage(void) {
  SEND_CMD_PACKET(FINGERPRINT_GETIMAGE);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to convert image to feature template
    @param slot Location to place feature template (put one in 1 and another in 2 for verification to create model)
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_IMAGEMESS</code> if image is too messy
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
    @returns <code>FINGERPRINT_FEATUREFAIL</code> on failure to identify fingerprint features
    @returns <code>FINGERPRINT_INVALIDIMAGE</code> on failure to identify fingerprint features
*/
uint8_t Adafruit_Fingerprint::image2Tz(uint8_t slot) {
  SEND_CMD_PACKET(FINGERPRINT_IMAGE2TZ,slot);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to take two print feature template and create a model
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
    @returns <code>FINGERPRINT_ENROLLMISMATCH</code> on mismatch of fingerprints
*/
uint8_t Adafruit_Fingerprint::createModel(void) {
  SEND_CMD_PACKET(FINGERPRINT_REGMODEL);
}


/**************************************************************************/
/*!
    @brief   Ask the sensor to store the calculated model for later matching
    @param   location The model location #
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_BADLOCATION</code> if the location is invalid
    @returns <code>FINGERPRINT_FLASHERR</code> if the model couldn't be written to flash memory
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/
uint8_t Adafruit_Fingerprint::storeModel(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_STORE, 0x01, (uint8_t)(location >> 8), (uint8_t)(location & 0xFF));
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to load a fingerprint model from flash into buffer 1
    @param   location The model location #
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_BADLOCATION</code> if the location is invalid
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/

//read a fingerprint template from flash into Char Buffer 1
uint8_t Adafruit_Fingerprint::loadModel(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_LOAD, 0x01, (uint8_t)(location >> 8), (uint8_t)(location & 0xFF));
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to transfer 256-byte fingerprint template from the buffer to the UART
    @returns <code>FINGE(RPRINT_OK</code> on success
        @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
    */
    
//------------------------------------------------------------------------------------------------------------
//read a fingerprint template from flash into Char Buffer 2
uint8_t Adafruit_Fingerprint::loadModeltwo(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_LOAD, 0x02, (uint8_t)(location >> 8), (uint8_t)(location & 0xFF));
}
//------------------------------------------------------------------------------------------------------------

//transfer a fingerprint template from Char Buffer 1 to host computer
uint8_t Adafruit_Fingerprint::getModel(void) {
  SEND_CMD_PACKET(FINGERPRINT_UPLOAD, 0x01);
}

//------------------------------------------------------------------------------------------------------------
//transfer a fingerprint template from Char Buffer 1 to host computer
uint8_t Adafruit_Fingerprint::getModel2(void) {
  SEND_CMD_PACKET(FINGERPRINT_UPLOAD, 0x02);
}
//------------------------------------------------------------------------------------------------------------


/**************************************************************************/
/*!
    @brief   Ask the sensor to delete a model in memory
    @param   location The model location #
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_BADLOCATION</code> if the location is invalid
    @returns <code>FINGERPRINT_FLASHERR</code> if the model couldn't be written to flash memory
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/
uint8_t Adafruit_Fingerprint::deleteModel(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_DELETE, (uint8_t)(location >> 8), (uint8_t)(location & 0xFF), 0x00, 0x01);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to delete ALL models in memory
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_BADLOCATION</code> if the location is invalid
    @returns <code>FINGERPRINT_FLASHERR</code> if the model couldn't be written to flash memory
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/
uint8_t Adafruit_Fingerprint::emptyDatabase(void) {
  SEND_CMD_PACKET(FINGERPRINT_EMPTY);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to search the current slot 1 fingerprint features to match saved templates. The matching location is stored in <b>fingerID</b> and the matching confidence in <b>confidence</b>
    @returns <code>FINGERPRINT_OK</code> on fingerprint match success
    @returns <code>FINGERPRINT_NOTFOUND</code> no match made
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/
/**************************************************************************/
  // high speed search of slot #1 starting at page 0x0000 and page #0x00A3
uint8_t Adafruit_Fingerprint::fingerFastSearch(void) {
  // high speed search of slot #1 starting at page 0x0000 and page #0x00A3
  GET_CMD_PACKET(FINGERPRINT_HISPEEDSEARCH, 0x01, 0x00, 0x00, 0x00, 0xA3);
  fingerID = 0xFFFF;
  confidence = 0xFFFF;

  fingerID = packet.data[1];
  fingerID <<= 8;
  fingerID |= packet.data[2];

  confidence = packet.data[3];
  confidence <<= 8;
  confidence |= packet.data[4];

  return packet.data[0];
}

//------------------------------------------------------------------------------------------------------------
//transfer a fingerprint template from host computer to Char Buffer 2
uint8_t Adafruit_Fingerprint::uploadModel(void) {
    uint8_t packet[] = {FINGERPRINT_DOWNLOAD, 0x02};    
    // ID = 1 [ JEMPOL KIRI]
      uint8_t packet2[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x55, 0x21, 0x7C, 0x00, 0xC0, 0x0E, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
      uint8_t packet3[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D}; 
      uint8_t packet4[] = {0x07, 0x19, 0x5E, 0x23, 0x8A, 0xD5, 0x3E, 0x5E, 0x8B, 0x5B, 0x1E, 0x43, 0x15, 0x97, 0xBE, 0x3A, 0x1B, 0x56, 0x9E, 0x16, 0x22, 0xCF, 0xBE, 0x21, 0xAE, 0x8C, 0x9E, 0x2B, 0x2F, 0xCB, 0xFE, 0x13} ;
      uint8_t packet5[] = {0x30, 0x0B, 0xBE, 0x73, 0x3A, 0x9A, 0x3E, 0x35, 0x3D, 0x08, 0x3E, 0x6F, 0xBF, 0x59, 0x1E, 0x64, 0x15, 0x84, 0xDF, 0x5D, 0x18, 0xDB, 0x3F, 0x2C, 0x1B, 0x93, 0x1F, 0x25, 0x20, 0x6A, 0x9F, 0x46} ;
      uint8_t packet6[] = {0xA1, 0x17, 0xDF, 0x3A, 0xA8, 0x11, 0xFF, 0x1D, 0x7D, 0xEF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x82, 0x50, 0xAA, 0xDA, 0x9F, 0x5F, 0xB1, 0xDA, 0xDF, 0x20, 0x35, 0xE3, 0x3F, 0x6B, 0xB6} ;
      uint8_t packet7[] = {0x1B, 0xFF, 0x5F, 0xBE, 0xD9, 0x3F, 0x27, 0x41, 0x47, 0xDF, 0x48, 0x2A, 0x55, 0xDC, 0x45, 0x25, 0xD7, 0x3D, 0x44, 0x2E, 0x16, 0x9D, 0x63, 0x28, 0xC6, 0xDA, 0x63, 0x2B, 0xDD, 0x5A, 0x3D, 0x37} ;
      uint8_t packet8[] = {0x86, 0x18, 0x3B, 0x2C, 0x80, 0xB9, 0x4B, 0xB4, 0xC3, 0xF9, 0x3C, 0x32, 0xAC, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} ;
      uint8_t packet9[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} ;
      uint8_t packet10[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0xEF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x82, 0x03, 0x01, 0x53}; 
      uint8_t packet11[] = {0x22, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 
      uint8_t packet12[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x84, 0x59, 0x1E, 0x27, 0x09, 0x54, 0x9E, 0x40, 0x18, 0xD6}; 
      uint8_t packet13[] = {0x1E, 0x0D, 0x1A, 0x8F, 0x9E, 0x2C, 0x9D, 0xAA, 0x1E, 0x1D, 0x21, 0x8F, 0x5E, 0x08, 0x2A, 0x64, 0xBE, 0x2A, 0xAC, 0x0C, 0x1E, 0x34, 0x2D, 0xCB, 0xBE, 0x08, 0x3F, 0x88, 0xBE, 0x61, 0x09, 0x1A}; 
      uint8_t packet14[] = {0xDF, 0x68, 0x92, 0x04, 0xBF, 0x49, 0x13, 0x97, 0x3F, 0x62, 0x15, 0x1A, 0xDF, 0x32, 0x99, 0x92, 0xDF, 0x43, 0x25, 0x51, 0xDF, 0x58, 0xA7, 0x99, 0xFF, 0x1A, 0xAE, 0x4B, 0x9F, 0x1C, 0xE8, 0xEF}; 
      uint8_t packet15[] = {0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x08, 0x00, 0x82, 0x68, 0xAE, 0x9A, 0xBF, 0x73, 0xB2, 0x9C, 0x1F, 0x2A, 0x34, 0x62, 0x7F, 0x68, 0xBC, 0x19, 0x7F, 0x30, 0xBF, 0x47, 0xBF, 0x46, 0x41, 0x85, 0x5F}; 
      uint8_t packet16[] = {0x6A, 0xA5, 0x86, 0xDC, 0x50, 0x27, 0x55, 0x9C, 0x4D, 0x1E, 0x17, 0x7D, 0x54, 0xB1, 0xC3, 0xDD, 0x4B, 0x21, 0x96, 0x5A, 0x42, 0x3A, 0xC6, 0x7A, 0x6A, 0x29, 0x5C, 0xFB, 0x4D, 0x2B, 0x15, 0x59}; 
      uint8_t packet17[] = {0x45, 0x2A, 0xC0, 0x10, 0x4A, 0x34, 0xC5, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25}; 
    writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet), packet);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet2), packet2);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet3), packet3); 
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet4), packet4);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet5), packet5);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet6), packet6);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet7), packet7);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet8), packet8);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet9), packet9);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet10), packet10);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet11), packet11);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet12), packet12);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet13), packet13);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet14), packet14);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet15), packet15);
     delay(10);
    writePacket(theAddress, FINGERPRINT_DATAPACKET, sizeof(packet16), packet16);
     delay(10);
    writePacket(theAddress, FINGERPRINT_ENDDATAPACKET, sizeof(packet17), packet17);
    uint8_t len = getReply(packet17);

    if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
        return -1;
    return packet17[1];
}
//------------------------------------------------------------------------------------------------------------
 
//------------------------------------------------------------------------------------------------------------
uint8_t Adafruit_Fingerprint::getMatch(void) 
{
  confidence = 0xFFFF;
 
 // matching

      uint8_t packet[] = {FINGERPRINT_MATCH, 0x01};
      writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet);
    uint8_t len = getReply(packet);

  if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
   return -1;


  confidence = packet[2];
  confidence <<= 8;
  confidence |= packet[3];

  return packet[1];
}
//------------------------------------------------------------------------------------------------------------

/**************************************************************************/
/*!
    @brief   Ask the sensor for the number of templates stored in memory. The number is stored in <b>templateCount</b> on success.
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::getTemplateCount(void) {
  GET_CMD_PACKET(FINGERPRINT_TEMPLATECOUNT);

  templateCount = packet.data[1];
  templateCount <<= 8;
  templateCount |= packet.data[2];

  return packet.data[0];
}

/**************************************************************************/
/*!
    @brief   Set the password on the sensor (future communication will require password verification so don't forget it!!!)
    @param   password 32-bit password code
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_PACKETRECIEVEERR</code> on communication error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::setPassword(uint32_t password) {
  SEND_CMD_PACKET(FINGERPRINT_SETPASSWORD, (password >> 24), (password >> 16), (password >> 8), password);
}

/**************************************************************************/
/*!
    @brief   Helper function to process a packet and send it over UART to the sensor
    @param   packet A structure containing the bytes to transmit
*/
/**************************************************************************/

void Adafruit_Fingerprint::writeStructuredPacket(const Adafruit_Fingerprint_Packet & packet) {
  SERIAL_WRITE_U16(packet.start_code);
  SERIAL_WRITE(packet.address[0]);
  SERIAL_WRITE(packet.address[1]);
  SERIAL_WRITE(packet.address[2]);
  SERIAL_WRITE(packet.address[3]);
  SERIAL_WRITE(packet.type);

  uint16_t wire_length = packet.length + 2;
  SERIAL_WRITE_U16(wire_length);

  uint16_t sum = ((wire_length)>>8) + ((wire_length)&0xFF) + packet.type;
  for (uint8_t i=0; i< packet.length; i++) {
    SERIAL_WRITE(packet.data[i]);
    sum += packet.data[i];
  }

  SERIAL_WRITE_U16(sum);
  return;
}
//------------------------------------------------------------------------------------------
void Adafruit_Fingerprint::writePacket(uint32_t addr, uint8_t packettype,
               uint16_t len, uint8_t *packet) {
#ifdef FINGERPRINT_DEBUG
  Serial.print("---> 0x");
  Serial.print((uint8_t)(FINGERPRINT_STARTCODE >> 8), HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)FINGERPRINT_STARTCODE, HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)(addr >> 24), HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)(addr >> 16), HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)(addr >> 8), HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)(addr), HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)packettype, HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)(len >> 8), HEX);
  Serial.print(" 0x");
  Serial.print((uint8_t)(len), HEX);
#endif

#if ARDUINO >= 100
  mySerial->write((uint8_t)(FINGERPRINT_STARTCODE >> 8));
  mySerial->write((uint8_t)FINGERPRINT_STARTCODE);
  mySerial->write((uint8_t)(addr >> 24));
  mySerial->write((uint8_t)(addr >> 16));
  mySerial->write((uint8_t)(addr >> 8));
  mySerial->write((uint8_t)(addr));
  mySerial->write((uint8_t)packettype);
  mySerial->write((uint8_t)(len >> 8));
  mySerial->write((uint8_t)(len));
#else
  mySerial->print((uint8_t)(FINGERPRINT_STARTCODE >> 8), BYTE);
  mySerial->print((uint8_t)FINGERPRINT_STARTCODE, BYTE);
  mySerial->print((uint8_t)(addr >> 24), BYTE);
  mySerial->print((uint8_t)(addr >> 16), BYTE);
  mySerial->print((uint8_t)(addr >> 8), BYTE);
  mySerial->print((uint8_t)(addr), BYTE);
  mySerial->print((uint8_t)packettype, BYTE);
  mySerial->print((uint8_t)(len >> 8), BYTE);
  mySerial->print((uint8_t)(len), BYTE);
#endif

  uint16_t sum = (len>>8) + (len&0xFF) + packettype;
  for (uint8_t i=0; i< len-2; i++) {
#if ARDUINO >= 100
    mySerial->write((uint8_t)(packet[i]));
#else
    mySerial->print((uint8_t)(packet[i]), BYTE);
#endif
#ifdef FINGERPRINT_DEBUG
    Serial.print(" 0x"); Serial.print(packet[i], HEX);
#endif
    sum += packet[i];
  }
#ifdef FINGERPRINT_DEBUG
  //Serial.print("Checksum = 0x"); Serial.println(sum);
  Serial.print(" 0x"); Serial.print((uint8_t)(sum>>8), HEX);
  Serial.print(" 0x"); Serial.println((uint8_t)(sum), HEX);
#endif
#if ARDUINO >= 100
  mySerial->write((uint8_t)(sum>>8));
  mySerial->write((uint8_t)sum);
#else
  mySerial->print((uint8_t)(sum>>8), BYTE);
  mySerial->print((uint8_t)sum, BYTE);
#endif
}
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
uint8_t Adafruit_Fingerprint::getReply(uint8_t packet[], uint16_t timeout) 
{
  uint8_t reply[20], idx;
  uint16_t timer=0;

  idx = 0;
  #ifdef FINGERPRINT_DEBUG
  Serial.print("<--- ");
  #endif
  while(true)
  {
    while (!mySerial->available()) 
    {
      delay(1);
      timer++;
      if (timer >= timeout) return FINGERPRINT_TIMEOUT;
    }
    // something to read!
      reply[idx] = mySerial->read();
    #ifdef FINGERPRINT_DEBUG
      Serial.print(" 0x"); Serial.print(reply[idx], HEX);
    #endif
      if ((idx == 0) && (reply[0] != (FINGERPRINT_STARTCODE >> 8)))
        continue;
      idx++;

      // check packet!
      if (idx >= 9) {
        if ((reply[0] != (FINGERPRINT_STARTCODE >> 8)) ||
            (reply[1] != (FINGERPRINT_STARTCODE & 0xFF)))
            return FINGERPRINT_BADPACKET;
        uint8_t packettype = reply[6];
        //Serial.print("Packet type"); Serial.println(packettype);
        uint16_t len = reply[7];
        len <<= 8;
        len |= reply[8];
        len -= 2;
        //Serial.print("Packet len"); Serial.println(len);
        if (idx <= (len+10)) continue;
        packet[0] = packettype;
        for (uint8_t i=0; i<len; i++) {
          packet[1+i] = reply[9+i];
        }
      #ifdef FINGERPRINT_DEBUG
          Serial.println();
      #endif
          return len;
        }
  }
}
//------------------------------------------------------------------------------------------

/**************************************************************************/
/*!
    @brief   Helper function to receive data over UART from the sensor and process it into a packet
    @param   packet A structure containing the bytes received
    @param   timeout how many milliseconds we're willing to wait
    @returns <code>FINGERPRINT_OK</code> on success
    @returns <code>FINGERPRINT_TIMEOUT</code> or <code>FINGERPRINT_BADPACKET</code> on failure
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::getStructuredPacket(Adafruit_Fingerprint_Packet * packet, uint16_t timeout) {
  uint8_t byte;
  uint16_t idx=0, timer=0;

  while(true) {
    while(!mySerial->available()) {
      delay(1);
      timer++; 
      if( timer >= timeout) {
#ifdef FINGERPRINT_DEBUG
	Serial.println("Timed out");
#endif
	return FINGERPRINT_TIMEOUT;
      }
    }
    byte = mySerial->read();
#ifdef FINGERPRINT_DEBUG
    Serial.print("<- 0x"); Serial.println(byte, HEX);
#endif
    switch (idx) {
      case 0:
        if (byte != (FINGERPRINT_STARTCODE >> 8)) 
	  continue;
        packet->start_code = (uint16_t)byte << 8;
        break;
      case 1:
        packet->start_code |= byte;
        if (packet->start_code != FINGERPRINT_STARTCODE) 
	  return FINGERPRINT_BADPACKET;
        break;
      case 2:
      case 3:
      case 4:
      case 5:
        packet->address[idx-2] = byte;
        break;
      case 6: 
	packet->type = byte; 
	break;
      case 7: 
	packet->length = (uint16_t)byte << 8; 
	break;
      case 8: 
	packet->length |= byte; 
	break;
      default:
        packet->data[idx-9] = byte;
        if((idx-8) == packet->length)
          return FINGERPRINT_OK;
        break;
    }
    idx++;
  }
  // Shouldn't get here so...
  return FINGERPRINT_BADPACKET;
}
SO This is it... :))))

in file header there is

Code: Select all

#define FINGERPRINT_DOWNLOAD 0x09
In Data Sheet, you can see, DownChar use code 09H

Code: Select all

 void writePacket(uint32_t addr, uint8_t packettype, uint16_t len, uint8_t *packet);

i get this from Don_Jeronimo and i copy it

in file library .cpp, there is

Code: Select all

uint8_t Adafruit_Fingerprint::uploadModel(void) 

i use "uploadModel" when i coding in my arduino to Upload Templete

Code: Select all

uint8_t packet[] = {FINGERPRINT_DOWNLOAD, 0x02};    

in here, use 0x02 to save upload templete in Char Buffer 2 (when you use 0x01, then will be save in Char Buffer 1

Code: Select all

uint8_t packet2[] = {....}
.......
uint8_t packet17[] = {....}
every packet, there is 32 code Hex Template (because i using modul ZFM60, which produce 512 code Hex)

and this is the my Source Code in Arduino

Code: Select all

#include <Adafruit_Fingerprint.h>

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

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

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


#include <SoftwareSerial.h>

int getFingerprintIDez();

// pin #11 is IN from sensor (GREEN wire)
// pin #10 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(11, 10);


Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial1);

void setup()  
{
  while(!Serial);
  Serial.begin(9600);
  Serial.println("Fingerprint template extractor");

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

  // Try to get the templates for fingers 1 through 10
  for (int finger = 1; finger < 5; finger++) {
    downloadFingerprintTemplate(finger);
  }
}

uint8_t downloadFingerprintTemplate(uint16_t id)
{
  uint8_t p;
  Serial.println("------------------------------------");

  
      //---------------------------------------------------------------------------------------------------------------------------
    p = finger.uploadModel();       
  switch (p) {
    case FINGERPRINT_OK:
      Serial.print("upload "); Serial.print(id); Serial.println(" loaded");Serial.println(p);
      Serial.read();
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_BADPACKET:
      Serial.println("Bad packet");
      return p;      
    default:
      Serial.println("Unknown error "); Serial.println(p);
      //return p;
  }
      //--------------------------------------------------------------------------------------------------------------------
      

  /*
  Serial.print("Attempting to load #"); Serial.println(id);
  p = finger.loadModeltwo(id);         // FP_LOAD 0x07   -loadModel() for Char Buffer 1 and loadModeltwo() for Char Buffer 2-
  switch (p) {
    case FINGERPRINT_OK:
      Serial.print("Template "); Serial.print(id); Serial.println(" loaded");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    default:
      Serial.print("Unknown error "); Serial.println(p);
      return p;
  }
 */
  

  // OK success!

  Serial.print("Attempting to get #"); Serial.println(id);
  p = finger.getModel2();       // FP_UPLOAD = UPCHAR 0x08  -getModel() for Char Buffer 1 and getModel2() for Char Buffer 2-
  switch (p) {
    case FINGERPRINT_OK:
      Serial.print("Template "); Serial.print(id); Serial.println(" transferring:");
      break;
   default:
      Serial.print("Unknown error "); Serial.println(p);
      return p;
  }
  
  // one data packet is 267 bytes. in one data packet, 11 bytes are 'usesless' :D
  uint8_t bytesReceived[534]; // 2 data packets
  memset(bytesReceived, 0xff, 534);

  uint32_t starttime = millis();
  int i = 0;
  while (i < 534 && (millis() - starttime) < 30000) {
      if (mySerial.available()) {
          bytesReceived[i++] = mySerial.read();
      }
  }
  Serial.print(i); Serial.println(" bytes read.");
  Serial.println("Decoding packet...");

  uint8_t fingerTemplate[512]; // the real template
  memset(fingerTemplate, 0xff, 512);

  // filtering only the data packets
  int uindx = 9, index = 0;
  uint32_t full = 0, halo = 0;
  while (index < 534) {
      while (index < uindx) ++index;
      uindx += 256;
      while (index < uindx) {
          fingerTemplate[index++] = bytesReceived[index];
      }
      uindx += 2;
      while (index < uindx) ++index;
      uindx = index + 9;
  }
  for (int i = 1; i <= 512; ++i) {
      //Serial.print("a"); Serial.print(id); Serial.print("["); Serial.print(i);Serial.print("] = ");
      Serial.print("0x"); printHex(fingerTemplate[i] , 2); Serial.print(", ");//Serial.print("/"); 
      //Serial.print(fingerTemplate[i]); Serial.print(", ");//halo = (i+1)*fingerTemplate[i]; Serial.print("/"); Serial.print(halo);
      
      full += halo;
      if(i%32 == 0)
      {
        Serial.println();
        //Serial.print(", ");
       // Serial.print("uint8_t packet[] = {");
      }
  }
  Serial.print("\t FULL = "); Serial.println(full);
  Serial.println("\ndone.");

  /*
  uint8_t templateBuffer[256];
  memset(templateBuffer, 0xff, 256);  //zero out template buffer
  int index=0;
  uint32_t starttime = millis();
  while ((index < 256) && ((millis() - starttime) < 1000))
  {
    if (mySerial.available())
    {
      templateBuffer[index] = mySerial.read();
      index++;
    }
  }
  
  Serial.print(index); Serial.println(" bytes read");
  
  //dump entire templateBuffer.  This prints out 16 lines of 16 bytes
  for (int count= 0; count < 16; count++)
  {
    for (int i = 0; i < 16; i++)
    {
      Serial.print("0x");
      Serial.print(templateBuffer[count*16+i], HEX);
      Serial.print(", ");
    }
    Serial.println();
  }*/
}



void printHex(int num, int precision) {
    char tmp[16];
    char format[128];
 
    sprintf(format, "%%.%dX", precision);
 
    sprintf(tmp, format, num);
    Serial.print(tmp);
}

void loop()
{}

So, i explain in little :D

Code: Select all

finger.uploadModel();

for upload templete that i save in library (.cpp) into Char Buffer in Module Fingerprint

Code: Select all

finger.getModel2

for download again my templete that i save in Char Buffer and put out in my Serial Monitor

Oh ya, in my library there is

Code: Select all

uint8_t Adafruit_Fingerprint::getModel2(void) {
  SEND_CMD_PACKET(FINGERPRINT_UPLOAD, 0x02);
}
this mean 0x02 i acces Char Buffer 2 (0x01 for Char Buffer 1)
and in my header file there is

Code: Select all

#define FINGERPRINT_UPLOAD 0x08
this mean 0x08 is code for UpChar (you see in Datasheet)

ANNDDDD, i havent find out, why i cannt upload my templete to Module
Sorry fulll ...:(

User avatar
MacielDavid
 
Posts: 3
Joined: Fri Mar 15, 2019 9:29 am

Re: Fingerprint question

Post by MacielDavid »

Hello Ianna ! tks for the code.

This code works fine, but, i have one question about this.

Why you create a 'fake' serial, i understand the fingerprint sensor works with the different baud rate . But if a use the same baud rate for send the informations for the serial monitor and send BANNED for the sensor , has any problem ?

I make some tests but doesnt work fine, when i use the Serial.Write commands or Serial.Reads.


Only works fine when i use the name 'fake' to send the BANNED.

Tks in advanced.

Code: Select all

#include <SoftwareSerial.h>                            //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>  
SoftwareSerial  myserial(2,3);                           //Create a 'fake' serial port. Pin 2 is the Rx verde  pin, pin 3 is the Tx bianco pin.
/*----------external commands----------*/
char receive_command[20]={};
char VfyPwd[10]="VfyPwd ";                             //Verify password
char GenImg[10]="GenImg ";                             //Record fingerprint image
char UpImg[10]="UpImg ";                               //Upload image
char DownImg[10]="DownImg ";                           //Download image
char Img1Tz[10]="Img1Tz ";                             //Geneated features saved to CharBuffer1
char Img2Tz[10]="Img2Tz ";                             //Generated features saved to CharBuffer2
char RegMode1[10]="RegMode1 ";                         //Template of geature combiation
char UpChar[10]="UpChar ";                             //Upload featues or template
char DownChar[10]="DownChar ";                         //Download features or template
char Store[10]="Store ";                               //store template 
char LoadChar[10]="LoadChar ";                         //Read template
char DeletChar[11]="DeletChar ";                       //delete template
char Empty[10]="Empty ";                               //clean out fingerprint library 




char cnt;
unsigned int Templete_Num;
unsigned int ACK_Sum;

volatile unsigned char UART1_FINGERPRINT_RECEVICE_BUFFER[24];
unsigned char receive_ACK[24];

/*----------FINGERPRINT protocol definition -----------*/

                                                    
unsigned char FP_Delet_All_Model[6]={0x01,0x0,0x03,0x0d,0x00,0x11};                                                 
                          //delete specified template 
unsigned char FP_Pack_Head [6] = {0xEF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF};
/*----------inilization-----------*/
void setup()
{
 
  Serial.begin(9600); // open serial port, and set the baud rate to 9600 bps
  myserial.begin(9600);
}
/*----------main loop-----------*/
void loop()
{

 Empty_Finger();
}



void FINGERPRINT_Cmd_Delete_All_Model(void)
{
     
     unsigned char b;    

    for(b=0;b<6;b++) 
     myserial.write(FP_Pack_Head[b]);   

    for(b=0;b<6;b++) 
    myserial.write(FP_Delet_All_Model[b]);   
}

void Empty_Finger(void)
{

        
        FINGERPRINT_Cmd_Delete_All_Model();                                         
        
        
        
        for(unsigned char b=0;b<12;b++)                                           
                                        {
                                           receive_ACK[b]= myserial.read();
                                        }
        if(receive_ACK[9]==0x00)
        {
           Serial.println("Empty_OK");
        }
        else
        {
           Serial.println("Empty_ERROReee");
           Serial.println(receive_ACK[9]);
        }
        delay(1000);
}
ianna wrote:here is the solution if it can help someone:

Code: Select all

#include <SoftwareSerial.h>                            //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>  
SoftwareSerial  FPM10A(2,3);                           //Create a 'fake' serial port. Pin 2 is the Rx verde  pin, pin 3 is the Tx bianco pin.
/*----------external commands----------*/
char receive_command[20]={};
char VfyPwd[10]="VfyPwd ";                             //Verify password
char GenImg[10]="GenImg ";                             //Record fingerprint image
char UpImg[10]="UpImg ";                               //Upload image
char DownImg[10]="DownImg ";                           //Download image
char Img1Tz[10]="Img1Tz ";                             //Geneated features saved to CharBuffer1
char Img2Tz[10]="Img2Tz ";                             //Generated features saved to CharBuffer2
char RegMode1[10]="RegMode1 ";                         //Template of geature combiation
char UpChar[10]="UpChar ";                             //Upload featues or template
char DownChar[10]="DownChar ";                         //Download features or template
char Store[10]="Store ";                               //store template 
char LoadChar[10]="LoadChar ";                         //Read template
char DeletChar[11]="DeletChar ";                       //delete template
char Empty[10]="Empty ";                               //clean out fingerprint library 


char cnt;
unsigned int Templete_Num;
unsigned int ACK_Sum;

volatile unsigned char UART1_FINGERPRINT_RECEVICE_BUFFER[24];
unsigned char receive_ACK[24];

/*----------FINGERPRINT protocol definition -----------*/

                                                    
unsigned char FP_Delet_All_Model[6]={0x01,0x0,0x03,0x0d,0x00,0x11};                                                 
                          //delete specified template 

/*----------inilization-----------*/
void setup()
{
 
  Serial.begin(9600); // open serial port, and set the baud rate to 9600 bps
  FPM10A.begin(57600);
}
/*----------main loop-----------*/
void loop()
{

 Empty_Finger();
}



void FINGERPRINT_Cmd_Delete_All_Model(void)
{
     
     unsigned char b;    

    for(b=0;b<6;b++) 
      FPM10A.write(FP_Pack_Head[b]);   

    for(b=0;b<6;b++) 
      FPM10A.write(FP_Delet_All_Model[b]);   
}

void Empty_Finger(void)
{

        
        FINGERPRINT_Cmd_Delete_All_Model();                                         
        
        
        
        for(unsigned char b=0;b<12;b++)                                           
                                        {
                                           receive_ACK[b]= FPM10A.read();
                                        }
        if(receive_ACK[9]==0x00)
        {
           Serial.println("Empty_OK");
        }
        else
        {
           Serial.println("Empty_ERROReee");
           Serial.println(receive_ACK[9]);
        }
        delay(1000);
}

User avatar
Hanif_Izzudin_Rahman
 
Posts: 2
Joined: Wed Feb 13, 2019 5:25 am

Re: Fingerprint question

Post by Hanif_Izzudin_Rahman »

Hello, everybody. combback with me... :D

Alhamdulillah, i have finished our Project for Research and Development for Fingerprint Module (with ZFM20 or DY50/FPM10A)
This is include file C for Arduino and surely the libraries
Enroll + Match + Upload Template + Show Template + Delete & Empty + Show Image Template + SFG Demo

So, i uploaded in github, you can visit it in
https://github.com/BANNED/M ... Y50-FPM10A
Attachments
Fingerprint Module.png
Fingerprint Module.png (455.95 KiB) Viewed 1280 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”