Fingerprint Scanner Interface

A few months ago I was researching lock boxes for guns and found that they ranged from simple key locks to combination locks to biometric locks.  I finally ended up getting a simple key lock one but the biometric locks intrigued me.  When I did some searching for them I found that I could buy a fairly common fingerprint scanner that is also pretty well supported in the Arduino community.  So I bought one and packed it away with my other PIC stuff during my move.  I don’t really have an application in mind for it yet but I figured that it would still be fun to get it working with a PIC.

Fingerprint Scanners

Scanner

There are a variety of scanners available including some that connect via USB so you can have biometric security for your computer login.  A typical one for connecting to a microcontroller is pictured here and goes by various part numbers.  The one I bought is a Model FPM10A.  As far as I can tell from the literature and the available User Manuals they all seem to connect the same way and have the same command set.  There is also a free software program (included here) that runs on Windows computers so you can check out the scanner before trying to make it work with the PIC.  To use it with the computer you will need a cheap USB to TTL-level serial converter cable or adapter like we’ve used in previous projects.  The scanner wires were not attached to a connecter so I soldered them to a pin header for ease of use.

If you read the User Manual you can see that there are a lot of commands available for the fingerprint scanner.  In general, however, the commands most likely to be used are the ones for Search and Register.  The Search command gets a fingerprint scan and then searches the library to find a matching print.  The Register function requires that the same finger be scanned twice.  It then combines the two images and stores the digital result in the library.

Scanner Manual

SFGDemoV2.0

Hardware

Fingerprint Module Interface

The hardware is pretty straightforward.  The fingerprint module needs +5 volts (red wire) and ground (black wire) to operate.  The receive wire (either yellow or white) connects to the serial transmit output of the PIC.  The transmit wire (green) connects to the serial receive input of the PIC.  The Unlock LED will light up whenever a fingerprint is found in the scanner library.  The LED is just a place holder because a real application would use the output high level to drive a transistor or relay that is used to power a lock solenoid.  The Start switch activates the scanner.  The Register switch is used to allow addition of a fingerprint to the scanner library.  There are unused PIC I/O pins which allow expansion for additional switches to activate functions like Clear Fingerprint Library or Enable Fingerprint Registration.  Those functions are not currently built into the software but should be easy to add.

Software

The software link is listed below.  While it is targeted for the 16F688, it is easily ported to other versions of the PIC.  Just make sure that you choose one that has the asynchronous serial port capability.  You will also need to change the line that identifies the PIC version (LIST=) and the INCLUDE file but those are intuitive changes.  The __CONFIG line may also need tweaking just because one or two of the labels used are spelled differently in some of the INCLUDE files.

The software includes just the command sequences for Search and Register.  The individual commands in each sequence match what you will find in the scanner User Manual.  The scanner will respond to each command sent and, usually, the confirmation code expected is 0x00.  There are a variety of possible confirmation codes depending on the command sent but pretty much anything other than 0x00 is an error so an error routine is called.  In this software the error routine will display the error code so you can look it up if you wish.  An arbitrary code of 0xFF is returned if the message header is not valid.  That is the only check done in the software for correctness of the message.  If you want to be more thorough you can add a routine to verify the response checksum.

The one error confirmation code that warrants its own display message is the 0x09 code that will be returned if a fingerprint is not found in the library.  In real life this may happen more often than one might expect because you may not get your finger placed quite the same way as when the original scan was made.  In that case the user is prompted to press the Start button to try again.

It makes sense to add some sort of security to prevent just anyone from adding their prints to the scanner library.  As mentioned in the Hardware section, you could add a hidden switch (and software) to enable that function.  Another way would be to register all allowed prints using a Windows PC and then not include the Register switch and software functions at all.  The way I set it up in this software is to register at least one print using a Windows PC and then requiring that the circuit be in the “Unlock” state before any new prints can be registered.  That means that any valid print could be used to enable the Register function.  Sort of like having Admin privileges.

The Register function requires that the Store command tells the scanner which library location to use for storing the new print.  I thought that I could extract the “locations used” information from the response to the ReadSysPara command but I was unable to get results that matched the definition in the manual.  Instead, I decided to just store the next location pointer in the PIC EEPROM.  At power up the PIC will read the EEPROM and determine if the pointer value has been initialized.  If it has, then the value is read and saved for possible use by the Register routine.  If the value has not been initialized then it will be set based on the defined value Next_Slot.  I picked an arbitrary sequence of 0x88, 0x66 for the first two locations in EEPROM to indicate that the pointer had been initialized.  If the Register routine gets called, it will increment the value of Next_Slot and then store the new value in the third location of the PIC EEPROM.

The LCD connections and software support what I detailed in the 3-wire, 8-bit LCD Interface post.   You can change those for whatever display interface you might use.  That’s it for this post.  Check out my other electronics projects.

Fingerprint Scanner SW