Git Product home page Git Product logo

fingerprint-mqtt's People

Contributors

adamburgoyne avatar aneisch avatar belgianrubs avatar everythingsmarthome avatar luckypants123 avatar unseemlycoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fingerprint-mqtt's Issues

Communication error

Creating model for #1
Fingerprints did not match
Exiting Learning mode

Image taken
Image converted
Unknown error
Communication error
Image taken
Image converted
Unknown error
Image taken
Image converted
Unknown error
Communication error

i flahed it on D1
board select: d1 R2&mini

R503 fingerprint - working script for esp

#include <SoftwareSerial.h>
#include <ArduinoJson.h>
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
#include <Adafruit_Fingerprint.h>

//12 seconds WatchDog Timer
#define WDT_TIMEOUT 12 

// Wifi Settings
#define SSID                          "abc"
#define PASSWORD                      "abc"

// MQTT Settings
#define HOSTNAME                      "fingerprint-sensor"
#define MQTT_SERVER                   "192.168.1.230"
#define STATE_TOPIC                   "/fingerprint/mode/status"
#define MODE_LEARNING                 "/fingerprint/mode/learning"
#define MODE_READING                  "/fingerprint/mode/reading"
#define MODE_DELETE                   "/fingerprint/mode/delete"
#define AVAILABILITY_TOPIC            "/fingerprint/available"
#define mqtt_username                 "abc"
#define mqtt_password                 "abc"
#define MQTT_INTERVAL 5000            //MQTT rate limiting when no finger present, in ms

#define SENSOR_TX 12                  //GPIO Pin for RX
#define SENSOR_RX 14                  //GPIO Pin for TX

SoftwareSerial mySerial(SENSOR_TX, SENSOR_RX);             //Hardware Serial
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

WiFiClient wifiClient;                // Initiate WiFi library
PubSubClient client(wifiClient);      // Initiate PubSubClient library

uint8_t id = 0;                       //Stores the current fingerprint ID
uint8_t lastID = 0;                   //Stores the last matched ID
uint8_t lastConfidenceScore = 0;      //Stores the last matched confidence score
boolean modeLearning = false;
boolean modeReading = true;
boolean modeDelete = false;
unsigned long lastMQTTmsg = 0;	      //Stores millis since last MQTT message

//Declare JSON variables
DynamicJsonDocument mqttMessage(100);
char mqttBuffer[100];

void setup()
{
  Serial.begin(57600);
  while (!Serial);
  delay(100);
  Serial.println("\n\nWelcome to the MQTT Fingerprint Sensor program!");

  // 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);
    }
  }

  WiFi.mode(WIFI_STA);
  WiFi.begin(SSID, PASSWORD);
  Serial.print("Connecting...");

  while (WiFi.status() != WL_CONNECTED) {       // Wait till Wifi connected
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());                     // Print IP address

  Serial.println("Configuring WDT...");
  //esp_task_wdt_init(WDT_TIMEOUT, true); //enable panic so ESP32 restarts
  //esp_task_wdt_add(NULL); //add current thread to WDT watch

  client.setServer(MQTT_SERVER, 1883);                // Set MQTT server and port number
  client.setCallback(callback);
}

int last = millis();

