BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk.run without internet freezes off line program

two problems:

  1. without internet program have freezes over 1 second. I need to stop a garage door, 1 second is too much.
    I need to read digital pin when magnet faces the sensor.

  2. attachInterrupt resets the nodemcu. (tried several ways).

Hello I’ve tried “Code isn’t working without connected Blynk” but every time that I put Blynk.run inside an if(Blynk connected==true) {Blynk.run},or any conditional combination, the connection became unstable: it connect and disconnect from blynk server, so don’t work normally with internet. the good news is everything else work ok.
sorry for this old problem but is not 100%solved.
Also I´ve tried difrent nodemcu boards with the same fail.
I think this is a kind of issue

Difficult to say without seeing your code, but almost certainly due to poor coding.
The interrupt issue is probably because you aren’t forcing your ISR to be stored in IRAM.

Pete.

thank you Pete, I’ve tried to store my isr in IRAM but was the same fail

Code??

Pete.

My first sketch upload I don’t know if I am doing correctly. I use this simbol: ` 3 times, we will see

#define BLYNK_PRINT Serial           //
//#define BLYNK_DEBUG        //                      //
#include <BlynkSimpleEsp8266.h> //            //   
#include <ESP8266WiFi.h>                                                 //  
#include <ESP8266mDNS.h>                                                 //   
#include <WiFiUdp.h>                                                     //   
#include <ArduinoOTA.h>                                                  //   
//web server                                                             //  
#include <ESP8266WebServer.h>                                            //   
ESP8266WebServer server(80);                                             //  
                                                                               //   
///////////////////////////USUARIO Y CLAVE OTA/////////////              // 
const char *ssid_AP = "acceso_local_sin_internet";       //               //
const char *password_AP = "internet";                    //              //     
const char* ssid = "linksys";                            //              //
const char* password = "";                               //                     //
///////////////////////// FIN USUARIO Y CLAVE OTA//////////              //
//Acá se declaran las variables a monitorear localmente por el web server//

bool LED1status = LOW;
bool LED2status = LOW;
bool triac = 0;
bool findecarreracerrado;
bool findecarreraabierto;
bool estaabriendo;
bool estacerrando;
bool abierto;
bool cerrado;
bool botoncierra;
bool botonabre;
bool variablepare;
bool htmlabre;
bool htmlcierra;

////////////////////////////Blynk/////////////////////////////////////////////////////////////////////////////////////////////////////////////
char auth[] = "9StmFKRVBTvsSixY3xIJTZx01i3sPvWi"; //otro mio
//char auth[] = "e1861a5b6775474aa770d5df240a5868"; //mio
//char auth[] = "ninguno"; //ivan.arnaez.ia@gmail.com
   BLYNK_WRITE(V0){ bool a = param.asInt();if (a==1){variablepare=1;}  } 
   BLYNK_WRITE(V1){ bool b = param.asInt();if (b==1){botonabre=1;}     }  
   BLYNK_WRITE(V2){ bool c = param.asInt();if (c==1){botoncierra=1;}   }                 
   WidgetLED led1 (V5); //abriendo
   WidgetLED led2 (V6); //cerrando 
  BlynkTimer timer1;
  BlynkTimer timer2;
  
void led_abriendo(){ //V5
   bool a2 = digitalRead(D7);
  if (a2==1) {led1.on();} else {led1.off();}
}
void led_cerrando(){ //V6
   bool a2 = digitalRead(D8);
   if (a2==1) {led2.on();} else {led2.off();}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////fin Blynk

/////////////////////////////////////////////////////////////////////////////SETUP/////

void setup() {
  Serial.begin  (115200);
  delay(100);
  
 
///////////////////////////////////////// WIFI IP FIJA ////////////////////////////////  
  WiFi.mode(WIFI_AP_STA);                                                            //
  WiFi.softAP(ssid_AP, password_AP);                                                 //
IPAddress local_IP(192, 168, 1, 37);                                                 //
IPAddress gateway(192, 168, 1, 254);                                                 //
IPAddress subnet(255, 255, 255, 0);                                                  //
IPAddress primaryDNS(8, 8, 8, 8);   //optional                                       //
IPAddress secondaryDNS(8, 8, 4, 4); //optional                                       //
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {             //
    Serial.println("STA Failed to configure"); }                                     //
  WiFi.begin(ssid, password);                                                        //
  int c;                                                                             // 
  if (WiFi.status() != WL_CONNECTED && c<10) {delay(500);Serial.print (".");c=c++; } //
  Serial.print("IP address: ");Serial.println(WiFi.localIP());                       //
  WiFi.setAutoReconnect(true);                                                       //
///////////////////////////////////////////////////////////////////////////////////////
  
////////////////////////////////////Blynk setup///////////////////////
                                                                    //
Blynk.config(auth);                                                 //
if (WiFi.status() == WL_CONNECTED) {Serial.println("conectado");    //
    Blynk.connect(5);Serial.println ("Blynk connect");}             //
                                                                    //
timer1.setInterval(2000L, led_abriendo);                            //
timer2.setInterval(2000L, led_cerrando);                            //
                                                                    //
//////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////OTA//     //
  ArduinoOTA.onStart([]() {                                                   //     //
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "sketch";
    } else { // U_SPIFFS
      type = "filesystem";
    }
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {                                                     //     //
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {       //     //
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {                                  //     //
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Auth Failed");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Begin Failed");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Connect Failed");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Receive Failed");
    } else if (error == OTA_END_ERROR) {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();                                                         //     //
  Serial.println("OTA Ready");                                                //     //
  Serial.print("IP address: ");                                               //     //
  Serial.println(WiFi.localIP());//////////////////////////////////////////OTA//  


  ///////////////////////////Funciones asociadas a web server (botones)///////
  server.on("/", handle_OnConnect);
  server.on("/emergencia_on", handle_emergenciaon);
  server.on("/emergencia_off", handle_emergenciaoff);
  server.on("/cerrando_", handle_cierra);
  server.on("/abriendo_", handle_abre);
  server.onNotFound(handle_NotFound);
  server.begin();
  Serial.println("HTTP server started");
  /////////////////////////////////////////////////////////////////////////////
  pinMode(D1,INPUT_PULLUP);// sensor abierto 
  pinMode(D2,INPUT_PULLUP);// sensor cerrado 
  pinMode(D5, OUTPUT);// triac  
  pinMode(D7, OUTPUT);// rele abre 
  pinMode(D8, OUTPUT);// rele cierra 
  
  triac=0;
  digitalWrite(D5, triac);
  digitalWrite(D7, LOW);
  digitalWrite(D8, LOW);
  botonabre=0;
  botoncierra=0;
 attachInterrupt(digitalPinToInterrupt(D1), fin_de_carrera_abre,   FALLING);
 attachInterrupt(digitalPinToInterrupt(D2), fin_de_carrera_cierra, FALLING);
}
///////////////////////////////////////////////////////////////////////////////////////loop
void loop() {
  Blynk.run();
  ArduinoOTA.handle();
  server.handleClient();
  timer1.run();
  timer2.run();
if (variablepare==1){pare();}
findecarreraabierto = digitalRead(D1);
findecarreracerrado = digitalRead(D2);
if (estaabriendo==1 && findecarreraabierto==0){ pare();Serial.println("abierto");}
if (estacerrando==1 && findecarreracerrado==0){ pare();Serial.println("cerrado");}
if (botonabre==1    && findecarreraabierto==1 && estaabriendo==0 && variablepare==0){
  pare();
  abre();Serial.println("abriendo");
}

if (botoncierra==1  && findecarreracerrado==1 && estacerrando==0 && variablepare==0){
  pare();
  cierra();Serial.println("cerrando");
}
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////fin de loop
ICACHE_RAM_ATTR void fin_de_carrera_abre(){ 
   Serial.println("fin abierto");
   pare();
}
ICACHE_RAM_ATTR void fin_de_carrera_cierra(){
   Serial.println("fin cerrado");
   pare();
}   
ICACHE_RAM_ATTR void pare(){
  Serial.println("pare");   
     triac=0;
     digitalWrite(D5, triac);
     digitalWrite(D7, LOW);
     digitalWrite(D8, LOW);
     botonabre=0;
     botoncierra=0;
     estaabriendo=0;
     estacerrando=0;
     variablepare=0;
     delay (1000);
}
void cierra(){Serial.println("cierra");
   digitalWrite(D8, HIGH);
    delay (50);
    triac=1;
    digitalWrite(D5, triac);
    estacerrando=1;
}
void abre(){Serial.println("abre");
    digitalWrite(D7, HIGH);
    delay (50);
    triac=1;
    digitalWrite(D5, triac);
    estaabriendo=1;
}
////////////////////////////////////////////////web server
void handle_OnConnect() {
  LED1status = LOW;
  LED2status = LOW;
  Serial.println("on connect");
  server.send(200, "text/html", SendHTML(LED1status,LED2status)); 
}

void handle_emergenciaon(){
  variablepare=1;
  server.send(200, "text/html", SendHTML(false,HIGH));
}

void handle_emergenciaoff(){
  server.send(200, "text/html", SendHTML(true,LOW)); 
}
void handle_cierra() {
  htmlcierra=1; 
  botoncierra=1;
  LED2status = HIGH;
  Serial.println("html cierra ");
  server.send(200, "text/html", SendHTML(LED1status,false)); 
}
void handle_abre() {
  htmlabre=1;
  botonabre=1;
  LED2status = LOW;
  Serial.println("html abre ");
  server.send(200, "text/html", SendHTML(LED1status,false)); 
}
void handle_NotFound(){
  server.send(404, "text/plain", "Not found");
}

String SendHTML(uint8_t led1stat,uint8_t led2stat){
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>Porton automatico </title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}\n";
  ptr +=".button {display: inline-block;width: 80px;height: 80px; background-color: #1abc9c;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
  ptr +=".button-on {background-color: #1abc9c;}\n";
  ptr +=".button-on:active {background-color: #BB070C;}\n";//16a085
  ptr +=".button-off {background-color: #1abc9c;}\n"; //34495e
  ptr +=".button-off:active {background-color: #BB070C;}\n";//2c3e50
  ptr +=".button1 {display: block;width: 200px;height: 60px; background-color: #1abc9c;border: none;color: white;padding: 13px 13px;text-decoration: none;font-size: 20px;margin: 0px auto 15px;cursor: pointer;border-radius: 4px;}\n";
  ptr +=".button1-off {background-color: #1abc9c;}\n";
  ptr +=".button1-on:active {background-color: #BB070C;}\n";//16a085
  ptr +=".button1-on {background-color: #BB070C;font-size: 40px;}\n"; //34495e
  ptr +=".button1-off:active {background-color: #2c3e50;}\n";
  ptr +="p {font-size: 14px;color: #888;margin-bottom: 10px;}\n";
  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<h1>   </h1>\n";
  if(led2stat)
  {ptr +="<a class=\"button1 button1-off\" href=\"/emergencia_off\">STOP activado       pulse para desactivar</a>\n";}
  else
  {ptr +="<a class=\"button1 button1-on\" href=\"/emergencia_on\">STOP</a>\n";}
  ptr +="<h3> </h3>\n";
  ptr +="<p>PORTON OESTE</p><a class=\"button button-off\" href=\"/abriendo_\">ABRE</a><a>     </a><a class=\"button button-off\" href=\"/cerrando_\">CIERRA</a>\n";//}
  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr;
}

Yes, that’s correct, but put them on a line of their own, otherwise you lose the first line of your code (I fixed that for you).

Some observations on your code…

Your void loop is a mess, and not compatible with Blynk. Read this:

You’re using two timer objects…

but one object will support up to 16 timers.
Also, both of your timers are being triggered at exactly the same time, every 2000ms…

You should stagger these.

This is wrong…

It should be like this:

void ICACHE_RAM_ATTR fin_de_carrera_abre(){

When you do it the correct way, the ISR needs to appear before the void loop in your code, otherwise you’ll get a ‘not found in this scope’ compilation error. Alternatively, you can pre-declare the ISRs at the top of your code.

Also, this ISR has no attachInterrupt command in the void setup…

Pete.

thank you very much Pete.
the timer’s tip was good, also the ``` tip
IRAM works better before setup:
work good with internet and blynk connected to blynk server
but the board reset when there isn’t internet and occures an interrupt.

