Intermediate
30 min

Simplify user interactions by employing a fingerprint-based solution with 100018754 and STM32F031K6

Seamless authentication

Fingerprint 4 Click with Nucleo 32 with STM32F031K6 MCU

Published Oct 01, 2024

Click board™

Fingerprint 4 Click

Dev. board

Nucleo 32 with STM32F031K6 MCU

Compiler

NECTO Studio

MCU

STM32F031K6

This solution aims to provide real-time matching and validation of fingerprint patterns, establishing a seamless and robust authentication process

A

A

Hardware Overview

How does it work?

Fingerprint 4 Click is based on the FPC BM-Lite module (100018754), a standalone, compact biometric fingerprint solution from Fingerprints with a robust fingerprint sensor, biometric processor, and on-board template storage ready to be used out-of-the-box. This Click board™ can be integrated into any application and controlled by a host MCU sending some basic commands for enrollment and verification via the selectable serial interface. The BM-Lite module is based on capacitive technology and utilizes a reflective measurement method. It acquires the fingerprint image from the fingerprint sensor. It stores them in the internal flash memory, which is pre-loaded with firmware from Fingerprints and used for all biometric operations and template storage.

The BM-Lite module, with a 160x160px sensor matrix, uses a 3D pixel sensing technology that can read virtually any finger, dry or wet, and brings together superior biometric performance and a high standard of integrated quality components to offer an embedded solution for increased security and enhanced user convenience. The module has a protective coating that protects against ±15kV ESD, scratches, and daily wear and tear impact. It is also waterproof, making it suitable for demanding industrial conditions and all-weather applications. Fingerprint 4 Click allows the UART interface with commonly used UART RX and TX pins, operating at 115200bps by default configuration, to transmit and exchange data with the host MCU or SPI interface with a maximum

frequency of 20MHz. The selection can be made by positioning SMD jumpers labeled as COMM SEL in an appropriate position. While using the SPI interface, users can use the data ready pin, marked IRQ and routed to the INT pin of the mikroBUS™ socket, to inform the host MCU about detecting a finger on the module and general reset function routed on the RST pin of the mikroBUS™ socket. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.

Fingerprint 4 Click top side image
Fingerprint 4 Click bottom side image

Features overview

Development board

Nucleo 32 with STM32F031K6 MCU board provides an affordable and flexible platform for experimenting with STM32 microcontrollers in 32-pin packages. Featuring Arduino™ Nano connectivity, it allows easy expansion with specialized shields, while being mbed-enabled for seamless integration with online resources. The

board includes an on-board ST-LINK/V2-1 debugger/programmer, supporting USB reenumeration with three interfaces: Virtual Com port, mass storage, and debug port. It offers a flexible power supply through either USB VBUS or an external source. Additionally, it includes three LEDs (LD1 for USB communication, LD2 for power,

and LD3 as a user LED) and a reset push button. The STM32 Nucleo-32 board is supported by various Integrated Development Environments (IDEs) such as IAR™, Keil®, and GCC-based IDEs like AC6 SW4STM32, making it a versatile tool for developers.

Nucleo 32 with STM32F031K6 MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

32

Silicon Vendor

STMicroelectronics

Pin count

32

RAM (Bytes)

4096

You complete me!

Accessories

Click Shield for Nucleo-32 is the perfect way to expand your development board's functionalities with STM32 Nucleo-32 pinout. The Click Shield for Nucleo-32 provides two mikroBUS™ sockets to add any functionality from our ever-growing range of Click boards™. We are fully stocked with everything, from sensors and WiFi transceivers to motor control and audio amplifiers. The Click Shield for Nucleo-32 is compatible with the STM32 Nucleo-32 board, providing an affordable and flexible way for users to try out new ideas and quickly create prototypes with any STM32 microcontrollers, choosing from the various combinations of performance, power consumption, and features. The STM32 Nucleo-32 boards do not require any separate probe as they integrate the ST-LINK/V2-1 debugger/programmer and come with the STM32 comprehensive software HAL library and various packaged software examples. This development platform provides users with an effortless and common way to combine the STM32 Nucleo-32 footprint compatible board with their favorite Click boards™ in their upcoming projects.

Click Shield for Nucleo-32 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PA11
RST
SPI Chip Select
PA4
CS
SPI Clock
PB3
SCK
SPI Data OUT
PB4
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Data Ready
PA12
INT
UART TX
PA10
TX
UART RX
PA9
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Fingerprint 4 Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-144 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo 32 with STM32F031K6 MCU as your development board.

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
2x4 RGB Click front image hardware assembly
Prog-cut hardware assembly
Nucleo-32 with STM32 MCU MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Clicker 4 for STM32F4 HA MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Fingerprint 4 Click driver.

