esp8266 не взаимодействует с датчиком отпечатков пальцев R305

Привет , моя проблема в том, что когда я подключаю датчик отпечатков пальцев к esp8266, он не работает! Я использую датчик отпечатков пальцев adafruit R305 и модуль esp esp8266 cp2102. Я подключил вывод vcc к выводу 3,3 В, а вывод заземления - к заземлению, затем я подключаю rx к выводу rx и tx к выводу tx. Я использую библиотеку датчиков adafruit, но когда я подключаю отпечаток пальца, она что-то делает. Я планирую создать простую систему посещаемости по отпечаткам пальцев с этими двумя компонентами, и я создал базу данных с приложением IFTTT. вот код.

#include <BearSSLHelpers.h>
#include <CertStoreBearSSL.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiGeneric.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiSTA.h>
#include <ESP8266WiFiType.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiClientSecureAxTLS.h>
#include <WiFiClientSecureBearSSL.h>
#include <WiFiServer.h>
#include <WiFiServerSecure.h>
#include <WiFiServerSecureAxTLS.h>
#include <WiFiServerSecureBearSSL.h>
#include <WiFiUdp.h>



#include <SoftwareSerial.h>

#include <Adafruit_Fingerprint.h>

#define rxPin 2
#define txPin 3

const char* NAME; // the name will be gievn in the code for each ID saved
const char* ID; // the ID that are save into the fingerprint sensor


String Event_Name = "FINGERPRINT "; // this is the name of the file of the database

String Key = "beStaVRpfye6wtonedU"; // this is my unique key for the database created

// Replace with your unique IFTTT URL resource
String resource = "/trigger/" + Event_Name + "/with/key/" + Key;

// Maker Webhooks IFTTT
const char* server = "maker.ifttt.com"; // here database is store

// Replace with your SSID and Password
char* ssid     = "Telecom-2"; //wifi name
char* pass = "X5NVY53V236k"; // wifi password
SoftwareSerial mySerial (rxPin, txPin);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); // communcation with the IoT and fingerprint sensor

void setup()
{
  Serial.begin(57600);
  mySerial.begin(57600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit finger detect test");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  delay(5);
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) {
      delay(1);
    }
  }
// the fingerpprint sensor will first starts
  finger.getTemplateCount();
  Serial.print("Sensor contains ");
  Serial.print(finger.templateCount);
  Serial.println(" templates");
  Serial.println("Waiting for valid finger...");

// meanwhile the esp8266 wifi module will start and conect to the wifi data given
  Serial.print("Connecting to: "); // connecting to a wifi avaible
  Serial.print(ssid);             // connecting to the given wifi name  
  WiFi.begin(ssid, pass);    // connection in progress 

  int timeout = 10 * 4; // 10 seconds
  while (WiFi.status() != WL_CONNECTED  && (timeout-- > 0)) {
    delay(250);
    Serial.print("Attempting to connect to SSID");
  }
  Serial.println("Connected");

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Failed to connect");
  }

  Serial.print("WiFi connected in: ");
  Serial.print(millis());
  Serial.print(", IP address: ");
  Serial.println(WiFi.localIP());
}

void loop()                     // run over and over again
{ // now the finger print sensor will wait for a register ID
  getFingerprintIDez();
  if (finger.fingerID == 1) //mean if the ID correspond to ID 1
  {

    Serial.print("!!--");
    Serial.println(finger.fingerID);
    NAME = "Sailen"; //therefore the name of sailen will appear as ID 1
    ID = "1";
    if (finger.confidence >= 60) // fingerprint test must over 60% of confidence
    {
      Serial.print("Attendace Marked for ");
      Serial.println(NAME);
      makeIFTTTRequest();
      // digital write - open the attendance
    }

  }

  if (finger.fingerID == 2 ) {
    Serial.print("!!--");
    Serial.println(finger.fingerID);
    digitalWrite(5, LOW);
    NAME = "Bob"; // therefore the name of bob will appear for ID 2
    ID = "2";
    if (finger.confidence >= 60) // fingerprint test must over 60% of confidence
    {
      Serial.print("Attendace Marked for ");
      Serial.println(NAME);
      makeIFTTTRequest();
      // digital write - open the door
    }      //don't ned to run this at full speed.

  }

}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  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!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }

  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);

  return finger.fingerID;
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;

  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID;
}

// Make an HTTP request to the IFTTT web service
void makeIFTTTRequest() {
  Serial.print("Connecting to "); // means connecting to my google database
  Serial.print(server);

  WiFiClient client;
  int retries = 5;
  while (!!!client.connect(server, 80) && (retries-- > 0)) {
    Serial.print(".");
  }
  Serial.println();
  if (!!!client.connected()) {
    Serial.println("Failed to connect...");
  }

  Serial.print("Request resource: ");
  Serial.println(resource);

// now that the IoT has access to the data base
// value 1 will be use for name and value 2 for which ID it is

  String jsonObject = String("{\"value1\":\"") + NAME + "\",\"value2\":\"" + ID
                      + "\"}"; // name and id is registered in the database

  client.println(String("POST ") + resource + " HTTP/1.1");
  client.println(String("Host: ") + server);
  client.println("Connection: close\r\nContent-Type: application/json");
  client.print("Content-Length: ");
  client.println(jsonObject.length());
  client.println();
  client.println(jsonObject);

  int timeout = 5 * 10; // 5 seconds
  while (!!!client.available() && (timeout-- > 0)) {
    delay(100);
  }
  if (!!!client.available()) {
    Serial.println("No response...");
  }
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("\nclosing connection");
  client.stop();
}`

здесь что-то не так? я смотрю подобное видео на YouTube, но мое немного другое https://techiesms.com/iot-projects/iot-attendance-system-without-website/

2 ответа

Как указано в даташите датчика:

Напряжение питания: 3,6 - 6,0 В постоянного
тока Рабочий ток: макс.120 мА
Пиковый ток: макс.150 мА

Поэтому вам нужно использовать соответствующий источник питания или аккумулятор с повышающим преобразователем, я рекомендую минимум 4,5 В и минимум 0,5 А для надежной работы.

Сэр, я подключаю отпечаток пальца на 5 В и вывод tx к выводу tx esp, а также rxpin к выводу esp rx, но он не работает

Другие вопросы по тегам