Biometric Fingerprint device LAN Based

Description: This project is a Biometric, fingerprint device with and ethernet shield. It helps to enroll a user and send data to server when ever a finger is registered. (This is a prototype).

Materials Required:

Circuit Diagram


Code


#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Ethernet.h>
//Connection via LAN
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "192.168.10.1";
IPAddress ip(192, 168, 10, 10);// give your Ip in the same Class
EthernetClient client;
String data;
int getFingerprintIDez();
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial1);
void setup()
{
while (!Serial); // For Yun/Leo/Micro/Zero/...
data = "";
Serial.begin(9600);
// start the Ethernet connection:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting to server ....");
Serial.println("Adafruit finger detect test");
// 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);
}
Serial.println("Waiting for valid finger...");
}
void loop() // run over and over again
{
getFingerprintIDez();
delay(50); //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!
data = "userId=" + (String)finger.fingerID;
Serial.print(data);
Serial.print("Found ID #"); Serial.print(finger.fingerID);
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("POST /Arduino/index.php HTTP/1.1");
client.println("Host: 192.168.10.1");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
// client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
Serial.print(" with confidence of "); Serial.println(finger.confidence);
}
// 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;
data = "userId=" + (String)finger.fingerID;
// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(data);
client.stop();
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("POST /Arduino/index.php HTTP/1.1");
client.println("Host: PHP Server IP Address");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
//client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
Serial.print(" with confidence of "); Serial.println(finger.confidence);
return finger.fingerID;
}

Extra Libraries


Adfruit_fingerprint.h  Adafruit-Fingerprint.zip(How to insert Library on Arduino)

4 thoughts on “Biometric Fingerprint device LAN Based

  1. Hi Girish,
    Nice work!
    I am going to make one for myself, but could not understand the software part which is needed on PC side.
    Could you please help with more details please.

    Thanks.

  2. Good job! You thoroughly included all important points with your post. I would like to read more from you. Do you write for any more blogs?

Leave a Reply

Your email address will not be published. Required fields are marked *

RSS
Follow by Email
Facebook
Twitter