Key functions:

  • fingerprint4_version - This function reads out version information from the device

  • fingerprint4_identify_finger - This function captures and identifies finger against existing templates in Flash storage

  • fingerprint4_wait_finger_not_present - This function waits until no finger is detected on the sensor

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief Fingerprint 4 Click example
 *
 * # Description
 * This example demonstrates the use of the Fingerprint 4 Click boards by registering 3 fingerprints and
 * then waiting until a finger is detected on the sensor and identifying if the fingerprint matches one of
 * those stored in the Flash storage.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver and reads the sensor firmware version, then resets the sensor and removes all
 * stored fingerprint templates. After that it registers 3 new fingerprint templates and stores them in the Flash storage.
 * 
 * ## Application Task  
 * Waits until a finger is detected on the sensor, takes an image of the finger and checks if there's
 * a fingerprint in the library that matches the one it has just read. If it finds a match, a fingerprint template
 * ID will be displayed. All data is being logged on the USB UART where you can track the program flow.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "fingerprint4.h"

#define LOCATION_IN_FLASH               0   // Starting location or template ID where the fingerprints will be stored.
#define NUMBER_OF_FINGERPRINTS          3   // Number of fingerprints to register.

static fingerprint4_t fingerprint4;
static log_t logger;

/**
 * @brief Fingerprint 4 error check function.
 * @details This function checks the @b error_flag and displays the result appended to @b message 
 * on the USB UART.
 * @param[in] message : Prefix message of the error_flag result.
 * @param[in] error_flag : Error flag, return value of the functions.
 * @return None.
 * @note None.
 */
static void fingerprint4_error_check ( char *message, err_t error_flag );

/**
 * @brief Fingerprint 4 enroll fingerprint function.
 * @details This function enrolls a single fingerprint by taking 3 image captures. Each step will be logged on the USB UART
 * where you can track the function flow.
 * @param[in] ctx : Click context object.
 * See #fingerprint4_t object definition for detailed explanation.
 * @return @li @c  0 - Success,
 *         @li @c <0 - Error.
 * See #fingerprint4_return_value_t definition for detailed explanation.
 * @note None.
 */
static err_t fingerprint4_enroll_fingerprint ( fingerprint4_t *ctx );

/**
 * @brief Fingerprint 4 register fingerprints function.
 * @details This function registers a desired number of fingerprints starting from the selected template ID.
 * Each step will be logged on the USB UART where you can track the function flow.
 * @param[in] ctx : Click context object.
 * See #fingerprint4_t object definition for detailed explanation.
 * @param[in] template_id : Starting template ID of fingerprints to store to Flash.
 * @param[in] num_fpc : Number of fingerprints to register.
 * @return None.
 * @note None.
 */
