Adafruit Fingerprint Arduino Library
Public Member Functions | Public Attributes | List of all members
Adafruit_Fingerprint Class Reference

! Helper class to communicate with and keep state for fingerprint sensors More...

#include <Adafruit_Fingerprint.h>

Public Member Functions

 Adafruit_Fingerprint (HardwareSerial *hs, uint32_t password=0x0)
 Instantiates sensor with Hardware Serial. More...
 
 Adafruit_Fingerprint (Stream *serial, uint32_t password=0x0)
 Instantiates sensor with a stream for Serial. More...
 
void begin (uint32_t baud)
 Initializes serial interface and baud rate. More...
 
boolean verifyPassword (void)
 Verifies the sensors' access password (default password is 0x0000000). A good way to also check if the sensors is active and responding. More...
 
uint8_t getParameters (void)
 Get the sensors parameters, fills in the member variables status_reg, system_id, capacity, security_level, device_addr, packet_len and baud_rate. More...
 
uint8_t getImage (void)
 Ask the sensor to take an image of the finger pressed on surface. More...
 
uint8_t image2Tz (uint8_t slot=1)
 Ask the sensor to convert image to feature template. More...
 
uint8_t createModel (void)
 Ask the sensor to take two print feature template and create a model. More...
 
uint8_t emptyDatabase (void)
 Ask the sensor to delete ALL models in memory. More...
 
uint8_t storeModel (uint16_t id)
 Ask the sensor to store the calculated model for later matching. More...
 
uint8_t loadModel (uint16_t id)
 Ask the sensor to load a fingerprint model from flash into buffer 1. More...
 
uint8_t getModel (void)
 Ask the sensor to transfer 256-byte fingerprint template from the buffer to the UART. More...
 
uint8_t deleteModel (uint16_t id)
 Ask the sensor to delete a model in memory. More...
 
uint8_t fingerFastSearch (void)
 Ask the sensor to search the current slot 1 fingerprint features to match saved templates. The matching location is stored in fingerID and the matching confidence in confidence More...
 
uint8_t fingerSearch (uint8_t slot=1)
 Ask the sensor to search the current slot fingerprint features to match saved templates. The matching location is stored in fingerID and the matching confidence in confidence More...
 
uint8_t getTemplateCount (void)
 Ask the sensor for the number of templates stored in memory. The number is stored in templateCount on success. More...
 
