Fingerprint Reader and serial pass through


#41

“Spark” was the name of the company before they switched to “Particle”. You’re most likely referring to the Spark Core, which was the first device they built, followed by the Photon, the next generation.
As mentioned, it should work on either.


#42

am sorry to bother u sir
but plz if u can explian to me how can i address this error,thank u sir

Adafruit_Fingerprint.cpp: At global scope:
Adafruit_Fingerprint.cpp:117:54: error: no 'uint8_t Adafruit_Fingerprint::deleteModel(uint16_t)' member function declared in class 'Adafruit_Fingerprint'
 uint8_t Adafruit_Fingerprint::deleteModel(uint16_t id) {

#43

should i delete it or what should i do to it thanks


#44

@ScruffR, PR merged!


#45

Thanks for that Paul (@peekay123) :+1:
Could you also bump the version number in spark.json and push it to Build, please?

@dannamo, once the fixed version has has come online in Particle Build, you can delete the library from your project an reimport it.
Or you just pull in the Adafruit_Fingerprint.h and Adafruit_Fingerprint.cpp files from the GitHub repo as seperate file tabs.


#46

@ScruffR, @dannamo, the update to the Build IDE library is done :wink:


#48

i used the IDE lib and also i used the gethub still getting the same errors


#49

@dannamo, this is a weird behavior caused by the pre-compiler. Simply delete one of the blanks lines above the #include "Adafruit_Fingerprint/Adafruit_Fingerprint.h" line and try again.


#50

wooow sir thank u very much it works and it compiled thank u very much i appreciate that.
so i just need to download the enroll first and enroll my fingerprint then download the fingerprint code it should works right
?and the wire connections its the same that u provided in the gethub ?

thanks


#51

hello sir just one q
how i can put the fingerprint sensor in sleep mode so its not On all the time ?
thanks


#52

I can’t see such a feature in the lib (the datasheet might provide hints).
But you can always power the sensor via a FET that’s controlled by another GPIO pin.


#53

U mean write IF statement
And power the fingerprint sensor the 5+ through digital pin as an output ?
It won’t burn the pin coz I think each pin hold 40 ml amp current I don’t know if am wrong sir ?
That’s what u mean by saying FET?


#54

A FET is an electronic switch that you can use to enable/disable power to the sensor, which is preferred since the GPIO pins can supply a maximum of 20mA.


#55

I found an English datasheet for the sensor (Adafruit only seems to link the Chinese one)

With a quick look through it I didn’t find any sleep commands.


#56

@ScruffR is correct. This particular device is not designed for low power operation. DO NOT use a GPIO pin to power the sensor. Instead use a FET transistor like the 2N7002 or similar device.


#57

thanks every one for the respond

so I tried to use relay instaed of the FET for powering the fingerprint so am using the NO of relay to power the fingerprint .
but am facing aproblem ,when am writing the IF STATEMENT so when I push button the output for the relay it will energize for 10 seconds to power the fingerprint then shut of so the fingerprint wont be flashing 24/7.
the problem is when I disconnect the fingerprint the IF STATE not working the code flooting ,when I power the fingerprint then the button working ,so as long as the fingerprint not powered on the button wont work its flooding the code .
I tried WHILE still not working I tried to create the simple timer to separate it still not working .
I took the`fingerprintID = getFingerprintID();` from the loop and put it in the IF State
now its not flooding the code but its not staying on I have to hold the button .
I don’t know exctly what am doing wrong .
I would appreciate ur guys help thanks .

thisis the code just to have the idea



#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>


// Color definitions
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0  
#define WHITE   0xFFFF
#include <SimpleTimer.h>

// the timer object
SimpleTimer timer;


#define relay 5
#define __CS 10
#define __DC 9
static const uint8_t icon [] PROGMEM = {
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x3f,0xc0,0x0,0x0,0x0,
0x0,0x0,0x3,0xff,0xf8,0x0,0x0,0x0,
0x0,0x0,0x7,0xff,0xfe,0x0,0x0,0x0,
0x0,0x0,0x1f,0xc0,0x7f,0x80,0x0,0x0,
0x0,0x0,0x3e,0x0,0x7,0xc0,0x0,0x0,
0x0,0x0,0x7c,0x0,0x3,0xe0,0x0,0x0,
0x0,0x0,0xfd,0xff,0x81,0xf0,0x0,0x0,
0x0,0x0,0xff,0xff,0xe0,0xf0,0x0,0x0,
0x0,0x1,0xff,0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x78,0x3,0xc7,0x80,0x0,
0x0,0xf,0x1c,0x3e,0x7,0x87,0x0,0x0,
0x0,0xf,0x1e,0x3f,0xff,0x8f,0x0,0x0,
0x0,0xf,0x1e,0x1f,0xff,0x1f,0x0,0x0,
0x0,0xf,0xf,0x7,0xfc,0x3e,0x0,0x0,
0x0,0x7,0x87,0x80,0x0,0x7c,0x0,0x0,
0x0,0x7,0x87,0xe0,0x0,0xfc,0x0,0x0,
0x0,0x3,0xc3,0xf8,0x7,0xf8,0x0,0x0,
0x0,0x3,0xe1,0xff,0xff,0xe1,0x0,0x0,
0x0,0x1,0xe0,0x7f,0xff,0x83,0x0,0x0,
0x0,0x1,0xf8,0xf,0xfe,0x7,0x0,0x0,
0x0,0x0,0xfc,0x0,0x0,0xe,0x0,0x0,
0x0,0x0,0x3f,0x0,0x0,0x3c,0x0,0x0,
0x0,0x0,0x1f,0xe0,0x1,0xf8,0x0,0x0,
0x0,0x0,0x7,0xff,0xff,0xf0,0x0,0x0,
0x0,0x0,0x1,0xff,0xff,0xc0,0x0,0x0,
0x0,0x0,0x0,0x1f,0xfc,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};


TFT_ILI9163C display = TFT_ILI9163C(__CS,8, __DC);
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

int fingerprintID = 0;

const int buttonPin = 6;     // the number of the pushbutton pin
const int ledPin =  4;      // the number of the LED pin

// variables will change:
int buttonState = 0;   

 void repeatMe() {
    Serial.print("Uptime (s): ");
    
    Serial.println(millis() / 1000);
   
}


void setup(void) {
  Serial.begin(9600);
    timer.setInterval(10, repeatMe);


  startFingerprintSensor();
  display.begin();
  displayLockScreen(); 
  pinMode(relay,OUTPUT);
   pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

 
  
  
}

void loop() {

    // read the state of the pushbutton value:
//  buttonState = digitalRead(buttonPin);
//
//  // check if the pushbutton is pressed.
//  // if it is, the buttonState is HIGH:
//  if (buttonState == HIGH) {
//    // turn LED on:
//    digitalWrite(ledPin, HIGH);
//     //fingerprintID = getFingerprintID();
//     //delay(5000);
//  } else {
//    //delay(5000);
//    // turn LED off:
//    digitalWrite(ledPin, LOW);
//    
//  }

 
  
    timer.run();
 

fingerprintID = getFingerprintID();
  delay(50);
  if(fingerprintID == 1) //Dan
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayDan();
   garageDoorOpen();
   delay(2000);
    display.fillScreen(BLACK);
    displayLockScreen();
    garageDoorClose();
  }

   if(fingerprintID == 2)  //ophie
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayOphie();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
   if(fingerprintID == 3) //bakos
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayBakos();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
   if(fingerprintID == 4)  //Ann
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayAnn();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
   if(fingerprintID == 5) //nabila
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayNabila();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
   if(fingerprintID == 6) //homi
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayHomi();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
   if(fingerprintID == 7) //Allen
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayAllen();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
   if(fingerprintID == 8) //nevin
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayNevin();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
  if(fingerprintID == 9) //nevin
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayAshuram();
    garageDoorOpen();
    delay(2000);
    garageDoorClose();
    display.fillScreen(BLACK);
    displayLockScreen();
  }
}


