In diesem Beitrag berichte ich über mein weitestgehend Adafruit kompatiblen Fingerprint R503 (Amazon, Aliexpress)*, den ich mittels eines Esp und MQTT mit Fhem verbunden habe.
Das Projekt hatte zwei kleinere Herausforderungen:
1. Die Modifikation der Adafruit Fingerprint Library um Fastfingersearch und die LED zu nutzen
2. MQTT einzurichten um mit FHEM zu kommunizieren
Neben dem Fingerprint (Amazon, Aliexpress)*und dem ESP (Amazon, Aliexpress)* benötigen wir einen Spannungsregler, der uns stabile 3.3V bringt.

Schaltplan:
Der Fingerprint, der nur 3.3V verträgt, wird wie folgt verdrahtet:
1. Power Supply (rot) an Vout des Spannungsreglers
2. GND (schwarz) an Minus / Ground.
3. TXD (gelb) an GPIO14 des ESP
4. RDS (grün) an GPIO12 des ESP
5. 3.3VT (weiß) an Vout des Spannungsreglers
Der ESP wird folgendermaßen angeschlossen:
1. GPIO14 des ESP an TXD (gelb) des Fingerprint
2. GPIO12 des ESP an RDS (grün) des Fingerprint
3. GPIO0 des ESP über einen 10k Widerstand an 3.3V (bei Normalbetrieb)
4. GPIO15 des ESP über einen 10k Widerstand an Minus / Ground
5. EN des ESP über einen 10k Widerstand an Vout 3.3V des Spannungswandlers
6. TX des ESP an RX des FT232 USB zu TTL Serial Adapter
7. RX des ESP an TX des FT232RL USB zu TTL Serial Adapter
8. VCC des ESP an Vout des Spannungswandlers
9. GND an Minus / Ground des Spannungswandlers
FT232 USB zu TTL Serial Adapter:
Denkt daran, den FT232 auf 3.3 Volt einzustellen!
1. VCC an Vout des Spannungswandlers
2. GND an Minus / Ground des Spannungswandlers
3. RX des FT232 USB zu TTL Serial Adapter an TX des ESP
4. TX des FT232 USB zu TTL Serial Adapter an RX des ESP
Beim Hochladen des Codes ist GPIO0 auf Masse zu legen. Erst nach dem Hochladen wieder auf 3.3V über einen 10k Widerstand.
Software
Die Adafruit Library habe ich modifiziert, damit wir auf die LED des Fingerprint ansteuern können. Die leicht modifizierte Library kann hier https://github.com/MarcBoettinger/Adafruit_Fingerprint_Sensor_Library heruntergeladen werden. Bitte kopiert diese in euren Arduino Library Folder.
Ihr könnt nun die Standard Skripte der Adafruit Fingerprint Sensory Library nutzen, wie zB den Skript enroll um neue Fingerprints zu speichern oder changepassword um ein Passwort für die Kommunikation des ESP und dem Fingerprint zu setzen. Ihr müsst dazu lediglich die Zeile
SoftwareSerial mySerial(2, 3); auf
SoftwareSerial mySerial(14, 12);
ändern. Denkt daran vor dem Hochladen bzw ausführen GPIO0 richtig zu setzen und danach einen Reset des Esp zu triggern.
Bitte speichert unter der ID Nummer 1 den Finger, der sozusagen Admin Rechte erhalten soll.
FHEM
In FHEM definieren wir zunächst den MQTT2 Server über die folgende Eingabe:
define MQTT2_FHEM_Server MQTT2_SERVER 1883 global
define MQTT2_FHEM_Server_allowed allowed
attr MQTT2_FHEM_Server_allowed validFor MQTT2_FHEM_Server
set MQTT2_FHEM_Server_allowed basicAuth *username* *password*
Bitte setzt euren eigenen *username* und *password* und tragt diesen bei mqttUser und mqttPassword in den folgendem Skript ein.
/***************************************************
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 <Adafruit_Fingerprint.h>
#include <SPI.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <PubSubClient.h> // Aus Wifi Mqtt
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <SoftwareSerial.h>
//************************************************************************
/* Set these to your desired credentials. */
SoftwareSerial mySerial(14, 12);
// 12: grün
// 14: gelb
const char *ssid = "DeinWifiSSID"; //ENTER YOUR WIFI SETTINGS
const char *password = "deinWifiPasswort";
const char* mqttServer = "192.168.x.x"; // Deine FHEM IP
const int mqttPort = 1883; // Broker PI Port
const char* mqttUser = "username"; // Broker PI Username
const char* mqttPassword = "passwort"; // Broker PI Password
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial, DeinPasswortAlsZahl);
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
// Falls Du kein Passwort für den Fingerprint vergeben hast.
WiFiClient espClient;
PubSubClient client(espClient);
char* mqttio = "12345"; // Broker PI Wert
char* confidence = "67890"; // Broker PI Wert
uint8_t id;
//************************************************************************
void setup()
{
Serial.begin(115200);
connectToWiFi();
Serial.println("\n\nAdafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
// send command to turn on R503 led
finger.led_control(1,100,2,1); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1) { delay(1); }
}
finger.getTemplateCount();
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
Serial.println("Waiting for valid finger...");
// mqtt
client.setServer(mqttServer, mqttPort);
client.setCallback(callback);
while (!client.connected()) {
Serial.println("Connecting to MQTT...");
if (client.connect("ESP8266Client", mqttUser, mqttPassword )) {
Serial.println("connected");
} else {
Serial.print("failed with state ");
Serial.print(client.state());
delay(2000);
}
}
client.subscribe("Fingerprint");
client.publish("Fingerprint", "FP1");
}
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived in topic: ");
Serial.println(topic);
Serial.print("Message:");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
Serial.println("-----------------------");
}
void loop() // run over and over again
{
//check if there's a connection to WiFi or not
if(WiFi.status() != WL_CONNECTED){
connectToWiFi();
}
if (!client.connected()) {
client.connect("ESP8266Client", mqttUser, mqttPassword );
}
if (getFingerprintIDez() == 1) {
delay(2000);
getFingerprintEnroll();
}
delay(50); //don't ned to run this at full speed.
}
// 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) {
// send command to turn on R503 led
finger.led_control(1,100,1,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
return -1;
}
// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
// send command to turn on R503 led
finger.led_control(1,100,2,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
// mqtt
sprintf(mqttio,"%d",finger.fingerID);
sprintf(confidence,"%d",finger.confidence);
client.subscribe("Confidence");
client.publish("Confidence", confidence);
client.subscribe("FingerprintNr");
client.publish("FingerprintNr", mqttio);
return finger.fingerID;
}
void connectToWiFi(){
WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)
delay(1000);
WiFi.mode(WIFI_STA);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //IP address assigned to your ESP
}
uint8_t getFingerprintEnroll() {
// send command to turn on R503 led
finger.led_control(1,100,3,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
id = min(finger.templateCount + 1, 127);
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;
}
// send command to turn on R503 led
finger.led_control(1,100,3,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
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!
// send command to turn on R503 led
finger.led_control(1,100,3,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
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;
}
}
Der Finger mit der ID 1 hat Admin Rechte. Wenn er aufgelegt wird, wird ein neuer Fingerprint angelegt mit der ID = Summe aller angelegter IDs + 1. Ihr könnt den Bereich auch auskommentieren, falls ihr ihn nicht benötigt.
Der MQTT2_ESP8266Client wird automatisch in FHEM angelegt, wenn sich der Esp meldet, insbesondere wenn er die erste Fingerprint ID übermittelt. Ihr könnt nun über ein notify in FHEM Aktionen pro Finger triggern!
English Version
Introduction
In this article I report on my largely Adafruit compatible Fingerprint R503 (Amazon, Aliexpress)*, which I connected to Fhem using an Esp and MQTT.
The project had two minor challenges:
1. the modification of the Adafruit Fingerprint Library to use Fastfingersearch and the LED
2. set up MQTT to communicate with FHEM
Used Material
Besides the fingerprint and the ESP (Amazon, Aliexpress)* we need a voltage regulator, which brings us stable 3.3V.
Wiring Diagramm
Wiring diagram:The fingerprint, which only tolerates 3.3V, is wired as follows:
1. power supply (red) to Vout of the voltage regulator
2. GND (black) to minus / ground.
3. TXD (yellow) to GPIO14 of ESP
4. RDS (green) on GPIO12 of ESP
5. 3.3VT (white) on Vout of the voltage regulator
The ESP is connected as follows:
1. GPIO14 of ESP to TXD (yellow) of the fingerprint
2. GPIO12 of ESP to RDS (green) of the fingerprint
3. GPIO0 of ESP via a 10k resistor at 3.3V (in normal operation)
4. GPIO15 of ESP via a 10k resistor at minus / ground
5. EN of ESP via a 10k resistor at Vout 3.3V of the voltage converter
6. TX of ESP to RX of FT232 USB to TTL Serial Adapter
7. RX of ESP to TX of FT232RL USB to TTL Serial Adapter
8. VCC of ESP to Vout of the voltage transformer
9. GND to minus / ground of voltage transformer
FT232 USB to TTL Serial Adapter:
Remember to set the FT232 to 3.3 Volt!
1. VCC to Vout of the voltage converter
2. GND to minus / ground of voltage transformer
3. RX of FT232 USB to TTL Serial Adapter to TX of ESP
4. TX of the FT232 USB to TTL Serial Adapter to RX of the ESP
When uploading the code, ground GPIO0. Only after uploading again to 3.3V via a 10k resistor.
Software
I have modified the Adafruit Library so that we can access the LED of the fingerprint. The slightly modified library can be downloaded here https://github.com/MarcBoettinger/Adafruit_Fingerprint_Sensor_Library Please copy it into your Arduino Library folder.
You can now use the standard scripts of the Adafruit Fingerprint Sensory Library, like the script enroll to save new fingerprints or changepassword to set a password for the communication between ESP and fingerprint. You only have to change the line
SoftwareSerial mySerial(2, 3); to
SoftwareSerial mySerial(14, 12);
Remember to set GPIO0 correctly before uploading/executing and to trigger a reset of the Esp afterwards.
Please save under ID number 1 the finger, which should get admin rights.
FHEM
In FHEM we first define the MQTT2 server by the following input:
define MQTT2_FHEM_Server MQTT2_SERVER 1883 global
define MQTT2_FHEM_Server_allowed allowed
attr MQTT2_FHEM_Server_allowed validFor MQTT2_FHEM_Server
set MQTT2_FHEM_Server_allowed basicAuth *username* *password*
Please set your own *username* and *password* and enter them at mqttUser and mqttPassword in the following script.
/***************************************************
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 <Adafruit_Fingerprint.h>
#include <SPI.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <PubSubClient.h> // Aus Wifi Mqtt
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <SoftwareSerial.h>
//************************************************************************
/* Set these to your desired credentials. */
SoftwareSerial mySerial(14, 12);
// 12: grün
// 14: gelb
const char *ssid = "DeinWifiSSID"; //ENTER YOUR WIFI SETTINGS
const char *password = "deinWifiPasswort";
const char* mqttServer = "192.168.x.x"; // Deine FHEM IP
const int mqttPort = 1883; // Broker PI Port
const char* mqttUser = "username"; // Broker PI Username
const char* mqttPassword = "passwort"; // Broker PI Password
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial, DeinPasswortAlsZahl);
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
// Falls Du kein Passwort für den Fingerprint vergeben hast.
WiFiClient espClient;
PubSubClient client(espClient);
char* mqttio = "12345"; // Broker PI Wert
char* confidence = "67890"; // Broker PI Wert
uint8_t id;
//************************************************************************
void setup()
{
Serial.begin(115200);
connectToWiFi();
Serial.println("\n\nAdafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
// send command to turn on R503 led
finger.led_control(1,100,2,1); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1) { delay(1); }
}
finger.getTemplateCount();
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
Serial.println("Waiting for valid finger...");
// mqtt
client.setServer(mqttServer, mqttPort);
client.setCallback(callback);
while (!client.connected()) {
Serial.println("Connecting to MQTT...");
if (client.connect("ESP8266Client", mqttUser, mqttPassword )) {
Serial.println("connected");
} else {
Serial.print("failed with state ");
Serial.print(client.state());
delay(2000);
}
}
client.subscribe("Fingerprint");
client.publish("Fingerprint", "FP1");
}
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived in topic: ");
Serial.println(topic);
Serial.print("Message:");
for (int i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
Serial.println("-----------------------");
}
void loop() // run over and over again
{
//check if there's a connection to WiFi or not
if(WiFi.status() != WL_CONNECTED){
connectToWiFi();
}
if (!client.connected()) {
client.connect("ESP8266Client", mqttUser, mqttPassword );
}
if (getFingerprintIDez() == 1) {
delay(2000);
getFingerprintEnroll();
}
delay(50); //don't ned to run this at full speed.
}
// 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) {
// send command to turn on R503 led
finger.led_control(1,100,1,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
return -1;
}
// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
// send command to turn on R503 led
finger.led_control(1,100,2,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
// mqtt
sprintf(mqttio,"%d",finger.fingerID);
sprintf(confidence,"%d",finger.confidence);
client.subscribe("Confidence");
client.publish("Confidence", confidence);
client.subscribe("FingerprintNr");
client.publish("FingerprintNr", mqttio);
return finger.fingerID;
}
void connectToWiFi(){
WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)
delay(1000);
WiFi.mode(WIFI_STA);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP()); //IP address assigned to your ESP
}
uint8_t getFingerprintEnroll() {
// send command to turn on R503 led
finger.led_control(1,100,3,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
id = min(finger.templateCount + 1, 127);
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;
}
// send command to turn on R503 led
finger.led_control(1,100,3,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
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!
// send command to turn on R503 led
finger.led_control(1,100,3,3); // code(1-6),speed(1-255),color(1-R/2-B/3_P),time(1-255)
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;
}
}
The finger with the ID 1 has Admin privileges. When he is hung up, a new fingerprint is created with the ID = sum of all created IDs + 1. You can also uncomment the area if you don’t need it.
The MQTT2_ESP8266Client is automatically created in FHEM when the Esp reports, especially when he submits the first fingerprint ID. You can now trigger actions per finger via a notify in FHEM!
*Affiliate Link
2 Antworten zu „Fingerprint R503 mittels Esp & MQTT an FHEM”.
no library on github! can you share it?
Thanks, done. It should be sufficient to comment it on one place.