Disconnected NodeMCU

Hi all,
I’m using a Node MCU v2 and Blynk to create a unique remote control for my house.
Everythink works pretty well and I’m able to control differente device like TV, DVD, HiFi and so on.

To keep the user interface simple I introduced a menu (bottom of UI) that select the device;
if TV is selected than the IR code sent from ON/OFF botton is the right one for TV; if you move from menu to DVD the same button (ON/OFF) will control the DVD player. …and and everythink works fine.

Now, to complete my project I decided to introduce colors… The bottom menu everytime a device is selected move the color of active button to the dedicated color.

HERE A SCREENSHOT:

EX: TV is green and DVD is red.

If I select TV from device the ON/OFF button become green. If I select DVD the ON/OFF button became red. This is super helpfull in terms of usability.

Now I got a problem… I probably introduced to many call to Blynk and I’m frequently disconnected. (is it correct?)

I don’t think is a connection problem is this I need the <SimpleTimer.h>… I gave a look to https://github.com/blynkkk/blynk-library/blob/master/examples/GettingStarted/PushData/PushData.ino but I don’t understand very well how to implement it.

this is my code; where/how I have to implement the simple timer:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// IR remote
#include <IRremoteESP8266.h>

char auth[] = "ac0c58077892411bae46ed5cd4743f76";

SimpleTimer timer;

IRsend irsend(0); ///an IR led is connected to GPIO --> D4




// ======= SKETCH IR

int pinValueV1;
int pinValueV4;
int pinValueV5;
unsigned int ScreenUp[63] = {1400, 400, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1350, 400, 1350, 400, 1350, 400, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1400, 400, 1400, 400, 1350, 400, 1350, 400, 500};
unsigned int ScreenDown[63] = {1400, 400, 1350, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 550, 1200, 1350, 400, 1350, 400, 1400, 400, 550, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 1400};

// ====== DEVICE SELECTOR


 

BLYNK_WRITE(V1) {
  switch (param.asInt())
  {
    case 1:               // Item 1 - TV LIVING
      pinValueV1 = 1;
      Blynk.setProperty(V2, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V4, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V6, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V7, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V13, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V14, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V15, "color", "#23C48E"); //GREEN
      
      break;

    case 2:               // Item 2 - DVD
      pinValueV1 = 2;
      Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
      Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V3, "label", "HOME");
      Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V4, "label", "LEFT/RIGHT");
      Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE
     
      break;

    case 3:               // Item 3 - AUX
      pinValueV1 = 3;
      Blynk.setProperty(V2, "color", "#04C0F8"); //BLU
      Blynk.setProperty(V4, "color", "#04C0F8"); //BLU
      delay(1000);
      break;

    case 4:
      pinValueV1 = 4;
      
      break;

    case 5:             // Item 5 - Projector Screen
      pinValueV1 = 5;
      Blynk.setProperty(V15, "color", "#ED9D00"); //YELLOW
      
      break;


  }
}

// ========== END DEVICE SELECTOR


BLYNK_WRITE(V2) // ON/OFF
{
  if ( param.asInt() && pinValueV1 == 1 )  // ON/OFF TV
  { irsend.sendNEC(0xFB38C7, 32);
  } else if ( param.asInt()   && pinValueV1 == 2 ) // ON/OFF DVD
  { irsend.sendSAMSUNG(0xB4B40CF3, 32);
  } else if ( param.asInt()   && pinValueV1 == 3 ) // ON/OFF AUX
  { irsend.sendNEC(0x7E8154AB, 32);
  }
}


BLYNK_WRITE(V3) // SOURCE
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBE817, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B4E619, 32);
  }
}