void loop() {

  if (millis() - last <= 11000) {
      //Serial.println("Resetting WDT...");
      //esp_task_wdt_reset(); //timer reset
      last = millis();
  }

    
  if (!client.connected()) {
    reconnect();                //Just incase we get disconnected from MQTT server
  }
  if (modeReading == true && modeLearning == false) {
    uint8_t result = getFingerprintID();
    if (result == FINGERPRINT_OK) {
      mqttMessage["mode"] = "reading";
      mqttMessage["id"] = lastID;
      mqttMessage["state"] = "Matched";
      mqttMessage["confidence"] = lastConfidenceScore;
      size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
      client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
      lastMQTTmsg = millis();
      delay(500);
    } else if (result == FINGERPRINT_NOTFOUND) {
      mqttMessage["mode"] = "reading";
      mqttMessage["match"] = false;
      mqttMessage["id"] = id;
      mqttMessage["state"] = "Not matched";
      size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
      client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
      lastMQTTmsg = millis();
      delay(500);
    } else if (result == FINGERPRINT_NOFINGER) {
      if ((millis() - lastMQTTmsg) > MQTT_INTERVAL){
        mqttMessage["mode"] = "reading";
        mqttMessage["id"] = id;
        mqttMessage["state"] = "Waiting";
        size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
        client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
        lastMQTTmsg = millis();
      }
      if ((millis() - lastMQTTmsg) < 0){
        lastMQTTmsg = millis();     //Just in case millis ever rolls over
      }
    } else {

    }
  }
  client.loop();
  delay(100);            //don't need to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_ON, 200, FINGERPRINT_LED_PURPLE);
      break;
    case FINGERPRINT_NOFINGER:
      //Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 10);
      return p;
    default:
      Serial.println("Unknown error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
      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");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 18, FINGERPRINT_LED_PURPLE, 5);
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_PURPLE, 10);
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_PURPLE, 15);
      return p;
    default:
      Serial.println("Unknown error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
      return p;
  }

  // OK converted!
  p = finger.fingerSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Match!");
    lastID = finger.fingerID;
    lastConfidenceScore = finger.confidence;
  }
    else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 24, FINGERPRINT_LED_RED, 4);
    return p;
  } else {
    Serial.println("Unknown error");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
    return p;
  }
  
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 18, FINGERPRINT_LED_BLUE, 5);

  digitalWrite(7,LOW);
  delay(500);
  digitalWrite(7,HIGH);
  
  return p;
}

uint8_t getFingerprintEnroll() {
  int p = -1;
  mqttMessage["mode"] = "learning";
  mqttMessage["id"] = id;
  mqttMessage["state"] = "Place finger..";
  size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
  client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
  Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
  finger.LEDcontrol(FINGERPRINT_LED_BREATHING, 100, FINGERPRINT_LED_PURPLE);
  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");
        finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
        break;
      case FINGERPRINT_IMAGEFAIL:
        Serial.println("Imaging error");
        finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 10);
        break;
      default:
        Serial.println("Unknown error");
        finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
        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");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 18, FINGERPRINT_LED_PURPLE, 5);
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_PURPLE, 10);
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_PURPLE, 15);
      return p;
    default:
      Serial.println("Unknown error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
      return p;
  }

  mqttMessage["mode"] = "learning";
  mqttMessage["id"] = id;
  mqttMessage["state"] = "Remove finger..";
  mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
  client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
  Serial.println("Remove finger");
  delay(2000);
  
  finger.LEDcontrol(FINGERPRINT_LED_BREATHING, 100, FINGERPRINT_LED_BLUE);
  
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }
  Serial.print("ID "); Serial.println(id);
  p = -1;
  mqttMessage["mode"] = "learning";
  mqttMessage["id"] = id;
  mqttMessage["state"] = "Place same finger..";
  mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
  client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
  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");
        finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
        break;
      case FINGERPRINT_IMAGEFAIL:
        Serial.println("Imaging error");
        finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 10);
        break;
      default:
        Serial.println("Unknown error");
        finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
        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");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 18, FINGERPRINT_LED_PURPLE, 5);
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_PURPLE, 10);
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_PURPLE, 15);
      return p;
    default:
      Serial.println("Unknown error");
      finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
      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");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    Serial.println("Fingerprints did not match");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 10);
    return p;
  } else {
    Serial.println("Unknown error");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
    return p;
  }
  
  finger.LEDcontrol(FINGERPRINT_LED_ON, 0, FINGERPRINT_LED_BLUE);
  
  Serial.print("ID "); Serial.println(id);
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    mqttMessage["mode"] = "learning";
    mqttMessage["id"] = id;
    mqttMessage["state"] = "Success, stored!";
    mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
    client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
    finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_OFF, 100, FINGERPRINT_LED_BLUE);
    Serial.println("Stored!");
    return true;
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not store in that location");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 10);
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 20);
    return p;
  } else {
    Serial.println("Unknown error");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
    return p;
  }
}

