Test of the GT-521F52 fingerprint reader

Test of the GT-521F52 fingerprint reader

We discovered somewhat by chance the ADH-Tech GT-521F52 fingerprint reader. As it is really affordable, less than fifty US dollars, we decided to buy one two, to see what we could do with it.





Presentation

The GT-521F52 is a PCB of about 36x21mm with a large parallelepiped smack in the middle: it's the fingerprint reader itself. There is a JST connector on each side of the PCB, the left one is used for the serial connection, the right one is used to reprogram the module and offers a logical output going to 1 when you put a finger on the sensor. Useful to wake up sleeping electronics.

The GT-521F52 fingerprint reader, top side / bottom side
The GT-521F52 fingerprint reader, top side / bottom side



This reader is apparently able to store up to 3000 fingerprints and it can tell you when you put your finder on it if this finger matches to one of the stored fingerprints. Of course, you do the fingerprint learning via the same sensor.

Connection and configuration

There are two ways to connect this sensor, you can

  • either directly solder a USB cable under the module, on the pads designed for this. This should allow you to control the module directly by USB, probably at the expense of installing a driver, the manufacturer's documentation doesn't say much on this point
  • or drive the module directly through its TTL serial port, with a Yocto-Serial for example. It's naturally the solution that we selected.


Beware, the reader works in 3.3V. To avoid damaging it foolishly, we recommend that you configure the working voltages on the Yocto-Serial before you connect the sensor. You must select:

  • Power output voltage =3.3V
  • Voltage level = TTL 3.3V

And while you are at it, you can define the serial port parameters:

  • Type of protocol = Frame base binary protocol
  • Baud rate and encoding = 9600 8N1
  • Flow control = None
  • Minimum frame interval Rx= 10ms, Tx= 10ms
  • Min. interval between bytes sent = 0


Configure the Yocto-Serial before you connect it to the GT-521F52
Configure the Yocto-Serial before you connect it to the GT-521F52



Wiring

To connect the fingerprint reader to the Yocto-Serial, we used the recommended cable that we cut in half to remove one of the connectors. However, the wire colors do not correspond at all to their functions. You must select:

Yocto-SerialCouleurGT-521F52
RDblackTx
TDredRx
GNDblueGND
pwryellowVin



Connecting the GT-521F52 to the Yocto-Serial
Connecting the GT-521F52 to the Yocto-Serial



The same, but in real life
The same, but in real life



Use

You drive the GT-521F52 by sending and receiving 12 byte binary frames. The documentation is very complete, but not necessarily very explicit. You must read the small characters carefully to know in which exact order you must send the commands. To render the system more user-friendly, we wrote a small Python library which enables you to use the basic functions of the reader without racking your brain. It allows you to

  • Store a fingerprint
  • Delete one or all the fingerprints
  • Call a callback each time a fingerprint is read

Managing fingerprint reading and recognition is performed in the background, so the application can do whatever it wants while waiting for someone to put a finger on the reader. Here is a very simple use example.

import os, sys
from  GT521F52 import *
from yocto_api import *
from yocto_serialport import *

def eventCallback(eventType, id):  #something happened
    if eventType== GT521F52_fingerPrintScanner.EVENT_IDENTOK:
        print("Sucessfull ID="+str(id))
    if eventType== GT521F52_fingerPrintScanner.EVENT_IDENTFAILED:
        print("Failed")

errmsg = YRefParam()
# Setup the API to use local USB devices
if YAPI.RegisterHub("usb", errmsg) != YAPI.SUCCESS:
    sys.exit("init error" + errmsg.value)
# assumes the  GT521F52 is connected to the first serial port available
serial = YSerialPort.FirstSerialPort()
scanner =  GT521F52_fingerPrintScanner(serial)

if not scanner.open(): print(scanner.lastErrorMsg)
YAPI.Sleep(100)
scanner.ledControl(True) # don't forget to turn the  internal LED on!
scanner.set_eventCallback(eventCallback) # callback to call after any fingerprint scan
scanner.runInBackground() # fingerprint recognition will automatically  run in background

while scanner.isBackgroundRunning():
  print("\nHello, "+str(scanner.getEnrollCount())+" fingerprints are enrolled")
  print("What would you like to do?")
  print("1- Add new entry")
  print("2- Clear All entries")
  print("3- Global Thermonuclear War")
  print("4- Quit")
  print("")
  c = input("your choice:")
  if c=="1": scanner.startEnrollProcess(print)
  if c=="2": scanner.deleteAll()
  if c=="3": print("Wouldn't you prefer a good game of chess?")
  if c=="4":
       scanner.stopBackgroundRun()
       while scanner.isBackgroundRunning(): time.sleep(2)
print("terminated")


Here is a short and quick demo made with a Yocto-Buzzer.

  



You can download the library as well as the example code here.

Encountered issues

We didn't get any bad surprise while writing the code managing the GT-521F52, but we still encountered two minor issues:

  • One must imperatively turn on the sensor internal led before asking it whether there is a finger on it, otherwise not only it doesn't work, but the sensor answers with a single zero byte instead of outputting a documented error.
  • Fingerprint recognition doesn't always work at the first try, better let it do several tryouts before crying wolf. In itself it, this is not an issue: users naturally leave their finger on the sensor until being told either yes or no.


Conclusion

This small GT-521F52 sensor works remarkably well for a basis scenario, that is recognizing a fingerprint. It even recognizes a finger colored with a big black permanent marker (someone knows where the acetone is?). However, as it is a purely optical sensor, we doubt that it could make the difference between a real finger and a latex imitation, and we don't even talk about making the difference between a live finger and a dead/cutoff finger.

Now, we still have to find the reader a somewhat fun application. We'll talk about it again at a later date :-)

Add a comment No comment yet Back to blog












Yoctopuce, get your stuff connected.