Test Program of GT-511C3 / GT-511C31 Fingerprint reader module.
GT-511-C31 指紋スキャンモジュールを mbed で動かしてみる
年末に大阪日本橋にあるデジットに行くと,指紋スキャンモジュールを販売していました.
値段は少しお高め(三千円〜八千円超え)ですが,使えると色々と応用が出来そうなので,GT-511-C31を購入して mbed で動かしてみました.
使い方とか
このページにある GT511C3test をそのままプログラムとしてインポートして下さい.
クラスライブラリ化していますので,クラスライブラリを使う場合は,以下からインポートして下さい. ドキュメントが追いついていなくてすみません.テストプログラムを参考にして頂けたらと思います...
Import libraryGT511C3
Class library of fingerprint reader module "GT-511C3 / GT-511C31"
テストプログラムでは,mbed と p28,p27 でシリアル通信します.Vin と GND はそのまま mbed の 3.3V と GND が使えます.
finger.Enroll(11,progress); この関数の呼び出しで,ID番号11番に指紋を登録します.同じ指紋を3回あてると登録できます.
その後,finger.Identify(); の呼び出しで指紋があたっていれば認識して,同じ指紋であればID番号11番を返すはずです. それ以外の指紋があたっていると -1 を返します.
注意点として,指紋の登録あるいは認識をする場合は,必ず CmosLed を点灯させて下さい.点灯させると指紋検出面が青く光ります.これが消灯していると,指紋の検出が出来ないようです.
雑感
指紋の認識は,感覚的にですが1秒ほどで認識します.10本の指それぞれで色々な角度であててみましたが,誤認識無く,登録した指紋があたるとIDが返ります.説明書によると,「違う指紋を同じ指紋として誤る確率:0.001%未満」と言うことなので,10万回に1回の確率で間違えそうですが,実用レベルだと感じます.
うまく使うと,mbed で生体認証チックな事ができそうですね.
指紋認証器モドキ(自動ログインのデモ)
これは,青mbed ではなく,lpclcd と指紋スキャンモジュールを組み合わせて,指紋認証器モドキを作って Mac に自動ログインするプロトタイプです.
lpclcd は mbed と同じように USBKeyboard の様に振る舞わせることが出来ますので,登録された指紋があたると,lpclcd で USBKeyboard::printf("パスワード\n"); を実行してあたかもパスワードがUSB Keyboard で打ち込まれたかの様に動作させています.
この指紋認証器モドキのメリットは,PCから見ればUSBキーボードの様に見えるので,特別なドライバを必要としないことです.要するに「登録された指紋があたれば事前にプログラムされた文字列を lpclcd が代わりにタイプしてくれる」だけです.
実用を考えた時,セキュリティ強度は 強くはないでしょう.このテストプログラムは,パスワードを生文字列で抱き込んでいるので,バイナリレベルで解析すればすぐに生文字列が分かってしまいます.なので指紋認証器モドキです.
GT511C3.h@3:459a4f985a45, 2014-01-03 (annotated)
- Committer:
- tosihisa
- Date:
- Fri Jan 03 12:56:03 2014 +0000
- Revision:
- 3:459a4f985a45
- Parent:
- 2:34a647292050
- Child:
- 4:3dd0f98e6f09
Add Enroll and Identify!;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tosihisa | 0:b11b455d4997 | 1 | |
tosihisa | 0:b11b455d4997 | 2 | #include "mbed.h" |
tosihisa | 0:b11b455d4997 | 3 | |
tosihisa | 0:b11b455d4997 | 4 | class GT511C3 : public Serial { |
tosihisa | 0:b11b455d4997 | 5 | public: |
tosihisa | 0:b11b455d4997 | 6 | enum Command { |
tosihisa | 0:b11b455d4997 | 7 | CMD_Open = 0x01, // 01 Open Initialization |
tosihisa | 0:b11b455d4997 | 8 | CMD_Close = 0x02, // 02 Close Termination |
tosihisa | 0:b11b455d4997 | 9 | CMD_UsbInternalCheck = 0x03, // 03 UsbInternalCheck Check if the connected USB device is valid |
tosihisa | 0:b11b455d4997 | 10 | CMD_ChangeBaudrate = 0x04, // 04 ChangeBaudrate Change UART baud rate |
tosihisa | 0:b11b455d4997 | 11 | CMD_SetIAPMode = 0x05, // 05 SetIAPMode Enter IAP Mode In this mode, FW Upgrade is available |
tosihisa | 0:b11b455d4997 | 12 | CMD_CmosLed = 0x12, // 12 CmosLed Control CMOS LED |
tosihisa | 0:b11b455d4997 | 13 | CMD_GetEnrollCount = 0x20, // 20 GetEnrollCount Get enrolled fingerprint count |
tosihisa | 0:b11b455d4997 | 14 | CMD_CheckEnrolled = 0x21, // 21 CheckEnrolled Check whether the specified ID is already enrolled |
tosihisa | 0:b11b455d4997 | 15 | CMD_EnrollStart = 0x22, // 22 EnrollStart Start an enrollment |
tosihisa | 0:b11b455d4997 | 16 | CMD_Enroll1 = 0x23, // 23 Enroll1 Make 1st template for an enrollment |
tosihisa | 0:b11b455d4997 | 17 | CMD_Enroll2 = 0x24, // 24 Enroll2 Make 2nd template for an enrollment |
tosihisa | 0:b11b455d4997 | 18 | CMD_Enroll3 = 0x25, // 25 Enroll3 Make 3rd template for an enrollment, merge three templates into one template, save merged template to the database |
tosihisa | 0:b11b455d4997 | 19 | CMD_IsPressFinger = 0x26, // 26 IsPressFinger Check if a finger is placed on the sensor |
tosihisa | 0:b11b455d4997 | 20 | CMD_DeleteID = 0x40, // 40 DeleteID Delete the fingerprint with the specified ID |
tosihisa | 0:b11b455d4997 | 21 | CMD_DeleteAll = 0x41, // 41 DeleteAll Delete all fingerprints from the database |
tosihisa | 0:b11b455d4997 | 22 | CMD_Verify = 0x50, // 50 Verify 1:1 Verification of the capture fingerprint image with the specified ID |
tosihisa | 0:b11b455d4997 | 23 | CMD_Identify = 0x51, // 51 Identify 1:N Identification of the capture fingerprint image with the database |
tosihisa | 0:b11b455d4997 | 24 | CMD_VerifyTemplate = 0x52, // 52 VerifyTemplate 1:1 Verification of a fingerprint template with the specified ID |
tosihisa | 0:b11b455d4997 | 25 | CMD_IdentifyTemplate = 0x53, // 53 IdentifyTemplate 1:N Identification of a fingerprint template with the database |
tosihisa | 0:b11b455d4997 | 26 | CMD_CaptureFinger = 0x60, // 60 CaptureFinger Capture a fingerprint image(256x256) from the sensor |
tosihisa | 0:b11b455d4997 | 27 | CMD_MakeTemplate = 0x61, // 61 MakeTemplate Make template for transmission |
tosihisa | 0:b11b455d4997 | 28 | CMD_GetImage = 0x62, // 62 GetImage Download the captured fingerprint image(256x256) |
tosihisa | 0:b11b455d4997 | 29 | CMD_GetRawImage = 0x63, // 63 GetRawImage Capture & Download raw fingerprint image(320x240) |
tosihisa | 0:b11b455d4997 | 30 | CMD_GetTemplate = 0x70, // 70 GetTemplate Download the template of the specified ID |
tosihisa | 0:b11b455d4997 | 31 | CMD_SetTemplate = 0x71, // 71 SetTemplate Upload the template of the specified ID |
tosihisa | 0:b11b455d4997 | 32 | CMD_GetDatabaseStart = 0x72, // 72 GetDatabaseStart Start database download, obsolete |
tosihisa | 0:b11b455d4997 | 33 | CMD_GetDatabaseEnd = 0x73, // 73 GetDatabaseEnd End database download, obsolete |
tosihisa | 0:b11b455d4997 | 34 | CMD_UpgradeFirmware = 0x80, // 80 UpgradeFirmware Not supported |
tosihisa | 0:b11b455d4997 | 35 | CMD_UpgradeISOCDImage = 0x81, // 81 UpgradeISOCDImage Not supported |
tosihisa | 0:b11b455d4997 | 36 | CMD_Ack = 0x30, // 30 Ack Acknowledge. |
tosihisa | 0:b11b455d4997 | 37 | CMD_Nack = 0x31, // 31 Nack Non-acknowledge. |
tosihisa | 1:4a1be9379e92 | 38 | }; |
tosihisa | 1:4a1be9379e92 | 39 | enum Error { |
tosihisa | 1:4a1be9379e92 | 40 | NACK_TIMEOUT = 0x1001, // NACK_TIMEOUT 0x1001 Obsolete, capture timeout |
tosihisa | 1:4a1be9379e92 | 41 | NACK_INVALID_BAUDRATE = 0x1002, // NACK_INVALID_BAUDRATE 0x1002 Obsolete, Invalid serial baud rate |
tosihisa | 1:4a1be9379e92 | 42 | NACK_INVALID_POS = 0x1003, // NACK_INVALID_POS 0x1003 The specified ID is not between 0~199 |
tosihisa | 1:4a1be9379e92 | 43 | NACK_IS_NOT_USED = 0x1004, // NACK_IS_NOT_USED 0x1004 The specified ID is not used |
tosihisa | 1:4a1be9379e92 | 44 | NACK_IS_ALREADY_USED = 0x1005, // NACK_IS_ALREADY_USED 0x1005 The specified ID is already used |
tosihisa | 1:4a1be9379e92 | 45 | NACK_COMM_ERR = 0x1006, // NACK_COMM_ERR 0x1006 Communication Error |
tosihisa | 1:4a1be9379e92 | 46 | NACK_VERIFY_FAILED = 0x1007, // NACK_VERIFY_FAILED 0x1007 1:1 Verification Failure |
tosihisa | 1:4a1be9379e92 | 47 | NACK_IDENTIFY_FAILED = 0x1008, // NACK_IDENTIFY_FAILED 0x1008 1:N Identification Failure |
tosihisa | 1:4a1be9379e92 | 48 | NACK_DB_IS_FULL = 0x1009, // NACK_DB_IS_FULL 0x1009 The database is full |
tosihisa | 1:4a1be9379e92 | 49 | NACK_DB_IS_EMPTY = 0x100A, // NACK_DB_IS_EMPTY 0x100A The database is empty |
tosihisa | 1:4a1be9379e92 | 50 | NACK_TURN_ERR = 0x100B, // NACK_TURN_ERR 0x100B Obsolete, Invalid order of the enrollment (The order was not as: EnrollStart -> Enroll1 -> Enroll2 -> Enroll3) |
tosihisa | 1:4a1be9379e92 | 51 | NACK_BAD_FINGER = 0x100C, // NACK_BAD_FINGER 0x100C Too bad fingerprint |
tosihisa | 1:4a1be9379e92 | 52 | NACK_ENROLL_FAILED = 0x100D, // NACK_ENROLL_FAILED 0x100D Enrollment Failure |
tosihisa | 1:4a1be9379e92 | 53 | NACK_IS_NOT_SUPPORTED = 0x100E, // NACK_IS_NOT_SUPPORTED 0x100E The specified command is not supported |
tosihisa | 1:4a1be9379e92 | 54 | NACK_DEV_ERR = 0x100F, // NACK_DEV_ERR 0x100F Device Error, especially if Crypto-Chip is trouble |
tosihisa | 1:4a1be9379e92 | 55 | NACK_CAPTURE_CANCELED = 0x1010, // NACK_CAPTURE_CANCELED 0x1010 Obsolete, The capturing is canceled |
tosihisa | 1:4a1be9379e92 | 56 | NACK_INVALID_PARAM = 0x1011, // NACK_INVALID_PARAM 0x1011 Invalid parameter |
tosihisa | 1:4a1be9379e92 | 57 | NACK_FINGER_IS_NOT_PRESSED = 0x1012, // NACK_FINGER_IS_NOT_PRESSED 0x1012 Finger is not pressed |
tosihisa | 1:4a1be9379e92 | 58 | }; |
tosihisa | 0:b11b455d4997 | 59 | GT511C3(PinName _tx, PinName _rx) : Serial(_tx,_rx){} |
tosihisa | 0:b11b455d4997 | 60 | int Init(void); |
tosihisa | 0:b11b455d4997 | 61 | int SendCommand(unsigned long Parameter,unsigned short Command); |
tosihisa | 0:b11b455d4997 | 62 | int RecvResponse(unsigned long *Parameter,unsigned short *Response); |
tosihisa | 2:34a647292050 | 63 | int SendRecv(unsigned short Command,unsigned long *Parameter,unsigned short *Response); |
tosihisa | 0:b11b455d4997 | 64 | int ClearLine(void); |
tosihisa | 3:459a4f985a45 | 65 | int WaitPress(int press); |
tosihisa | 3:459a4f985a45 | 66 | int CmosLed(int onoff); |
tosihisa | 3:459a4f985a45 | 67 | int IsPress(void); |
tosihisa | 3:459a4f985a45 | 68 | int Capture(int best); |
tosihisa | 3:459a4f985a45 | 69 | int Enroll_N(int N); |
tosihisa | 3:459a4f985a45 | 70 | int Identify(void); |
tosihisa | 0:b11b455d4997 | 71 | }; |