Problem with fingerprint sensor and blynk

Hello everyone, I have the following problem:

I’m doing a degree project that consists of home automation with arduino and I decided to use blynk because it facilitated communication, so I use a mega arduino with a w5100 shield for control, I also have a 16-channel relay module, two voltage regulators 4 channels each, current sensors, rotary encoders, and a fingerprint sensor for opening the main door.

The problem I have at this moment is that the fingerprint sensor does not read my fingerprint with Blynk’s programming, but I do it without Blynk and it works well for me, and I wanted to know what I’m doing wrong, annex images and programming, I hope that can you help me, thank you very much

This is the system that I have done, it is not 100% finished but I have a lot of progress

I can control some lights and fans with this and virtually (sliders)

I have located the fingerprint sensor as well, and I have virtually tested the opening of the door and it works for me.

This is the application on the cell phone (It’s in Spanish because I’m from Colombia xd)

    #include <Adafruit_Fingerprint.h>
    #define BLYNK_PRINT Serial
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    #include  <TimerOne.h>          // Avaiable from http://www.arduino.cc/playground/Code/Timer1
    #include <SoftwareSerial.h>
    #include <WidgetRTC.h>
    #include <TimeLib.h>
    SoftwareSerial mySerial(10, 11);
    Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
    int fingerprintID = 0;
    BlynkTimer timer;
    WidgetRTC rtc;
    int manual=0;
    int x = 0;
    char Date[16];
    char Time[16];
    long startsecondswd;            // weekday start time in seconds
    long stopsecondswd;             // weekday stop  time in seconds
    long nowseconds;                // time now in seconds

    int val = 0; //val se emplea para almacenar el estado del boton
    int state = 0; // 0 LED apagado, mientras que 1 encendido
    int old_val = 0; // almacena el antiguo valor de val
    int val2 = 0;
    int state2 = 0;
    int old_val2 = 0;
    int val3 = 0;
    int state3 = 0;
    int old_val3 = 0;
    int val4 = 0;
    int state4 = 0;
    int old_val4 = 0;
    int val5 = 0;
    int state5 = 0;
    int old_val5 = 0;
    int val6 = 0;
    int state6 = 0;
    int old_val6 = 0;
    int val7 = 0;
    int state7 = 0;
    int old_val7 = 0;
    volatile int i=0;               // Variable to use as a counter volatile as it is in an interrupt
    volatile int j=0;
    volatile int k=0;
    volatile int l=0;
    volatile int m=0;
    volatile int n=0;
    volatile boolean zero_cross=0;  // Boolean to store a "switch" to tell us if we have crossed zero
    volatile boolean zero_cross2=0;
    volatile boolean zero_cross3=0;
    volatile boolean zero_cross4=0;
    volatile boolean zero_cross5=0;
    volatile boolean zero_cross6=0;
    int AC_pin = 3;                // Output to Opto Triac
    int AC_pin2 = 4;
    int AC_pin3 = 5;
    int AC_pin4 = 6;
    int AC_pin5 = 7;
    int AC_pin6 = 8;
    int puerta = 14;
    int BAfuera = 15;
    int pulPuerta = 9;
    int rl1 = 34;
    int rl2 = 35;
    int rl3 = 36;
    int rl4 = 37;
    int rl5 = 38;
    int rl6 = 39;
    int rl7 = 40;
    int brightness = 0;
    int brightness2 = 0;
    int brightness3 = 0;
    int brightness4 = 0;
    int brightness5 = 0;
    int brightness6 = 0;
    int reading1;           
    int previous1 = LOW;    
    int freqStep = 65;    // This is the delay-per-brightness step in microseconds.
    long time = 0;         // the last time the output pin was toggled
    long time2 = 0;
    long time3 = 0;
    long time4 = 0;
    long time5 = 0;
    long time6 = 0;
    long debounce1 = 200;
    int reading2;           
    int previous2 = LOW; 
    long debounce2 = 200;
    int reading3;           
    int previous3 = LOW; 
    long debounce3 = 200;
    int reading4;           
    int previous4 = LOW; 
    long debounce4 = 200;
    int reading5;           
    int previous5 = LOW; 
    long debounce5 = 200;
    int reading6;           
    int previous6 = LOW; 
    long debounce6 = 200;
      int pinA1 = 16;  // Pin digital para el pin CLK del codificador rotatorio
      int pinB1 = 17;  // Pin digital para el pin DT del codificador rotatorio
      int inPin1 = 18; // Pin para el pulsador del encoder
      int pinA2 = 19;
      int pinB2 = 20;
      int inPin2 = 21;
      int pinA3 = 22;
      int pinB3 = 23;
      int inPin3 = 24;
      int pinA4 = 25;
      int pinB4 = 26;
      int inPin4 = 27;
      int pinA5 = 28;
      int pinB5 = 29;
      int inPin5 = 30;
      int pinA6 = 31;
      int pinB6 = 32;
      int inPin6 = 33;
      // Variables para el funcionamiento del programa
      int valorInicial1 = 0;  
      int valorActual1 = 0;
      boolean horario1;
      int valorInicial2 = 0;  
      int valorActual2 = 0;
      boolean horario2;
      int valorInicial3 = 0;  
      int valorActual3 = 0;
      boolean horario3;
      int valorInicial4 = 0;  
      int valorActual4 = 0;
      boolean horario4;
      int valorInicial5 = 0;  
      int valorActual5 = 0;
      boolean horario5;
      int valorInicial6 = 0;  
      int valorActual6 = 0;
      boolean horario6;

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "811ff566ff004ada8fbea476f50c0d31";

    #define W5100_CS  10
    #define SDCARD_CS 4


    void setup()
    {
        startFingerprintSensor();
        //Serial.begin(9600);
        rtc.begin();
        Blynk.virtualWrite(V1, 0);
    //    while (!Serial);
    //    delay(100);
    //    finger.begin(57600);
        pinMode(pinA1, INPUT);
        pinMode(pinB1, INPUT);
        pinMode(inPin1, INPUT_PULLUP);
        pinMode(pinA2, INPUT);
        pinMode(pinB2, INPUT);
        pinMode(inPin2, INPUT_PULLUP);
        pinMode(pinA3, INPUT);
        pinMode(pinB3, INPUT);
        pinMode(inPin3, INPUT_PULLUP);
        pinMode(pinA4, INPUT);
        pinMode(pinB4, INPUT);
        pinMode(inPin4, INPUT_PULLUP);
        pinMode(pinA5, INPUT);
        pinMode(pinB5, INPUT);
        pinMode(inPin5, INPUT_PULLUP);
        pinMode(pinA6, INPUT);
        pinMode(pinB6, INPUT);
        pinMode(inPin6, INPUT_PULLUP);
        pinMode(pulPuerta, INPUT);
        valorInicial1 = digitalRead(pinA1);
        valorInicial2 = digitalRead(pinA2);
        valorInicial3 = digitalRead(pinA3);
        valorInicial4 = digitalRead(pinA4);
        valorInicial5 = digitalRead(pinA5);
        valorInicial6 = digitalRead(pinA6);
        pinMode(puerta, OUTPUT);
        pinMode(BAfuera, OUTPUT);
        pinMode(rl1, OUTPUT);
        pinMode(rl2, OUTPUT);
        pinMode(rl3, OUTPUT);
        pinMode(rl4, OUTPUT);
        pinMode(rl5, OUTPUT);
        pinMode(rl6, OUTPUT);
        pinMode(rl7, OUTPUT);
        pinMode(AC_pin, OUTPUT);
        pinMode(AC_pin2, OUTPUT);
        pinMode(AC_pin3, OUTPUT);
        pinMode(AC_pin4, OUTPUT);
        pinMode(AC_pin5, OUTPUT);
        pinMode(AC_pin6, OUTPUT);
        pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
      Blynk.begin(auth, IPAddress(192,168,1,24), 8080);
      attachInterrupt(0, zero_cross_detect, RISING);    // Attach an Interupt to Pin 2 (interupt 0) 
      Timer1.initialize(freqStep);                      // Initialize TimerOne library 
      Timer1.attachInterrupt(dim_check, freqStep);
      timer.setInterval(10000L, syncRelay);
    }

      BLYNK_WRITE(V10)//      slider brillo1 (Luz Sala)
    {
     int brillo = param.asInt(); 
    brightness=brillo;
    }

      BLYNK_WRITE(V11)//      slider brillo2 (Ven. Sala)
    {
     int brillo2 = param.asInt(); 
    brightness2=brillo2;
    }

      BLYNK_WRITE(V12)//      slider brillo3 (Luz Cuarto2)
    {
     int brillo3 = param.asInt(); 
    brightness3=brillo3;
    }

      BLYNK_WRITE(V13)//      slider brillo4 (Ven. Cuarto2)
    {
     int brillo4 = param.asInt(); 
    brightness4=brillo4;
    }

      BLYNK_WRITE(V14)//      slider brillo5 (Luz Cuarto3)
    {
     int brillo5 = param.asInt(); 
    brightness5=brillo5;
    }

      BLYNK_WRITE(V15)//      slider brillo6 (Ven. Cuarto3)
    {
     int brillo6 = param.asInt(); 
    brightness6=brillo6;
    }

      BLYNK_WRITE(V16)//     Boton virtual para puerta 
    {
      int Valorpin = param.asInt();
      if (Valorpin == HIGH)
      {
        digitalWrite(puerta, HIGH);
      }
      else
      {
        digitalWrite(puerta,LOW);
      }
    }

    BLYNK_WRITE(V17)
    {
      int Valorpin = param.asInt();
    if ((Valorpin == 1) && (old_val == 0)){
    state=1-state;
    delay(10);
    }
    old_val = val; // valor del antiguo estado
    if (state==1){
    digitalWrite(rl1, HIGH);
    Blynk.virtualWrite(V24, 255);}
    else{
    digitalWrite(rl1,LOW);
    Blynk.virtualWrite(V24, 0);
    }
    }

    BLYNK_WRITE(V18)
    {
      int Valorpin2 = param.asInt();
    if ((Valorpin2 == 1) && (old_val2 == 0)){
    state2=1-state2;
    delay(10);
    }
    old_val2 = val2; // valor del antiguo estado
    if (state2==1){
    digitalWrite(rl2, HIGH);
    Blynk.virtualWrite(V25, 255);}
    else{
    digitalWrite(rl2,LOW);
    Blynk.virtualWrite(V25, 0);
    }
    }

    BLYNK_WRITE(V19)
    {
      int Valorpin3 = param.asInt();
    if ((Valorpin3 == 1) && (old_val3 == 0)){
    state3=1-state3;
    delay(10);
    }
    old_val3 = val3; // valor del antiguo estado
    if (state3==1){
    digitalWrite(rl3, HIGH);
    Blynk.virtualWrite(V26, 255);}
    else{
    digitalWrite(rl3,LOW);
    Blynk.virtualWrite(V26, 0);
    }
    }
    BLYNK_WRITE(V20)
    {
      int Valorpin4 = param.asInt();
    if ((Valorpin4 == 1) && (old_val4 == 0)){
    state4=1-state4;
    delay(10);
    }
    old_val4 = val4; // valor del antiguo estado
    if (state4==1){
    digitalWrite(rl4, HIGH);
    Blynk.virtualWrite(V27, 255);}
    else{
    digitalWrite(rl4,LOW);
    Blynk.virtualWrite(V27, 0);
    }
    }
    BLYNK_WRITE(V21)
    {
      int Valorpin5 = param.asInt();
    if ((Valorpin5 == 1) && (old_val5 == 0)){
    state5=1-state5;
    delay(10);
    }
    old_val5 = val5; // valor del antiguo estado
    if (state5==1){
    digitalWrite(rl5, HIGH);
    Blynk.virtualWrite(V28, 255);}
    else{
    digitalWrite(rl5,LOW);
    Blynk.virtualWrite(V28, 0);
    }
    }
    BLYNK_WRITE(V22)
    {
      int Valorpin6 = param.asInt();
    if ((Valorpin6 == 1) && (old_val6 == 0)){
    state6=1-state6;
    delay(10);
    }
    old_val6 = val6; // valor del antiguo estado
    if (state6==1){
    digitalWrite(rl6, HIGH);
    Blynk.virtualWrite(V29, 255);}
    else{
    digitalWrite(rl6,LOW);
    Blynk.virtualWrite(V29, 0);
    }
    }
    BLYNK_WRITE(V23)
    {
      int Valorpin7 = param.asInt();
    if ((Valorpin7 == 1) && (old_val7 == 0)){
    state7=1-state7;
    delay(10);
    }
    old_val7 = val7; // valor del antiguo estado
    if (state7==1){
    digitalWrite(rl7, HIGH);
    Blynk.virtualWrite(V30, 255);}
    else{
    digitalWrite(rl7,LOW);
    Blynk.virtualWrite(V30, 0);
    }
    }


    BLYNK_WRITE(V1)//Slider Automático - Manual (Afuera)
    {
      if (param.asInt()==1) 
      {
        manual=1;
      } 
      else 
      {
        manual=0;
      }
    }

    BLYNK_WRITE(V2)// Tiempo para encender (Afuera) 
    {  
        if (manual==1)
          { 
          
          sprintf(Date, "%02d/%02d/%04d",  day(), month(), year());
          sprintf(Time, "%02d:%02d:%02d", hour(), minute(), second());
        
          TimeInputParam t(param);
          //Serial.println(Time);
          //Serial.println(Date);
        
          int dayadjustment = -1;  
          if(weekday() == 1){
            dayadjustment =  6; // needed for Sunday, Time library is day 1 and Blynk is day 7
          }
          if(t.isWeekdaySelected (weekday() + dayadjustment)){ //Time library starts week on Sunday, Blynk on Monday
                
          nowseconds = ((hour() * 60) + (minute()));
          startsecondswd = ((t.getStartHour() * 60) + (t.getStartMinute()));
          //Serial.println(nowseconds);
          //Serial.println(startsecondswd);  // used for debugging
          if(nowseconds >= startsecondswd){    
            
            if(nowseconds <= startsecondswd){    // 90s on 60s timer ensures 1 trigger command is sent
              Blynk.virtualWrite(V3, 1);
              // code here to switch the relay ON
            }      
          }
          else
          {
          }
          stopsecondswd = (t.getStopHour() * 60) + (t.getStopMinute());
          //Serial.println(stopsecondswd);  // used for debugging
          if(nowseconds >= stopsecondswd){
            Blynk.virtualWrite(V3, 0);
            
            if(nowseconds <= stopsecondswd){   // 90s on 60s timer ensures 1 trigger command is sent
              
             Blynk.virtualWrite(V3, 0);
              // code here to switch the relay OFF
            }              
          }
          else{
            if(nowseconds >= startsecondswd){  
              Blynk.virtualWrite(V3, 1);
              
             
            }          
          }
          }
          else
          {
           // nothing to do today, check again in 30 SECONDS time    
          }
          }
    }

    BLYNK_WRITE(V3)// Boton
     {
     x = param.asInt();
     }
    void syncRelay()
    {
      Blynk.syncAll();
    }

    void zero_cross_detect() {    
      zero_cross = true;
      zero_cross2 = true;
      zero_cross3 = true;
      zero_cross4 = true;
      zero_cross5 = true;
      zero_cross6 = true;               
      i=0;
      j=0;
      k=0;
      l=0;
      m=0;
      n=0;
      digitalWrite(AC_pin, LOW);       // turn off TRIAC (and AC)
      digitalWrite(AC_pin2, LOW);
      digitalWrite(AC_pin3, LOW);
      digitalWrite(AC_pin4, LOW);
      digitalWrite(AC_pin5, LOW);
      digitalWrite(AC_pin6, LOW);
    }
    // Turn on the TRIAC at the appropriate time
    void dim_check() {
      
      if(zero_cross == true) { 
                  
        if(i>=brightness) {                     
          digitalWrite(AC_pin, HIGH); // turn on light       
          i=0;  // reset time step counter                         
          zero_cross = false; //reset zero cross detection
        } 
        else {
          i++; // increment time step counter                     
        }

      }
      if(zero_cross2 == true) {
        
        if(j>=brightness2) {                     
          digitalWrite(AC_pin2, HIGH); // turn on light       
          j=0;  // reset time step counter                         
          zero_cross2 = false; //reset zero cross detection
        } 
        else {
          j++; // increment time step counter                     
        }
      }

        if(zero_cross3 == true) {
        
        if(k>=brightness3) {                     
          digitalWrite(AC_pin3, HIGH); // turn on light       
          k=0;  // reset time step counter                         
          zero_cross3 = false; //reset zero cross detection
        } 
        else {
          k++; // increment time step counter                     
        }
      }

        if(zero_cross4 == true) {
        
        if(l>=brightness4) {                     
          digitalWrite(AC_pin4, HIGH); // turn on light       
          l=0;  // reset time step counter                         
          zero_cross4 = false; //reset zero cross detection
        } 
        else {
          l++; // increment time step counter                     
        }
      }

        if(zero_cross5 == true) {
        
        if(m>=brightness5) {                     
          digitalWrite(AC_pin5, HIGH); // turn on light       
          m=0;  // reset time step counter                         
          zero_cross5 = false; //reset zero cross detection
        } 
        else {
          m++; // increment time step counter                     
        }
      }

        if(zero_cross6 == true) {
        
        if(n>=brightness6) {                     
          digitalWrite(AC_pin6, HIGH); // turn on light       
          n=0;  // reset time step counter                         
          zero_cross6 = false; //reset zero cross detection
        } 
        else {
          n++; // increment time step counter                     
        }
      }
    }

     void Afuera(){
        if (x == 1)
     {
      digitalWrite(BAfuera, HIGH);
      //Blynk.notify("Se encendió la iluminación exterior");
      //delay(1000);
     }
     else if (x == 0)
     {
      digitalWrite(BAfuera, LOW);
     }
     }
    void loop()
    {
      Blynk.run();
      timer.run();  
      Afuera();
      Encoder1();
      Encoder2();
      Encoder3();
      Encoder4();
      Encoder5();
      Encoder6();
      pulEncoder1();
      pulEncoder2();
      pulEncoder3();
      pulEncoder4();
      pulEncoder5();
      pulEncoder6();
      //BotonPuerta();
      //getFingerprintIDez();

          fingerprintID = getFingerprintID();
          //delay(50);
          if(fingerprintID > 0) //Dan
          {
       digitalWrite(puerta , HIGH);
       delay(100);
       digitalWrite(puerta , LOW);
          }
     //--------------------------------------------------------------------------------------

    }

    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;


      return finger.fingerID; 
    }

    void BotonPuerta(){
      int lec1 = digitalRead(pulPuerta); // lee el estado del Boton
      if (lec1 == HIGH){
      digitalWrite(puerta, HIGH);
      delay(100);
      digitalWrite(puerta,LOW);
      }
    }
    void Encoder1(){  
    // Encoder 1
    valorActual1 = digitalRead(pinA1);
        if (valorActual1 != valorInicial1)
        {
          if (digitalRead(pinB1) != valorActual1)
          {  
            if(brightness < 130)
            {
              brightness=brightness+10;
            }
            horario1 = true;
          }
          else
          {
            if(brightness > 0)
            {
              brightness=brightness-10;
            }
            horario1 = false;        
          }
         Blynk.virtualWrite(V10, brightness);               
       }
      valorInicial1 = valorActual1;
    }
    void pulEncoder1(){

      reading1 = digitalRead(inPin1);

      if (reading1 == HIGH && previous1 == LOW && millis() - time > debounce1) {
        if (brightness <= 125)
          brightness = 130;
        else
          brightness = 0;
        time = millis();
        Blynk.virtualWrite(V10, brightness);    
      }
      previous1 = reading1;
    }

    void Encoder2(){
    //-----------------------------------------------------------------------------------
      // Encoder 2
      valorActual2 = digitalRead(pinA2);
        if (valorActual2 != valorInicial2)
        {
          if (digitalRead(pinB2) != valorActual2)
          {  
            if(brightness2 < 130)
            {
              brightness2=brightness2+10;
            }
            horario2 = true;
          }
          else
          {
            if(brightness2 > 0)
            {
              brightness2=brightness2-10;
            }
            horario2 = false;        
          }
         Blynk.virtualWrite(V11, brightness2);               
       }
      valorInicial2 = valorActual2;

    }
    void pulEncoder2(){

      reading2 = digitalRead(inPin2);

      if (reading2 == HIGH && previous2 == LOW && millis() - time2 > debounce2) {
        if (brightness2 <= 125)
          brightness2 = 130;
        else
          brightness2 = 0;
        time2 = millis();
        Blynk.virtualWrite(V11, brightness2);    
      }
      previous2 = reading2;
    }

    void Encoder3(){
      // Encoder 3
      valorActual3 = digitalRead(pinA3);
        if (valorActual3 != valorInicial3)
        {
          if (digitalRead(pinB3) != valorActual3)
          {  
            if(brightness3 < 130)
            {
              brightness3=brightness3+10;
            }
            horario3 = true;
          }
          else
          {
            if(brightness3 > 0)
            {
              brightness3=brightness3-10;
            }
            horario3 = false;        
          }
         Blynk.virtualWrite(V12, brightness3);               
       }
      valorInicial3 = valorActual3;
    }
    void pulEncoder3(){


      reading3 = digitalRead(inPin3);

      if (reading3 == HIGH && previous3 == LOW && millis() - time3 > debounce3) {
        if (brightness3 <= 125)
          brightness3 = 130;
        else
          brightness3 = 0;
        time3 = millis();
        Blynk.virtualWrite(V12, brightness3);    
      }
      previous3 = reading3;
    }

     void Encoder4(){
     // Encoder 4
      valorActual4 = digitalRead(pinA4);
        if (valorActual4 != valorInicial4)
        {
          if (digitalRead(pinB4) != valorActual4)
          {  
            if(brightness4 < 130)
            {
              brightness4=brightness4+10;
            }
            horario4 = true;
          }
          else
          {
            if(brightness4 > 0)
            {
              brightness4=brightness4-10;
            }
            horario4 = false;        
          }
         Blynk.virtualWrite(V13, brightness4);               
       }
      valorInicial4 = valorActual4;
     }
     void pulEncoder4(){


      reading4 = digitalRead(inPin4);

      if (reading4 == HIGH && previous4 == LOW && millis() - time4 > debounce4) {
        if (brightness4 <= 125)
          brightness4 = 130;
        else
          brightness4 = 0;
        time4 = millis();
        Blynk.virtualWrite(V13, brightness4);    
      }
      previous4 = reading4;
     }

     
     void Encoder5(){
      // Encoder 5
      valorActual5 = digitalRead(pinA5);
        if (valorActual5 != valorInicial5)
        {
          if (digitalRead(pinB5) != valorActual5)
          {  
            if(brightness5 < 130)
            {
              brightness5=brightness5+10;
            }
            horario5 = true;
          }
          else
          {
            if(brightness5 > 0)
            {
              brightness5=brightness5-10;
            }
            horario5 = false;        
          }
         Blynk.virtualWrite(V14, brightness5);               
       }
      valorInicial5 = valorActual5;
     }
    void pulEncoder5(){

      reading5 = digitalRead(inPin5);

      if (reading5 == HIGH && previous5 == LOW && millis() - time5 > debounce5) {
        if (brightness5 <= 125)
          brightness5 = 130;
        else
          brightness5 = 0;
        time5 = millis();
        Blynk.virtualWrite(V14, brightness5);    
      }
      previous5 = reading5;
     }
      
      void Encoder6(){  
        // Encoder 6
      valorActual6 = digitalRead(pinA6);
        if (valorActual6 != valorInicial6)
        {
          if (digitalRead(pinB6) != valorActual6)
          {  
            if(brightness6 < 130)
            {
              brightness6=brightness6+10;
            }
            horario6 = true;
          }
          else
          {
            if(brightness6 > 0)
            {
              brightness6=brightness6-10;
            }
            horario6 = false;        
          }
         Blynk.virtualWrite(V15, brightness6);               
       }
      valorInicial6 = valorActual6;
      }
      
      void pulEncoder6(){
      reading6 = digitalRead(inPin6);

      if (reading6 == HIGH && previous6 == LOW && millis() - time6 > debounce6) {
        if (brightness6 <= 125)
          brightness6 = 130;
        else
          brightness6 = 0;
        time6 = millis();
        Blynk.virtualWrite(V15, brightness6);    
      }
      previous6 = reading6;
      }

          void startFingerprintSensor()
        {
          Serial.begin(9600);
          while (!Serial);
          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...");
        }

