Introduction: Unlock a Door With Your Fingerprint
We built a biometric fingerprint-controlled lock prototype. A fingerprint scanner is used to capture and store the fingerprints of authorized users. When the scanner recognizes a user, a solenoid plunger disengages and opens the lock.
The fingerprint scanner module is powered by an ARM Cortex M3 CPU, which controls the on-board optical sensor and fingerprint recognition. Fingerprints are stored and processed by the module, which supports a UART protocol for communicating with a host application. The solenoid is powered from Kinoma Create and controlled by a digital output pin.
Step 1: Wiring
The protoboard is connected to the solenoid and Kinoma Create back header pins. The fingerprint scanner is also connected to the back header UART TX and RX pins.
Both front pin headers are configured for +5V and pin 51 is configured as a digital output. The application programmatically configures the front pins and displays the Pins Settings dialog.
Step 2: Protoboard
The solenoid used to lock and unlock the door requires two additional bits of electronics: a transistor and a flyback diode. The transistor acts as a switch for the 5v power supply from Kinoma Create, allowing us to turn on and off that current to the solenoid using our 3.3v digital out pin. The diode helps to protect Kinoma Create from electrical surges generated by the solenoid, dissipating flyback energy as heat through the solenoid rather than as a power spike into the Kinoma Create’s digital output pin.
Step 3: Application Overview
The KinomaJS application opens to a screen that displays a list of registered fingerprints. Three buttons are provided at the bottom of the screen to interact with the scanner.
The Register button kicks off the fingerprint capture and registration flow. Once fingerprint registration is complete, the user associates his or her name with the fingerprint using the Kinoma Create on-screen keyboard. The registered fingerprint is added to the displayed list. The Authorize button is used to validate a fingerprint against the list of registered users. The door is unlocked and a success sound is played if the fingerprint scanned matches a registered user. If the fingerprint is not authorized, the door remains locked and the application plays a failure sound. The Clear button removes all registered fingerprints from the displayed list and clears the fingerprint scanner module storage.
Step 4: The Code
The project includes the KinomaJS application and BLLs to control the fingerprint scanner and solenoid.
Step 5: Fingerprint Processing
The scanner module does all the work required to capture, store and match fingerprint images. The application controls the scanner by calling functions in the GT511C3.js BLL. The BLL functions in turn send commands to the module via the Kinoma Create serial pins.
A fingerprint capture requires pressing and releasing the finger on the scanner three times. The fingerprint is registered and stored after the third press. The application uses a KinomaJS Behavior instance to implement a state machine that processes each of the three fingerprint scans. To start scanning, a prompt is displayed, the LED is turned on and the code waits for acknowledgement that the finger is pressed on the scanner:
The is_finger_pressed BLL function is called every 200 milliseconds by invoking a repeated polling hardware pins request. The result is sent to the application fingerPressed handler.
The handler notifies the application by distributing the onFingerPressed and onFingerReleased events to the application behavior, which in turn advances the state machine to capture once the finger is pressed.
Step 6: Fingerprint Images
The fingerprint scanner captures fingerprints to a binary template format and stores the templates in an on-board database. In addition to the fingerprint templates, the scanner provides the ability to read the raw fingerprint image. The application displays the fingerprint image on the Kinoma Create screen.
The get_rawimage BLL function is invoked to retrieve the raw fingerprint image from the scanner.
The function returns a memory chunk containing the 160 x 120 raw fingerprint image at 32 bits per pixel. The application lightens the pixels for display.
Finally the application instantiates a FingerprintPicture template to display the fingerprint BMP image file. Since the raw image is rotated sideways, the Picture behavior rotates the image 90 degrees about the center for display.
The fingerprint list, including references to the saved fingerprint image files is stored as JSON in a preferences file.
The preferences file is read at application launch and included in the instantiating data used to build and display the list.
Step 7: Finish!
If you got stuck along with way, we’re here to help — come visit us at our forum and let us know how we can help.
We have a be nice policy.
Please be positive and constructive.