EN
CN

FINGERPRINT IDENTIFICATION WITH STM32 MCU AND SERIAL TFT LCD MODULE

 

This month, I planned to develop a fingerprint door lock project. When I selected the fingerprint identification module, the project was suspended. However, I thought that since the fingerprint identification module had been purchased, I would simply test it.

This fingerprint module can be easily purchased online, connected over UART to an MCU  board. It supports fingerprint scanning, fingerprint entry, fingerprint comparison, and fingerprint deletion.

Since the fingerprint module manufacturer provides a demo program for STM32F103 series microcontrollers, I bought a small development board based on STM32F103C8T6.

The demo program of the fingerprint module uses LED lights to prompt the user to enter the fingerprint and compare the status (success or failure). But I want to use an LCD display, so I chose a 480×272 resolution serial LCD display. The specific model of this display is STONE STVC050WT-01, which communicates with MCU through UART, and will be covered in later chapters.

 

 

3 hardware components

 

A total of three hardware modules are used:

  • STM32 development board
  • Fingerprint module
  • STONE STVC050WT-01 LCD display

 

Fingerprint identification module with UART-TTL

 

serial-fingerprint-module

 

The UART fingerprint reader module is powered by STM32F205 high-speed digital processor from STMicro and integrates a fingerprint algorithm (TFS-9), as well as a high-precision optical sensor (TFS-d400). It supports fingerprint entry, image processing, feature value extraction, template generation, template storage, fingerprint comparison, and search. It exposes a UART interface to be driven from a host microcontroller or processor.

 

 

Features

  1. Sensitive fingerprint sensing and fast identification speed: the fingerprint module adopts high-precision optical path and imaging components, so only hands are needed when using it.
  2. Stability first: the module adopts STM32F205 MCU with low power consumption and fast speed. Speed & stability are better than Chinese chips.
  3. “Scientific structure”: the module adopts a modular structure, fingerprint sensor + processing motherboard + algorithm platform.
  4. Standard 16-pin universal interface: sensors can be independently selected and replaced by optical and other sensors; commercial algorithms are used.
  5. Easy development: serial port UART operation (directly connect to any single-chip microcomputer with serial port), extremely simple operation. The company provides demo software, learning software, MCU routines, and related tools.
  6. Openness: free input and output of fingerprint pictures, fingerprint characteristic value files and various fingerprint operations.

 

 

Application scenarios

 

Typical applications include fingerprint locks, fingerprint safes, fingerprint access control, fingerprint attendance,  intercoms, personnel identification, permission management, etc…

The fingerprint module can be purchased on Aliexpress for $37.78.

 

 

STONE 5-inch STVC050WT-01 4:3 TFT-LCD module

 

480×272 TFT LCD Display introduction

 

In this project, I would like to use STONE STVC050WT-01 TFT LCD to display the status of the fingerprint module (entry status, comparison status and deletion of fingerprint data). This display comes with a driver chip, and development software is provided for user interface development. The user simply needs to add the designed UI picture through the software as well as any button or text box as needed, and then generate the configuration file to flash into the display.

The STONE STVC050WT-01 display communicates with MCU through UART-TTL signals.

In theory, the STONE display and fingerprint module can communicate directly. However, due to the different communication data protocols, it is impossible to establish communication. Therefore, an MCU is still needed to handle serial communication.

 

STONE-LCD-Display

 

More technical information including the datasheet can be found on the product page.

 

 

4 steps to get started with STONE Touch LCD module

 

  1. Design the user display interface with PhotoShop, or other photo editing software.
  2. Design the display logic and button logic with STONE TOOL software, and download the design file onto the display module.
  3. The MCU communicates with the STONE LCD module through the serial port.
  4. The data obtained in step 3 shall be used for other actions by MCU.

 

 

STONE TOOL Software installation

 

Download the latest version of the STONE TOOL software (currently TOOL 2019) from the official website and install it.

After the software installation is completed, the following interface will be opened:

 

STONE-TOOL-Software-LCD

Click the “File” button in the upper left corner to create a new project, which will be explained in the following sections.

 

 

STM32 MCU Board

 