BLYNK_WRITE(V4) // AUDIO + / -
{
  pinValueV4 = V4  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBD22D, 32); // + AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBF20D, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX -
  { irsend.sendNEC(0x5EA1D827, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX +
  { irsend.sendNEC(0x5EA158A7, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Left
  { irsend.sendSAMSUNG(0xB4B49A65, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Right
  { irsend.sendSAMSUNG(0xB4B45AA5, 32); // - AUDIO
  }
}




BLYNK_WRITE(V5) // CHANNELS + / -
{
  pinValueV5 = V5  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB906F, 32); // + CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBA05F, 32); // - CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD CH -
  { irsend.sendSAMSUNG(0xB4B41EE1, 32); // - CH
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD CH +
  { irsend.sendSAMSUNG(0xB4B4EE11, 32); // - CH
  }



}

BLYNK_WRITE(V6) // TXT
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB807F, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V7) // INFO
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendNEC(0xFB1AE5, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V8) // Rewind
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V9) // Play
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B48C73, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V10) // Stop
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B49C63, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V11) // Forward
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V12) // Eject
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B46C93, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V13) // OK
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB609F, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B41AE5, 32);
  }
}

BLYNK_WRITE(V14) // KO
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB50AF, 32); //
  } else {
    // LOW - OFF
  }
}



BLYNK_WRITE(V15) // UP/DOWN-
{
  pinValueV5 = V15  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 ) //+ CH
  { irsend.sendNEC(0xFB58A7, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 ) // - CH
  { irsend.sendNEC(0xFB12ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD UP
  { irsend.sendSAMSUNG(0xB4B4E21D, 32); //
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD DOWN
  { irsend.sendSAMSUNG(0xB4B412ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 5 )    // SCREEN UP
  { irsend.sendRaw(ScreenUp, 63, 32);
  } else if ( param.asInt()  == 4 && pinValueV1 == 5 )    // SCREEN DOWN
  { irsend.sendRaw(ScreenDown, 63, 32);
  }

}



// ========LOOP
void setup()
{
  Serial.begin(9600);
  irsend.begin();
  Blynk.begin(auth, "A....io", "x----");
  //Blynk.begin(auth, "N------1", "k.....");
  Blynk.syncAll();
  
}

void loop()
{
  Blynk.run();
  timer.run();
}

@Ellis_Bosisio the PushData example has a link to the SimpleTimer docs on Arduino and Blynk provide the SimpleTimer library with each of their releases. That is becuase ā€œyou can’t Blynk without learning how to use SimpleTimerā€. It’s as simple as that.

Maximum consecutive setProperties for a decent processor like the ESP is 4, maybe less for others.

So keep a maximum of 4 setProperties for each case, start a timer and send the other 4, then stop the timer. Trial and error will give you the pause time between the first 4 and the second 4 but perhaps start at 100ms.

You can change the baud from 9600 to 115200. 9600 is only required for inferior MCU’s / connection methods.

Hi Costas,
thank you for your quick answer.
I tried to implement as you proposed the simpletimer library.

I need a little support on coding. It’s something pretty new.

I tried to move the device selector (V1) into a void called void timedevice() but it generates problem.
I don’t also understand how to pause after 3lines …where I’m wrong…?

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

// IR remote
#include <IRremoteESP8266.h>
   

char auth[] = "ac0c5XXXX";

// the timer object
SimpleTimer timer;

IRsend irsend(0); ///an IR led is connected to GPIO --> D4




// ======= SKETCH IR

int pinValueV1;
int pinValueV4;
int pinValueV5;
unsigned int ScreenUp[63] = {1400, 400, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1350, 400, 1350, 400, 1350, 400, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1400, 400, 1400, 400, 1350, 400, 1350, 400, 500};
unsigned int ScreenDown[63] = {1400, 400, 1350, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 550, 1200, 1350, 400, 1350, 400, 1400, 400, 550, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 1400};

// ====== DEVICE SELECTOR

// a function to be executed periodically









// ========== END DEVICE SELECTOR


BLYNK_WRITE(V2) // ON/OFF
{
  if ( param.asInt() && pinValueV1 == 1 )  // ON/OFF TV
  { irsend.sendNEC(0xFB38C7, 32);
  } else if ( param.asInt()   && pinValueV1 == 2 ) // ON/OFF DVD
  { irsend.sendSAMSUNG(0xB4B40CF3, 32);
  } else if ( param.asInt()   && pinValueV1 == 3 ) // ON/OFF AUX
  { irsend.sendNEC(0x7E8154AB, 32);
  }
}


BLYNK_WRITE(V3) // SOURCE
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBE817, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B4E619, 32);
  }
}


BLYNK_WRITE(V4) // AUDIO + / -
{
  pinValueV4 = V4  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBD22D, 32); // + AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBF20D, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX -
  { irsend.sendNEC(0x5EA1D827, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX +
  { irsend.sendNEC(0x5EA158A7, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Left
  { irsend.sendSAMSUNG(0xB4B49A65, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Right
  { irsend.sendSAMSUNG(0xB4B45AA5, 32); // - AUDIO
  }
}




BLYNK_WRITE(V5) // CHANNELS + / -
{
  pinValueV5 = V5  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB906F, 32); // + CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBA05F, 32); // - CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD CH -
  { irsend.sendSAMSUNG(0xB4B41EE1, 32); // - CH
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD CH +
  { irsend.sendSAMSUNG(0xB4B4EE11, 32); // - CH
  }



}

BLYNK_WRITE(V6) // TXT
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB807F, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V7) // INFO
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendNEC(0xFB1AE5, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V8) // Rewind
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V9) // Play
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B48C73, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V10) // Stop
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B49C63, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V11) // Forward
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V12) // Eject
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B46C93, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V13) // OK
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB609F, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B41AE5, 32);
  }
}