uint8_t deleteFingerprint() {
  uint8_t p = -1;
  finger.LEDcontrol(FINGERPRINT_LED_BREATHING, 100, FINGERPRINT_LED_RED);
  p = finger.deleteModel(id);

  if (p == FINGERPRINT_OK) {
    Serial.println("Deleted!");
    mqttMessage["mode"] = "deleting";
    mqttMessage["id"] = id;
    mqttMessage["state"] = "Deleted!";
    size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
    client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
    finger.LEDcontrol(FINGERPRINT_LED_GRADUAL_OFF, 200, FINGERPRINT_LED_RED);
    return true;
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 5);
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not delete in that location");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 10);
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 20);
    return p;
  } else {
    Serial.print("Unknown error: 0x"); Serial.println(p, HEX);
    finger.LEDcontrol(FINGERPRINT_LED_FLASHING, 50, FINGERPRINT_LED_RED, 15);
    return p;
  }
}

void reconnect() {
  while (!client.connected()) {       // Loop until connected to MQTT server
    Serial.print("Attempting MQTT connection...");
    if (client.connect(HOSTNAME, mqtt_username, mqtt_password, AVAILABILITY_TOPIC, 1, true, "offline")) {       //Connect to MQTT server
      Serial.println("connected");
      client.publish(AVAILABILITY_TOPIC, "online");         // Once connected, publish online to the availability topic
      client.subscribe(MODE_LEARNING);       //Subscribe to Learning Mode Topic
      client.subscribe(MODE_READING);
      client.subscribe(MODE_DELETE);
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);  // Will attempt connection again in 5 seconds
    }
  }
}

void callback(char* topic, byte* payload, unsigned int length) {                    //The MQTT callback which listens for incoming messages on the subscribed topics
  if (strcmp(topic, MODE_LEARNING) == 0) {
    char charArray[3];
    for (int i = 0; i < length; i++) {
      //Serial.print((char)payload[i]);
      charArray[i] = payload[i];
    }
    id = atoi(charArray);
    if (id > 0 && id < 128) {
      Serial.println("Entering Learning mode");
      mqttMessage["mode"] = "learning";
      mqttMessage["id"] = id;
      size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
      client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
      while (!getFingerprintEnroll());
      Serial.println("Exiting Learning mode");
      modeLearning = false;
      modeReading = true;
      modeDelete = false;
      id = 0;
    } else {
      Serial.println("No");
    }
    Serial.println();
  }

  if (strcmp(topic, MODE_DELETE) == 0) {
    char charArray[3];
    for (int i = 0; i < length; i++) {
      //Serial.print((char)payload[i]);
      charArray[i] = payload[i];
    }
    id = atoi(charArray);
    if (id > 0 && id < 128) {
      mqttMessage["mode"] = "deleting";
      mqttMessage["id"] = id;
      size_t mqttMessageSize = serializeJson(mqttMessage, mqttBuffer);
      client.publish(STATE_TOPIC, mqttBuffer, mqttMessageSize);
      Serial.println("Entering delete mode");
      while (! deleteFingerprint());
      Serial.println("Exiting delete mode");
      delay(2000); //Make the mqttMessage readable in HA
      modeLearning = false;
      modeReading = true;
      modeDelete = false;
      id = 0;
    }
    Serial.println();
  }
}

Support for R503 FPS and watchdog

The adafruit fingerprint library supports FPM10A (optical) and R30x/R50x (Capacitive) Fingerprint sensors. However, the Capacitive fingerprint sensors (FPS) do not support the following function:

finger.fingerFastSearch();

The above line throws "Unknown Error" on Serial Monitor via switch-case logic.
but instead use

finger.fingerSearch();

The R-series FPS have an LED ring around the sensor that can be used to indicate various states via

finger.LEDcontrol(uint8_t control, uint8_t speed, uint8_t coloridx, uint8_t count=0)

I have also noticed that certain microcontrollers (ESP32xx family) get stuck and do not publish mqtt messages, even though broker and wifi are available. I am yet to ascertain the issue via logs as this bug appears only when microcontroller is on power (for an extended period of time - days) and not connected to a system for serial monitor. Currently using a watchdog to raise a hardware interrupt and reboot the device on such a scenario.