We used a development board based on STM32F103C8T6 MCU, which can be purchased on Aliexpress for under $2 shipped.

 

BlueBill_STM32_Board

 

 

The development environment of STM32

 

Keil vision is an integrated development environment developed by Keil. Currently, there are several versions of Vision2, Vision3, Vision4, and Vision5. In 2005, Keil was acquired by Arm. In March 2011, the latest integrated development environment Realview MDK development tool released by Arm integrated the latest version of Keil uvision4, and its compiler and debugging tool were optimized for Arm devices.

STM32 uses the KEIL MDK development environment, available on the company’s website.

 

 

STONE LCD Fingerprint module test project implementation

 

Hardware connection to development board and stone LCD module

To make sure that we can write code later, we must first determine the reliability of the hardware connection.

The STM32F103C8T6 development board and STVC050WT-01 TFT-LCD display are connected through UART, and then the STM32F103C8T6 development board and fingerprint module are also connected through UART.

Make sure the hardware connection is correct, then move on to the next step.

 

 

Only 1 step to design UI Graphic

 

First of all, we need to design a UI display image, which can be designed with PhotoShop software or other image design tools. After designing the UI display image, save the image as JPG format. Here’s the UI I designed in Photoshop.

 

fingerprint-scanner-UI

 

 

TFT-LCD Display module design

 

Open the STONE TOOL2019 software and create a new project:

 

STONE-TOOL-New_Project

 

Change-UI

 

Delete the image that the new project loads by default, and add the UI image that we designed ourselves.

 

 

How to add font file via STONE Tool

 

STONE-Tool-Font

 

 

The UI includes a status bar that shows fingerprint verification in real-time, so you need to add a font, as well as text display components and buttons.

The effect is as follows:

 

UI-font-

 

 

 

 

How to generate the configuration file for STONE LCD

 

Once the UI design above is complete, you can generate the configuration file and download it to the STVC050WT-01 display, which is described in the STONE development materials.

 

Upload-UI-to-STONE-LCD

 

Perform step 1 to generate the configuration file, then insert the USB flash drive into the computer. The flash drive will display. Then click “Download to u-disk” to download the configuration file to the USB flash drive, and then insert the USB flash drive into STVC050WT-01 to complete the upgrade.

 

 

How to connect the fingerprint module via UART-TTL

 

The fingerprint module actually consists of two parts:

  1. Optical collector
  2. Driver circuit

The core part is the driver circuit, which is integrated with an STM32F2 series chip. The fingerprint algorithm and scanning algorithm are embedded into the chip, and UART communication is used to get the results making it very convenient for application developers.

Hardware connection:

VCC —— — 3.3v or 5V
GND — — — — — -GND
TXD (fingerprint module serial port send) —— RXD (PC or MCU serial port Rx)
RXD (fingerprint module serial port receive) —— TXD (PC or MCU serial port Tx)
BL (backlight of fingerprint head, not connected) —- IO port
RST(fingerprint module reset, not connected) —— IO port

The first time, you can use a Windows PC to communicate with the fingerprint module through the serial port to do testing. You can find more details on Waveshare Wiki (in Chinese).

 

 

STM32 Application development

 

Visit the official website of the fingerprint module supplier, download the fingerprint module demo program (示例程序), and then open the program with KEIL software.

But before going further with software development, let’s connect the hardware first.

 

STM32-Fingerprint-TFT-LCD

 

Then send instructions through the serial console to check the connection is working properly.

 

SSCOM-serial-data-debugger

 

We made some minor modifications to the program with the final code (main.c) as follows:

 

#include

#include "usart.h"

#include "timer.h"

#include "fingerprint.h"

 

#define ADDUSER_BTN_ADDR       0x01

#define VERIFY_BTN_ADDR        0x05

#define CLEAR_BTN_ADDR         0x09

#define TEXT_STATUS_ADDR       0x0c

 

#define USER_SUCESS            0x01

#define USER_FAIL              0X00

u8 data_send[8]=  {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x00, 0x00,0x00};

 

void delay()

{

u16 i, j;

for (i = 0; i < 1000; i++)

for(j = 0; j < 10000; j++);

}

 

