本项目将利用STM32单片机来实现指纹识别或RFID刷卡的门禁或考勤系统。
功能可选组合:1、指纹识别;2、RDIF刷卡识别;3、指纹+刷卡
实现功能:指纹识别、射频RFID刷卡、LCD显示、用户交互
硬件平台:STM32单片机
所需工具:STM32开发板、指纹模块、刷卡模块
编程语言:C语言
代做/辅导:毕业设计<博主qq:914406940>
毕设资料下载/学习交流群:436609296
推荐其他毕业设计题目参考:毕业设计:电子/通信/计算机/物联网专业毕业设计选题参考(嵌入式linux/单片机STM32/web/图像)https://blog.csdn.net/qq_30155503/article/details/120339296
以下以指纹识别为例进行详细讲解:(刷卡只是模块不同,其他功能差不多)
选用微雪的UART Fingerprint Reader,亦可选其他款指纹模块。
微雪的UART Fingerprint Reader是一款专用于二次开发集成应用的新型指纹开发模块,高速度、快识别、高稳定性。
产品特性:
指纹感应灵敏,识别速度快:
指纹模块采用高精度光路和成像元件,使用时,只需要手指轻轻一点,就能快速识别;
稳定性强:
采用ST的STM32F205高级数字处理芯片作处理器,低功耗,快速稳定;
开发方便:
串口用UART操作(直接接任何带串口单片机),操作简单,并配有PC机的演示学习等工具;
开放:
可以自由输入输出指纹图片、指纹特征文件及各种指纹操作,协议更全,开放更好。
选用正点原子的STM32F103RCT6开发板,亦可选用其他款STM32开发板。
开发板的要求:
1、有UART串口:用来接指纹模块(视指纹模块而定,有些指纹模块可能为IIC或SPI等接口);
2、LCD屏:用以图形显示(若无图形显示需求亦可不要);
3、EEPROM存储芯片:用来存储用户数据;
4、其他,如按键、GPIO、LED等,视需求而定。
指纹模块的驱动,要参考其配套的资料手册。
在用户手册中,会详细说明如何编程使用,截取部分章节如下:
如上,说明串口UART的波特率、数据位、停止位等;
以及通信协议的数据格式、指令定义等。
部分驱动程序如下:
#include "stm32f1xx_hal.h"
#include "usart.h"
#include "fingerprint.h"
#include
uint8_t finger_TxBuf[9];
uint8_t Finger_SleepFlag;
/***************************************************************************
* @brief Query the number of existing fingerprints
* @return 0xFF: error
other: success, the value is the number of existing fingerprints
****************************************************************************/
uint8_t GetUserCount(void)
{
uint8_t m;
finger_TxBuf[0] = CMD_USER_CNT;
finger_TxBuf[1] = 0;
finger_TxBuf[2] = 0;
finger_TxBuf[3] = 0;
finger_TxBuf[4] = 0;
m = TxAndRxCmd(5, 8, 100);
if (m == ACK_SUCCESS && Usart1_ReceiveStruct.RX_pData[4] == ACK_SUCCESS)
{
return Usart1_ReceiveStruct.RX_pData[3];
}
else
{
return 0xFF;
}
}
/***************************************************************************
* @brief Get Compare Level
* @return 0xFF: error
other: success, the value is compare level
****************************************************************************/
uint8_t GetcompareLevel(void)
{
uint8_t m;
finger_TxBuf[0] = CMD_COM_LEV;
finger_TxBuf[1] = 0;
finger_TxBuf[2] = 0;
finger_TxBuf[3] = 1;
finger_TxBuf[4] = 0;
m = TxAndRxCmd(5, 8, 100);
if (m == ACK_SUCCESS && Usart1_ReceiveStruct.RX_pData[4] == ACK_SUCCESS)
{
return Usart1_ReceiveStruct.RX_pData[3];
}
else
{
return 0xFF;
}
}
/***************************************************************************
* @brief Set Compare Level
* @param temp: Compare Level,the default value is 5, can be set to 0-9, the bigger, the stricter
* @return 0xFF: error
other: success, the value is compare level
****************************************************************************/
uint8_t SetcompareLevel(uint8_t temp)
{
uint8_t m;
finger_TxBuf[0] = CMD_COM_LEV;
finger_TxBuf[1] = 0;
finger_TxBuf[2] = temp;
finger_TxBuf[3] = 0;
finger_TxBuf[4] = 0;
m = TxAndRxCmd(5, 8, 100);
if (m == ACK_SUCCESS && Usart1_ReceiveStruct.RX_pData[4] == ACK_SUCCESS)
{
return Usart1_ReceiveStruct.RX_pData[3];
}
else
{
return 0xFF;
}
}
/***************************************************************************
* @brief Register fingerprint
* @return ACK_SUCCESS: success
other: see the macro definition
****************************************************************************/
uint8_t AddUser(void)
{
uint8_t m;
m = GetUserCount();
if (m >= USER_MAX_CNT)
return ACK_FULL;
finger_TxBuf[0] = CMD_ADD_1;
finger_TxBuf[1] = 0;
finger_TxBuf[2] = m +1;
finger_TxBuf[3] = 3;
finger_TxBuf[4] = 0;
m = TxAndRxCmd(5, 8, 5000);
if (m == ACK_SUCCESS && Usart1_ReceiveStruct.RX_pData[4] == ACK_SUCCESS)
{
finger_TxBuf[0] = CMD_ADD_3;
m = TxAndRxCmd(5, 8, 5000);
if (m == ACK_SUCCESS && Usart1_ReceiveStruct.RX_pData[4] == ACK_SUCCESS)
{
return ACK_SUCCESS;
}
else
return ACK_FAIL;
}
else
return ACK_GO_OUT;
}
/***************************************************************************
* @brief Clear fingerprints
* @return ACK_SUCCESS: success
ACK_FAIL: error
****************************************************************************/
uint8_t ClearAllUser(void)
{
uint8_t m;
finger_TxBuf[0] = CMD_DEL_ALL;
finger_TxBuf[1] = 0;
finger_TxBuf[2] = 0;
finger_TxBuf[3] = 0;
finger_TxBuf[4] = 0;
m = TxAndRxCmd(5, 8, 500);
if (m == ACK_SUCCESS && Usart1_ReceiveStruct.RX_pData[4] == ACK_SUCCESS)
{
return ACK_SUCCESS;
}
else
{
return ACK_FAIL;
}
}
/***************************************************************************
* @brief Check if user ID is between 1 and 3
* @return TRUE
FALSE
****************************************************************************/
uint8_t IsMasterUser(uint8_t UserID)
{
if ((UserID == 1) || (UserID == 2) || (UserID == 3)) return TRUE;
else return FALSE;
}
/***************************************************************************
* @brief Fingerprint matching
* @return ACK_SUCCESS: success
other: see the macro definition
****************************************************************************/
uint8_t VerifyUser(void)
{
uint8_t m;
finger_TxBuf[0] = CMD_MATCH;
finger_TxBuf[1] = 0;
finger_TxBuf[2] = 0;
finger_TxBuf[3] = 0;
finger_TxBuf[4] = 0;
m = TxAndRxCmd(5, 8, 5000);
if ((m == ACK_SUCCESS) && (IsMasterUser(Usart1_ReceiveStruct.RX_pData[4]) == TRUE))
{
return ACK_SUCCESS;
}
else if(Usart1_ReceiveStruct.RX_pData[4] == ACK_NO_USER)
{
return ACK_NO_USER;
}
else if(Usart1_ReceiveStruct.RX_pData[4] == ACK_TIMEOUT)
{
return ACK_TIMEOUT;
}
else{
return ACK_FAIL;
}
}
/***************************************************************************
* @brief
If you enter the sleep mode, then open the Automatic wake-up function of the finger,
begin to check if the finger is pressed, and then start the module and match
****************************************************************************/
void Auto_Verify_Finger(void)
{
if(Read_Finger_WAKE_Pin == GPIO_PIN_SET) // If you press your finger
{
while(Read_Finger_WAKE_Pin != GPIO_PIN_RESET){
Finger_RST_Pin_HIGH; // Pull up the RST to start the module and start matching the fingers
LED1_Pin_HIGH;
HAL_Delay(300); // Wait for module to start
printf("Waiting Finger......Please try to place the center of the fingerprint flat to sensor !\r\n");
switch(VerifyUser())
{
case ACK_SUCCESS:
printf("Matching successful !\r\n");
break;
case ACK_NO_USER:
printf("Failed: This fingerprint was not found in the library !\r\n");
break;
case ACK_TIMEOUT:
printf("Failed: Time out !\r\n");
break;
case ACK_GO_OUT:
printf("Failed: Please try to place the center of the fingerprint flat to sensor !\r\n");
break;
default:
break;
}
//After the matching action is completed, drag RST down to sleep
//and continue to wait for your fingers to press
}
Finger_RST_Pin_LOW;
LED1_Pin_LOW;
return;
}
}
更多内容,期待补充!
更多资料请加群(见前面),如有疑问或毕设代做需求,请私聊博主。