Blynk.connect(timeout) working with YUN Shield?

Hi,

I’ve been trying to get this working with this shield/avr board and seems there is a problem with this function…in these boards… No matter what timeout I put, it stays always the same: (around 120seconds until it hangs) and the the arduino resumes its code without blynk…

has someone happened the same with these boards?

Clarifying my previous post, this simple code doesn’t do what is supposed to do, meaning that timeout connection doesn’t happen in the specified time. It takes as I said previously about 120s to timeout Blynk connection when I intensionally turn off my local Blynk server on first connection…

So… any suggestions?


#include <Bridge.h>
#include <BlynkSimpleYun.h>
#include <TMP102.h>
#include  <Console.h>

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";

IPAddress server_ip (192, 168, 51, 209);
void setup()
{
  Bridge.begin();
  Console.begin();  
  Blynk.config(auth, server_ip, 8442);
  Blynk.connect(1000);
}

void loop()
{
    TMP102 tmp102;
    tmp102.setup();

int   tempC = tmp102.getTemperatureCelsius();
 
Console.println(tempC);

}

Format your code correctly like so:

``` cpp
CODE
```

Dont use the Auto-Format code button in the text editor.

cpp = c++ syntax formatting
It should look like this:

CODE

Just stopped by to help with the formatting :wink:
I have no experience with the Yun

:slight_smile: ok, thanks

Please post ypur console output

Hi vhymanskyy,

thank you with the prompt response…

here it goes…in first connection, with the local server intensionally disconnected to test the timeout property…and apparently, not working as it should… (NOTE: there are other lines in the output that are test comments that I made…)

Erro ao estabelecer ligação: a tentar (1)... [10580] 
    ___  __          __
   / _ )/ /_ _____  / /__
ligado!
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on Arduino Uno

  First Conection......
[11535] Connecting to 192.168.51.209
[138918] Disconnected
Disconnected!
[139047] Disconnected
[139284] Disconnected
[139408] Disconnected
[139532] Disconnected
[139657] Disconnected
[139781] Disconnected
[139905] Disconnected
[140028] Disconnected
[140151] Disconnected
[140275] Disconnected
[140399] Disconnected
[140523] Disconnected
[140647] Disconnected
[140771] Disconnected
[140895] Disconnected
[141019] Disconnected
  angulo XX:   215.31  angulo YY:   -135.75   Air Temperature:  8.88
Not connected to local Blynk
[141305] Disconnected
[141429] Disconnected
[141554] Disconnected
[141678] Disconnected
[141802] Disconnected
[141926] Disconnected
[142049] Disconnected
[142173] Disconnected
[142298] Disconnected
[142422] Disconnected
[142544] Disconnected
[142668] Disconnected
[142791] Disconnected
[142915] Disconnected
[143037] Disconnected
  angulo XX:   215.61  angulo YY:   -135.81   Air Temperature:  8.88
Not connected to local Blynk
[143312] Disconnected
[143438] Disconnected
[143563] Disconnected
[143686] Disconnected
[143810] Disconnected
[143935] Disconnected
[144059] Disconnected
[144184] Disconnected
[144306] Disconnected
[144430] Disconnected
[144555] Disconnected
[144677] Disconnected
[144801] Disconnected
[144925] Disconnected
[145048] Disconnected
  angulo XX:   215.97  angulo YY:   -135.91   Air Temperature:  8.88
Not connected to local Blynk
[145325] Disconnected
[145460] Disconnected
[145584] Disconnected
[145708] Disconnected
[145832] Disconnected
[145956] Disconnected
[146080] Disconnected
[146204] Disconnected
[146327] Disconnected
[146452] Disconnected
[146575] Disconnected
[146698] Disconnected
[146822] Disconnected
[146947] Disconnected
  angulo XX:   216.33  angulo YY:   -136.06   Air Temperature:  8.88