void displayUnlockedScreen()
{
   display.fillScreen(BLACK);
   display.drawRect(0,0,128,128,WHITE);
   
   display.setCursor(18,10);
   display.setTextColor(GREEN); 
   display.setTextSize(2);
   display.print("UNLOCKED");

   display.setCursor(20,50);
   display.setTextColor(WHITE); 
   display.setTextSize(2);
   display.print("WELCOME");
}
void displayOphie()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Ophie!");
}
void displayBakos()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Bakos!");
}
void displayNabila()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Nabila!");
}

void displayDan()
{
  display.setCursor(25,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Dan!");
}
void displayAnn()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Ann!");
}
void displayAllen()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Allen!");
}
void displayHomi()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Homi!");
}
void displayNevin()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Nevin!");
}
void displayAshuram()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Ashuram!");
}

void displayLockScreen()
{
  display.drawRect(0,0,128,128,BLUE);
  display.setCursor(30,10);
  display.setTextColor(RED); 
  display.setTextSize(2);
  display.print("LOCKED");

  display.setCursor(10,100);
  display.setTextColor(RED); 
  display.setTextSize(1);
  display.print("Waiting for valid \n    fingerprint.");

  display.drawBitmap(30,35,icon,60,60,WHITE);
}
void garageDoorOpen()
{
  digitalWrite(relay,HIGH);
  
}
void garageDoorClose()
{
  digitalWrite(relay,LOW);
}
void startFingerprintSensor()
{
  Serial.begin(9600);
  finger.begin(57600);
  
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor");
  }
  Serial.println("Waiting for valid finger...");
}

