#include <ESP8266WiFi.h>
#include <Adafruit_Fingerprint.h>
#include <HardwareSerial.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 = "finger"; // this is the name of the file of the database
String Key = "6yg6iEi1eDqCsPGHBRx0N2OnDLT4HPDVygsJ7lsxFU"; // 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 = "Home Solate"; //wifi name
char* pass = "bread2009a"; // wifi password
#define mySerial Serial1
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); // communcation with the IoT and fingerprint sensor
void setup()
{
Serial.begin(74880);
mySerial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("Adafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
delay(5);
// the fingerpprint sensor will first starts
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :("); finger.getTemplateCount();
Serial.print("Sensor contains ");
Serial.print(finger.templateCount);
Serial.println(" templates");
Serial.println("Waiting for valid finger...");
while (1) {
delay(1);
}
}
// 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();
}
Are you going to tell us what the problem is ?
The problem is that when ever I connect the r301t correctly to the esp8266 it does not respond in serial monitor, while if I connect the TX and RX pins wrongly it responds that "Did not find fingerprint sensor"
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
}
The logic and/or messages here look wrong. From the name of the function, verifyPassword() should try to verify a fingerprint, the outcome of which will be either that it is verified or not but instead it reports whether a fingerprint sensor was found or not
The else clause is even odder because it reports that it did not find a sensor, says that it is waiting for a valid finger then goes into an endless loop from which it cannot escape
Please how do i do this
Are there any examples with the library ?
i dont know i got this from a youtube video
Do you have the Adafruit_Fingerprint library installed ?
yes
Then there are examples of its use in the IDE
Look in File->Examples
ok i should try right
The solution to my problem was that I had to use another pin instead of the rx and tx pins this is the edited code :
#include <Adafruit_Fingerprint.h>
#include <HardwareSerial.h>
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 = "fingerprints"; // this is the name of the file of the database
String Key = "6yg6iEi1eDqCsPGHBRx0N2OnDLT4HPDVygsJ7lsxFU"; // 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 = "Home Solate"; //wifi name
char* pass = "bread2009a"; // wifi password
SoftwareSerial mySerial(14, 12); //14 for D5
//12 for D6
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial); // communcation with the IoT and fingerprint sensor
void setup()
{
Serial.begin(74880);
mySerial.begin(9600);
while (!Serial); // For Yun/Leo/Micro/Zero/...
delay(100);
Serial.println("Adafruit finger detect test");
// set the data rate for the sensor serial port
finger.begin(57600);
delay(5);
// the fingerpprint sensor will first starts
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :("); finger.getTemplateCount();
Serial.print("Sensor contains ");
Serial.print(finger.templateCount);
Serial.println(" templates");
Serial.println("Waiting for valid finger...");
while (1) {
delay(1);
}
}
// 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();
}```
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.