Not connected to local Blynk
[147221] Disconnected
[147346] Disconnected
[147481] Disconnected
[147605] Disconnected
[147729] Disconnected
[147852] Disconnected
[147976] Disconnected
[148100] Disconnected
[148224] Disconnected
[148347] Disconnected
[148471] Disconnected
[148595] Disconnected
[148719] Disconnected
[148841] Disconnected
[148965] Disconnected
  angulo XX:   216.74  angulo YY:   -136.33   Air Temperature:  8.63
Not connected to local Blynk
[149239] Disconnected
[149363] Disconnected
[149497] Disconnected
[149621] Disconnected
[149746] Disconnected
[149869] Disconnected
[149993] Disconnected
[150117] Disconnected
[150240] Disconnected
[150364] Disconnected
[150488] Disconnected
[150612] Disconnected
[150735] Disconnected
[150859] Disconnected
[150983] Disconnected
  angulo XX:   217.20  angulo YY:   -136.72   Air Temperature:  9.13
Not connected to local Blynk
[151289] Disconnected
[151415] Disconnected
[151548] Disconnected
[151672] Disconnected
[151795] Disconnected
[151918] Disconnected
[152041] Disconnected
[152165] Disconnected
[152289] Disconnected
[152413] Disconnected
[152536] Disconnected
[152659] Disconnected
[152784] Disconnected
[152908] Disconnected
[153032] Disconnected
  angulo XX:   217.67  angulo YY:   -137.31   Air Temperature:  8.88
Not connected to local Blynk
[153307] Disconnected
[153431] Disconnected
[153554] Disconnected
[153682] Disconnected
[153804] Disconnected
[153928] Disconnected
[154052] Disconnected
[154176] Disconnected
[154301] Disconnected
[154425] Disconnected
[154548] Disconnected
[154671] Disconnected
[154796] Disconnected
[154919] Disconnected
[155042] Disconnected
  angulo XX:   218.22  angulo YY:   -138.18   Air Temperature:  9.13
Not connected to local Blynk

Is a Yun loop() for Blynk intended to take a totally different format to a regular Blynk loop()?

Sorry, I didn’t understand the question. Could you please reformulate?

Has you can see, the entire code is a little bit bigger than the sketch I show you previously, but the for the issue I am having, (not doing timeout on specified time) I think is no different…



//The main board of this tower is a ARDUINO UNO
//with a YUN Shield

#define BLYNK_PRINT Console
#include <Bridge.h>
#include <BlynkSimpleYun.h>
#include <Motor_Torre_1.h>
#include <ADXL335_V3_Torre_1.h>
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <LCD03.h>
#include <SeguimentoSolar.h>
#include <SPI.h>
#include <SimpleTimer.h>
#include "TMP102.h"  //TMP102 library
#include  <math.h>
#include  <Console.h>

using namespace std;

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store

WidgetLCD lcd1(V2);
WidgetLCD lcd2(V7);
//Condiçoes iniciais  do  filtro  passa baixo. Factor de  rapidez do  filtro  no  ADXL335.h
 
float xFilter = 0;
float yFilter = 0;
float zFilter = 0;

int      dAno=0;
int  modoManual=0;
int botaoDormir=0;
int dormir=0;
float AzimuthRef=180;
float ElevationRef=85;
float    tempC=23;
int Hour=0;
int Minute=0;
int Second=0;
float SunRise=0;
float SunSet=0;
float pitchAngle=180;       //Convém colocar um valor apróximado por causa do factor relaxação do filtro
float rollAngle=180;        //Convém colocar um valor apróximado por causa do factor relaxação do filtro
int mLST=0;
int hLST=0;
int LimitXXmin=160;
int LimitXXmax=200;
int LimitYYmin=45;
int LimitYYmax=80;
bool BlynkConnected = false;           //inicialização da função connected para teste se está ligado ao servidor Blynk;

SimpleTimer timer;
SimpleTimer timerConsola;

char auth[] = "My Token";

IPAddress server_ip (192, 168, 51, 209);