Hardware WatchDog Timer - ESP32xx Stuck WiFi

esp_task_wdt.h no such file or directory

I'm trying to compile : fingerprint-R503-mqtt-led-WDT.ino
But i can't get it to work on my wemos d1 mini.
I always get the error : esp_task_wdt.h no such file or directory
But how can i solve this error?
I really don't know where to find this esp_task_wdt.h

Arduino: 1.8.19 (Windows 10), Board: "LOLIN(WEMOS) D1 mini (clone), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, DOUT (compatible), 40MHz, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

fingerprint_sensor:19:10: fatal error: esp_task_wdt.h: No such file or directory

Multiple libraries were found for "PubSubClient.h"

19 | #include <esp_task_wdt.h>

Used: C:\Users\Jo\Documents\Arduino\libraries\PubSubClient

  |          ^~~~~~~~~~~~~~~~

Not used: C:\Users\Jo\Documents\Arduino\libraries\ESP8266_Microgear

compilation terminated.

exit status 1

esp_task_wdt.h: No such file or directory

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Reboot regulary

Hi
First thanks for your great work.

In my case, all work, learning deleting, matched...
i can open my nuki lock or unlock with him

but regulary my wemos reboot and i have this message

23:17:26.679 -> --------------- CUT HERE FOR EXCEPTION DECODER --------------- 23:17:26.679 -> 23:17:26.679 -> Exception (0): 23:17:26.679 -> epc1=0x40209144 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000 23:17:26.679 -> 23:17:26.679 -> >>>stack>>> 23:17:26.679 -> 23:17:26.679 -> ctx: sys 23:17:26.713 -> sp: 3fffebe0 end: 3fffffb0 offset: 0190 23:17:26.713 -> 3fffed70: 00000025 00000000 00000001 3fffee90 23:17:26.713 -> 3fffed80: 3ffeb069 3ffecea0 3ffeb08e 00000030 23:17:26.713 -> 3fffed90: 00001770 000002ee 00001000 40100d06 23:17:26.746 -> 3fffeda0: 0000001a 3ffedf00 00000020 c0036005 23:17:26.746 -> 3fffedb0: 00000000 00000001 0000000c 401008c4 23:17:26.746 -> 3fffedc0: 00000020 3ffef804 3ffea3af 3ffedaf8 23:17:26.746 -> 3fffedd0: 4022423d 3fffee90 3ffedf00 00000022 23:17:26.779 -> 3fffede0: 3fffc200 40100800 3fffc258 4000050c .......................23:18:25.855 -> 3ffffe10: 3ffefe14 3ffef1fc 3ffef1f0 40217a98 23:18:25.855 -> 3ffffe20: 00000000 000002ad 3ffeeb98 4020496c 23:18:25.891 -> 3ffffe30: 00000001 00000025 00000023 00000001 23:18:25.891 -> 3ffffe40: 3ffefe14 3fff0854 00000020 00000161 23:18:25.891 -> 3ffffe50: 00000160 3ffefe04 3ffeebec 40204c91 23:18:25.891 -> 3ffffe60: 3ffefe14 3ffe916c 0054a991 00000000 23:18:25.924 -> 3ffffe70: 40106361 0054aaec 3ffeecdc 00000000 23:18:25.924 -> 3ffffe80: 3ffee5e0 3ffeecdc 3ffe85dc 3ffeecdc 23:18:25.924 -> 3ffffe90: 00000008 3ffffef0 40206190 3fffefb0 23:18:25.924 -> 3ffffea0: 3ffeecdc 00000008 00000001 402062e5 23:18:25.957 -> 3ffffeb0: 40204312 3ffeeb58 00000003 40204312 23:18:25.957 -> 3ffffec0: 000003e8 3ffeeaec 3ffeeb58 402090ec 23:18:25.957 -> 3ffffed0: 00000005 00000000 3ffe85dc 3ffeed04 23:18:25.957 -> 3ffffee0: 3ffeeb58 3ffeeaec 3ffeeb58 402045ea 23:18:25.992 -> 3ffffef0: ffffef01 0007ffff 00010000 4020397a 23:18:25.992 -> 3fffff00: 00000001 3ffeeaec 3ffeeaec 40202c3a 23:18:25.992 -> 3fffff10: 00000000 00003caf 072b020c 00462a60 23:18:25.992 -> 3fffff20: 3ffe8945 3ffeeaec 0000002b 3ffeeaec 23:18:26.025 -> 3fffff30: 00000000 00004512 7d01a3d7 004fdd61 23:18:26.025 -> 3fffff40: 3ffeea48 3ffeeaec 3ffeecd8 40201202 23:18:26.025 -> 3fffff50: 00000000 3ffeeaec 3ffeecd8 40202440 23:18:26.058 -> 3fffff60: 00000000 00000000 00000000 00000000 23:18:26.058 -> 3fffff70: 40106361 0054a28a 3ffeecdc 00000000 23:18:26.058 -> 3fffff80: 00000000 3ffeecdc 3ffe85dc 3ffeecdc 23:18:26.058 -> 3fffff90: 3fffdad0 3ffeed04 40206190 3ffeed04 23:18:26.093 -> 3fffffa0: 3fffdad0 00000000 3ffeecd8 3ffeed04 23:18:26.093 -> <<<stack<<< 23:18:26.093 -> 23:18:26.093 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------