int getFingerprintID() {
  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; 
}


#58

When dealing with switches that don’t provide a descrete logical level at any given time you cannot use pinMode(pin, INPUT) since that will leave the pin floating when the switch is not providing the discrete signal.
For such cases you’ll use external pull-resistors or one of INPUT_PULLUP/INPUT_PULLDOWN.

May I also suggest to rework all your copy-pasted code blocks into some reusable functions or blocks and use arrays.

Like instead of loads of these

void displayOphie()
{
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  display.print("Ophie!");
}

just have one

void displayName(const char* name)
{
  char msg[24];
  display.setCursor(35,75);
  display.setTextColor(WHITE); 
  display.setTextSize(2);
  snprintf(msg, sizeof(msg), "%s!", name);
  display.print(msg);
}

And instead of a row of

  if(fingerprintID == 1) //Dan
  {
    display.drawBitmap(30,35,icon,60,60,GREEN);
    delay(2000);
    displayUnlockedScreen();
    displayDan();
   garageDoorOpen();
   delay(2000);
    display.fillScreen(BLACK);
    displayLockScreen();
    garageDoorClose();
  }

have

const char users[][16] = {
  "ID0"
, "Dan"
, "Ophie"
, "Bakos"
...
, "WhoEver"
};
...
void loop() {
  ...
  display.drawBitmap(30,35,icon,60,60,GREEN);
  delay(2000);
  displayUnlockedScreen();
  displayName(users[gingerprintID]);
  garageDoorOpen();
  delay(2000);
  display.fillScreen(BLACK);
  displayLockScreen();
  garageDoorClose();
  ...
}

#59

hello sir
thanks for ur answer am pro in coding but am learning and also ill start using the array to simple the code thank u very much .
and for the INPUT am using external resistor 10K to ground
so the 5 V TO the button then from the button one wire to the PIN and one wire to the resistor then to ground.


#60

the button working very fine whenthe finger sensor powered on .
but once I wire up the positive of the finger sensor thro relay to power on by pushing the button its floating


#61

Here is the video to be clear thanks