本專案將利用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機的演示學習等工具;
開放:
可以自由輸入輸出指紋圖片、指紋特征檔案及各種指紋操作,協議更全,開放更好,
STM32單片機
選用正點原子的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 <string.h>
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;
}
}
更多內容,期待補充!
更多資料請加群(見前面),如有疑問或畢設代做需求,請私聊博主,
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/310608.html
標籤:其他
上一篇:秒殺鏈路兜底方案之限流&降級實戰
