arduino+AS608的使用教程

arduino+AS608的使用教程

解决 Adafruit Fingerprint sensor enrollment

Did not find fingerprint sensor 的问题

器材的准备

  1. AS608光学指纹模块
  2. uno板子一个
  3. 杜邦线若干
  4. usb转ttl

接线

这个我就不说了小孩子都知道怎么接线

开始搭载AS608模块

直接上代码,不废话

/*************************************************** 
  This is an example sketch for our optical Fingerprint sensor

  Designed specifically to work with the Adafruit BMP085 Breakout 
  ----> http://www.adafruit.com/products/751

  These displays use TTL Serial to communicate, 2 pins are required to 
  interface
  Adafruit 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 

// 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 port
  finger.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
arduino+AS608的使用教程_第1张图片
第一步:将模块的 Tx、Rx 连接到 USB 转串口设备。(提示:开发板可使用板载的 CH340)。

第二步:在计算机设备管理器找到识别的串口号

第三步:打开模块资料\2,配套软件\指纹模块测试上位机\指纹测试.exe,然后在上位机
选择对应串口号
arduino+AS608的使用教程_第2张图片
第四步:点击“确定”,通讯成功。

第五步:通讯成功之后可查看硬件信息、波特率等,可以点击面板上按钮等功能操作。

arduino+AS608的使用教程_第3张图片
下面我们点击“录入指纹”按钮,点击后。并输入 0为录入指纹 ID。

第六步:点击“确定”,软件提示“请将手指平放在传感器上”

第七步:按照提示将手指平放在传感器上,等待图像上传, 所示。提示:
上传时间稍微久一点。波特率越高速度越快,使用 USB 模块测试则会更快。

第八步:第一次录入图像成功之后,软件会提示“2.请将手指平放在传感器上”表示第
二次录入图像。
arduino+AS608的使用教程_第4张图片
第九步:当两次录入图像的指纹经过对比匹配之后,如果一致的话指纹就录入成功了。
录入成功

第十步:前面操作是录入了一个指纹,下面我们测试一下刷指纹(验证指纹)。首先我
们点击“搜索”

第十一步:点击了搜索之后软件提示“请将手指平放在传感器上”

第十二步:按照提示将手指放在传感器上录入图像成功之后,系统对比录入图像与指纹
库,如果对比成功,则提示“找到相同手指,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的使用教程_第5张图片
大功告成

如果还有不会的伙伴在下方评论,我教你

创作不易,如果对你有帮助的还麻烦点个赞

你可能感兴趣的:(电子,技术,单片机,编程,技术,科技类,创作类)