0% found this document useful (0 votes)
23 views9 pages

2023 - Fall - Progress Test 2 - 01 - SE17xx - Gy

This document describes an IoT fingerprint authentication system using an Arduino board. It includes a circuit diagram connecting an Arduino, fingerprint sensor, LCD display and keypad. The code uses the fingerprint sensor and LCD display to enroll, verify and delete fingerprints from the sensor database. Users can select enrollment, verification or deletion modes using the keypad to navigate an on-screen menu.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views9 pages

2023 - Fall - Progress Test 2 - 01 - SE17xx - Gy

This document describes an IoT fingerprint authentication system using an Arduino board. It includes a circuit diagram connecting an Arduino, fingerprint sensor, LCD display and keypad. The code uses the fingerprint sensor and LCD display to enroll, verify and delete fingerprints from the sensor database. Users can select enrollment, verification or deletion modes using the keypad to navigate an on-screen menu.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Title

Short description about your designed IoT system.

Hardware Required
 Arduino or Genuino Board
 ESP8266

Theory
(Theory required for this Lab)

Circuit
(Block diagram and Circuit diagram shows the wire connection).

Installations
(Libraries, software or app installation)

1
Settings
(Config Firebase or Blynk,…)

Code
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <SoftwareSerial.h>
#include <Adafruit_Fingerprint.h>

SoftwareSerial mySerial(2, 3);


Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

// LCD Connections
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
const byte rows = 4;
const byte cols = 4;

//keypad
int pos = 0;

char key[rows][cols] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[rows] = {10, 12, 13, 4};
byte colPins[cols] = {5, 6, 7, 11};
Keypad customKeypad = Keypad(makeKeymap(key), rowPins, colPins, rows, cols);
//init ID
int id = 1;

void setup() {
Serial.begin(9600);

finger.begin(57600);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1) {
delay(1);
}

2
}

lcd.begin(16, 2);

//check ID has fingerPrint or not


while (finger.loadModel(id) == 0) {
id++;
}

delay(1000);
}
char IdString[100];
void loop() {
char customKey;
customKey = customKeypad.getKey();
lcd.clear();
lcd.print("A:Enroll");
lcd.setCursor(0, 1);
lcd.print("B:Verify");
lcd.setCursor(9, 0);
lcd.print("C:Empty");

while (customKey == '\0') {


customKey = customKeypad.getKey();
}

Serial.println("custom key");
Serial.print(customKey);

lcd.clear();
if (customKey == 'A') {
lcd.print("Enroll mode");
delay(2000);
lcd.clear();
lcd.print("Enrolling ID #");
lcd.setCursor(0, 1);
printInteger(id);
delay(2000);
while (!getFingerprintEnroll());

} else if (customKey == 'B') {


lcd.print("Verify mode");
delay(2000);
while (!verifyFingerPrint());
}
else if (customKey == 'C') {
emptyFingerDB();
}
}

uint8_t getFingerprintEnroll() {
int p = -1;
Serial.print("Waiting for valid finger to enroll as #");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:

3
Serial.println("Image taken");
lcd.clear();
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
lcd.clear();
lcd.print("Detecting");
lcd.setCursor(0, 1);
lcd.print("finger ID ");
for (int i = 0; i < 3; i++) {
if (IdString[i] >= '0' && IdString[i] <= '9')
lcd.print(IdString[i]);
else break;
}
lcd.print("...");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
delay(2000);

// OK success!

p = finger.image2Tz(1);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
lcd.clear();
lcd.print("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;
}
delay(2000);
p = finger.fingerSearch();
if (p == FINGERPRINT_OK) {

4
Serial.println("Found a print match");
lcd.clear();
lcd.print("Found a print");
lcd.setCursor(0, 1);
lcd.print("Match ID ");
printInteger(finger.fingerID);
delay(2000);
lcd.clear();
lcd.print("Enroll again");
delay(2000);
return false;
}

p = 0;
while (p != FINGERPRINT_NOFINGER) {
p = finger.getImage();
}

p = -1;
lcd.clear();
lcd.print("Place again");
delay(2000);
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
lcd.clear();
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
lcd.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
delay(2000);

p = finger.image2Tz(2);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
lcd.clear();
lcd.print("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;

5
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;
}
delay(2000);

// OK converted!
Serial.print("Creating model for #"); Serial.println(id);

p = finger.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("Prints matched!");
lcd.clear();
lcd.print("Prints matched!");
delay(1000);
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("Fingerprints did not match");
lcd.clear();
lcd.print("Not match");
delay(1000);
return false;
} else {
Serial.println("Unknown error");
return p;
}

p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Stored!");
id++;
lcd.clear();
lcd.print("Success");
lcd.setCursor(0, 1);
lcd.print("Enrolling");
delay(2000);
lcd.clear();
} 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;

6
} else {
Serial.println("Unknown error");
return p;
}

return true;
}

uint8_t verifyFingerPrint() {
int p = -1;
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
lcd.clear();
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
lcd.clear();
lcd.print("Detecting");
lcd.setCursor(0, 1);
lcd.print("finger");
lcd.print("...");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
break;
}
}
p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
lcd.clear();
lcd.print("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");

7
return p;
}
delay(2000);
p = finger.fingerSearch();
if (p == FINGERPRINT_OK) {
Serial.println("Found a print match!");
lcd.clear();
lcd.print("Found a print");
lcd.setCursor(0, 1);
lcd.print("Match ID ");
printInteger(finger.fingerID);
delay(2000);
lcd.clear();
lcd.print("Success");
lcd.setCursor(0, 1);
lcd.print("Verify");
delay(2000);
lcd.clear();
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_NOTFOUND) {
Serial.println("Did not find a match");
lcd.clear();
lcd.print("Not exist");
delay(2000);
lcd.clear();
lcd.print("Back to menu...");
delay(2000);
return true;
} else {
Serial.println("Unknown error");
return p;
}
return true;
}

void emptyFingerDB() {
id = 1;
finger.emptyDatabase();
lcd.clear();
lcd.print("Empty DB success");
delay(2000);
}

void printInteger(int number) {


char string[100];
sprintf(string, "%d", number);
for (int i = 0; i < 3; i++) {
if (string[i] >= '0' && string[i] <= '9')
lcd.print(string[i]);
else break;
}
}

8
Demonstrations
(Demonstrations with photos of experiments)

References

You might also like