arduino+AS608的使用教程
arduino+AS608的使用教程
解決 Adafruit Fingerprint sensor enrollment
Did not find fingerprint sensor ? 的問題
器材的準備
接線
這個我就不說了小孩子都知道怎么接線
開始搭載AS608模塊
直接上代碼,不廢話
/*************************************************** This is an example sketch for our optical Fingerprint sensorDesigned specifically to work with the Adafruit BMP085 Breakout ----> http://www.adafruit.com/products/751These displays use TTL Serial to communicate, 2 pins are required to interfaceAdafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution****************************************************/#include <Adafruit_Fingerprint.h>// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white // uncomment this line: // #define mySerial Serial1// For UNO and others without hardware serial, we must use software serial... // pin #2 is IN from sensor (GREEN wire) // pin #3 is OUT from arduino (WHITE wire) // comment these two lines if using hardware serial SoftwareSerial mySerial(2, 3);Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);uint8_t id;void setup() {Serial.begin(9600);while (!Serial); // For Yun/Leo/Micro/Zero/...delay(100);Serial.println("\n\nAdafruit Fingerprint sensor enrollment");// set the data rate for the sensor serial portfinger.begin(57600);if (finger.verifyPassword()) {Serial.println("Found fingerprint sensor!");} else {Serial.println("Did not find fingerprint sensor :(");while (1) { delay(1); }} }uint8_t readnumber(void) {uint8_t num = 0;while (num == 0) {while (! Serial.available());num = Serial.parseInt();}return num; }void loop() // run over and over again {Serial.println("Ready to enroll a fingerprint!");Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");id = readnumber();if (id == 0) {// ID #0 not allowed, try again!return;}Serial.print("Enrolling ID #");Serial.println(id);while (! getFingerprintEnroll() ); }uint8_t getFingerprintEnroll() {int p = -1;Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);while (p != FINGERPRINT_OK) {p = finger.getImage();switch (p) {case FINGERPRINT_OK:Serial.println("Image taken");break;case FINGERPRINT_NOFINGER:Serial.println(".");break;case FINGERPRINT_PACKETRECIEVEERR:Serial.println("Communication error");break;case FINGERPRINT_IMAGEFAIL:Serial.println("Imaging error");break;default:Serial.println("Unknown error");break;}}// OK success!p = finger.image2Tz(1);switch (p) {case FINGERPRINT_OK:Serial.println("Image converted");break;case FINGERPRINT_IMAGEMESS:Serial.println("Image too messy");return p;case FINGERPRINT_PACKETRECIEVEERR:Serial.println("Communication error");return p;case FINGERPRINT_FEATUREFAIL:Serial.println("Could not find fingerprint features");return p;case FINGERPRINT_INVALIDIMAGE:Serial.println("Could not find fingerprint features");return p;default:Serial.println("Unknown error");return p;}Serial.println("Remove finger");delay(2000);p = 0;while (p != FINGERPRINT_NOFINGER) {p = finger.getImage();}Serial.print("ID "); Serial.println(id);p = -1;Serial.println("Place same finger again");while (p != FINGERPRINT_OK) {p = finger.getImage();switch (p) {case FINGERPRINT_OK:Serial.println("Image taken");break;case FINGERPRINT_NOFINGER:Serial.print(".");break;case FINGERPRINT_PACKETRECIEVEERR:Serial.println("Communication error");break;case FINGERPRINT_IMAGEFAIL:Serial.println("Imaging error");break;default:Serial.println("Unknown error");break;}}// OK success!p = finger.image2Tz(2);switch (p) {case FINGERPRINT_OK:Serial.println("Image converted");break;case FINGERPRINT_IMAGEMESS:Serial.println("Image too messy");return p;case FINGERPRINT_PACKETRECIEVEERR:Serial.println("Communication error");return p;case FINGERPRINT_FEATUREFAIL:Serial.println("Could not find fingerprint features");return p;case FINGERPRINT_INVALIDIMAGE:Serial.println("Could not find fingerprint features");return p;default:Serial.println("Unknown error");return p;}// OK converted!Serial.print("Creating model for #"); Serial.println(id);p = finger.createModel();if (p == FINGERPRINT_OK) {Serial.println("Prints matched!");} else if (p == FINGERPRINT_PACKETRECIEVEERR) {Serial.println("Communication error");return p;} else if (p == FINGERPRINT_ENROLLMISMATCH) {Serial.println("Fingerprints did not match");return p;} else {Serial.println("Unknown error");return p;} Serial.print("ID "); Serial.println(id);p = finger.storeModel(id);if (p == FINGERPRINT_OK) {Serial.println("Stored!");} else if (p == FINGERPRINT_PACKETRECIEVEERR) {Serial.println("Communication error");return p;} else if (p == FINGERPRINT_BADLOCATION) {Serial.println("Could not store in that location");return p;} else if (p == FINGERPRINT_FLASHERR) {Serial.println("Error writing to flash");return p;} else {Serial.println("Unknown error");return p;} }然后很多人到這一步就會報錯
Adafruit Fingerprint sensor enrollment Did not find fingerprint sensor :(出現了這個報錯
不要緊,拿出早就準備好的usb轉ttl然后將usb轉ttl和AS608連接,接口部分只用接VCC GND RX TX
第一步:將模塊的 Tx、Rx 連接到 USB 轉串口設備。(提示:開發板可使用板載的 CH340)。
第二步:在計算機設備管理器找到識別的串口號
第三步:打開模塊資料\2,配套軟件\指紋模塊測試上位機\指紋測試.exe,然后在上位機
選擇對應串口號
第四步:點擊“確定”,通訊成功。
第五步:通訊成功之后可查看硬件信息、波特率等,可以點擊面板上按鈕等功能操作。
下面我們點擊“錄入指紋”按鈕,點擊后。并輸入 0為錄入指紋 ID。
第六步:點擊“確定”,軟件提示“請將手指平放在傳感器上”
第七步:按照提示將手指平放在傳感器上,等待圖像上傳, 所示。提示:
上傳時間稍微久一點。波特率越高速度越快,使用 USB 模塊測試則會更快。
第八步:第一次錄入圖像成功之后,軟件會提示“2.請將手指平放在傳感器上”表示第
二次錄入圖像。
第九步:當兩次錄入圖像的指紋經過對比匹配之后,如果一致的話指紋就錄入成功了。
錄入成功
第十步:前面操作是錄入了一個指紋,下面我們測試一下刷指紋(驗證指紋)。首先我
們點擊“搜索”
第十一步:點擊了搜索之后軟件提示“請將手指平放在傳感器上”
第十二步:按照提示將手指放在傳感器上錄入圖像成功之后,系統對比錄入圖像與指紋
庫,如果對比成功,則提示“找到相同手指,FingerID=88……”
提示:如果通訊不成功請檢查接線方式是否正確,正確方式是模塊 Tx、Rx 分別接到 USB
轉串口設備的 Rx、Tx。如果更改了模塊地址必須更改回默認 OxFFFFFFFF,同時口令也
必須是默認值 0,這樣才能正常通訊!CH340 USB 轉串口的驅動程序在模塊資料\3,配套
軟件\CH340 驅動程序。
燒代碼部分
結束了上面的操作后你的AS608(相當于激活了)能工作了
下載Adafruit-Fingerprint-Sensor-Library-master這個ardino的庫文件
1.在Arduino IDE中,轉到File > Examples > Adafruit Fingerprint Sensor Library > Enroll。
2.上傳代碼到Arduino開發板,并以9600的波特率打開串行監視器。
3.這時您應該輸入指紋的ID。由于這是您的第一個指紋,請在左上角輸入1,然后單擊Send按鈕。
大功告成
如果還有不會的伙伴在下方評論,我教你
創作不易,如果對你有幫助的還麻煩點個贊
總結
以上是生活随笔為你收集整理的arduino+AS608的使用教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java.net.BindExcepti
- 下一篇: 手机阅读PDF时怎么调到夜间模式?