This is the programming (it’s a bit long)
I appreciate your help, thanks.

2 Likes

Because Blynk needs to maintain a communication link with the server, it can be susceptible to delays, causing disconnections.

Your void loop() is full of functions and even a small delay (which stops ALL Arduino processing for that time).

And your fingerprint routine uses a while() command which is also a blocking command that stops everything until it gets all that it needs.

So, lots happening that could cause timeouts and disconnection.

You could try using more interval timers for any functions that don’t need to run hundreds of times a second in the void loop()

Perhaps even a timeout timer for your blinking “puerta” (door?? probably an LED by a door :stuck_out_tongue_winking_eye: ) when reading the fingerprint sensor.

1 Like

What happens is that the processes that are in the void loop are necessary that are always running, because they are the physical encoders that regulate me the light and the fans, I also tried to eliminate all delay and I changed it by millis () so that I was late, although with all the processes that I have I understand that there are still delays.

But, when I run that programming without the fingerprint sensor, everything works very well for me, the only thing I could not add was that, the fingerprint sensor, I saw some programming to light an LED with the fingerprint and they work for me, but time to add that to Blynk is what fails me, so for me it is not a problem of delay.

This is the programming that I have tried to add to Blynk, obviously removing what I do not need, like the serial.print and those things, I try it this way and it works perfect, but I just add it to the programming that I have with Blynk and I do not works, I even recognize the fingerprint sensor, but when I put a fingerprint it does not do anything.