Almost can say that program work, because when it resets the door stops and the board begin waiting new command :wink:

anoter attempt was clean the loop and remove the attachinterrupt and the problem remains
some times the Digital.read is not readed in the right moment.

Do you mean “delay”?

I don’t understand what this means!

Pete.

hello, I mean stack and reset

I // the line attachInterrupt to prevent the reset and detect end of race with Digital.read in the loop
and in order to clean the loop I take all inside the loop and put it inside a timer in this way:

timer3.setInterval(100L, lup); //extract form setup

void loop() {
  Blynk.run();
  ArduinoOTA.handle();
  server.handleClient();
  timer1.run();
  timer2.run();
  timer3.run();
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////fin de loop
void lup(){
if (variablepare==1){pare();}
findecarreraabierto = digitalRead(D1);
findecarreracerrado = digitalRead(D2);
if (estaabriendo==1 && findecarreraabierto==0){ pare();Serial.println("abierto");}
if (estacerrando==1 && findecarreracerrado==0){ pare();Serial.println("cerrado");}
if(botonabre==1    && findecarreraabierto==1 && estaabriendo==0 && variablepare==0){
  pare();
  abre();Serial.println("abriendo");}
if (botoncierra==1  && findecarreracerrado==1 && estacerrando==0 && variablepare==0){
  pare();
  cierra();Serial.println("cerrando");}
}

the result was that when Blink.run attempt to connect, the timer don’t work in it´s time

So instead of taking my advice and having a single timer object, you now have three!

I don’t understand what this means

Pete.

now I corrected the timer 1 and 2 became only timer1
but have not change
I say stack and reset because Idon´t know the programers language for this:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
10:19:59.039 -> 
10:19:59.039 -> Exception (9):
10:19:59.039 -> epc1=0x40105614 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000003 depc=0x00000000
10:19:59.074 -> 
10:19:59.074 -> >>>stack>>>
10:19:59.074 -> 
10:19:59.074 -> ctx: sys
10:19:59.074 -> sp: 3fffec20 end: 3fffffb0 offset: 0190
10:19:59.074 -> 3fffedb0:  3ffe86eb 00000000 006f6461 00000020  
10:19:59.074 -> 3fffedc0:  40105845 010e640b 3ffefc9c 00000000  
10:19:59.074 -> 3fffedd0:  3ffeec30 3ffefc9c 3ffe8ee2 4020886d  
10:19:59.074 -> 3fffede0:  00000000 01099f57 4020aee4 000003e8  
and so on to
3fffffa0:  3fffdad0 00000000 3ffefbfc 4020a9ac  
10:20:00.384 -> <<<stack<<<
10:20:00.384 -> 
10:20:00.384 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
10:20:00.384 -> 
10:20:00.384 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
10:20:00.384 -> 
10:20:00.384 -> load 0x4010f000, len 3584, room 16 
10:20:00.419 -> tail 0
10:20:00.419 -> chksum 0xb0
10:20:00.419 -> csum 0xb0
10:20:00.419 -> v2843a5ac
10:20:00.419 -> ~ld

I decoded and readed but don’t understand enough

This is the stack decoded:

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x40105614
EXCVADDR: 0x00000003

Decoding stack results
0x4020886d: Print::write(char const*) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Print.h line 62
0x4020aee4: __delay(unsigned long) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 51
0x40100429: __digitalWrite(uint8_t, uint8_t) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 86
0x402016bc: pare() at D:\arduino_sketchbook\porton_automatico_8.1/porton_automatico_8.1.ino line 203
0x40100202: fin_de_carrera_cierra() at D:\arduino_sketchbook\porton_automatico_8.1/porton_automatico_8.1.ino line 67
0x401004fe: interrupt_handler(void*) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 141
0x40100588: interrupt_handler(void*) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/interrupts.h line 29
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x401004c4: interrupt_handler(void*) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 135
0x40100398: millis() at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 188
0x4021b3c9: sys_timeout_abs at core/timeouts.c line 194
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x401002c1: esp_schedule() at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 125
0x4020a808: loop_task(ETSEvent*) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 205
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x402180be: _svfprintf_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 554
0x40217e7a: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 234
0x40213e19: _printf_i at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c line 196
0x40217e7a: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 234
0x40217db0: __ssputs_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 180
0x40213f44: _printf_i at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c line 251
0x402182ab: _svfprintf_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 669
0x4021ed04: tcp_write at core/tcp_out.c line 666
0x40214549: snprintf at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/snprintf.c line 120
0x4020aef2: __delay(unsigned long) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 55
0x40204fb4: BlynkMillis() at D:\arduino_sketchbook\libraries\Blynk\src\utility\BlynkDebug.cpp line 290
0x40201a3c: BlynkArduinoClientGen ::connected() at D:\arduino_sketchbook\libraries\Blynk\src/Adapters/BlynkArduinoClient.h line 115
0x40202594: BlynkProtocol   >::sendCmd(unsigned char, unsigned short, void const*, unsigned int, void const*, unsigned int) at D:\arduino_sketchbook\libraries\Blynk\src/Blynk/BlynkProtocol.h line 426
0x402027c8: BlynkApi    > >::virtualWrite (int, unsigned char) at D:\arduino_sketchbook\libraries\Blynk\src/Blynk/BlynkApi.h line 83
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40221778: etharp_raw at core/ipv4/etharp.c line 1166
0x40219c15: glue2esp_linkoutput at glue-esp/lwip-esp.c line 303
0x40219ea2: new_linkoutput at glue-lwip/lwip-git.c line 262
0x4021a2b7: ethernet_output at netif/ethernet.c line 312
0x4021a2c0: ethernet_output at netif/ethernet.c line 319
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x401002a0: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40219ea2: new_linkoutput at glue-lwip/lwip-git.c line 262
0x4022361c: ip4_output_if at core/ipv4/ip4.c line 1547
0x402241d7: ip_chksum_pseudo at core/inet_chksum.c line 395
0x4021f612: tcp_output at core/tcp_out.c line 1363
0x4021e8fd: tcp_create_segment at core/tcp_out.c line 193
0x4020a888: __esp_yield() at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 111
0x4020aef2: __delay(unsigned long) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 55
0x40206e90: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src/include/ClientContext.h line 144
0x402084d4: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/HardwareSerial.h line 162
0x40206da4: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClient.cpp line 141
0x4020639d: WiFiClient::connect(char const*, unsigned short) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClient.cpp line 133
0x40208c88: Print::println(int, int) at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\Print.cpp line 216
0x40201b8c: BlynkArduinoClientGen ::connect() at D:\arduino_sketchbook\libraries\Blynk\src/Adapters/BlynkArduinoClient.h line 58
0x40206fb4: WiFiClient::stopAll() at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClient.cpp line 386
0x40202506: BlynkProtocol   >::run(bool) at D:\arduino_sketchbook\libraries\Blynk\src/Blynk/BlynkProtocol.h line 210
0x4020c9ea: esp8266::MDNSImplementation::MDNSResponder::update() at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266mDNS\src\LEAmDNS.cpp line 1337
0x40204d27: loop() at D:\arduino_sketchbook\porton_automatico_8.1/porton_automatico_8.1.ino line 172
0x4020a9ac: loop_wrapper() at C:\Users\epda\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 198

I have repetitivity and always the same decode (begining and end)

Okay, so this actually means that the board crashes and throws an exception error.

What does your serial monitor say BEFORE the exception error, and what does your current full sketch look like?

Pete.

this happens before th crash:

10:19:45.302 -> [42037] Connecting to blynk-cloud.com:80
10:19:48.730 -> [45468] Login timeout
10:19:50.749 -> [47468] Connecting to blynk-cloud.com:80
10:19:54.249 -> [50990] Login timeout
10:19:56.249 -> [52990] Connecting to blynk-cloud.com:80
10:19:59.039 -> fin cerrado
10:19:59.039 -> pare
10:19:59.039 -> 
10:19:59.039 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Pete.

This is the way it looks, but don’t work: when isn´t internet and inerrupt is called, the board crashes.
I don’t know if some of the lines in the loop also can work inside timer3

///////////////////////////////////////////////////////////////////////////   
#define BLYNK_PRINT Serial                                               //            
//#define BLYNK_DEBUG                                                    //
#include <BlynkSimpleEsp8266.h> //por el uso de BlynkTimer               //   
#include <ESP8266WiFi.h>                                                 //   
#include <ESP8266mDNS.h>                                                 //   
#include <WiFiUdp.h>                                                     //   
#include <ArduinoOTA.h>                                                  //   
//web server                                                             //   
#include <ESP8266WebServer.h>                                            //   
ESP8266WebServer server(80);                                             //   
                                                                         //   
///////////////////////////USUARIO Y CLAVE OTA/////////////              // 
const char *ssid_AP = "acceso_local_sin_internet";       //              //
const char *password_AP = "internet";                    //              //     
const char* ssid = "linksys";                            //              //
const char* password = "";                               //              //
///////////////////////// FIN USUARIO Y CLAVE OTA//////////              //
//Acá se declaran las variables a monitorear localmente por el web server//

bool LED1status = LOW;
bool LED2status = LOW;
bool triac = 0;
bool findecarreracerrado;
bool findecarreraabierto;
bool estaabriendo;
bool estacerrando;
bool abierto;
bool cerrado;
bool botoncierra;
bool botonabre;
bool variablepare;

////////////////////////////Blynk///////////////////////////////////////////////////////////
char auth[] = "9StmFKRVBTvsSixY3xIJTZx01i3sPvWi"; //otro mio
//char auth[] = "e1861a5b6775474aa770d5df240a5868"; //mio
//char auth[] = "ninguno"; //ivan.arnaez.ia@gmail.com
   BLYNK_WRITE(V0){ bool a = param.asInt();if (a==1){variablepare=1;}  } 
   BLYNK_WRITE(V1){ bool b = param.asInt();if (b==1){botonabre=1;}     }  
   BLYNK_WRITE(V2){ bool c = param.asInt();if (c==1){botoncierra=1;}   }                
   WidgetLED led1 (V5); //abriendo
   WidgetLED led2 (V6); //cerrando 
  BlynkTimer timer1,timer3;
void leds(){ //V5 y V6
   bool a1 = digitalRead(D7);
  if (a1==1) {led1.on();}
  else {led1.off();}
   bool a2 = digitalRead(D8);
  if (a2==1) {led2.on();}
  else {led2.off();}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////fin Blynk

//////////////////////////////funciones de attachInterrupt/////
void ICACHE_RAM_ATTR  fin_de_carrera_abre(){                 //
   Serial.println("fin abierto");                            //
   digitalWrite(D7, LOW);                                    //
   digitalWrite(D8, LOW);                                    //
   pare();                                                   //
}                                                            //
void ICACHE_RAM_ATTR  fin_de_carrera_cierra(){               //
   Serial.println("fin cerrado");                            //
   digitalWrite(D7, LOW);                                    //
   digitalWrite(D8, LOW);                                    //
   pare();                                                   //
}                                                            //
/////////////////////////////////////////////////////////////// 

/////////////////////////////////////////////////////////////////////////////SETUP/////

void setup() {
  Serial.begin  (115200);
  delay(100);
  
///////////////////////////////////////// WIFI IP FIJA ////////////////////////////////  
  WiFi.mode(WIFI_AP_STA);                                                            //
  WiFi.softAP(ssid_AP, password_AP);                                                 //
IPAddress local_IP(192, 168, 1, 37);                                                 //
IPAddress gateway(192, 168, 1, 254);                                                 //
IPAddress subnet(255, 255, 255, 0);                                                  //
IPAddress primaryDNS(8, 8, 8, 8);   //optional                                       //
IPAddress secondaryDNS(8, 8, 4, 4); //optional                                       //
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {             //
    Serial.println("STA Failed to configure"); }                                     //
  WiFi.begin(ssid, password);                                                        //
  int c;                                                                             // 
  if (WiFi.status() != WL_CONNECTED && c<10) {delay(500);Serial.print (".");c=c++; } //
  Serial.print("IP address: ");Serial.println(WiFi.localIP());                       //
  WiFi.setAutoReconnect(true);                                                       //
///////////////////////////////////////////////////////////////////////////////////////
  
////////////////////////////////////Blynk setup///////////////////////
                                                                    //
Blynk.config(auth);                                                 //
if (WiFi.status() == WL_CONNECTED) {Serial.println("conectado");    //
    Blynk.connect(5);Serial.println ("Blynk connect");}             //
                                                                    //
timer1.setInterval(2000L, leds);                                    //
timer3.setInterval(100L, lup);                                      //
                                                                    //
                                                                    //
//////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////OTA//     //
  ArduinoOTA.onStart([]() {                                                   //     //
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "sketch";
    } else { // U_SPIFFS
      type = "filesystem";
    }

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {                                                     //     //
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {       //     //
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {                                  //     //
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Auth Failed");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Begin Failed");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Connect Failed");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Receive Failed");
    } else if (error == OTA_END_ERROR) {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();                                                         //     //
  Serial.println("OTA Ready");                                                //     //
  Serial.print("IP address: ");                                               //     //
  Serial.println(WiFi.localIP());//////////////////////////////////////////OTA//  


  ///////////////////////////Funciones asociadas a web server (botones)///////
  server.on("/", handle_OnConnect);
  server.on("/emergencia_on", handle_emergenciaon);
  server.on("/emergencia_off", handle_emergenciaoff);
  server.on("/cerrando_", handle_cierra);
  server.on("/abriendo_", handle_abre);
  server.onNotFound(handle_NotFound);
  server.begin();
  Serial.println("HTTP server started");
  /////////////////////////////////////////////////////////////////////////////
  pinMode(D1,INPUT_PULLUP);// sensor abierto 
  pinMode(D2,INPUT_PULLUP);// sensor cerrado 
  pinMode(D5, OUTPUT);// triac  
  pinMode(D7, OUTPUT);// rele abre 
  pinMode(D8, OUTPUT);// rele cierra 
  
  triac=0;
  digitalWrite(D5, triac);
  digitalWrite(D5, LOW);
  digitalWrite(D7, LOW);
  digitalWrite(D8, LOW);
  botonabre=0;
  botoncierra=0;
 attachInterrupt(digitalPinToInterrupt(D1), fin_de_carrera_abre,   FALLING);
 attachInterrupt(digitalPinToInterrupt(D2), fin_de_carrera_cierra, FALLING);
}
///////////////////////////////////////////////////////////////////////////////////////loop
void loop() {
  Blynk.run();
  ArduinoOTA.handle();
  server.handleClient();
  timer1.run();
  timer3.run();
 } ///////////////////////////////////////////////////////////////////////////////////////////////////////////fin de loop
void lup(){
if (variablepare==1){pare();}
findecarreraabierto = digitalRead(D1);
findecarreracerrado = digitalRead(D2);
if (estaabriendo==1 && findecarreraabierto==0){ pare();Serial.println("abierto");}
if (estacerrando==1 && findecarreracerrado==0){ pare();Serial.println("cerrado");}
if(botonabre==1    && findecarreraabierto==1 && estaabriendo==0 && variablepare==0){
  pare();
  abre();Serial.println("abriendo");}
if (botoncierra==1  && findecarreracerrado==1 && estacerrando==0 && variablepare==0){
  pare();
  cierra();Serial.println("cerrando");}
}

void pare(){
  Serial.println("pare");   
     triac=0;
     digitalWrite(D5, triac);
     digitalWrite(D7, LOW);
     digitalWrite(D8, LOW);
     botonabre=0;
     botoncierra=0;
     estaabriendo=0;
     estacerrando=0;
     variablepare=0;
     delay (1000);
}
void cierra(){Serial.println("cierra");
   digitalWrite(D8, HIGH);
    delay (50);
    triac=1;
    digitalWrite(D5, triac);
    estacerrando=1;
}
void abre(){Serial.println("abre");
    digitalWrite(D7, HIGH);
    delay (50);
    triac=1;
    digitalWrite(D5, triac);
    estaabriendo=1;
}

////////////////////////////////////////////////web server
void handle_OnConnect() {
  LED1status = LOW;
  LED2status = LOW;
  Serial.println("GPIO7 Status: OFF | GPIO6 Status: OFF");
  server.send(200, "text/html", SendHTML(LED1status,LED2status)); 
}

void handle_emergenciaon(){
  variablepare=1;
  server.send(200, "text/html", SendHTML(false,HIGH));
}

void handle_emergenciaoff(){
  server.send(200, "text/html", SendHTML(true,LOW));
}
void handle_cierra() {
  botoncierra=1;
  LED2status = HIGH;
  Serial.println("html cierra ");
  server.send(200, "text/html", SendHTML(LED1status,false)); 
}
void handle_abre() {
  botonabre=1;
  LED2status = LOW;
  Serial.println("html abre ");
  server.send(200, "text/html", SendHTML(LED1status,false)); 
}
void handle_NotFound(){
  server.send(404, "text/plain", "Not found");
}

String SendHTML(uint8_t led1stat,uint8_t led2stat){
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>Porton automatico </title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}\n";
  ptr +=".button {display: inline-block;width: 80px;height: 80px; background-color: #1abc9c;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
  ptr +=".button-on {background-color: #1abc9c;}\n";
  ptr +=".button-on:active {background-color: #BB070C;}\n";//16a085
  ptr +=".button-off {background-color: #1abc9c;}\n"; //34495e
  ptr +=".button-off:active {background-color: #BB070C;}\n";//2c3e50
  ptr +=".button1 {display: block;width: 200px;height: 60px; background-color: #1abc9c;border: none;color: white;padding: 13px 13px;text-decoration: none;font-size: 20px;margin: 0px auto 15px;cursor: pointer;border-radius: 4px;}\n";
  ptr +=".button1-off {background-color: #1abc9c;}\n";
  ptr +=".button1-on:active {background-color: #BB070C;}\n";//16a085
  ptr +=".button1-on {background-color: #BB070C;font-size: 40px;}\n"; //34495e
  ptr +=".button1-off:active {background-color: #2c3e50;}\n";
  ptr +="p {font-size: 14px;color: #888;margin-bottom: 10px;}\n";
  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<h1>   </h1>\n";
   // ptr +="<h3>DOS BOTONES</h3>\n";
  
  if(led2stat)
  {ptr +="<a class=\"button1 button1-off\" href=\"/emergencia_off\">STOP activado       pulse para desactivar</a>\n";}
  else
  {ptr +="<a class=\"button1 button1-on\" href=\"/emergencia_on\">STOP</a>\n";}
  ptr +="<h3> </h3>\n";
  ptr +="<p>PORTON</p><a class=\"button button-off\" href=\"/abriendo_\">ABRE</a><a>     </a><a class=\"button button-off\" href=\"/cerrando_\">CIERRA</a>\n";//}
  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr;
}

Okay, you obvioulsy dont uindersand what I was saying about only having ONE timer instance.

This…

BlynkTimer timer1,timer3;

timer1.setInterval(2000L, leds);                                    //
timer3.setInterval(100L, lup); 

  timer1.run();
  timer3.run();

should be this…

BlynkTimer timer;

timer.setInterval(2000L, leds);                                    //
timer.setInterval(100L, lup); 

  timer.run();

It’s nit a good idea to call a function from within an ISR, so this:

   pare();   

is a bad move, and this delay within the pare function is an extremely bad move…

Pete.

Thank you very much Pete, I value the time that you gave me.
I had to travel to my father’s home and leave my nodemcu at home.
In time I was searching about how to replace delay (). I’ve readed some link about simpletimer that you gave in other answer.
finally I found “timer.setTimeout(1000,function);” in order to avoid to use delay(); this work with the blynk timer.
Also I replace the call of function pare() that was inside the interrupt and place a value into a variable and a digitalWrite that makes stop the motor
The variable that is checked by the pseudo loop (I named lup() and one timer call the lup() function every 100 miliseconds).

Work well, No more crashes.