//void USERGPIO_Init(void)

//{

// GPIO_InitTypeDef  GPIO_InitStructure;

//

// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG, ENABLE);

//

// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9;

// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

// GPIO_Init(GPIOF, &GPIO_InitStructure);

// GPIO_ResetBits(GPIOF,GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9);

 

// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_8;

// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

// GPIO_Init(GPIOG, &GPIO_InitStructure);

 

// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

// GPIO_Init(GPIOC, &GPIO_InitStructure);

//}

 

//u8 key_scan(void)

//{

// if(!USER_KEY||!PRESS_KEY||!DEL_KEY)

// {

// delay();

// if(!USER_KEY) return 1;

// if(!PRESS_KEY) return 2;

// if(!DEL_KEY) return 3;

// }

// return 0;

//}

void UART1_Send_Array(u8 send_array[],unsigned char num)

{

        u8 i=0;  

        while(i

        {

                USART_SendData(USART1,send_array[i]);  

                while( USART_GetFlagStatus(USART1,USART_FLAG_TC)!= SET);  

                i++;  

        }

}

extern u8  USART_RX_BUF[10];

extern u8 USART_RX_END;

extern u16 USART_RX_STA;

int main(void)

{

int i = 5;

SystemInit();

// USERGPIO_Init();

usart_Configuration(115200,19200); //Ö¸ÎÆÄ£¿éĬÈÏÊÇ19200

 

// printf("Test Uart Fingerprint Reader\r\n");

SetcompareLevel(5);

// printf("compare level£º%d\r\n", GetcompareLevel());

// printf("time out£º%d\r\n",GetTimeOut());

// printf("total user:%d\r\n",GetUserCount());

while(1)

{

if(USART_RX_END)

{

//UART1_Send_Array(USART_RX_BUF,8);

switch (USART_RX_BUF[5])

{

case ADDUSER_BTN_ADDR:

//printf("User:%d\r\n",GetUserCount());

switch(AddUser(i))

{

case ACK_SUCCESS:

i++;

//printf("finger add success\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_SUCESS;

UART1_Send_Array(data_send,8);

LED2_ON;

delay();

LED2_OFF;

break;

case ACK_FAIL:

//printf("fail\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_FAIL;

UART1_Send_Array(data_send,8);

LED3_ON;

delay();

LED3_OFF;

break;

case ACK_FULL:

//printf("full\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_FAIL;

UART1_Send_Array(data_send,8);

LED4_ON;

delay();

LED4_OFF;

break;

}

break;

case VERIFY_BTN_ADDR:

switch(VerifyUser())

{

case ACK_SUCCESS:

//printf("Verify sucess\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_SUCESS;

UART1_Send_Array(data_send,8);

LED2_ON;

delay();

LED2_OFF;

break;

case ACK_NO_USER:

//printf("NO_USER\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_FAIL;

UART1_Send_Array(data_send,8);

LED3_ON;

delay();

LED3_OFF;

break;

case ACK_TIMEOUT:

//printf("time out\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_FAIL;

UART1_Send_Array(data_send,8);

LED3_ON;

delay();

LED3_OFF;

break;

case ACK_GO_OUT:

//printf("GO OUT\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_FAIL;

UART1_Send_Array(data_send,8);

break;

};

break;

case CLEAR_BTN_ADDR:

ClearAllUser();

//printf("all user remove\r\n");

data_send[5]=TEXT_STATUS_ADDR;

data_send[7]=USER_SUCESS;

UART1_Send_Array(data_send,8);

break;

default:

USART_RX_END=0;

USART_RX_STA=0;

}

USART_RX_END=0;

USART_RX_STA=0;

}

}

}

 

STM32-USART-IRQ-handler

 

 

The final result

We only need to connect the STM32 board, fingerprint module, display screen, and power supply.  Press the button above the STONE display, and you should be able to add, delete, and verify fingerprints.

 

stm32-pringerprint-demo

STM32-fingerprint-verification-success

 

Article source:  https://www.cnx-software.com/2019/11/12/fingerprint-identification-with-stm32-mcu-and-serial-tft-lcd-module/