/*************************************************** 
  This is an example sketch for our optical Fingerprint sensor

  Designed specifically to work with the Adafruit BMP085 Breakout 
  ----> http://www.adafruit.com/products/751

  These displays use TTL Serial to communicate, 2 pins are required to 
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/


#include <Adafruit_Fingerprint.h>

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1

// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
// comment these two lines if using hardware serial
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()  
{
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit 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) { delay(1); }
  }

  finger.getTemplateCount();
  Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
  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!
  Serial.print("Found ID #"); Serial.print(finger.fingerID); 
  Serial.print(" with confidence of "); Serial.println(finger.confidence); 

  return finger.fingerID;
}

// 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);
  return finger.fingerID; 
}

This statement always amazes me :stuck_out_tongue_winking_eye: To paraphrase “everything works until I add in something else that requires its own timing needs, of which I do not account for, then wonder why nothing works.

Blynk has significant timing needs (as would ALL other IoT applications… due the need to maintain a communications link to something on the internet)… if you want to use Blynk you have to change how you run other programmed functions and features that would otherwise work on bare Arduino/ESP code.

You may want to consider moving the fingerprint sensor and code onto a seperate Arduino and then just sending a GO, NO GO signal to your Blynkified device via something like EasyTransfer?

I know I have to change the programming to make things work for me, that’s why Blynk has given me this project, but at no time did I say that nothing works when I add the fingerprint programming, everything else works for me, the problem is that I have not been able to operate the fingerprint sensor with blynk, because I have tried to see at least one example of that but I can not find it, so there is some variable that I must add or delete.

A bit contradictory :stuck_out_tongue:

I don’t have any fingerprint scanners to test… but based on what I see in the code, it wants to take full timing away from everything else until it is done scanning… normally not a big issue as the Arduino would just sit there waiting… but you can’t do that with Blynk… so this is your problem as I understand it.

The solution is to really optimise your code so that Blynk can stretch it’s timing needs and/or offload the processing needed for the fingerprint scanner.

Very interesting, but I’ve seen projects, like this one where you have a fingerprint sensor and you connect it with Blynk, I would like to know how you did it, to know if it can be done at least, but I will have it as a plan b

Another thing, to do what you say, I must have something more, apart from a separate arduino?

From what I can see, the scanner and door control is possibly separate from Blynk (possibly self contained with it’s own MCU, display, etc), and Blynk is just being used to monitor the status of the door.


Yes, looks like the sensor and TFT was a separate, and non-blynkified process…

I was doing a test and it works, I have an arduino one connected to the fingerprint sensor and the door, while the system (Arduino Mega with the Ethernet shield) is working normally, but I can have two inputs and one output? that is, in the arduino that goes the fingerprint sensor connect (Arduino one) connect the door (which is a relay) on pin 9, and that same relay connect it to the Arduino Mega to be able to open the door from Blynk, that I can do?

Great work you were doing here! and it is inspiring can you send your final code please? I would appreciate it.