Intermediate
30 min

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

Seamless authentication

Fingerprint 4 Click with EasyAVR v7

Published Aug 25, 2023

Click board™

Fingerprint 4 Click

Dev. board

EasyAVR v7

Compiler

NECTO Studio

MCU

ATmega644

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

EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more

efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)

connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyAVR v7 horizontal image

Microcontroller Overview

MCU Card / MCU

ATmega644

Architecture

AVR

MCU Memory (KB)

64

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

4096

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PA6
RST
SPI Chip Select
PA5
CS
SPI Clock
PB7
SCK
SPI Data OUT
PB6
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Data Ready
PD2
INT
UART TX
PD1
TX
UART RX
PD0
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

EasyAVR v7 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyAVR v7 as your development board.

EasyAVR v7 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyAVR v7 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
EasyPIC PRO v7a Display Selection Necto Step hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image 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.