![]() |
SparkFun Fingerprint Sensor - FPC2534 Pro
v0.9.9-3-g5d0d172
Library for the SparkFun Fingerprint Sensor - FPC2534 Pro
|
Arduino Library for the SparkFun Fingerprint Sensor - FPC2534 Pro
The SparkFun Fingerprint Sensor - FPC2534 Pro is a small, highly capable and robust fingerprint sensor that can easily be integrated into virtually any application. Based off the AllKey Biometric System family from Fingerprints Cards (FPC), the FPC2534AP delivers incredible functionality in a small, compact form factor.
The SparkFun Fingerprint Sensor - FPC2534 Pro is accessible via a variety of interfaces, including I2C, UART and SPI, which are supported by this library.
This library provides a message-based, easy to use interface that enables fingerprint biometric authentication and simple finger-based navigation. Specifically, the FPC2534AP provides:
[!NOTE] The structure of the I2C transactions implemented by the FPC2434 sensor are not directly supported by the Arduino Wire/I2C library. To support the I2C interface to the FPC2434, this library implements helper functions that handle the FPC2434 I2C transactions. These implementations are only supported on RP2 and ESP32 systems.
Features that the FPC2534 supports, but are not currently implemented by this library include:
If any of these advanced features are desired for use, an implementation can be found within the Fingerprints FPC2543 SDK, which is available on the Fingerprints Website.
The operation of the FPC2534AP is performed by a messaging protocol implemented on the device. A client application sends message requests to the sensor and receives responses to the request made.
To support integration and messaging, the FPC2534AP provides support for four (4) different communication implementations. These are:
The communication method used is selected via a pair of configuration jumpers on the SparkFun Fingerprint Sensor - FPC2534 Pro board. Further information on the use is outlined in the associated Hookup Guide for the SparkFun fingerprint breakout board.
[!NOTE] The I2C (qwiic) interface for the SparkFun Fingerprint Sensor - FPC2534 Pro board is currently only supported on ESP32 and Raspberry RP2 (RP2040, RP2350) boards. The I2C implementation of the FPC2534 device performs a dynamic payload transmission that is not supported by the Arduino Wire library. Because of this, a custom implementation is provided by this library for the ESP32 and RP2 platforms.
In addition to the communication method selected, the FPC2534AP requires additional connections to facilitate communication. The following connections are required:
| Pin | Use | Notes |
|---|---|---|
| RST | Reset Device | Setting the pin low, then high will reset the FPC2534AP, placing it into a known state |
| IQ | IRQ/Interrupt Request | Used by the sensor to signal a new message/data availability - note: this is not required when using the serial interface |
Unlike a majority of sensors and their associated libraries which are synchronous function calls - a function/method call returns a requested value or performs a specific action - the FPC2534AP operates using a messaging methodology - sending messages to the client as actions occur on the device, or in response to earlier requests.
Since messaging methodology is used by the FPC2534AP, this library makes use of the following implementation pattern:
loop() function).While this methodology is unique to the when compared to other libraries, it fits well with the event driven nature of the FPC2534AP fingerprint sensor.
The first step to using the library is selected the method used to communicate with the device. The library supports I2C on select platforms, UART (a Serial interface in Arduino) or SPI. Once selected, and device connected as outlined in the hookup guide for the SparkFun Fingerprint Sensor - FPC2534 Pro. The type of connection depends on the method used to communicate with the device.
How the sensor is initialized is dependent on the communication method being utilized. The following sections outline how to use setup and initialize the I2C, UART or SPI interfaces to the device. Once setup, the operation of the device is communication method independent.
When using I2C to communicate with the fingerprint sensor, the class named SfeFPC2534I2C is used. An example of how to declare the sensor object is as follows:
To initialize the device, the following is needed:
0 or 1An example of calling the begin method:
At this point, the sensor is ready for normal operation.
Often, to determine if a sensor is available on the I2C bus, the bus is queried at the address for the device (a simple "ping"). In Arduino this often looks like:
Developing with the sensor has shown that once the sensor is "pinged", it enters an unknown state. To ensure proper device operation, a reset() of the device is needed after a ping operation is performed.
[!NOTE] The I2C (qwiic) interface for the SparkFun Fingerprint Sensor - FPC2534 Pro board is currently only supported on ESP32 and Raspberry RP2 (RP2040, RP2350) boards. The I2C implementation of the FPC2534 device performs a dynamic payload transmission that is not supported by the Arduino Wire library. Because of this, a custom implementation is provided by this library for the ESP32 and RP2 platforms.
When using a UART (Serial) to communicate with the fingerprint sensor, the class named SfeFPC2534UART is used. An example of how to declare the sensor object is as follows:
Configure the following settings on the UART/Serial connection being used:
| Setting | Value |
|---|---|
| Baud Rate | 921600 |
| Config | SERIAL_8N1 |
| Read Buffer Size | 512 |
[!NOTE] Due to the amount of information sent by the fingerprint sensor, the default size of the internal buffer used by Arduino Serial objects is rapidly exceeded. To prevent this, the buffer size must be increased before initializing the FPC2534AP device.
To increase the buffer size when using a Raspberry pi RP2 Microcontroller:
{c++}Serial1.setFIFOSize(512);</blockquote>> On an ESP32:
{c++}Serial.setRxBufferSize(512);If using a different controller for your project, the method used to expand the Serial read buffer will need to be determined. Some platforms (STM32 appears to self-adjust FIFO size) no additional calls are needed, but on others (normally older systems) no option exists rendering the Serial interface the FPC2543 un-usable on the platform.
To initialize the device, the Serial object used to communicate with the device is passed into the begin call.
An example of calling the begin method:
{c++}bool status = mySensor.begin(Serial1);At this point, the sensor is ready for normal operation.
Using SPI
When using SPI to communicate with the fingerprint sensor, the class named
SfeFPC2534SPIis used. An example of how to declare the sensor object is as follows:{c++}// Declare our sensor objectSfeFPC2534I2C mySensor;To initialize the device, the following is needed:
- The SPI bus to use - if using a the simple begin function, the default bus is used.
- The Settings for the SPI connection - if using a the simple begin function, default settings are used.
- The CS PIN for the SPI connection
- The Pin number the IRQ of the device is connected to. This IRQ is used by the sensor to indicated data is available for reading from the device.
An example of calling the simple begin method:
{c++}bool status = mySensor.begin(myCSPin, interruptPin );At this point, the sensor is ready for normal operation.
[!NOTE] In the provided examples, the FPC2534 sensor is reset after the
beginmethod is called, to ensure the senors is in a startup state.
The operational pattern for the SparkFun FPC2543 Fingerprint sensor library is outlined in the following diagram:
1) The first step is library initialization and setup.
loop section of system operation. 3) The application makes a request/sends a command to the sensor. These calls are asynchronous, and result in a message being sent to the sensor by the library. 4) During each loop iteration, the library method processNextResponse() is called. This method will check for new messages and process any messages sent by the sensor. 5) When checking for new messages, the library gets the next message/response from the device via the in-use communication bus. This message is parsed and processed. 6) When a response message is parsed and identified, if the host application has registered a callback for this message type, that callback function is called.The loop sequence of operation - make a request, check for messages and respond via callback functions continue during the operation of the sensor.
The results from the FPC2543 sensor are reported through the use of callback functions, which are user provided. While more advanced that standard functional programming, this implementation pattern is recommended by the FPC2543 manufacturer and fits nicely with the operational use of the sensor.
Callback functions are assigned with a structure of type sfDevFPC2534Callbacks_t, which is passed to the library during the setup sequence.
The following callbacks are available for use:
| Callback Name | Description |
|---|---|
| on_error | Called when the sensor send an error message. An error code is provided |
| on_status | Called with status update information from the sensor |
| on_version | Called as a result of a version request. The version string is passed to the callback |
| on_enroll | Called during a fingerprint enrollment process. The number of samples remaining and feedback are provided |
| on_list_templates | Called with the results of a requestListTemplates() call |
| on_navigation | Called when a navigation event is sent from the sensor |
| on_gpio_control | Called as the result of a GPIO get request call |
| on_system_config_get | Called when the system config is requested |
| on_bist_done | Called when the built-in testing routine is finished. The result of this test is provided |
| on_mode_change | Called when the mode of the sensor changes |
| on_finger_change | Called when the finger presence on the sensor changes |
| on_is_read_change | Called when the ready status of the sensor changes |
When the FPC2534 starts up, it posts a is ready for use status message, which can be detected within the on_status() callback function if provided to the library.
Another option is to register a on_is_ready_change() callback function, which is called when the ready state of the sensor changes. This simplifies the required implementation for using the sensor.
It the examples provided with this library, the on_is_ready_change() callback is used to determine when the sensor is ready for operation. When this callback is called with a "ready" value, the examples begin FPC2543 operations.
If an error is reported by the sensor, the error value is pass to the registered on_error() callback function.
One of the operating modes of FPC2534 is Navigation Mode. Enabled by calling the startNavigationMode() on the library, the FPC2534 acts like a small touch pad/joystick when in Navigation Mode. It should be noted, the startNavigationMode() method also takes a parameter that sets the orientation of the sensor. This is used when determining event type (up, down, left, right).
Events from this mode are communicated to the callback function assigned in the on_navigation field of the callback function structure that is passed to the library. The following events are supported:
The operation of this mode is outlined in the following diagram:
1) Standard setup, with a on_navigation() callback function provided 2) Once the sensor is running, start navigation mode. The sensor will interpret finger movements as navigation events and send messages when events are detected. 3) Loop mode is entered 4) Messages from the sensor are processed 5) When a navigation event message is identified, the message is parsed and the corresponding navigation event sent to the supplied on_navigation() callback function.
To further understand how to use Navigation mode, review the Navigation examples provided with this library.
Before the fingerprint sensor can validate a finger, that finger is enrolled into the sensor as a template. This operation is performed using an Enroll Mode of the sensor.
To enter the Enroll Mode, the requestEnroll() method is called in the library. Once in Enroll Mode, the user places and removes the desired finger from the sensor, and the sensor report back the number samples remaining/progress to the library. The library then calls the on_enroll() callback method as the process progresses. once the value of the remaining scans reaches zero, the process is complete.
This process is outlined in the following diagram:
1) Standard setup, with a on_enroll() callback function provided to the library. 2) Once the sensor is operational, the requestEnroll() method is called to start the enrollment process 3) A standard loop()* application pattern/method is started. 4) The method processNextResponse() is called on the library to get updates from the sensor. 5) The library identifies and parse an enrollment status message from the sensor 6) The registered on_enroll() callback method is called, with the number of samples remaining.
[!NOTE] An operational note when performing an enrollment process, when the user lifts their finger from the sensor, the
on_status()callback method is called with an event type of EVENT_FINGER_LOST. If this type is detected, and the methodcurrentMode()returns a value of STATE_IDENTIFY, it's helpful to indicate progress to the user. In our examples, a.is printed.
To further understand how to use the Enroll mode in your application, review the Enroll and Identify examples provided with this library:
Once the sensor has registered one or more fingerprints, an Identify operation can take place, matching a finger to an enrolled fingerprint. This is started by calling the requestIdentify() method of this library.
Once in Identify mode, the sensor will try to match a finger press to a registered fingerprint. The results of this match are communicated to the library and the user provided on_indentify() method is called with the results of the match process.
The overall identify sequence is outlined in the following diagram.
1) Standard setup, with a on_identify() callback function provided to the library. 2) Once the sensor is operational, the requestIdentify() method is called to start the identify process. 3) A standard loop() application pattern/method is started. 4) The method processNextResponse() is called on the library to get updates from the sensor. 5) The library identifies and parses an identify result message from the sensor. 6) The registered on_identify() callback method is called with the results from the identify operation.
To further understand how to use the Identify mode in your application, review the Enroll and Identify examples provided with this library:
[!NOTE] A behavior noticed when using I2C communication mode and performing an Identify operation was that the sensor can hang until the finger is removed from the sensor. When this occurs, the
on_status()callback is called with an event type of EVENT_IMAGE_READ and methodcurrentMode()reports a value of STATE_IDENTIFY. When detected, it is helpful to prompt the user to remove their finger from the sensor, which will return to normal operation.