Fingerprint Recognition Sensor
The optical fingerprint recognition sensor uses the AS608 fingerprint recognition chip from Synochip, a renowned fingerprint recognition chip company in China. The chip has a built-in DSP processing unit and integrates fingerprint recognition algorithms, allowing for efficient and fast image acquisition and fingerprint feature recognition. The module is equipped with serial and USB communication interfaces, so users do not need to study complex image processing or fingerprint recognition algorithms. It can be controlled simply through serial or USB communication according to the protocol. This module can be applied in various scenarios such as attendance systems, safes, fingerprint access control systems, fingerprint locks, and more.
Module Source
Purchase Link:
https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-24706531953.10.73946a4bXBZb14&id=566648022446
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1mCDdiU5nwtooxmHiPfYTFA
Password: kj8o
Specifications
Operating Voltage: 3.0-3.6V Operating Current: 30~60mA
Fingerprint Storage Capacity: 300 fingerprints (ID: 0299)
False Recognition Rate: <0.001% Search Time: <0.3s Control Method: Serial or USB
Pin Count: 8 Pin (2.54mm pitch header)
Hardware Connection
The system is equipped with a 72KB image buffer and two 512-byte feature file buffers, named ImageBuffer, CharBuffer1, and CharBuffer2. Users can read and write to any of these buffers via commands. CharBuffer1 or CharBuffer2 can be used to store either regular feature files or template feature files. When uploading or downloading images via the UART port, to speed up the process, only the high 4 bits of each pixel byte are used, meaning two pixels are combined into one byte for transmission. When using the USB port, 8-bit pixel data is transmitted.
The fingerprint database capacity varies depending on the attached FLASH capacity, and the system will automatically detect it. Fingerprint templates are stored in sequential order, defined as: 0—(N-1) (where N is the fingerprint database capacity). Users can only access the fingerprint database content based on the index number.
In this case, we are using serial control, and the USB interface can be left unconnected.
Red wire: Module main power supply, connect to 3.3V power (Do not connect to power supply above 3.3V, as it may damage the module!).
Yellow wire: Module UART TX (transmit pin), connect to MCU or TTL UART RX (receive pin). White wire: Module UART RX (receive pin), connect to MCU or TTL UART TX (transmit pin).
Black wire: Module ground, connect to 3.3V power ground (negative).
Blue wire: Module touch sensing signal output (high level indicates touch detection), connect VTI to 3.3V.
Green wire: Module touch sensing circuit power supply (3.3V), can be connected to pin 1 (red wire). Pins 7 and 8: USB signal lines, can be left unconnected when using serial control.
To connect the AS608 Fingerprint Recognition Sensor to the development board as follows:
- VCC connects to the development board's 3.3V power supply.
- GND connects to the development board's GND.
- TXD (sensor's transmit pin) connects to the development board's digital pin 2 (used as RX).
- RXD (sensor's receive pin) connects to the development board's digital pin 3 (used as TX).
Usage Method
- This example interacts with the user through the serial monitor, providing functions to add, recognize, and delete fingerprints.
- The
showMenu
function is used to allow the user to choose different operations. - The
addFingerprint
function takes a fingerprint ID as a parameter, which is entered by the user. - The
deleteFingerprint
function deletes the fingerprint data of a specific ID. - The program prompts the user to input their choices in the serial monitor, and they can enter the fingerprint ID as instructed.
- The
Serial.parseInt()
function is required to retrieve an integer from the serial input. - In the
loop
function,Serial.available()
is used to check if there is incoming data from the serial port.
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 8, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
// 软串口配置,根据实际连接的TX、RX引脚修改
SoftwareSerial mySerial(2, 3); // RX, TX
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
// 函数声明
void addFingerprint(uint8_t id);
void deleteFingerprint(uint8_t id);
uint8_t getFingerprintIDez();
void showMenu();
void setup() {
Serial.begin(9600);
mySerial.begin(57600);
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("指纹传感器连接成功");
} else {
Serial.println("指纹传感器连接失败");
while (1) { delay(1); } // 无限循环直到重启
}
showMenu(); // 显示菜单
}
void loop() {
if (Serial.available()) {
int choice = Serial.parseInt();
switch (choice) {
case 1:
Serial.println("请输入要添加的指纹ID号(1-127):");
while(!Serial.available()); // 等待用户输入
addFingerprint(Serial.parseInt());
break;
case 2:
getFingerprintIDez(); // 识别指纹
break;
case 3:
Serial.println("请输入要删除的指纹ID号(1-127):");
while(!Serial.available()); // 等待用户输入
deleteFingerprint(Serial.parseInt());
break;
default:
Serial.println("无效选择,请重新选择:");
showMenu();
break;
}
}
}
void showMenu(){
Serial.println("--- 指纹传感器Demo 菜单 ---");
Serial.println("1. 添加新指纹");
Serial.println("2. 识别指纹");
Serial.println("3. 删除指纹");
Serial.print("请输入你的选择:");
}
/**************************************** 添加指纹 ********************************************/
void addFingerprint(uint8_t id) {
int p = -1;
Serial.println("请放置手指...");
// 等待手指按下
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("图像采集成功");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("通信错误");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("图像采集失败");
break;
default:
Serial.println("未知错误");
break;
}
delay(50); // 短暂等待再次检测
}
// 将图像转换为特征并存储在CharBuffer 1
p = finger.image2Tz(1);
if (p != FINGERPRINT_OK) {
Serial.println("Error in image2Tz");
return;
}
Serial.println("请移开手指");
delay(2000);
p = -1;
Serial.println("请再次放置同一手指...");
// 等待手指再次按下
while (p != FINGERPRINT_OK) {
p = finger.getImage();
if (p == FINGERPRINT_OK) {
Serial.println("图像采集成功");
} else if (p == FINGERPRINT_NOFINGER) {
Serial.print(".");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("通信错误");
} else if (p == FINGERPRINT_IMAGEFAIL) {
Serial.println("图像采集失败");
} else {
Serial.println("未知错误");
}
delay(50); // 短暂等待再次检测
}
// 将图像转换为特征并存储在CharBuffer 2
p = finger.image2Tz(2);
if (p != FINGERPRINT_OK) {
Serial.println("Error in image2Tz");
return;
}
// 创建模型
p = finger.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("指纹匹配");
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("指纹不匹配");
return;
} else {
Serial.println("未知错误");
return;
}
// 将模型存储在传感器的存储库中,位置ID自行设置,例如从1开始
Serial.print("存储指纹模板中...");
p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("完成");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("通信错误");
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("无法存储在该位置");
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("写入Flash出错");
} else {
Serial.println("未知错误");
}
showMenu();//显示菜单
}
/**************************************** 识别指纹 ********************************************/
//注意该函数的写法是要先放好手指再进行识别
uint8_t getFingerprintIDez() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("图像采集成功");
break;
case FINGERPRINT_NOFINGER:
Serial.println("没有检测到指纹");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("通信错误");
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println("图像采集失败");
return p;
default:
Serial.println("未知错误");
return p;
}
// 尝试转换图像
p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
Serial.println("图像转换成功");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("图像模糊");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("通信错误");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("无法找到指纹的特征");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("指纹图像无效");
return p;
default:
Serial.println("未知错误");
return p;
}
// 在库中搜索指纹
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK) {
Serial.println("找到匹配的指纹");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("通信错误");
} else if (p == FINGERPRINT_NOTFOUND) {
Serial.println("没有找到匹配");
} else {
Serial.println("未知错误");
}
// 如果找到匹配,finger.fingerID 将会有匹配指纹的ID
Serial.print("找到ID #"); Serial.println(finger.fingerID);
Serial.print("匹配得分: "); Serial.println(finger.confidence);
showMenu();//显示菜单
return p;
}
/**************************************** 删除指纹 ********************************************/
void deleteFingerprint(uint8_t id){
uint8_t p = -1;
Serial.print("正在删除ID "); Serial.println(id);
p = finger.deleteModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("删除成功!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("通讯错误");
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("Could not delete in that location");
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error writing to flash");
} else {
Serial.print("Unknown error: 0x"); Serial.println(p, HEX);
}
showMenu();//显示菜单
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
Usage Method
Based on the prompt from the serial debugging tool, first select "Add Fingerprint" and save the fingerprint data at position 1. When recognizing the fingerprint, it is clear that the fingerprint with ID 1 has been successfully identified, indicating a successful recognition. Then, after deleting the fingerprint with ID 1 and attempting recognition again, the failure to recognize confirms that the deletion of the fingerprint was successful.