Interface (AdafruitFingerprint API)

This is the core interface API documentation. This and the Responses is all the documentation you need look at to implement a use case like the ones in Example Codes

AdafruitFingerprint core API

Classes

class AdafruitFingerprint
Implements the core interface of the fingerprint module as methods
class adafruit_fingerprint.interface.AdafruitFingerprint(port=None)[source]

Interface class for adafruit fingerprint module

This class implements the methods for interacting with the adafruit fingerprint module as is in the official datasheet

__init__(port=None)[source]

Initialize class with serial port object

This sets up the AdafruitFingerprint class with the serial port object to be used for serial communication. The port object is passed down during initialization of the Package class from the core module (which composes this class) where it is actually used. The implementation of the type of serial object port must be is not strict. This is why it is left up to the user to select the type of serial object to be used, as can be seen in the examples section.

In development, the pyserial package is used. So the constraints are that the serial port object must implement two (2) methods (a read and a write); which reads and writes from the serial in and out-buffer of the specified port string used when creating the serial connection, and a property in_waiting; which checks the in-buffer for waiting (buffered) incoming data, as specified in the pyserial docs. We advise you simply go with the pyserial package for 100% compatibility. We refused to be strict on this, by abstracting away the serial connection entirely from the user (to the core module perhaps), this is so as to have similiarities with the actual adafruit fingerprint library implemented in arduino which accepts a serial port connection (a hardware or software serial).

Parameters:port (serial.Serial) – Instance of the Serial class from the serial module. The serial port passed to allow serial communication (Default is None)
package

Instance of the Package class from the local core module that describes the complete format for communicating with the adafruit fingerprint module over serial communication. The format describes and composes, and receives and sends the complete read and raw write packets

Type:core.Package
delete_char(page_id, num=1)[source]

To delete a segment (n) of templates of Flash library started from the specified location (or Page_id).

Parameters:
  • page_id (int) – location in module flash library to start delete from
  • num (int) – number of templates to be deleted from module flash library (Default is 1)
Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

down_char(buffer, template)[source]

To download character file or template from upper computer to the Specified buffer of Module.

Parameters:
  • buffer (int) – one of two module CharBuffers used for template storage
  • template (str) – previously generated template passed down from upper computer
Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

empty()[source]

To delete all the templates in the Flash library

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

gen_img()[source]

Try detecting finger and store the detected finger image in ImageBuffer while returning successful confirmation code; If there is no finger, returned confirmation code would be “can’t detect finger”.

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

img_2Tz(buffer)[source]

To generate character file from the original finger image in ImageBuffer and store the file in CharBuffer1 or CharBuffer2.

Parameters:

buffer (int) – one of two module CharBuffers used for template storage

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

reg_model()[source]

To combine information of character files from CharBuffer1 and CharBuffer2 and generate a template which is stroed back in both CharBuffer1 and CharBuffer2.

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

search(buffer, page_start=0, page_num=255)[source]

To search the whole finger library or a protion of it for the template that matches the One in CharBuffer1 or CharBuffer2 When found, page_id will be returned.

Parameters:
  • buffer (int) – one of two module CharBuffers used for template storage
  • page_start (int, optional) – location in module flash library to start search from (Default is 0)
  • page_num (int, optional) – location in module flash library to end search (Default is 255)
Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

  • tuple – On success. Confirmation code (A response object), page_id where template was fonud, and the confidence score
  • int – On failure. Confirmation code (A response object)

store(buffer, page_id)[source]

To store the template of specified buffer (Buffer1/Buffer2) at the designated Location (page) of Flash library.

Parameters:
  • buffer (int) – one of two module CharBuffers used for template storage
  • page_id (int) – designated location in module flash library (0 - 255)
Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

template_num()[source]

To read the current valid template number of the Module

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

  • tuple – On success. Confirmation code (A response object), template number count in flash library
  • int – On failure. Confirmation code (A response object)

up_char(buffer)[source]

To upload the character file or template of CharBuffer1 or CharBuffer2 to upper computer.

Parameters:

buffer (int) – one of two module CharBuffers used for template storage

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

  • tuple – On success. Confirmation code (A response object) and fingerprint template template
  • int – On failure. Confirmation code (A response object)

vfy_pwd()[source]

Verify module’s handshaking password

Raises:
  • UnknownConfirmationCodeException – if no valid confirmation code is received from module
  • SerialReadException – if no serial data can be read from buffer (from module)
Returns:

Confirmation code (A response object)

Return type:

int

Note

This has to be the first method to be called on any created instance of this class. It also serves as a checker for proper hardware connections as it first tries to establish communication with the connected module