Test Program of GT-511C3 / GT-511C31 Fingerprint reader module.

Dependencies:   GT511C3 mbed

GT-511-C31 指紋スキャンモジュールを mbed で動かしてみる

年末に大阪日本橋にあるデジットに行くと,指紋スキャンモジュールを販売していました.

値段は少しお高め(三千円〜八千円超え)ですが,使えると色々と応用が出来そうなので,GT-511-C31を購入して mbed で動かしてみました.

/media/uploads/tosihisa/2014-01-03_23.43.55.jpg

使い方とか

このページにある 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 で生体認証チックな事ができそうですね.

/media/uploads/tosihisa/2014-01-03_23.44.18.jpg

指紋認証器モドキ(自動ログインのデモ)

これは,青mbed ではなく,lpclcd と指紋スキャンモジュールを組み合わせて,指紋認証器モドキを作って Mac に自動ログインするプロトタイプです.

lpclcd は mbed と同じように USBKeyboard の様に振る舞わせることが出来ますので,登録された指紋があたると,lpclcd で USBKeyboard::printf("パスワード\n"); を実行してあたかもパスワードがUSB Keyboard で打ち込まれたかの様に動作させています.

この指紋認証器モドキのメリットは,PCから見ればUSBキーボードの様に見えるので­,特別なドライバを必要としないことです.要するに「登録された指紋があたれば事前に­プログラムされた文字列を lpclcd が代わりにタイプしてくれる」だけです.

実用を考えた時,セキュリティ強度は 強くはないでしょう.このテストプログラムは,パスワードを生文字列で抱き込んでいる­ので,バイナリレベルで解析すればすぐに生文字列が分かってしまいます.なので指紋認­証器モドキです.

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?