uint8_t setPassword (uint32_t password)
 Set the password on the sensor (future communication will require password verification so don't forget it!!!) More...
 
uint8_t LEDcontrol (bool on)
 Control the built in LED. More...
 
uint8_t LEDcontrol (uint8_t control, uint8_t speed, uint8_t coloridx, uint8_t count=0)
 Control the built in Aura LED (if exists). Check datasheet/manual for different colors and control codes available. More...
 
uint8_t setBaudRate (uint8_t baudrate)
 Change UART baudrate. More...
 
uint8_t setSecurityLevel (uint8_t level)
 Change security level. More...
 
uint8_t setPacketSize (uint8_t size)
 Change packet size. More...
 
void writeStructuredPacket (const Adafruit_Fingerprint_Packet &p)
 Helper function to process a packet and send it over UART to the sensor. More...
 
uint8_t getStructuredPacket (Adafruit_Fingerprint_Packet *p, uint16_t timeout=DEFAULTTIMEOUT)
 Helper function to receive data over UART from the sensor and process it into a packet. More...
 

Public Attributes

uint16_t fingerID
 The matching location that is set by fingerFastSearch()
 
uint16_t confidence
 
uint16_t templateCount
 The number of stored templates in the sensor, set by getTemplateCount()
 
uint16_t status_reg = 0x0
 The status register (set by getParameters)
 
uint16_t system_id = 0x0
 The system identifier (set by getParameters)
 
uint16_t capacity = 64
 The fingerprint capacity (set by getParameters)
 
uint16_t security_level = 0
 The security level (set by getParameters)
 
uint32_t device_addr
 The device address (set by getParameters) More...
 
uint16_t packet_len = 64
 The max packet length (set by getParameters)
 
uint16_t baud_rate = 57600
 The UART baud rate (set by getParameters)
 

Detailed Description

! Helper class to communicate with and keep state for fingerprint sensors

Constructor & Destructor Documentation

◆ Adafruit_Fingerprint() [1/2]

Adafruit_Fingerprint::Adafruit_Fingerprint ( HardwareSerial *  hs,
uint32_t  password = 0x0 
)

Instantiates sensor with Hardware Serial.

Parameters
hsPointer to HardwareSerial object
password32-bit integer password (default is 0)

◆ Adafruit_Fingerprint() [2/2]

Adafruit_Fingerprint::Adafruit_Fingerprint ( Stream *  serial,
uint32_t  password = 0x0 
)

Instantiates sensor with a stream for Serial.

Parameters
serialPointer to a Stream object
password32-bit integer password (default is 0)

Member Function Documentation

◆ begin()

void Adafruit_Fingerprint::begin ( uint32_t  baudrate)

Initializes serial interface and baud rate.

Parameters
baudrateSensor's UART baud rate (usually 57600, 9600 or 115200)

◆ verifyPassword()

boolean Adafruit_Fingerprint::verifyPassword ( void  )

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

◆ getParameters()

uint8_t Adafruit_Fingerprint::getParameters ( void  )

Get the sensors parameters, fills in the member variables status_reg, system_id, capacity, security_level, device_addr, packet_len and baud_rate.

Returns
True if password is correct

◆ getImage()

uint8_t Adafruit_Fingerprint::getImage ( void  )

Ask the sensor to take an image of the finger pressed on surface.

Returns
FINGERPRINT_OK on success
FINGERPRINT_NOFINGER if no finger detected
FINGERPRINT_PACKETRECIEVEERR on communication error
FINGERPRINT_IMAGEFAIL on imaging error

◆ image2Tz()

uint8_t Adafruit_Fingerprint::image2Tz ( uint8_t  slot = 1)

Ask the sensor to convert image to feature template.

Parameters
slotLocation to place feature template (put one in 1 and another in 2 for verification to create model)
Returns
FINGERPRINT_OK on success
FINGERPRINT_IMAGEMESS if image is too messy
FINGERPRINT_PACKETRECIEVEERR on communication error
FINGERPRINT_FEATUREFAIL on failure to identify fingerprint features
FINGERPRINT_INVALIDIMAGE on failure to identify fingerprint features

◆ createModel()

uint8_t Adafruit_Fingerprint::createModel ( void  )

Ask the sensor to take two print feature template and create a model.

Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error
FINGERPRINT_ENROLLMISMATCH on mismatch of fingerprints

◆ emptyDatabase()

uint8_t Adafruit_Fingerprint::emptyDatabase ( void  )

Ask the sensor to delete ALL models in memory.

Returns
FINGERPRINT_OK on success
FINGERPRINT_BADLOCATION if the location is invalid
FINGERPRINT_FLASHERR if the model couldn't be written to flash memory
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ storeModel()

uint8_t Adafruit_Fingerprint::storeModel ( uint16_t  location)

Ask the sensor to store the calculated model for later matching.

Parameters
locationThe model location #
Returns
FINGERPRINT_OK on success
FINGERPRINT_BADLOCATION if the location is invalid
FINGERPRINT_FLASHERR if the model couldn't be written to flash memory
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ loadModel()

uint8_t Adafruit_Fingerprint::loadModel ( uint16_t  location)

Ask the sensor to load a fingerprint model from flash into buffer 1.

Parameters
locationThe model location #
Returns
FINGERPRINT_OK on success
FINGERPRINT_BADLOCATION if the location is invalid
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ getModel()

uint8_t Adafruit_Fingerprint::getModel ( void  )

Ask the sensor to transfer 256-byte fingerprint template from the buffer to the UART.

Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ deleteModel()

uint8_t Adafruit_Fingerprint::deleteModel ( uint16_t  location)

Ask the sensor to delete a model in memory.

Parameters
locationThe model location #
Returns
FINGERPRINT_OK on success
FINGERPRINT_BADLOCATION if the location is invalid
FINGERPRINT_FLASHERR if the model couldn't be written to flash memory
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ fingerFastSearch()

uint8_t Adafruit_Fingerprint::fingerFastSearch ( void  )

Ask the sensor to search the current slot 1 fingerprint features to match saved templates. The matching location is stored in fingerID and the matching confidence in confidence

Returns
FINGERPRINT_OK on fingerprint match success
FINGERPRINT_NOTFOUND no match made
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ fingerSearch()

uint8_t Adafruit_Fingerprint::fingerSearch ( uint8_t  slot = 1)

Ask the sensor to search the current slot fingerprint features to match saved templates. The matching location is stored in fingerID and the matching confidence in confidence

Parameters
slotThe slot to use for the print search, defaults to 1
Returns
FINGERPRINT_OK on fingerprint match success
FINGERPRINT_NOTFOUND no match made
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ getTemplateCount()

uint8_t Adafruit_Fingerprint::getTemplateCount ( void  )

Ask the sensor for the number of templates stored in memory. The number is stored in templateCount on success.

Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ setPassword()

uint8_t Adafruit_Fingerprint::setPassword ( uint32_t  password)

Set the password on the sensor (future communication will require password verification so don't forget it!!!)

Parameters
password32-bit password code
Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ LEDcontrol() [1/2]

uint8_t Adafruit_Fingerprint::LEDcontrol ( bool  on)

Control the built in LED.

Parameters
onTrue if you want LED on, False to turn LED off
Returns
FINGERPRINT_OK on success

◆ LEDcontrol() [2/2]

uint8_t Adafruit_Fingerprint::LEDcontrol ( uint8_t  control,
uint8_t  speed,
uint8_t  coloridx,
uint8_t  count = 0 
)

Control the built in Aura LED (if exists). Check datasheet/manual for different colors and control codes available.

Parameters
controlThe control code (e.g. breathing, full on)
speedHow fast to go through the breathing/blinking cycles
coloridxWhat color to light the indicator
countHow many repeats of blinks/breathing cycles
Returns
FINGERPRINT_OK on fingerprint match success
FINGERPRINT_NOTFOUND no match made
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ setBaudRate()

uint8_t Adafruit_Fingerprint::setBaudRate ( uint8_t  baudrate)

Change UART baudrate.

Parameters
baudrate8-bit Uart baudrate
Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ setSecurityLevel()

uint8_t Adafruit_Fingerprint::setSecurityLevel ( uint8_t  level)

Change security level.

Parameters
level8-bit security level
Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ setPacketSize()

uint8_t Adafruit_Fingerprint::setPacketSize ( uint8_t  size)

Change packet size.

Parameters
size8-bit packet size
Returns
FINGERPRINT_OK on success
FINGERPRINT_PACKETRECIEVEERR on communication error

◆ writeStructuredPacket()

void Adafruit_Fingerprint::writeStructuredPacket ( const Adafruit_Fingerprint_Packet packet)

Helper function to process a packet and send it over UART to the sensor.

Parameters
packetA structure containing the bytes to transmit

◆ getStructuredPacket()

uint8_t Adafruit_Fingerprint::getStructuredPacket ( Adafruit_Fingerprint_Packet packet,
uint16_t  timeout = DEFAULTTIMEOUT 
)

Helper function to receive data over UART from the sensor and process it into a packet.

Parameters
packetA structure containing the bytes received
timeouthow many milliseconds we're willing to wait
Returns
FINGERPRINT_OK on success
FINGERPRINT_TIMEOUT or FINGERPRINT_BADPACKET on failure

Member Data Documentation

◆ confidence

uint16_t Adafruit_Fingerprint::confidence

The confidence of the fingerFastSearch() match, higher numbers are more confidents

◆ device_addr

uint32_t Adafruit_Fingerprint::device_addr
Initial value:
=
0xFFFFFFFF

The device address (set by getParameters)


The documentation for this class was generated from the following files: