Fingerprint Recognition Sensor
The optical fingerprint recognition sensor uses the AS608 fingerprint recognition chip from Synochip, a well-known domestic fingerprint recognition chip company based in Hangzhou. The chip has a built-in DSP computing unit and integrates fingerprint recognition algorithms, enabling efficient and fast image acquisition and fingerprint feature recognition. The module is equipped with UART and USB communication interfaces, so users do not need to study complex image processing and fingerprint recognition algorithms. They can control the module simply through UART or USB according to the communication protocol. This module can be applied to various occasions such as attendance machines, safes, fingerprint access control systems, fingerprint locks, and so on.
Module Source
Purchase link: https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-24706531953.10.73946a4bXBZb14&id=566648022446 Materials download link: https://pan.baidu.com/s/1mCDdiU5nwtooxmHiPfYTFA Materials extraction code: kj8o
Specifications
Operating voltage: 3.0-3.6V Operating current: 30~60mA Fingerprint storage capacity: 300 (ID: 0~299) False acceptance rate: <0.001% Search time: <0.3 (S) Control method: UART or USB Number of pins: 8 Pin (2.54mm pitch header)
File Download
File 2.7.2-1 Product Specification
Principle Analysis
The system has a 72KB image buffer and two 512-byte feature file buffers, named ImageBuffer, CharBuffer1, and CharBuffer2 respectively. Users can read and write any buffer through commands. CharBuffer1 or CharBuffer2 can be used to store ordinary feature files or template feature files. When uploading or downloading images through the UART port, to speed up the process, only the upper 4 bits of each pixel byte are used, that is, two pixels are combined into one byte for transmission. Through the USB port, the full 8-bit pixel is used. The fingerprint library capacity varies according to the connected FLASH capacity, and the system will automatically detect it. Fingerprint templates are stored in order, with serial numbers defined as 0—(N-1) (N is the fingerprint library capacity). Users can only access the fingerprint library contents by serial number. Here we use UART as the control method, and the USB interface can be left floating (unconnected).
Pin 1 (red wire): Module main power, connected to 3.3V power supply (do NOT connect to a power source above 3.3V, otherwise the module will burn out!); Pin 2 (yellow wire): Module UART TX (transmit end), connected to the RX (receive end) of the MCU or TTL serial port; Pin 3 (white wire): Module UART RX (receive end), connected to the TX (transmit end) of the MCU or TTL serial port; Pin 4 (black wire): Module power ground, connected to 3.3V power ground (negative pole); Pin 5 (blue wire): Module touch sensing signal output (high level means touch is detected), needs to be connected to VTI to 3.3V. Pin 6 (green wire): Module touch sensing circuit power (3.3V), can be connected in parallel with pin 1 (red wire). Pins 7 and 8 are USB signal lines, which can be left floating when using UART to control the module.
Porting Process
Pin Selection
Next we need a CH340 module. The physical connection is shown in the figure below:
Port to Project
Our goal is to port the example to the ESP32-S3 dev board. Complete driver code has been provided for you. Follow the steps below to complete the porting. For detailed instructions on creating folders and new .c and .h files, refer to section 1.4.2 in the [DHT11 Temperature and Humidity Sensor] chapter; we will not repeat it here. Just note that here we change the file names bsp_dht11.c and bsp_dht11.h to bsp_as608.c and bsp_as608.h, and the folder name to AS608.
Write Code
Write the following in the bsp_as608.c file:
#include "bsp_as608.h"
#include "stdio.h"
#include "string.h"
volatile unsigned char FPM10A_RECEICE_BUFFER[32];
unsigned int finger_id = 0;
const unsigned char FPM10A_Get_Device[10] ={0x01,0x00,0x07,0x13,0x00,0x00,0x00,0x00,0x00,0x1b};//Password verification
const unsigned char FPM10A_Pack_Head[6] = {0xEF,0x01,0xFF,0xFF,0xFF,0xFF}; //Protocol packet header
const unsigned char FPM10A_Get_Img[6] = {0x01,0x00,0x03,0x01,0x00,0x05}; //Get fingerprint image
const unsigned char FPM10A_Get_Templete_Count[6] ={0x01,0x00,0x03,0x1D,0x00,0x21 }; //Get total number of templates
const unsigned char FPM10A_Search[11]={0x01,0x00,0x08,0x04,0x01,0x00,0x00,0x03,0xE7,0x00,0xF8}; //Search fingerprint, search range 0 - 999, use feature code in BUFFER1 to search
const unsigned char FPM10A_Search_0_9[11]={0x01,0x00,0x08,0x04,0x01,0x00,0x00,0x00,0x13,0x00,0x21}; //Search fingerprint No.0-9
const unsigned char FPM10A_Img_To_Buffer1[7]={0x01,0x00,0x04,0x02,0x01,0x00,0x08}; //Put image into BUFFER1
const unsigned char FPM10A_Img_To_Buffer2[7]={0x01,0x00,0x04,0x02,0x02,0x00,0x09}; //Put image into BUFFER2
const unsigned char FPM10A_Reg_Model[6]={0x01,0x00,0x03,0x05,0x00,0x09}; //Combine BUFFER1 and BUFFER2 into a feature template
const unsigned char FPM10A_Delete_All_Model[6]={0x01,0x00,0x03,0x0d,0x00,0x11};//Delete all templates in the fingerprint module
volatile unsigned char FPM10A_Save_Finger[9]={0x01,0x00,0x06,0x06,0x01,0x00,0x0B,0x00,0x19};//Save the feature code in BUFFER1 to the specified location
uint8_t u2_recv_buff[USART_RECEIVE_LENGTH]; // Receive buffer
uint16_t u2_recv_length = 0; // Receive data length
uint8_t u2_recv_flag = 0; // Receive data completion flag
uint8_t g_recv_buff[USART_RECEIVE_LENGTH];
void delay_ms(unsigned int ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}
void delay_us(unsigned int us)
{
ets_delay_us(us);
}
/******************************************************************
* Function Name: as608_gpio_config
* Function Description: Initialize as608 pins
* Function Parameters: Set baud rate; the default baud rate of as608 is 57600
* Function Return: None
* Author: LC
* Notes: The default baud rate of as608 is 57600
******************************************************************/
void as608_gpio_config(uint32_t band_rate)
{
//Define the UART configuration structure, must be assigned initial values, otherwise it cannot work
uart_config_t uart_config={0};
uart_config.baud_rate = band_rate; //Configure baud rate
uart_config.data_bits = UART_DATA_8_BITS; //Configure data bits to 8 bits
uart_config.parity = UART_PARITY_DISABLE; //Configure parity check as not required
uart_config.stop_bits = UART_STOP_BITS_1; //Configure stop bits to one bit
uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; //Disable hardware flow control
//Load the above parameters into the registers of UART1
uart_param_config(AS608_UART, &uart_config);
uart_param_config(CH340_UART, &uart_config);
//Bind pins TX=tx_pin RX=rx_pin RTS=not used CTS=not used
uart_set_pin(AS608_UART, AS608_TX_PIN, AS608_RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
//Bind pins TX=tx_pin RX=rx_pin RTS=not used CTS=not used
uart_set_pin(CH340_UART, CH340_TX, CH340_RX, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
//Install UART driver
uart_driver_install(AS608_UART, USART_RECEIVE_LENGTH, USART_RECEIVE_LENGTH, 0, NULL, 0);
//Install UART driver
uart_driver_install(CH340_UART, USART_RECEIVE_LENGTH, USART_RECEIVE_LENGTH, 0, NULL, 0);
}
/************************************************
Function Name: uart_send_byte
Function: UART send one byte
Parameters: ucch: the byte to send
Return Value:
Author: LC
*************************************************/
void uart_send_byte(uint8_t ucch)
{
uart_write_bytes(AS608_UART,&ucch,sizeof(ucch));
}
/**
* @Function Description UART2 receive task
* @Parameters None
* @Function Return None
* @Function Description Please create this task via xTaskCreate
*/
void uart2_rx_task(void)
{
while(1)
{
//Receive the data length received by UART
u2_recv_length = uart_read_bytes(AS608_UART, u2_recv_buff, USART_RECEIVE_LENGTH, 10 / portTICK_PERIOD_MS);
if( u2_recv_length > 0 )//Data length greater than 0 means data was received
{
u2_recv_buff[u2_recv_length] = 0;//Set the last byte of the UART data to 0 to form a string
u2_recv_flag = 1;
// //Output the length of the received data
// sprintf((const char*)temp,"uart2 string length : %d\r\n", rx_bytes);
// uart_write_bytes(AS608_UART, (const char*)temp, strlen((const char*)temp));
//Output the received data via UART2
// uart_write_bytes(AS608_UART, (const char*)"uart2 received : ", strlen("uart2 received : "));
// uart_write_bytes(AS608_UART, (const char*)rx_data, strlen((const char*)rx_data));
// //UART ring buffer flush. Discard all data in the UART RX buffer, prepare for the next reception
// uart_flush(AS608_UART);
}
delay_ms(50);
}
}
/**
* @Function Description UART1 receive task
* @Parameters None
* @Function Return None
* @Function Description Please create this task via xTaskCreate
*/
void uart1_rx_task(void)
{
while(1)
{
//Receive the data length received by UART
int u1_recv_length = uart_read_bytes(CH340_UART, g_recv_buff, USART_RECEIVE_LENGTH, 10 / portTICK_PERIOD_MS);
if( u1_recv_length > 0 )//Data length greater than 0 means data was received
{
g_recv_buff[u1_recv_length] = 0;//Set the last byte of the UART data to 0 to form a string
}
delay_ms(100);
}
}
/************************************************
Function Name: uart_receive_clear
Function: Clear all received UART data
Parameters: None
Return Value: None
Author: LC
*************************************************/
void uart_receive_clear(void)
{
unsigned int i = 0;
for( i = 0; i < USART_RECEIVE_LENGTH; i++ )
{
u2_recv_buff[ i ] = 0;
}
uart_flush(AS608_UART);
u2_recv_length = 0;
}
/******************************************************************
* Function Name: get_as608_touch
* Function Description: Get whether there is a finger touching the recognition area
* Function Parameters: None
* Function Return: 0 no touch 1 touch detected
* Author: LC
* Notes: None
******************************************************************/
char get_as608_touch(void)
{
if( TOUCH_IN == 1 )//Touch is 1
{
// printf("1\r\n");
return 1;
}
return 0;
}
/******************************************************************
* Function Name: FPM10A_Cmd_Send_Pack_Head
* Function Description: Send packet header
* Function Parameters: None
* Function Return: none
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Cmd_Send_Pack_Head(void)
{
int i;
for(i=0;i<6;i++) //Packet header
{
uart_send_byte(FPM10A_Pack_Head[i]);
}
}
/******************************************************************
* Function Name: FPM10A_Cmd_Check
* Function Description: Send command
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Cmd_Check(void)
{
int i=0;
FPM10A_Cmd_Send_Pack_Head(); //Send communication protocol packet header
for(i=0;i<10;i++)
{
uart_send_byte(FPM10A_Get_Device[i]);
}
}
/******************************************************************
* Function Name: FPM10A_Receive_Data
* Function Description: Receive feedback data buffer
* Function Parameters: ucLength receive length
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Receive_Data(unsigned char ucLength)
{
unsigned char i = 0;
unsigned int timeout = 10;//Timeout, unit: ms
//Wait for data reception to complete
while(u2_recv_flag==0 && timeout > 0 )
{
delay_ms(100);
timeout--;
}
if( u2_recv_flag == 1 )
{
u2_recv_flag = 0;
for (i=0;i<ucLength;i++)
{
FPM10A_RECEICE_BUFFER[i] = u2_recv_buff[i];
}
uart_receive_clear();
}
else
{
//Error, no data received
}
}
/******************************************************************
* Function Name: FPM10A_Cmd_Get_Img
* Function Description: Get fingerprint image command
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Cmd_Get_Img(void)
{
unsigned char i;
FPM10A_Cmd_Send_Pack_Head(); //Send communication protocol packet header
for(i=0;i<6;i++) //Send command 0x1d
{
uart_send_byte(FPM10A_Get_Img[i]);
}
}
/******************************************************************
* Function Name: FINGERPRINT_Cmd_Img_To_Buffer1
* Function Description: Convert image into feature code and store in Buffer1
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FINGERPRINT_Cmd_Img_To_Buffer1(void)
{
unsigned char i;
FPM10A_Cmd_Send_Pack_Head(); //Send communication protocol packet header
for(i=0;i<7;i++) //Send command to convert image into feature code and store in CHAR_buffer1
{
uart_send_byte(FPM10A_Img_To_Buffer1[i]);
}
}
/******************************************************************
* Function Name: FINGERPRINT_Cmd_Img_To_Buffer2
* Function Description: Convert image into feature code and store in Buffer2
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FINGERPRINT_Cmd_Img_To_Buffer2(void)
{
unsigned char i;
for(i=0;i<6;i++) //Send packet header
{
uart_send_byte(FPM10A_Pack_Head[i]);
}
for(i=0;i<7;i++) //Send command to convert image into feature code and store in CHAR_buffer1
{
uart_send_byte(FPM10A_Img_To_Buffer2[i]);
}
}
/******************************************************************
* Function Name: FPM10A_Cmd_Search_Finger
* Function Description: Search all 999 users
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Cmd_Search_Finger(void)
{
unsigned char i;
FPM10A_Cmd_Send_Pack_Head(); //Send communication protocol packet header
for(i=0;i<11;i++)
{
uart_send_byte(FPM10A_Search[i]);
}
}
/******************************************************************
* Function Name: FPM10A_Cmd_Reg_Model
* Function Description: Combine BUFFER1 and BUFFER2 into a feature template
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Cmd_Reg_Model(void)
{
unsigned char i;
FPM10A_Cmd_Send_Pack_Head(); //Send communication protocol packet header
for(i=0;i<6;i++)
{
uart_send_byte(FPM10A_Reg_Model[i]);
}
}
/******************************************************************
* Function Name: FINGERPRINT_Cmd_Delete_All_Model
* Function Description: Delete all fingerprint templates in the fingerprint module
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FINGERPRINT_Cmd_Delete_All_Model(void)
{
unsigned char i;
for(i=0;i<6;i++) //Packet header
{
uart_send_byte(FPM10A_Pack_Head[i]);
}
for(i=0;i<6;i++) //Command to combine fingerprint templates
{
uart_send_byte(FPM10A_Delete_All_Model[i]);
}
}
/******************************************************************
* Function Name: FPM10A_Cmd_Save_Finger
* Function Description: Save fingerprint
* Function Parameters: Location (ID number) to save the fingerprint
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Cmd_Save_Finger( unsigned int storeID )
{
unsigned long temp = 0;
unsigned char i;
FPM10A_Save_Finger[5] =(storeID&0xFF00)>>8;
FPM10A_Save_Finger[6] = (storeID&0x00FF);
for(i=0;i<7;i++) //Calculate checksum
{
temp = temp + FPM10A_Save_Finger[i];
}
FPM10A_Save_Finger[7]=(temp & 0x00FF00) >> 8; //Store checksum data
FPM10A_Save_Finger[8]= temp & 0x0000FF;
FPM10A_Cmd_Send_Pack_Head(); //Send communication protocol packet header
for(i=0;i<9;i++)
{
//Send command to convert image into feature code and store in CHAR_buffer1
uart_send_byte(FPM10A_Save_Finger[i]);
}
}
/******************************************************************
* Function Name: key_scanf
* Function Description: Key function - confirm/cancel
* Function Parameters:
* Function Return: 0=no action 1=confirm 2=cancel
* Author: LC
* Notes: Currently using UART to simulate keys; if you have physical keys, please modify accordingly
* Modification requirement: return 1 when the confirm key is pressed; return 2 when the cancel key is pressed.
******************************************************************/
void usart_receive_clear(void)
{
unsigned int i = 0;
for( i = 0; i < USART_RECEIVE_LENGTH; i++ )
{
g_recv_buff[ i ] = 0;
}
uart_flush(CH340_UART);
}
char key_scanf(void)
{
/*************** Your code ***************/
if(strstr( (const char*)g_recv_buff, "Yes") != NULL )
{
usart_receive_clear();
return 1;//Return confirm key pressed
}
if(strstr( (const char*)g_recv_buff, "No") != NULL )
{
usart_receive_clear();
return 2;//Return cancel key pressed
}
/*************** Your code ***************/
return 0;
}
/******************************************************************
* Function Name: FPM10A_Add_Fingerprint
* Function Description: Add fingerprint
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Add_Fingerprint(void)
{
unsigned char id_show[]={0,0,0};
unsigned char key_num= key_scanf();
finger_id=0;
printf("Do you want to add fingerprints? [Yes/No]\r\n");
while( key_num != 2 )//Press the return key to go directly back to the main menu
{
key_num= key_scanf();
//Press the switch key to increment the fingerprint ID value by 1
// if(KEY_DOWN == 0)
// {
// while(KEY_DOWN==0);
// if(finger_id == 1000)
// {
// finger_id = 0;
// }
// else
// finger_id = finger_id + 1;
// }
// printf("Current refreshed ID: %d \r\n", finger_id);
//Press the confirm key to start fingerprint entry
if( key_num == 1 )
{
printf("start add\r\n");
while( key_num != 2 )//Press the return key to exit entry and return to the fingerID adjustment state
{
key_num= key_scanf();
FPM10A_Cmd_Get_Img(); //Get fingerprint image
FPM10A_Receive_Data(12);
//Judge the received confirmation code, equal to 0 means fingerprint acquisition is successful
if(FPM10A_RECEICE_BUFFER[9]==0)
{
delay_ms(100);
FINGERPRINT_Cmd_Img_To_Buffer1();
FPM10A_Receive_Data(12);
printf("Successfully entered\r\n");
delay_ms(1000);
while( key_num != 2 )
{
key_num= key_scanf();
FPM10A_Cmd_Get_Img(); //Get fingerprint image
FPM10A_Receive_Data(12);
//Judge the received confirmation code, equal to 0 means fingerprint acquisition is successful
if(FPM10A_RECEICE_BUFFER[9]==0)
{
delay_ms(200);
printf("ID = %d\r\n",finger_id);
FINGERPRINT_Cmd_Img_To_Buffer2();
FPM10A_Receive_Data(12);
FPM10A_Cmd_Reg_Model();//Convert into feature code
FPM10A_Receive_Data(12);
//Save fingerprint
FPM10A_Cmd_Save_Finger(finger_id);
FPM10A_Receive_Data(12);
delay_ms(1000);
finger_id=finger_id+1;
break;
}
}
break;
}
}
}
delay_ms(100);
}
}
/******************************************************************
* Function Name: FPM10A_Find_Fingerprint
* Function Description: Search fingerprint
* Function Parameters: None
* Function Return: Fingerprint ID number
* Author: LC
* Notes: 255: not found other: found
******************************************************************/
unsigned int FPM10A_Find_Fingerprint(void)
{
unsigned int find_fingerid = 255;
// printf("Please put your finger in\r\n");
if( get_as608_touch() == 1 )//There is a finger touching the recognition area
{
FPM10A_Cmd_Get_Img(); //Get fingerprint image
FPM10A_Receive_Data(12);
//Judge the received confirmation code, equal to 0 means fingerprint acquisition is successful
if(FPM10A_RECEICE_BUFFER[9]==0)
{
delay_ms(100);
FINGERPRINT_Cmd_Img_To_Buffer1();
FPM10A_Receive_Data(12);
FPM10A_Cmd_Search_Finger();
FPM10A_Receive_Data(16);
if(FPM10A_RECEICE_BUFFER[9] == 0) //Search successful
{
//Assemble fingerprint ID number
find_fingerid = FPM10A_RECEICE_BUFFER[10]*256 + FPM10A_RECEICE_BUFFER[11];
printf("ID = %d\r\n",find_fingerid);
delay_ms(500);
}
else //Not found
{
printf("not found\r\n");
}
}
}
return find_fingerid;
}
/******************************************************************
* Function Name: FPM10A_Delete_All_Fingerprint
* Function Description: Delete all stored fingerprint library
* Function Parameters: None
* Function Return: None
* Author: LC
* Notes: None
******************************************************************/
void FPM10A_Delete_All_Fingerprint(void)
{
unsigned char key_num=0;
printf("Whether to delete fingerprint ? [Yes/No]\r\n");
do
{
key_num = key_scanf();
if(key_num == 1 )//Click the confirm key
{
printf("deleting\r\n");
delay_ms(300);
FINGERPRINT_Cmd_Delete_All_Model();
FPM10A_Receive_Data(12);
printf("Have all been cleared\r\n");
break;
}
delay_ms(100);
}while( key_num != 2 );//If the cancel key was not clicked, continue the loop
}
/******************************************************************
* Function Name: Device_Check
* Function Description: Module check
* Function Parameters: None
* Function Return: 0 module not detected or module abnormal 1 module detected and communication successful
* Author: LC
* Notes: When returning 0, please pay attention to whether the wiring is correct and whether the UART configuration is available
******************************************************************/
char Device_Check(void)
{
unsigned char i=0;
FPM10A_RECEICE_BUFFER[9]=1; //The 9th byte of the UART array can determine whether communication is normal
FPM10A_Cmd_Check(); //MCU sends verification command to the fingerprint module
FPM10A_Receive_Data(12); //Transfer the data received by UART
if(FPM10A_RECEICE_BUFFER[9] == 0) //Determine whether the 9th byte of the data has received 0
{
return 1;
}
return 0;
}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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
Write the following in the bsp_as608.h file:
#ifndef _BSP_AS608_H_
#define _BSP_AS608_H_
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_rom_sys.h"
#include "esp_timer.h"
#include "driver/uart.h"
#include "rom/ets_sys.h"
#include "esp_system.h"
#include "driver/gptimer.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_adc_cal.h"
#include <string.h>
#define AS608_TX_PIN 2
#define AS608_RX_PIN 1
#define AS608_WAK_PIN 3
#define AS608_UART UART_NUM_2
#define CH340_TX 10
#define CH340_RX 9
#define CH340_UART UART_NUM_1
#define TOUCH_IN gpio_get_level(AS608_WAK_PIN)
/* Data length of the UART buffer */
#define USART_RECEIVE_LENGTH 1024
extern uint8_t u2_recv_buff[USART_RECEIVE_LENGTH]; // Receive buffer
extern uint16_t u2_recv_length; // Receive data length
extern uint8_t u2_recv_flag; // Receive completion flag
extern uint8_t g_recv_buff[USART_RECEIVE_LENGTH];
void uart1_rx_task(void);
void uart2_rx_task(void);
void delay_us(unsigned int us);
void delay_ms(unsigned int ms);
void uart2_rx_task(void);
void as608_gpio_config(uint32_t band_rate);
char get_as608_touch(void);
void uart_receive_clear(void);
char Device_Check(void);
void FPM10A_Add_Fingerprint(void);//Add fingerprint
unsigned int FPM10A_Find_Fingerprint(void);//Find fingerprint
void FPM10A_Delete_All_Fingerprint(void);
#endif2
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
Porting Verification
Enter the following code in main.c:
#include <stdio.h>
#include "bsp_as608.h"
void app_main(void)
{
as608_gpio_config(57600U);
//Create UART1 receive task
xTaskCreate(uart1_rx_task, "uart1_rx_task", 1024*2, NULL, configMAX_PRIORITIES, NULL);
//Create UART2 receive task
xTaskCreate(uart2_rx_task, "uart2_rx_task", 1024*2, NULL, configMAX_PRIORITIES, NULL);
printf("AS608 demo start\r\n");
Device_Check();//Module detection
FPM10A_Delete_All_Fingerprint(); //Whether to delete all fingerprints
FPM10A_Add_Fingerprint();//Whether to add fingerprint
while(1)
{
FPM10A_Find_Fingerprint();//Find fingerprint
delay_ms(100);
}
}2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Two serial debug assistants are used: one for receiving and one for sending. The one on the right is the display window of UART0 (for debugging). The one on the left is the input window of UART1 (CH340 module). Power-on effect:
Driver code:
File Download
📌 Materials Download Center (click to jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.