BLYNK_WRITE(V14) // KO
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB50AF, 32); //
  } else {
    // LOW - OFF
  }
}



BLYNK_WRITE(V15) // UP/DOWN-
{
  pinValueV5 = V15  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 ) //+ CH
  { irsend.sendNEC(0xFB58A7, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 ) // - CH
  { irsend.sendNEC(0xFB12ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD UP
  { irsend.sendSAMSUNG(0xB4B4E21D, 32); //
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD DOWN
  { irsend.sendSAMSUNG(0xB4B412ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 5 )    // SCREEN UP
  { irsend.sendRaw(ScreenUp, 63, 32);
  } else if ( param.asInt()  == 4 && pinValueV1 == 5 )    // SCREEN DOWN
  { irsend.sendRaw(ScreenDown, 63, 32);
  }

}



// ========LOOP
void setup()
{

  Serial.begin(115200);
  irsend.begin();
  Blynk.begin(auth, "XXX", "YYY");
  Blynk.syncAll();
  timer.setInterval(1000L, timedevice);
}


void timedevice()
{
BLYNK_WRITE(V1) {
  switch (param.asInt())
  {
    case 1:               // Item 1 - TV LIVING
      pinValueV1 = 1;
      Blynk.setProperty(V2, "color", "#23C48E");  //GREEN
      Blynk.setProperty(V4, "color", "#23C48E"); //GREEN
     // how to wait 100ms?
      Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V6, "color", "#23C48E"); //GREEN
      // how to wait 100ms? 
      Blynk.setProperty(V7, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V13, "color", "#23C48E"); //GREEN
       // how to wait 100ms?
      Blynk.setProperty(V14, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V15, "color", "#23C48E"); //GREEN

      break;

    case 2:               // Item 2 - DVD
      pinValueV1 = 2;
      Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
      Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
       // how to wait 100ms?
      Blynk.setProperty(V3, "label", "HOME");
      Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
       // how to wait 100ms?
      Blynk.setProperty(V4, "label", "LEFT/RIGHT");
      Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
       // how to wait 100ms?
      Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE

      break;

    case 3:               // Item 3 - AUX
      pinValueV1 = 3;
      Blynk.setProperty(V2, "color", "#04C0F8"); //BLU
      Blynk.setProperty(V4, "color", "#04C0F8"); //BLU

      break;

    case 4:
      pinValueV1 = 4;

      break;

    case 5:             // Item 5 - Projector Screen
      pinValueV1 = 5;
      Blynk.setProperty(V15, "color", "#ED9D00"); //YELLOW

      break;


  }
}









}



void loop()
{
  Blynk.run();
  timer.run();

}

You cannot put BLYNK_WRITE() functions inside other functions like void timedevice()
They must be on top.

You need to limit the number of setProperty requests that go out ā€˜instantly’. When you have the following:

Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
Blynk.setProperty(V3, "label", "HOME");
Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
Blynk.setProperty(V4, "label", "LEFT/RIGHT");
Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE

you end up flooding your hardware (not the server) and your poor little ESP8266 has to drop connection.

Potential fix, get an ESP32 (it has 2 cores, 1 entirely dedicated to keeping you connected).

SimpleTimer fix, write a simple function containing 3-4 (experiment) setProperty calls only.

void mySetPropertyFunction2a(){
   Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
   Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V3, "label", "HOME");
   Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
}
void mySetPropertyFunction2b(){
   Blynk.setProperty(V4, "label", "LEFT/RIGHT");
   Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE
}

Then you would write:

case 2:               // Item 2 - DVD
  pinValueV1 = 2;
  timer.setTimeout(50, mySetPropertyFunction2a); // perform the first function almost instantly
  timer.setTimeout(400,mySetPropertyFunction2b); // perform the second function 400ms later (experiment)
1 Like

@Ellis_Bosisio from the code provided by @jamin you only really need1b and 2b (not 1a, 1b, 2a, 2b) functions with a 300ms timeout as the first 4 setProperty() calls can be left in for case 1 and case 2. 200ms still crashes an ESP.

You could hook up a Blynk slider to determine the minimum setting between 200ms and 300ms below which the ESP crashes. Saves you having to keep changing the sketch to determine the optimum timeout value.

1 Like

I was going to do it like this, but though it might have been too confusing explaining the b part of it without the a part.

1 Like

@Jamin fair point, but just call them 1 and 2, forget the a’s and b’s :slight_smile:

Hi.
And according to you which would be the most suitable processor to avoid this lack of power ???, maybe with an Onion Omega 2 would not have these problems ??

a greeting

BlackTiger.

@BlackTiger I posted a few days ago that I would wait 6 months before considering an Omega 2 unless you are a serious hacker.

The ESP’s are fine and it’s just a case of working with their limitations. I wouldn’t go looking for other hardware. ESP32’s will be better, but again I wouldn’t but them yet either.

Hi all, thank you for all feedback, and thanks also for the deep explanation of the problem.
I opted to limit the ESP. It’s the cheapest and quick.

That said I made al the suggested changes. To avoid problems I created more void function and increased the ā€œdelayā€ between functions. Now code is more stable but I’m still frequently disconnected. I don’t understand why. there are huge gaps between functions now.

Here the code. Where I’m wrong?

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

// IR remote
#include <IRremoteESP8266.h>
   

char auth[] = "WWWWWWWWWWWWW";

// the timer object
SimpleTimer timer;

IRsend irsend(0); ///an IR led is connected to GPIO --> D4




// ======= SKETCH IR

int pinValueV1;
int pinValueV4;
int pinValueV5;
unsigned int ScreenUp[63] = {1400, 400, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1350, 400, 1350, 400, 1350, 400, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1400, 400, 1400, 400, 1350, 400, 1350, 400, 500};
unsigned int ScreenDown[63] = {1400, 400, 1350, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 550, 1200, 1350, 400, 1350, 400, 1400, 400, 550, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 1400};

// ====== DEVICE SELECTOR

// a function to be executed periodically

BLYNK_WRITE(V1) {
  switch (param.asInt())
  {
    case 1:               // Item 1 - TV LIVING
      pinValueV1 = 1;
      Blynk.setProperty(V2, "color", "#23C48E");  //GREEN
      Blynk.setProperty(V4, "color", "#23C48E"); //GREEN  
      timer.setTimeout(900, mySetPropertyFunction2a); // perform the second function 
      timer.setTimeout(900, mySetPropertyFunction3a); // perform the 3rd function 
      timer.setTimeout(900, mySetPropertyFunction4a); // perform the 4th function 
      break;

    case 2:               // Item 2 - DVD
      pinValueV1 = 2;
      Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
      Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
      timer.setTimeout(900, mySetPropertyFunction2b); // perform the second function 
      timer.setTimeout(900, mySetPropertyFunction3b); // perform the 3rd function  
      timer.setTimeout(900, mySetPropertyFunction4b); // perform the 4th function 

      break;

    case 3:               // Item 3 - AUX
      pinValueV1 = 3;
      Blynk.setProperty(V2, "color", "#04C0F8"); //BLU
      Blynk.setProperty(V4, "color", "#04C0F8"); //BLU

      break;

    case 4:
      pinValueV1 = 4;

      break;

    case 5:             // Item 5 - Projector Screen
      pinValueV1 = 5;
      Blynk.setProperty(V15, "color", "#ED9D00"); //YELLOW

      break;


  }
}







// ========== END DEVICE SELECTOR


BLYNK_WRITE(V2) // ON/OFF
{
  if ( param.asInt() && pinValueV1 == 1 )  // ON/OFF TV
  { irsend.sendNEC(0xFB38C7, 32);
  } else if ( param.asInt()   && pinValueV1 == 2 ) // ON/OFF DVD
  { irsend.sendSAMSUNG(0xB4B40CF3, 32);
  } else if ( param.asInt()   && pinValueV1 == 3 ) // ON/OFF AUX
  { irsend.sendNEC(0x7E8154AB, 32);
  }
}


BLYNK_WRITE(V3) // SOURCE
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBE817, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B4E619, 32);
  }
}