what is the problem, how i can fix it . Thanks

unknown error

Hi,

I'm using a Wemos D1 mini with a R503 Fingerprint sensor. The wiring seems to be correct and mqtt is working too.
I can learn new fingers but everytime i put my finger on the sensor i get this output

Found fingerprint sensor!
Connecting.......
Connected, IP address: 192.168.7.172
Attempting MQTT connection...connected
Image taken
Image converted
Unknown error
Communication error

It seems to happen in this part of the sketch

  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
    lastID = finger.fingerID;
    lastConfidenceScore = finger.confidence;
    return p;
  } 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;
  }

Any idea how to solve the problem? I tired it with 2 different R503 and two different Wemos D1 mini

My wiring is

Red + White > 3,3V
Black > Ground
Yellow > D6
Green > D5
Blue > not connected

Not getting it to work with Oled

Hello,

when i use the first version fingerprint-mqtt.ino the sensor works perfectly.
i followedd your video and it works in home assistant too.

When i try any other version it doesnt. I did solder the extra wires 4 and 5 to D3 and 3v as written.
but non of the codes work with it. I am using a Wemos d1 mini for it with a OLED on pins D1 sda, and D2 scl.

Any idea what could be causing this?

Fingerprint matched but unavailable name

Hi,
I am using Home assistant in a virtual environment with the following:

Home Assistant 2022.10.3
Supervisor 2022.10.0
Operating System 9.2
Frontend 20221010.0 - latest.

I've used your code to set fingerprint and I recorded 3 of my fingers with different names but only the last one has a name available. The other 2 are unavaillable but matched.
I've used scripts.yaml and configuration.yaml but splited with sensors.yaml.
This is in configuration.yaml:

  • name: "Fingerprint"
    state_topic: "/fingerprint/mode/status"
    value_template: "{{value_json.state}}"
    json_attributes_topic: "/fingerprint/mode/status"
    json_attributes_template: "{{value_json | tojson}}"

The rest is in sensors.yaml

What am I missing?

relay

Is there a version were you can connect a relay to use the sensor standalone without a internet connection but sends data when available?
I want to use the sensor in my garage were the internet conncetion is not always stable.

No createModel in class Adafruit_Fingerprint

When I compile I get the error:

/Users/username/Downloads/Fingerprint/fingerprint-mqtt-led-touch/fingerprint-mqtt-led-touch.ino: In function 'uint8_t getFingerprintEnroll()':
fingerprint-mqtt-led-touch:342:14: error: 'class Adafruit_Fingerprint' has no member named 'createModel'
p = finger.createModel();
^
exit status 1
'class Adafruit_Fingerprint' has no member named 'createModel'

I can indeed not find that function in the version of AdaFruit_fingerprint that I am using. Could it be that it is renamed to loadModel?

ESP01 not booting with his code.