void leds()
{
  WidgetLED led1(V4); //register to virtual pin 4
  if (modoManual==0)      
      {
led1.on();
      }
      else
      led1.off();

WidgetLED led2(V6); //register to virtual pin 6
if (modoManual==1)      
      {
led2.on();
}
      else
      led2.off();

 WidgetLED led3(V1); //register to virtual pin V1
if (botaoDormir==1)            
    led3.on();     
      else
      led3.off();      

    WidgetLED led4(V9); //register to virtual pin 1
if (digitalRead(2)==1||digitalRead(3)==1||digitalRead(5)==1||digitalRead(6)==1)            
    led4.on();     
      else if(digitalRead(2)==0 && digitalRead(3)==0 && digitalRead(5)==0 && digitalRead(6)==0)
      led4.off();
      
}

void blynkClockMinutesSeconds()   //Funcao que manda para o Blynk todos os dados
{
    Blynk.virtualWrite(28,Hour);
    Blynk.virtualWrite(27,Minute);
    Blynk.virtualWrite(26,Second);    
}

void blynkClockHours()   //Funcao que manda para o Blynk todos os dados
{
    Blynk.virtualWrite(28,Hour);  
}

void blynkInstantAngles()   //Funcao que manda para o Blynk todos os dados
{
    Blynk.virtualWrite(2,round(pitchAngle));
    Blynk.virtualWrite(5,round(rollAngle));

}

void blynkReferencesAngles()   //Funcao que manda para o Blynk todos os dados
{    
    Blynk.virtualWrite(1,ElevationRef);
    Blynk.virtualWrite(3,AzimuthRef);
}

void blynkTemperature()   //Funcao que manda para o Blynk todos os dados
{    
    Blynk.virtualWrite(31,tempC);
}

  BLYNK_WRITE(V0)                 //COLOCAÇÃO EM MODO MANUAL
  {
    int x = param.asInt();
    if(x==1)
    {
    modoManual=1;
    botaoDormir=0;
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);      
    }

  }

  BLYNK_WRITE(V15)              //COLOCAÇAO EM MODO AUTOMÁTICO
  {
    int abc = param.asInt();
    if(abc==1)
    {
    modoManual=0;
    botaoDormir=0;     
    }

  }

  BLYNK_WRITE(V16)            //Colocação em modo Dormir
  {
    int abcd = param.asInt();
    if(abcd==1)
    {
    botaoDormir=1;
    modoManual=0;      
    }

  }

  BLYNK_WRITE(V30)              //Joystick
  {  
 //    modoManual=digitalRead(7);
              
      if (modoManual==1&&botaoDormir==0)              //Se o modo manual estiver ligado na plataforma Blynk...
      {    

                                                //Colocar todas as  saidas  dos motores a OFF
                             digitalWrite(6, LOW);
                             digitalWrite(5, LOW);
                             digitalWrite(2, LOW);
                             digitalWrite(3, LOW);
   
                            int x = param[0].asInt();
                            int y = param[1].asInt();
                            
                            int joystick=0;


            
                       
                       joystick=mexerJoystick(x,y);       //Ver qual  o output  do  joystick na app do Blynk;

                      switch (mexerMotorManual(joystick,round(rollAngle),round(pitchAngle)))
                      {
                
                      case 0:                           //meter todos os outputs dos motores a zero
                             digitalWrite(6, LOW);
                             digitalWrite(5, LOW);
                             digitalWrite(2, LOW);
                             digitalWrite(3, LOW);
                             break;
                
                      case 1:                           //apenas move para esquerda
                             digitalWrite(2, LOW);
                             digitalWrite(3, HIGH);   // 
                             break;
                
                      case 2:                           //apenas move para a direita
                              digitalWrite(3, LOW);
                              digitalWrite(2, HIGH);   // 
                              break;
                    
                      case 3:                           //apenas move para cima
                             digitalWrite(5, LOW);
                             digitalWrite(6, HIGH);   // 
                             break;
                      case 4:                          //apenas move para baixo
                             digitalWrite(6, LOW);
                             digitalWrite(5, HIGH);   // 
                             break;        
                      case 5:                          // move para a esquerda e para cima
                              digitalWrite(2, LOW);
                              digitalWrite(5, LOW);
                              digitalWrite(3, HIGH);   // 
                              digitalWrite(6, HIGH);
                              break;   
                      case 6:                          // move para a esquerda e para baixo
                             digitalWrite(2, LOW);
                             digitalWrite(6, LOW);
                             digitalWrite(3, HIGH);   // 
                             digitalWrite(5, HIGH);
                              break;  
                      case 7:                          // move para a direita e para cima
                             digitalWrite(3, LOW);
                             digitalWrite(5, LOW);
                             digitalWrite(2, HIGH);   // 
                             digitalWrite(6, HIGH);
                             break;  
                      case 8:                          // move para a direita e para baixo
                              digitalWrite(3, LOW);
                              digitalWrite(6, LOW);
                              digitalWrite(2, HIGH);   // 
                              digitalWrite(5, HIGH);
                              break;                
                      } //Fim  do joystick

      }   //Fim do  if  do  modo  manual

        
      else  if(digitalRead(8)==1)         //Botão de dormir na app blynk, vai ler esse botão        
      {
        digitalWrite(7,LOW);
        modoManual=digitalRead(7);
            
        AzimuthRef=180;
        ElevationRef=85;
      }
  }     //Fim da  funcao  BlynkWrite