static void fingerprint4_register_fingerprints ( fingerprint4_t *ctx, uint16_t template_id, uint8_t num_fpc );

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    fingerprint4_cfg_t fingerprint4_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    fingerprint4_cfg_setup( &fingerprint4_cfg );
    FINGERPRINT4_MAP_MIKROBUS( fingerprint4_cfg, MIKROBUS_1 );
    if ( FINGERPRINT4_RES_OK != fingerprint4_init( &fingerprint4, &fingerprint4_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    fingerprint4_reset_device ( &fingerprint4 );
    
    fingerprint4.phy_rx_timeout = FINGERPRINT4_DEFAULT_PHY_RX_TIMEOUT_MS;
    
    uint8_t version[ 50 ] = { 0 };
    if ( FINGERPRINT4_RES_OK == fingerprint4_version ( &fingerprint4, version, 50 ) )
    {
        log_printf( &logger, " FW version: %s\r\n", version );
        log_printf( &logger, "---------------------------------\r\n\n" );
    }
    
    fingerprint4_error_check( "Sensor reset", fingerprint4_sensor_reset ( &fingerprint4 ) );
    
    fingerprint4_error_check( "Remove all templates", fingerprint4_template_remove_all ( &fingerprint4 ) );
    
    fingerprint4_register_fingerprints ( &fingerprint4, LOCATION_IN_FLASH, NUMBER_OF_FINGERPRINTS );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    uint16_t template_id;
    bool match;
    log_printf( &logger, " Put your finger on the sensor.\r\n" );
    err_t error_flag = fingerprint4_identify_finger ( &fingerprint4, FINGERPRINT4_INFINITE_TIMEOUT, &template_id, &match );
    if ( error_flag )
    {
        fingerprint4_error_check( "Identify finger", error_flag );
    }
    else
    {
        if ( match )
        {
            log_printf( &logger, " >>>>> Fingerprint MATCH - Template ID: %u <<<<<\r\n", template_id );
        }
        else
        {
            log_printf( &logger, " >>>>> NO MATCH in the library <<<<<\r\n" );
        }
    }
    log_printf( &logger, " Lift the finger of the sensor.\r\n" );
    fingerprint4_wait_finger_not_present ( &fingerprint4, FINGERPRINT4_INFINITE_TIMEOUT );
    log_printf( &logger, "---------------------------------\r\n\n" );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static void fingerprint4_error_check ( char *message, err_t error_flag )
{
    log_printf( &logger, " %s: ", message );
    if ( error_flag )
    {
        log_printf( &logger, "FAIL! [ERROR] Num: %ld\r\n", error_flag );
    }
    else
    {
        log_printf( &logger, "DONE!\r\n" );
    }
    log_printf( &logger, "---------------------------------\r\n\n" );
}

static void fingerprint4_register_fingerprints ( fingerprint4_t *ctx, uint16_t template_id, uint8_t num_fpc )
{
    err_t error_flag = FINGERPRINT4_RES_OK;
    uint8_t cnt = 1;
    while ( cnt <= num_fpc )
    {
        log_printf( &logger, " >>> Registering fingerprint %u of %u <<<\r\n", ( uint16_t ) cnt, 
                                                                              ( uint16_t ) num_fpc );
        error_flag = fingerprint4_enroll_fingerprint ( ctx );
        if ( error_flag )
        {
            fingerprint4_error_check( "Enroll finger", error_flag );
        }
        else
        {
            error_flag = fingerprint4_template_save ( &fingerprint4, template_id + cnt - 1 );
            if ( error_flag )
            {
                fingerprint4_error_check( "Template save", error_flag );
            }
            else
            {
                log_printf( &logger, " Fingerprint template ID: %u\r\n", template_id + cnt - 1 );
                log_printf( &logger, "---------------------------------\r\n\n" );
                cnt++;
            }
        }
    }
}

static err_t fingerprint4_enroll_fingerprint ( fingerprint4_t *ctx )
{
    err_t error_flag = FINGERPRINT4_RES_OK;
    bool enroll_done = false;
    // Enroll start
    error_flag = fingerprint4_send_cmd ( ctx, FINGERPRINT4_CMD_ENROLL, FINGERPRINT4_ARG_START );
    if ( error_flag )
    {
        fingerprint4_error_check( "Enroll start", error_flag );
        return error_flag;
    }
    uint8_t cnt = 1;
    while ( cnt <= FINGERPRINT4_NUM_IMAGES )
    {
        log_printf( &logger, " >>> Taking image %u of %u <<<\r\n", ( uint16_t ) cnt, 
                                                                   ( uint16_t ) FINGERPRINT4_NUM_IMAGES );
        log_printf( &logger, " Put your finger on the sensor.\r\n" );
        // Capture image
        uint32_t prev_timeout = ctx->phy_rx_timeout;
        ctx->phy_rx_timeout = FINGERPRINT4_INFINITE_TIMEOUT;
        error_flag = fingerprint4_send_cmd_arg ( ctx, FINGERPRINT4_CMD_CAPTURE, FINGERPRINT4_ARG_NONE, 
                                                 FINGERPRINT4_ARG_TIMEOUT, &ctx->phy_rx_timeout, sizeof ( ctx->phy_rx_timeout ) );
        ctx->phy_rx_timeout = prev_timeout;
        if ( error_flag ) 
        {
            fingerprint4_error_check( "Capture image", error_flag );
            continue;
        }
        // Enroll add
        error_flag = fingerprint4_send_cmd ( ctx, FINGERPRINT4_CMD_ENROLL, FINGERPRINT4_ARG_ADD );
        if ( error_flag ) 
        {
            fingerprint4_error_check( "Enroll add", error_flag );
            continue;
        }
        cnt++;
        uint32_t samples_remaining;
        fingerprint4_copy_arg ( ctx, FINGERPRINT4_ARG_COUNT, ( uint8_t * ) &samples_remaining, 4 );
        // Break enrolling if we collected enough correct images
        if ( !samples_remaining ) 
        {
            enroll_done = true;
            break;
        }
        log_printf( &logger, " Lift the finger of the sensor.\r\n" );
        log_printf( &logger, "---------------------------------\r\n" );
        fingerprint4_wait_finger_not_present ( ctx, FINGERPRINT4_INFINITE_TIMEOUT );
    }
    error_flag = fingerprint4_send_cmd ( ctx, FINGERPRINT4_CMD_ENROLL, FINGERPRINT4_ARG_FINISH );
    if ( error_flag )
    {
        fingerprint4_error_check( "Enroll finish", error_flag );
        return error_flag;
    }
    log_printf( &logger, " Lift the finger of the sensor.\r\n" );
    log_printf( &logger, "---------------------------------\r\n" );
    fingerprint4_wait_finger_not_present ( ctx, FINGERPRINT4_INFINITE_TIMEOUT );
    return ( !enroll_done ) ? FINGERPRINT4_RES_ERROR : error_flag;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.