BLYNK_WRITE(V4) // AUDIO + / -
{
  pinValueV4 = V4  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBD22D, 32); // + AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBF20D, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX -
  { irsend.sendNEC(0x5EA1D827, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX +
  { irsend.sendNEC(0x5EA158A7, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Left
  { irsend.sendSAMSUNG(0xB4B49A65, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Right
  { irsend.sendSAMSUNG(0xB4B45AA5, 32); // - AUDIO
  }
}




BLYNK_WRITE(V5) // CHANNELS + / -
{
  pinValueV5 = V5  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB906F, 32); // + CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBA05F, 32); // - CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD CH -
  { irsend.sendSAMSUNG(0xB4B41EE1, 32); // - CH
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD CH +
  { irsend.sendSAMSUNG(0xB4B4EE11, 32); // - CH
  }



}

BLYNK_WRITE(V6) // TXT
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB807F, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V7) // INFO
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendNEC(0xFB1AE5, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V8) // Rewind
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V9) // Play
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B48C73, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V10) // Stop
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B49C63, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V11) // Forward
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V12) // Eject
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B46C93, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V13) // OK
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB609F, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B41AE5, 32);
  }
}

BLYNK_WRITE(V14) // KO
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB50AF, 32); //
  } else {
    // LOW - OFF
  }
}