void displayTopo1()
{
  lcd1.print(0, 0, "Rxx"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd1.print(4, 0,"Ryy");
  lcd1.print(0, 1, (int) AzimuthRef);
  lcd1.print(4, 1, (int) ElevationRef);
  lcd1.print(8,0,"LT:");
  lcd1.print(11,0,Hour);
  lcd1.print(13,0,":");
  lcd1.print(14,0,Minute);
  lcd1.print(8,1,"ST:");
  lcd1.print(11,1,hLST);
  lcd1.print(13,1,":");
  lcd1.print(14,1,mLST);
}

void displayTopo2()
{
  lcd2.print(1, 0, "XX"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd2.print(0, 1, (int) rollAngle);
  lcd2.print(4, 0, "YY"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd2.print(4, 1, (int) pitchAngle);
  lcd2.print(7,0,"SR:");
  lcd2.print(11,0,(int)SunRise);
  lcd2.print(12,0,":");
  lcd2.print(13,0,(int)((SunRise-(int)SunRise)*60.0));
  lcd2.print(7,1,"SS:");
  lcd2.print(10,1,(int)SunSet);
  lcd2.print(12,1,":");
  lcd2.print(13,1,(int)((SunSet-(int)SunSet)*60.0));
}

void testBlynkConnection()
{
  
//  if(Blynk.connected()==true)
//  Console.println("Conectado ao servidor local Blynk");
  if(!BlynkConnected)
  {  
    colocarMotoresOFF();
      Console.println("Trying to connect to local Blynk server...");
        Blynk.connect(1000);
//      Blynk.begin(auth, server_ip, 8442);
        if(Blynk.connected()==false)
        {
          Blynk.disconnect();
          Console.println("Failed to Reconnect!");
        } 
  } 
}  
/*
void statusConnected()
{
  if(BlynkConnected)
  Console.println("Conectado ao servidor local Blynk");
  if(!BlynkConnected)
  Console.println("Não connectado ao servidor local Blynk");
} 
*/

void mandarInfoConsola()
{
  if(BlynkConnected)
  Console.println("Connected to Blynk local Blynk server");
  Console.print("  angulo XX:   ");
  Console.print(rollAngle);
  Console.print("  angulo YY:   ");
  Console.print(pitchAngle);
  Console.print("   Air Temperature:  ");
  Console.println(tempC);
  if(!BlynkConnected)
  Console.println("Not connected to local Blynk");

  /*
//  Console.print(AzimuthRef);
//  Console.print("        ");
//  Console.println(ElevationRef);
//  Console.print("Vcc:    ");
//  Console.print(Vcc);
//  Console.print("  xFilter:  ");
//  Console.print(xFilter);
//  Console.print("    ");
*/
/*
  Console.print("  AcceXX:   ");
  Console.print(AcceXX);
  Console.print("  AcceYY:   ");
  Console.print(AcceYY);
  Console.print("  AcceZZ:   ");
  Console.println(AcceZZ);
 */
}

void setup()
{
  
  Bridge.begin();
  Console.begin();     //??????comentar ou não ??????
//  while(!Console);
  Blynk.config(auth, server_ip, 8442);
  Console.println("  First Conection......");
  Blynk.connect(1000);
  BlynkConnected=Blynk.connected();
  if(BlynkConnected)
  {
      Console.println("Successfully CONNECTED!");
      Blynk.syncAll();                                //Sincroniza todos os Vpins para os valores anteriores

  }
  if(!BlynkConnected)
  {
      Blynk.disconnect();
      Console.println("Disconnected!");
  }

    lcd1.clear();
    lcd2.clear();
    
//Configuracao para arduino UNO, PINOS!

  pinMode(2,OUTPUT);      //Saída para relé   Azimuth
  pinMode(3,OUTPUT);      //Saída para relé   Azimuth
  pinMode(6,OUTPUT);      //Saída para relé  Elevation
  pinMode(5,OUTPUT);      //Saída para relé  Elevation

colocarMotoresOFF();          //Turn off all motors


//  timer.setInterval(1000, blynkInstantAngles);
//  timer.setInterval(60000, blynkReferencesAngles);
  timer.setInterval(60000L, blynkTemperature);
//  timer.setInterval(30000, blynkClockHours);
//  timer.setInterval(1000, blynkClockMinutesSeconds);
  timer.setInterval(2000L, leds);
  timer.setInterval(30000L, displayTopo1);       //Display Cima
  timer.setInterval(2000L, displayTopo2);        //Display Baixo
  timer.setInterval(3600000L, testBlynkConnection);
//  timer.setInterval(5000, statusConnected);
  timerConsola.setInterval(2000L, mandarInfoConsola);
    
}


void loop()
{
  BlynkConnected=Blynk.connected();     //NÃO POSSO COLOCAR isto assim sem simpletimer...faz reboot ao YUN

  
    if (BlynkConnected)
    {
      Blynk.run();
    }
    else if (!BlynkConnected)
    {
      Blynk.disconnect();
    }
    
  
  int x,y,z,Month,Day,sLST,luz,AzimuthRefMan,ElevationRefMan,botaoTeste;
  tmElements_t tm;
  float X,Y,Z,AcceXX,AcceYY,AcceZZ,AngleXX,AngleYY,AngleZZ,oxc,oyc,LSTM,HRA,Declination,Latitude,Longitude,EoT,LST,TC;


    RTC.read(tm);
    timer.run(); // Initiates SimpleTimer
    timerConsola.run();

    TMP102 tmp102;
    tmp102.setup();
    tempC = tmp102.getTemperatureCelsius();
    

    Latitude=38.71667;
    Longitude=-9.13333;


    LSTM=0;                 //Desfazamento em graus da multiplicação de 15ºx Diferença GMT do local... está feito de momento para portugal.

    
    dAno=diaAno(tmYearToCalendar(tm.Year),tm.Month,tm.Day);
    EoT=getEoT(dAno);
    TC=getTC(Longitude,LSTM,EoT);
    
    Hour=tm.Hour;
    Minute=tm.Minute;
    Second=tm.Second;
    
    LST=getLST(Hour,Minute,Second,TC);    //LST em horas??
    HRA=getHRA(LST);
    Declination=getDeclination(dAno);
    ElevationRef=getElevation(Declination,Latitude,HRA);
    AzimuthRef=getAnzimuth(Declination,Latitude,HRA,ElevationRef,LST);
    hLST=gethHOUR(LST);
    mLST=getmHOUR(LST);
    sLST=getsHOUR(LST);
    SunRise=getSunRise(Latitude,Declination,TC);
    SunSet=getSunSet(Latitude,Declination,TC);

   long  Vcc=readVcc();         //Mede automáticamente o valor da tensão que está a receber...e ajusta para as leituras anaógicas serem decentes comparando com a referencia interna


     X=getXCorrigido(Vcc);
     Y=getYCorrigido(Vcc);
     Z=getZCorrigido(Vcc);

//Aplicar filtro  "passa baixo" directamente  nas leituras  do  acelerometro, para  eliminar  os  picos
    
     xFilter=((X*alpha)+(xFilter*(1.0-alpha)));

     yFilter=(Y*alpha)+(yFilter*(1.0-alpha));
     
     zFilter=(Z*alpha)+(zFilter*(1.0-alpha));

     
//Aplicar leituras  para  calculos  já  com o filtro  aplicado  
  
    AcceXX=getAcceXX(xFilter,Vcc);
    AcceYY=getAcceYY(yFilter,Vcc);
    AcceZZ=getAcceZZ(zFilter,Vcc);
    
    
pitchAngle=pitch(AcceXX,AcceYY,AcceZZ);
rollAngle=roll(AcceXX,AcceYY,AcceZZ);


//pitchAngle=90-pitchAngle;
rollAngle=180+rollAngle;

       if(modoManual==0)    
              digitalWrite(7,LOW);
       else if(modoManual==1)
              digitalWrite(7,HIGH);
   
    dormir=modoDescanso(SunSet,SunRise,LST,botaoDormir);      //Basta uma das 3 condições de entrada nesta função se verificarem para se tornar 1!

    
      if(dormir==1)
      {        
      AzimuthRef=180;
      ElevationRef=85;      
      }

      if(AzimuthRef>LimitXXmax)
      {        
      AzimuthRef=LimitXXmax;            
      }

      if(AzimuthRef<LimitXXmin)
      {        
      AzimuthRef=LimitXXmin;            
      }

      if(ElevationRef>LimitYYmax)
      {        
      ElevationRef=LimitYYmax;           
      }

      if(ElevationRef<LimitYYmin)
      {        
      ElevationRef=LimitYYmin;            
      }



      if (modoManual==0&&dormir==1&&millis()>120000||modoManual==0&&dormir==0&&millis()>120000)      //MODO AUTOMÁTICO com delay de 120s no primeiro arranque para os motores estabilizarem
      {

      switch (mexerMotorAzimuth(round(AzimuthRef),round(rollAngle),modoManual))
      {

      case 1:
             digitalWrite(3, LOW);
             digitalWrite(2, HIGH);   // 
             break;

      case 2:
              digitalWrite(2, LOW);
              digitalWrite(3, HIGH);   // 
              break;

      case 0:
//              colocarMotoresOFF();          //Desligar TODOS os motores
              digitalWrite(2, LOW);
              digitalWrite(3, LOW);
              break;

      }   //Fim do  switch dos  XX

      switch (mexerMotorElevation(round(ElevationRef),round(pitchAngle),modoManual))
      {

      case 3:
              digitalWrite(5, LOW);
              digitalWrite(6, HIGH);   // 
              break;

      case 4:
              digitalWrite(6, LOW);
              digitalWrite(5, HIGH);   // 
              break;

      case 0:

              digitalWrite(6, LOW);
              digitalWrite(5, LOW);
              break;
      }         //Fim do  switch  da  elevacao

      }           //Fim do  modo  Automatico

    
}

@professor_pardal looks a lot better now we can see the real loop().

In loop() the else if for not connected states disconnect, surely this should be connect?

I would remove all none Blynk stuff from loop() and call with SimpleTimer. This is a Blynk sketch not an Arduino sketch, different things.

Thanks for the feedback. Yes, I agree that the code needs to be optimized for blynk.

But what about the first connection that I showed the console output? In that stage, it was still on setup()… not yet on loop(), and the timeout didn’t occur in the specified time provided by me (10003 milliseconds). Even if I clean all the code, and put a simple task, the command Blynk.connect(1000) doesn’t do what it should, doesn’t timeout after 10003 milliseconds.

My issue is that the avr “freezes” in the time that it tries to connect to the blynk server…and since I am running a local Server for Blynk, I must arrange a solution to the avr run the code even if the server for some reason (and it happens) is down. So what I did in the loop you saw (in the first lines) was a temporary fix not to freeze when server was down (Blynk.disconnect() ), and then call a SimpleTimer to once an hour (when the avr was not necessary) to try and connect again. The goal here is to keep low timeouts. Hope I make sense in what am saying.

Put together a 10 line sketch and see if that still fails. You have far too much in the current sketch for us to see what the problem is.

Post your bear minimum formatted sketch that shows your problem.

Very few Yun guys here.

ok, will do that. Thanks

Here it goes. This code simply puts out in the console some “chars” in intervals of 1s, after it reaches loop(). By looking the output console, we can see easily that the timeout of Blynk.connect(1000) isn’t 3000 milliseconds (1000*3).

The code:

#define BLYNK_PRINT Console
#include <Bridge.h>
#include <BlynkSimpleYun.h>
#include <SimpleTimer.h>
#include  <Console.h>

SimpleTimer timerSoccer;

void euroSoccerWinner()
{
  Console.println("Portugal WON the Soccer Eurocup!" );
}

void setup() 
{
  Bridge.begin();
  Console.begin();
  Blynk.config("My Token",IPAddress(192,168,51,209), 8442);
  Blynk.connect(1000);
  Blynk.connect(1000);        //it is here just to see the time that it takes to complete timeout of the first Blynk.connect(1000)
  timerSoccer.setInterval(1000,euroSoccerWinner);
}

void loop() 
{
    if (Blynk.connected())
    {
      Blynk.run();
    }
    timerSoccer.run();
}

The console Output:

[9979] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on Arduino Uno

[10973] Connecting to 192.168.51.209
[138385] Connecting to 192.168.51.209
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!
Portugal WON the Soccer Eurocup!

127412 milliseconds was the timeout of the Blynk.connect(1000), when it should be around 1000*3 milliseconds… After both timeouts, it resumes normal operation outputting the chars has instructed.

So, this is my issue.

@professor_pardal so you are saying it is taking 127s for the timeout to kick in rather than the 3.3s you have set in Blynk.connect().

Does your Yun ever actually connect to your local Blynk server?

What version is your Blynk server as Blynk connections were recently changed to blocking functions and need to match up with the correct server version. That said, Blynk.config() and Blynk.connect() are made to circumvent the blocking routine.

What happens when you use the standard Blynk Yun sketch, with Blynk.begin(), to the Blynk cloud server and separately to your local Blynk server?

Thats it! Timeout its taking 127s to kick and I want it to be 3.3s.

“Does your Yun ever actually connect to your local Blynk server?”
When I start the local server (or connect to remote), yes, no problem…

added a test condition to see if is connected in de SimpleTimer:

void euroSoccerWinner()
{
  Console.println("Portugal WON the Soccer Eurocup!" );
  if (Blynk.connected())
      Console.println("Connected");
}

Console Output:

         __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.3 on Arduino Uno

[12141] Connecting to 192.168.51.209
[12468] Ready (ping: 59ms).
Portugal WON the Soccer Eurocup!
Connected
Portugal WON the Soccer Eurocup!
Connected
Portugal WON the Soccer Eurocup!
Connected
Portugal WON the Soccer Eurocup!
Connected
Portugal WON the Soccer Eurocup!
Connected

My local server version is server-0.21.4.jar, but for the purpose, this happens before connecting the server…so…is it a factor…?(…if the server is off…no diference there I suppose…and this test is with server off line and just for info, the server is installed in a Windows 10 Virtual Machine Running on a QNAP NAS).

ok, so answering your last paragraph, just finished those tests and with standard Blynk.begin() with server present (local or remote) no problem as well, starts and the only diference is the increase of ping as expected (from local to remote). without server (and here only tested de local server) the timeout is around the same… 127 seconds before timeout kicks… so, Blynk.connect(timeout) and Blynk.begin() in here appears to be have same behavior…