UserRevisionLine numberNew contents of line
tosihisa 0:b11b455d4997 1 #include "mbed.h"
tosihisa 0:b11b455d4997 2 #include "GT511C3.h"
tosihisa 0:b11b455d4997 3
tosihisa 0:b11b455d4997 4 Serial debug(USBTX,USBRX);
tosihisa 0:b11b455d4997 5
tosihisa 0:b11b455d4997 6 DigitalOut myled(LED1);
tosihisa 0:b11b455d4997 7 GT511C3 finger(p28,p27);
tosihisa 0:b11b455d4997 8
tosihisa 2:34a647292050 9 int Enroll(void)
tosihisa 2:34a647292050 10 {
tosihisa 2:34a647292050 11 int EnrollID = 10;
tosihisa 2:34a647292050 12 unsigned long Parameter = 0;
tosihisa 2:34a647292050 13 unsigned short Response = 0;
tosihisa 2:34a647292050 14 int sts = 0;
tosihisa 2:34a647292050 15
tosihisa 3:459a4f985a45 16 debug.printf("EnrollStart\n");
tosihisa 3:459a4f985a45 17 finger.CmosLed(1);
tosihisa 3:459a4f985a45 18
tosihisa 3:459a4f985a45 19 while(1){
tosihisa 3:459a4f985a45 20 debug.printf("CMD_EnrollStart\n");
tosihisa 3:459a4f985a45 21 Parameter = EnrollID;
tosihisa 3:459a4f985a45 22 sts = finger.SendRecv(GT511C3::CMD_EnrollStart,&Parameter,&Response);
tosihisa 3:459a4f985a45 23 debug.printf("sts = %d,Response=0x%04x Parameter=0x%08lx\n",sts,Response,Parameter);
tosihisa 3:459a4f985a45 24 if(sts != 0)
tosihisa 3:459a4f985a45 25 return sts;
tosihisa 3:459a4f985a45 26 if(Response != GT511C3::CMD_Ack)
tosihisa 3:459a4f985a45 27 return -100;
tosihisa 3:459a4f985a45 28
tosihisa 3:459a4f985a45 29 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 30 finger.WaitPress(0);
tosihisa 3:459a4f985a45 31
tosihisa 3:459a4f985a45 32 while(1){
tosihisa 3:459a4f985a45 33 debug.printf("Press finger to Enroll (1st)\n");
tosihisa 3:459a4f985a45 34 finger.WaitPress(1);
tosihisa 3:459a4f985a45 35 if(finger.Capture(1) == 0)
tosihisa 3:459a4f985a45 36 break;
tosihisa 3:459a4f985a45 37 }
tosihisa 3:459a4f985a45 38
tosihisa 3:459a4f985a45 39 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 40 if(finger.Enroll_N(1) != 0)
tosihisa 3:459a4f985a45 41 continue;
tosihisa 3:459a4f985a45 42 finger.WaitPress(0);
tosihisa 3:459a4f985a45 43
tosihisa 3:459a4f985a45 44 while(1){
tosihisa 3:459a4f985a45 45 debug.printf("Press finger to Enroll (2nd)\n");
tosihisa 3:459a4f985a45 46 finger.WaitPress(1);
tosihisa 3:459a4f985a45 47 if(finger.Capture(1) == 0)
tosihisa 3:459a4f985a45 48 break;
tosihisa 3:459a4f985a45 49 }
tosihisa 3:459a4f985a45 50
tosihisa 3:459a4f985a45 51 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 52 if(finger.Enroll_N(2) != 0)
tosihisa 3:459a4f985a45 53 continue;
tosihisa 3:459a4f985a45 54 finger.WaitPress(0);
tosihisa 3:459a4f985a45 55
tosihisa 3:459a4f985a45 56 while(1){
tosihisa 3:459a4f985a45 57 debug.printf("Press finger to Enroll (3rd)\n");
tosihisa 3:459a4f985a45 58 finger.WaitPress(1);
tosihisa 3:459a4f985a45 59 if(finger.Capture(1) == 0)
tosihisa 3:459a4f985a45 60 break;
tosihisa 3:459a4f985a45 61 }
tosihisa 3:459a4f985a45 62
tosihisa 3:459a4f985a45 63 debug.printf("Remove finger\n");
tosihisa 3:459a4f985a45 64 if(finger.Enroll_N(3) != 0)
tosihisa 3:459a4f985a45 65 continue;
tosihisa 3:459a4f985a45 66 finger.WaitPress(0);
tosihisa 3:459a4f985a45 67
tosihisa 3:459a4f985a45 68 debug.printf("Enroll OK!\n");
tosihisa 3:459a4f985a45 69 break;
tosihisa 3:459a4f985a45 70 }
tosihisa 3:459a4f985a45 71 return 0;
tosihisa 2:34a647292050 72 }
tosihisa 2:34a647292050 73
tosihisa 0:b11b455d4997 74 int main() {
tosihisa 0:b11b455d4997 75 unsigned long Parameter;
tosihisa 0:b11b455d4997 76 unsigned short Response;
tosihisa 0:b11b455d4997 77 int sts = 0;
tosihisa 1:4a1be9379e92 78 int count = 0;
tosihisa 2:34a647292050 79 int ispress;
tosihisa 3:459a4f985a45 80 int ID;
tosihisa 0:b11b455d4997 81
tosihisa 0:b11b455d4997 82 debug.format(8,Serial::None,1);
tosihisa 0:b11b455d4997 83 debug.baud(115200);
tosihisa 0:b11b455d4997 84
tosihisa 0:b11b455d4997 85 debug.printf("Init\n");
tosihisa 0:b11b455d4997 86 finger.Init();
tosihisa 0:b11b455d4997 87 debug.printf("Open\n");
tosihisa 2:34a647292050 88 Parameter = 0;
tosihisa 2:34a647292050 89 sts = finger.SendRecv(GT511C3::CMD_Open,&Parameter,&Response);
tosihisa 0:b11b455d4997 90 debug.printf("sts = %d,Response=0x%04x\n",sts,Response);
tosihisa 0:b11b455d4997 91
tosihisa 3:459a4f985a45 92 if(1){
tosihisa 3:459a4f985a45 93 Enroll();
tosihisa 3:459a4f985a45 94 }
tosihisa 3:459a4f985a45 95
tosihisa 3:459a4f985a45 96 finger.CmosLed(1);
tosihisa 0:b11b455d4997 97 while(1) {
tosihisa 3:459a4f985a45 98 ispress = finger.IsPress();
tosihisa 3:459a4f985a45 99 debug.printf("IsPressFinger=%d\n",ispress);
tosihisa 3:459a4f985a45 100 if(ispress){
tosihisa 3:459a4f985a45 101 if(finger.Capture(1) != 0)
tosihisa 3:459a4f985a45 102 continue;
tosihisa 3:459a4f985a45 103 ID = finger.Identify();
tosihisa 3:459a4f985a45 104 debug.printf("ID = %d\n",ID);
tosihisa 2:34a647292050 105 }
tosihisa 2:34a647292050 106 #if 0
tosihisa 0:b11b455d4997 107 myled = 1;
tosihisa 1:4a1be9379e92 108 wait(0.5);
tosihisa 0:b11b455d4997 109 myled = 0;
tosihisa 1:4a1be9379e92 110 wait(0.5);
tosihisa 2:34a647292050 111 #endif
tosihisa 1:4a1be9379e92 112 count++;
tosihisa 0:b11b455d4997 113 }
tosihisa 0:b11b455d4997 114 }