BLYNK_WRITE(V15) // UP/DOWN-
{
  pinValueV5 = V15  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 ) //+ CH
  { irsend.sendNEC(0xFB58A7, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 ) // - CH
  { irsend.sendNEC(0xFB12ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD UP
  { irsend.sendSAMSUNG(0xB4B4E21D, 32); //
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD DOWN
  { irsend.sendSAMSUNG(0xB4B412ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 5 )    // SCREEN UP
  { irsend.sendRaw(ScreenUp, 63, 32);
  } else if ( param.asInt()  == 4 && pinValueV1 == 5 )    // SCREEN DOWN
  { irsend.sendRaw(ScreenDown, 63, 32);
  }

}




void setup()
{

  Serial.begin(115200);
  irsend.begin();
  //Blynk.begin(auth, "xxxx", "yyyy");
  Blynk.begin(auth, "xxxx", "yyy");
  Blynk.syncAll();
 
}


//////VOID for Colors - they are a must to avoid NodeMCU chip flooding


void mySetPropertyFunction2a(){
      Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V6, "color", "#23C48E"); //GREEN  
}

void mySetPropertyFunction3a(){
      Blynk.setProperty(V7, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V13, "color", "#23C48E"); //GREEN   
}

void mySetPropertyFunction4a(){
      Blynk.setProperty(V14, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V15, "color", "#23C48E"); //GREEN  
}


void mySetPropertyFunction2b(){     
      Blynk.setProperty(V3, "label", "HOME");
      Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
}      

void mySetPropertyFunction3b(){     
  Blynk.setProperty(V4, "label", "LEFT/RIGHT");
  Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
}     

 void mySetPropertyFunction4b(){ 
   Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE
} 






void loop()
{
  Blynk.run();
  timer.run();

}

@Ellis_Bosisio try this sketch, works fine for me.

/* IR_Remote.ino per http://community.blynk.cc/t/disconnetted-nodemcu/11599 */
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// IR remote
#include <IRremoteESP8266.h>

char auth[]   = "xxxxxxxxxxxxxxxxxxxxxxx";
char ssid[]   = "xxxxxxxxxx;
char pass[]   = "xxxxxxxxxxx";
char server[] = "blynk-cloud.com";

SimpleTimer testingTimer;

//IRsend irsend(0); ///an IR led is connected to GPIO 0 --> D4
IRsend irsend(5); ///an IR led is connected to GPIO 5 --> D1

// ======= SKETCH IR

int pinValueV1;
int pinValueV4;
int pinValueV5;
unsigned int ScreenUp[63] = {1400, 400, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1350, 400, 1350, 400, 1350, 400, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 500, 1200, 1400, 400, 1400, 400, 1350, 400, 1350, 400, 500};
unsigned int ScreenDown[63] = {1400, 400, 1350, 400, 1400, 400, 1400, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1350, 400, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 550, 1200, 1350, 400, 1350, 400, 1400, 400, 550, 1200, 500, 1200, 500, 1200, 500, 1200, 1400, 400, 1400, 400, 1400, 400, 1400, 400, 1400};

// ====== DEVICE SELECTOR

void mySetPropertyFunction1notneeded(){
  Blynk.setProperty(V2, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V4, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V6, "color", "#23C48E"); //GREEN
}
void mySetPropertyFunction1(){
  Blynk.setProperty(V7, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V13, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V14, "color", "#23C48E"); //GREEN
  Blynk.setProperty(V15, "color", "#23C48E"); //GREEN
}

void mySetPropertyFunction2notneeded(){
   Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
   Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V3, "label", "HOME");
   Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
}
void mySetPropertyFunction2(){
   Blynk.setProperty(V4, "label", "LEFT/RIGHT");
   Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
   Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE
}
 

BLYNK_WRITE(V1) {
  switch (param.asInt())
  {
    case 1:               // Item 1 - TV LIVING
      pinValueV1 = 1;
      Blynk.setProperty(V2, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V4, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V5, "color", "#23C48E"); //GREEN
      Blynk.setProperty(V6, "color", "#23C48E"); //GREEN
      //Blynk.setProperty(V7, "color", "#23C48E"); //GREEN
      //Blynk.setProperty(V13, "color", "#23C48E"); //GREEN
      //Blynk.setProperty(V14, "color", "#23C48E"); //GREEN
      //Blynk.setProperty(V15, "color", "#23C48E"); //GREEN
      testingTimer.setTimeout(300,mySetPropertyFunction1); // perform the second function 400ms later
      break;

    case 2:               // Item 2 - DVD
      pinValueV1 = 2;
      Blynk.setProperty(V2, "color", "#D3435C"); //RED POWER
      Blynk.setProperty(V3, "color", "#D3435C"); //RED SOURCE
      Blynk.setProperty(V3, "label", "HOME");
      Blynk.setProperty(V4, "color", "#D3435C"); //RED SOURCE
      //Blynk.setProperty(V4, "label", "LEFT/RIGHT");
      //Blynk.setProperty(V5, "color", "#D3435C"); //RED SOURCE
      //Blynk.setProperty(V13, "color", "#D3435C"); //RED SOURCE
      //Blynk.setProperty(V15, "color", "#D3435C"); //RED SOURCE
      testingTimer.setTimeout(300,mySetPropertyFunction2); // perform the second function 400ms later 
      break;

    case 3:               // Item 3 - AUX
      pinValueV1 = 3;
      Blynk.setProperty(V2, "color", "#04C0F8"); //BLU
      Blynk.setProperty(V4, "color", "#04C0F8"); //BLU
      delay(1000);
      break;

    case 4:
      pinValueV1 = 4;
      
      break;

    case 5:             // Item 5 - Projector Screen
      pinValueV1 = 5;
      Blynk.setProperty(V15, "color", "#ED9D00"); //YELLOW
      
      break;

  }
}

// ========== END DEVICE SELECTOR


BLYNK_WRITE(V2) // ON/OFF
{
  if ( param.asInt() && pinValueV1 == 1 )  // ON/OFF TV
  { irsend.sendNEC(0xFB38C7, 32);
  } else if ( param.asInt()   && pinValueV1 == 2 ) // ON/OFF DVD
  { irsend.sendSAMSUNG(0xB4B40CF3, 32);
  } else if ( param.asInt()   && pinValueV1 == 3 ) // ON/OFF AUX
  { irsend.sendNEC(0x7E8154AB, 32);
  }
}


BLYNK_WRITE(V3) // SOURCE
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBE817, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B4E619, 32);
  }
}


