Tuesday, May 29, 2018

Arduino 220v switch using fingerprint scanner FPM10A

This arduino project used fingerprint scanner module FPM10A for turns ON/OFF some AC or DC loads by fingerprint.
In this project we should using two different codes, the first code is for saving your fingerprint on the memory of the module, and the second code used for scanning the fingerprint of people in each time to compare that with saved fingerprint on the memory.

Parts list:
Arduino board (UNO or Nano)
LCD display 16X2
Fingerprint scanner FPM10A  
One channel relay module
Breadboard
Connecting wires
Potentiometer 1K
Resistor 220 ohm


Please subscribe to my YouTube channel here: 
https://www.youtube.com/c/EngMousaalkaabi?sub_confirmation=1


Follow this steps:
1-Install the library from here
2-Connect the module and the relay as shown in this picture

Arduino fingerprint FPM10A
3-Go to Example and upload the enroll code to arduino

Arduino 220v switch using fingerprint scanner FPM10A

4-Open the serial monitor and insert a number between 1 to 127 then put your finger and scan it several time to saved that on the module, i saved my thumb and index finger and saved them as number 10 and number 20 because i want to turn ON the load by thumb and turn OFF that by index finger

Arduino fingerprint FPM10A

5-The code below is the second code that you should used, but insert the number that you choose in prior step and put that in place of 10 and 20, then upload the code to the arduino board :

Arduino fingerprint FPM10A


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

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
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);

void setup() 
{
  Serial.begin(9600);
  Serial.println("fingertest");
  pinMode(5,OUTPUT);
  lcd.begin(16, 2); // lcd rows and columns

  // 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 :(");
    lcd.setCursor(0,0);
    lcd.print("NO Sensor find ");

    while (1);
  }
  Serial.println("Waiting for valid finger...");
  lcd.setCursor(0,0);
  lcd.print("Put your 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!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  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;
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  if (finger.fingerID == 10){
      digitalWrite(5,HIGH);
      lcd.setCursor(0,0);
      lcd.print("Load ON        ");
       lcd.setCursor(0,1);
       lcd.print("Put your finger");
       return finger.fingerID;

  }
 
  else if (finger.fingerID == 20){
     
       digitalWrite(5,LOW);
       lcd.setCursor(0,0);
       lcd.print("Load OFF        ");
       lcd.setCursor(0,1);
       lcd.print("Put your finger");
       return finger.fingerID;
  }
}

NOTE:
If arduino didn't find the fingerprint scanner, first make sure your wiring is correct,
if the problem still don't solved, press on the restart button on the arduino board several time and the problem will solved, as you can see in following picture my problem solved after pressing the restart button two times.

Did not find fingerprint scanner :(