Realize AS608 fingerprint recognition based on Raspberry Pi

Realize AS608 fingerprint recognition based on Raspberry Pi


1. Display effect

1.1, press the finger

Insert picture description here

1.2, input finger

Input

1.3, the match is successful

Insert picture description here
Note : Others only implement basic functions, and there are many other functions that can be added by yourself.


2. The specific process

2.1, connect usb
首先使用ttl转接头跟AS608指纹模块相连接,插入树莓派,在命令行输入lsusb,查看是否出现HL-340

Insert picture description here

2.2, view the serial port
输入如下命令:

Insert picture description here
Insert picture description here

2.3, download serial port assistant

Insert picture description here

2.4, run minicom

Insert picture description here

2.5, enter the welcome page
此处运行即会产生如下画面,按下ctrl+A再按下Z进入帮助页面

Insert picture description here

2.6. Press o to enter the setting page

Insert picture description here

2.7, select setup
设置如下操作:
  • serial device:ttyUSB0
  • bps / par / bits : 57600
  • hardware: NO
    Insert picture description here
    Note : The baud rate of AS608 is 57600. If it is too high, the module may be burned out.

3. Code

import binascii
import serial
import serial.tools.list_ports
import time
# volatile unsigned char FPM10A_RECEICE_BUFFER[32];        //定义接收缓存区
# code unsigned char FPM10A_Pack_Head[6] = {0xEF,0x01,0xFF,0xFF,0xFF,0xFF};  //协议包头
# code unsigned char FPM10A_Get_Img[6] = {0x01,0x00,0x03,0x01,0x00,0x05};    //获得指纹图像
# code unsigned char FPM10A_Img_To_Buffer1[7]={0x01,0x00,0x04,0x02,0x01,0x00,0x08}; //将图像放入到BUFFER1
# code unsigned char FPM10A_Search[11]={0x01,0x00,0x08,0x04,0x01,0x00,0x00,0x00,0x64,0x00,0x72}; //搜索指纹搜索范围0 - 999,使用BUFFER1中的特征码搜索

def recv(serial):
    while True:
        data = serial.read_all()
        if data == '':
            continue
        else:
            break
    return data

if __name__ == '__main__':
    serial = serial.Serial('/dev/ttyUSB0', 57600, timeout=0.5)  #/dev/ttyUSB0
    if serial.isOpen() :
        print("open success")
    else :
        print("open failed")
    while True:
        a = 'EF 01 FF FF FF FF 01 00 03 01 00 05'
        d = bytes.fromhex(a)
        serial.write(d)
        time.sleep(1)
        data =recv(serial)
        if data != b'' :
            data_con = str(binascii.b2a_hex(data))[20:22]
            if(data_con == '02'):
                print("请按下手指")
            elif(data_con == '00'):
                print("载入成功")
                buff = 'EF 01 FF FF FF FF 01 00 04 02 01 00 08'
                buff = bytes.fromhex(buff)
                serial.write(buff)
                time.sleep(1)
                buff_data = recv(serial)
                buff_con = str(binascii.b2a_hex(buff_data))[20:22]
                if(buff_con == '00'):
                    print("生成特征成功")
                    serch = 'EF 01 FF FF FF FF 01 00 08 04 01 00 00 00 64 00 72'
                    serch = bytes.fromhex(serch)
                    serial.write(serch)
                    time.sleep(1)
                    serch_data = recv(serial)
                    serch_con = str(binascii.b2a_hex(serch_data))[20:22]
                    if (serch_con == '09'):
                        print("指纹不匹配")
                    elif(serch_con == '00'):
                        print("指纹匹配成功")
                serial.close()
                exit()
            else:
                print("不成功")
其中有一些16进制的字符串,那就是所代表的命令,用hex接受的。在指南手册里面还有许多功能,比如添加指纹什么的,只需要按照这个写就行了。

4. Specific effects

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45125250/article/details/105968283