Hello! I had wanted to run this code on one of many esp01's I had sitting around. I seems that whenever I put this code on them, It doesn't want to boot. It has no logs and doesnt do anything. I was wondering if anyone had success with using these small boards with this sensor. I am using GPIO pins 0 and 2. It does boot with other things like esphome and just a blink code but with this code, no logs. If anyone was successful and got it working, that would be very nice. I have also tried it on multiple boards with no avail.

2nd Sensor

Hi
Great project, finally implemented into my HA!

I would like to add second sensor to Home Assistant
What should be changed, to have 2 sensors in one HA instance?

in sketch, and in HA Configs.

also, what should be disabled in sketch when connection error triggers, that no red light flashes.
thank You in advance!

MQTT - learning

What is the mosquitto_pub message to start learning a new fingerprint?

Home assistant and the name of id

I

i ve a bug with the name of persnon.

When i learning a fingerprint ( ex ID 1 name John) with id and name it's ok
when i scan again the id it's good and the name of person same.. ID 1 Name John

Now when i learning a second finger, it's good ( ID2 name jack)
scan finger > name and ID ok : ID 2 Name JAck

But if i scan the previous finger the ID is good ID1 but name is "unavailable".

if The id is good i thing the memory and the module is good.
may be an error in the configuration of sensor in yam code.

Thanks

Configuration sensor/topic code depricated

Issue
When copy pasting your configuration.yaml code into HomeAssistant, the editor shows that your mqtt topic code is depricated.
Also after restarting HomeAssistant the logs show a warning regarding the same and is referring to:
https://www.home-assistant.io/integrations/sensor.mqtt/#new_format

Suggestion

#Fingerprint mqtt topic
mqtt:
  sensor:
    - name: "Fingerprint"
      state_topic: "/fingerprint/mode/status"
      value_template: "{{value_json.state}}"
      json_attributes_topic: "/fingerprint/mode/status"
      json_attributes_template: "{{value_json | tojson}}"

#Fingerprint template sensors
sensor:
  - platform: template
    sensors:
      fingerprint_mode:
        friendly_name: "Fingerprint Sensor Mode"
        value_template: >-
          {{state_attr('sensor.fingerprint', 'mode')}}
        icon_template: >-
          {% if is_state('sensor.fingerprint_mode', 'reading') %}
            mdi:book-open-outline
          {% elif is_state('sensor.fingerprint_mode', 'learning') %}
            mdi:book-open-page-variant
          {% endif %}
      fingerprint_state:
        friendly_name: "Fingerprint State"
        value_template: >-
          {{states('sensor.fingerprint')}}
        icon_template: >-
          {% if is_state('sensor.fingerprint', 'Waiting') %}
            mdi:fingerprint
          {% elif is_state('sensor.fingerprint', 'Matched') %}
            mdi:fingerprint
          {% elif is_state('sensor.fingerprint', 'Not matched') %}
            mdi:fingerprint-off
          {% endif %}
      fingerprint_id:
        friendly_name: "Fingerprint ID"
        value_template: >-
          {{state_attr('sensor.fingerprint', 'id')}}
      fingerprint_person:
        friendly_name: "Fingerprint Person"
        value_template: >-
          {% if states('sensor.fingerprint_id') | int >= 1 %}
            {%- set printid = states('sensor.fingerprint_id') | int -%}
            {%- set prints = states("input_text.fingerprint_data") | from_json if states("input_text.fingerprint_data") else [] -%}
            {%- set fingerprint = prints|selectattr('id', 'eq', states('sensor.fingerprint_id') | int) | first -%}
            {{fingerprint["name"]}}
          {% elif is_state('sensor.fingerprint', 'Waiting') %}
            Waiting
          {% elif is_state('sensor.fingerprint', 'Not matched') %}
            Not matched
          {% endif %}
        icon_template: >-
          {% if is_state('sensor.fingerprint', 'Waiting') %}
            mdi:human-male
          {% elif is_state('sensor.fingerprint', 'Matched') %}
            mdi:human-greeting
          {% elif is_state('sensor.fingerprint', 'Not matched') %}
            mdi:police-badge
          {% endif %}

(love your work and tutorials, thanks!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.