Fingerprint Reader and serial pass through


#62

Can you provide a (complete) schematic of your setup (working vs. not working)
That video doesn’t show that really.
Also what relay are you using and how are you powering it?


#63

Here is the circuit very easy and am just using the relay to power up the finger sensor instead of MOSFET
But when I hock it up like that the code is floating
I tried to take the
FingerprintID=getFingerPrintID();
From the loop the button when I push it it’s not floating but the sensor won’t stay on
Yes put delay(5000); so wen I push it it should stay on 5 seconds then turn off and it’s doing the job the relay staying 5 seconds but the sensor won’t stay on flashing unless if I hold the button then
This is the diagram


#64

Thank u sir to take time and respond me I know u busy
But I just wanted to share with u guys
Thanks again.


#65

I don’t quite understand what you mean with “code is floating”.
Floating pins are a common expression, but what is floating code? :confused:

When I asked how you are powering the relay, I meant_ "Where is the power for the relay coil comming from?"
And when I asked for

I wanted to get some info about the electric characteristics of that particlular relay, like coil voltage, digital signal level, current draw of the coil when active, has it got a flyback diode, …
things that would be found in the datasheets of the relay board.

It might well be, that the fingerprint reader plus the power draw of the relay may be too much for the device when the whole setup is only powered via USB and the controller board.

And to test the relay/sensor power issue, just have some code that doesn’t do anything else but that and post this without any other clutter to focus on that one task only.


#66

sorry about the code floating
i meant the way u said it (pin floating ) which the code frees the micro controller freez and wont function.

the relay works fine and i used external voltage for it so from the amps side its good both fingerprint and relay .
also i did basic skatch as u said to test it and it work very perfect .

but the problem is this sir
so the original code and wiring works very perfect the fingerprint sensor flashing all time waiting for the ID print .
every thing workds perfectly .

i wanted to change one thing that instead of the fingerprint being flashing 24/7 i wanted to Add button so when i push the button the fingerprint sensor flash to scan the finger for 10 seconds then turn off or sleep or disable until i push the button again like that .

so i tried to change in the code it wasnt successful then another thing came to my mind to do is .
add one relay and instead power the fingerprint directly to the board ill wire it to the NO of th relay so when i push the button the relay will stay on for 10s and power the fingerprint then turn back off ,but the plan wasnt successful again coz when i diconnect the power to the sensor the code frees (micor controller frees) wont functions .
when i power it back directly to the board or supply the code wont frees it function good .

am sorry again sir i might bothered u but if i cant do nothing about it its alright
i really appreciate ur time reading and responding me thanks again .

this is the code



#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.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>




#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,0xff,0xf8,0x78,0x0,0x0,
0x0,0x1,0xff,0x80,0x7c,0x38,0x0,0x0,
0x0,0x3,0xfc,0x0,0xe,0x3c,0x0,0x0,
0x0,0x3,0xf0,0x0,0x7,0x1c,0x0,0x0,
0x0,0x7,0xc0,0x7f,0x83,0x8e,0x0,0x0,
0x0,0x7,0x83,0xff,0xe0,0xe,0x0,0x0,
0x0,0x7,0xf,0xff,0xf8,0xf,0x0,0x0,
0x0,0x6,0x1f,0x80,0xfc,0x7,0x0,0x0,
0x0,0x4,0x7e,0x0,0x3f,0x7,0x0,0x0,
0x0,0x0,0xf8,0x0,0xf,0x7,0x0,0x0,
0x0,0x0,0xf0,0x3e,0x7,0x87,0x0,0x0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0,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;   


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

void setup(void) {
  Serial.begin(9600);
   
timer.setInterval(10L, repeatMe);
  startFingerprintSensor();
  
  display.begin();
  displayLockScreen(); 
  pinMode(relay,OUTPUT);
   pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

 
  
  
}


void loop() {
  timer.run();

    // 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);
    
  }
 
//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; 
}


#67

and am using external power supply so wont draw to much amp from the micro controller


#68

The schematic you posted above doesn’t show that you are using an external power supply, it shows you are getting the power from the micro controller. So which is the actual situation, what you say above or the schematic? Also, you need to provide a link to the relay that you are using, so we can look at its electrical characteristics.


#69

yes in the schematic its just showing the basic what am trying to do.
but i did test with external power supply and i did test as in the schematic also .the relay works fine
this is the info


thanks


#70

Without going through your code (since it still makes my eyes bleed with all that copy-paste stuff cluttering it - and I can’t see any improvement or new relay logic compared to the original one despite all the given hints), from that description I’d deduce that some function you call that require the fingerprint reader to be powered otherwise it blocks.
The way around that is to only call these functions when the fingerprint reader is powered. And since you are in control of that via your relay logic (which I can’t really see), you can just use that knowledge in an if() statement that bypasses the whole fingerprint stuff, while the relay is off.

Also in order to have your code run during that 10sec periode, you need to keep that part non-blocking (no use of delay()).


#71

Hello,
Can anyone help me with interfacing the fingerprint module as i am getting communication error again and again.
:confounded::confounded:


#72

That’s not a lot of information to work with, is it?


#74

how to show fingerprint data from r305 fingerprint module and to generate fingerprint id?


#75

Welcome to the community - You at least need to supply either some code you already have or perhaps some kind of error in a section of your code for someone to offer an opinion or some guidance?


#76

@CriticalStrike1k, are you asking for a Particle device or for an Arduino device?