BLYNK_WRITE(V4) // AUDIO + / -
{
  pinValueV4 = V4  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBD22D, 32); // + AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBF20D, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX -
  { irsend.sendNEC(0x5EA1D827, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 3 )  // AUDIO AUX +
  { irsend.sendNEC(0x5EA158A7, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Left
  { irsend.sendSAMSUNG(0xB4B49A65, 32); // - AUDIO
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD Right
  { irsend.sendSAMSUNG(0xB4B45AA5, 32); // - AUDIO
  }
}


BLYNK_WRITE(V5) // CHANNELS + / -
{
  pinValueV5 = V5  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB906F, 32); // + CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 )
  { irsend.sendNEC(0xFBA05F, 32); // - CH
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD CH -
  { irsend.sendSAMSUNG(0xB4B41EE1, 32); // - CH
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD CH +
  { irsend.sendSAMSUNG(0xB4B4EE11, 32); // - CH
  }

}

BLYNK_WRITE(V6) // TXT
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB807F, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V7) // INFO
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendNEC(0xFB1AE5, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V8) // Rewind
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V9) // Play
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B48C73, 32); //
  } else {
    //LOW - OFF
  }
}

BLYNK_WRITE(V10) // Stop
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B49C63, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V11) // Forward
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B44CB3, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V12) // Eject
{
  if ( param.asInt() && pinValueV1 == 2 )
  { irsend.sendSAMSUNG(0xB4B46C93, 32); //
  } else {
    //LOW - OFF
  }
}


BLYNK_WRITE(V13) // OK
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB609F, 32); //
  } else if ( param.asInt()   && pinValueV1 == 2 ) // SAMSUNG
  { irsend.sendSAMSUNG(0xB4B41AE5, 32);
  }
}

BLYNK_WRITE(V14) // KO
{
  if ( param.asInt() && pinValueV1 == 1 )
  { irsend.sendNEC(0xFB50AF, 32); //
  } else {
    // LOW - OFF
  }
}

BLYNK_WRITE(V15) // UP/DOWN-
{
  pinValueV5 = V15  ;
  if ( param.asInt()  == 4 && pinValueV1 == 1 ) //+ CH
  { irsend.sendNEC(0xFB58A7, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 1 ) // - CH
  { irsend.sendNEC(0xFB12ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 2 )  // DVD UP
  { irsend.sendSAMSUNG(0xB4B4E21D, 32); //
  } else if ( param.asInt()  == 4 && pinValueV1 == 2 )    // DVD DOWN
  { irsend.sendSAMSUNG(0xB4B412ED, 32); //
  } else if ( param.asInt()  == 3 && pinValueV1 == 5 )    // SCREEN UP
  { irsend.sendRaw(ScreenUp, 63, 32);
  } else if ( param.asInt()  == 4 && pinValueV1 == 5 )    // SCREEN DOWN
  { irsend.sendRaw(ScreenDown, 63, 32);
  }
}

// ========LOOP
void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println(F("Started"));
  irsend.begin();
  //Blynk.begin(auth, "A....io", "x----");
  //Blynk.begin(auth, "N------1", "k.....");
  Blynk.begin(auth, ssid, pass, server); 
  Blynk.syncAll();
  
}

void loop()
{
  Blynk.run();
  testingTimer.run();
}

Yes confirmed. now is working perfectly.
I think the problem was in where they void funtion was in my sketch. Thank you so much.

I’ll put some picture/video in the Project mad with Blynk area when everythink will be done.

1 Like