BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Random Device Offline (Clean Loop)

Good Day!
My project, running on a D1 mini Pro, keeps randomly going offline for varying amounts of times, sometime for a couple of seconds and sometime for a whole day or more! I have to reset the board and it works perfectly, until it decides to go offline.
I am using the latest Blynk version, ESP Core and arudino IDE.

I am convinced it is not my code, as when I flash a skeleton (blank) Blynk Edgent code with only the credentials, on ANOTHER D1 mini Pro, the same thing happens. I’ve tried two different ISP and that hasn’t solved the issue. Another thing i’ve noticed is that the device is still connected to the router even though Blynk says its offline (I verified this by looking at the router admin portal, it says its online).
Could this be a server issue on Blynk’s side?!
I am connecting to “Region: sgp1”. Is there a way to change the server my device connects to, perhaps somewhere close to where I live?
I look forward to any inputs and advice :slight_smile:
Thank you

    #define BLYNK_TEMPLATE_ID "xxx"
    #define BLYNK_DEVICE_NAME "xxx"
    //#define BLYNK_AUTH_TOKEN "xxx"
    #define BLYNK_PRINT Serial
    #define BLYNK_FIRMWARE_VERSION        "5.4"
    #define APP_DEBUG

    #define BLYNK_GREEN     "#23C48E"
    #define BLYNK_RED       "#D3435C"
    #define BLYNK_YELLOW    "#ED9D00"

    #define USE_WEMOS_D1_MINI

    #include "BlynkEdgent.h"

    int CEBsensor = 0; 
    int CEBstate = 0;
    int Timerstate = 0;
    int InvTimerstate = 0;
    int inverterstate = 0;

    //Voltage Sensor 
    int Vsensor = A0; 
    float correctionfactor = 7.40; 
    float vout = 0.0; 
    float vin = 0.0; 
    float fuelcon = 0.0;

    float R1 = 30000; 
    float R2 = 7500;
    int value = 0;


    //Declare millis for timers
    unsigned long msec = 0;
    unsigned long msec2 = 0;
    float times = 0.0;
    float hourmeter = 0.0;

    BlynkTimer timer;

    //Blynk LED Widgets 
    WidgetLED led1(V3); //COIL LED
    WidgetLED led2(V7); //FUEL LED
    WidgetLED led3(V4); //STARTER LED
    WidgetLED led13(V13); //GENERATOR SHUTOFF LED 
    WidgetLED led14(V14); //CEB STATUS LED
    WidgetLED led15(V18); //INVERTER STATUS LED
    WidgetLED led16(V20); //INVERTER SHUTOFF LED
    WidgetLED led17(V24); //CHANGEOVER RELEASE INDICATOR

    int newTimer = 1;

    void setup()
    {
      Serial.begin(115200);
      delay(100); 
      pinMode(D0, OUTPUT);  //STARTER Relay 
      pinMode(D5, OUTPUT);  //FUEL Relay
      pinMode(D6, OUTPUT);  //COIL Relay
      pinMode(D7, OUTPUT);  //INVERTER Relay
      pinMode(D1, INPUT);   //CEB LDR Sensor
      pinMode(Vsensor, INPUT); //Voltage Sensor (A0)
      {
        digitalWrite(D0,HIGH);
        digitalWrite(D5,HIGH);  //(To prevent self-trigger during initial boot)
        digitalWrite(D6,HIGH);
      }
     
      BlynkEdgent.begin();

      timer.setInterval(1000L,CEBsensor1);
      timer.setInterval(1000L,runtime); 
      timer.setInterval(1000L,invertertime);
      timer.setInterval(10000L,Voltagesensor1); 
    }

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


    BLYNK_CONNECTED() {
       Blynk.syncVirtual(V10,V18); //Works, Doesn't get triggered when not on
    }

    void invertertime()
    {
     if(CEBstate == LOW){
      if(inverterstate == HIGH){
        led15.on(); 
        Blynk.setProperty(V10, "color", "#23C48E");
        Blynk.setProperty(V18, "color", "#23C48E"); //Inverter Status (ON) GREEN
        digitalWrite(D7,HIGH); //INV RELAY ON
        delay(100);
        Blynk.setProperty(V2, "offLabel", "OFF Inverter Before Starting");
        Blynk.setProperty(V2, "onLabel", "OFF Inverter!");
       } else {
        Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
        Blynk.setProperty(V10, "color", "#ED9D00");
        digitalWrite(D7,LOW); //INV RELAY OFF
        delay(100);
        Blynk.setProperty(V2, "offLabel", "Hold to Start");
        Blynk.setProperty(V2, "onLabel", "Release");
       }
      } else {
      }
      
     if(inverterstate == HIGH && CEBsensor ==LOW){ 
       led16.on(); //Inverter Shutoff Indicator ON
       yield();
       } else {
       led16.off(); //Inverter Shutoff Indicator OFF
       yield();
      }
    }

    void runtime() 
    {
      if(CEBstate == HIGH && Timerstate == HIGH){
        times = ((millis() - msec));
        Blynk.setProperty(V16, "label", "Current Generator Run Time");
        Blynk.setProperty(V17, "label", "Current Fuel Consumption");
        {
        String readableTime;
        getReadableTime(readableTime);
        Blynk.virtualWrite(V16, readableTime);
        Blynk.virtualWrite(V17, 1.7 * ((millis() - msec)/1000)/3600);
        delay(500);
        }
       } else {
       }

        if(InvTimerstate == HIGH && CEBstate == LOW && Timerstate == LOW){
        times = ((millis() - msec2));
        Blynk.setProperty(V16, "label", "Inverter Run Time");
        {
        String readableTime;
        getReadableTime(readableTime);
        Blynk.virtualWrite(V16, readableTime);
        }
        delay(500);
       } else {
       }
    }

    void getReadableTime(String &readableTime) {
      unsigned long currentMillis;
      unsigned long seconds;
      unsigned long minutes;
      unsigned long hours;
      unsigned long days;

      currentMillis = times;
      seconds = currentMillis / 1000;
      minutes = seconds / 60;
      hours = minutes / 60;
      days = hours / 24;
      currentMillis %= 1000;
      seconds %= 60;
      minutes %= 60;
      hours %= 24;

      if (days > 0) {
        readableTime = String(days) + " ";
      }

      if (hours > 0) {
        readableTime += String(hours) + "H:";
      }

      if (minutes < 10) {
        readableTime += "0";
      }
      readableTime += String(minutes) + "m:";

      if (seconds < 10) {
        readableTime += "0";
      }
      readableTime += String(seconds) + "s";
    }

    BLYNK_WRITE(V1) 
    //attach Button on virtual V1,  
    //it will control the Coil 
    { 
       if (param.asInt() == 1){ 
      delay(100);
      digitalWrite(D6,LOW); //COIL RELAY ON
      delay(100);
      led1.on();
      msec = millis();
      CEBstate = 1;
      } 
       if (param.asInt() == 0){ 
      delay(100);
      digitalWrite(D6,HIGH); //COIL RELAY OFF
      delay(100);
      led1.off();
      CEBstate = 0;
      Blynk.setProperty(V16, "label", "Previous Generator Run Time");
      Blynk.setProperty(V17, "label", "Previous Fuel Consumption");
      //Blynk.setProperty(V23, "isDisabled", true);
      delay(100);
      Blynk.logEvent("generator_off");
      } 
    } 

    BLYNK_WRITE(V2) 
    //attach Button on virtual V2,  
    //it will control the Starter 
    { 
       if(param.asInt()){
        newTimer = timer.setTimeout(2000,Starter); // button pressed for >2Sec
      } 
      else {
        timer.disable(newTimer);
      }
    }

    void Starter() 
    {
      
      if(inverterstate == LOW){ 
       led3.on();
       digitalWrite(D0,LOW); //STARTER CRANK ON
       delay(1200); //CRANK DURATION
       digitalWrite(D0,HIGH); //STARTER CRANK OFF
       led3.off();
       Blynk.logEvent("generator_on");
       //Blynk.setProperty(V23, "isDisabled", true);
      }else{
      }
    }

    BLYNK_WRITE(V9) 
    //attach Button on virtual V9,  
    //This will control the Fuel
    { 
      if (param.asInt() == 1){ 
       delay(100);
       digitalWrite(D5,LOW); //FUEL RELAY ON
       delay(100);
       led2.on();
       Timerstate = 1;
     } 
      if (param.asInt() == 0){ 
       delay(100);  
       digitalWrite(D5,HIGH); //FUEL RELAY OFF
       delay(100);
       led2.off();
       Timerstate = 0;
     }
    } 

    BLYNK_WRITE(V10) 
    //attach Button on virtual V10,  
    //it will control the Inverter Relay
    { 
       ESP.wdtFeed();
       if (param.asInt() == 1){   
        inverterstate = 1;
        msec2 = millis();
        InvTimerstate = 1;
        Blynk.logEvent("inverter_on");
        Blynk.setProperty(V22, "isDisabled", true);
        Blynk.setProperty(V23, "isDisabled", false);
      } 
       if (param.asInt() == 0){ 
        inverterstate = 0;
        InvTimerstate = 0;
        Blynk.logEvent("inverter_off");
        Blynk.setProperty(V22, "isDisabled", false);
      } 
    } 


    BLYNK_WRITE(V15) 
    //attach Button on virtual V15,  
    //This will update System Status
    { 
        if (param.asInt() == 1){ 
          Blynk.virtualWrite(V8, map(WiFi.RSSI(), -110, -30, 30, 100));
          delay(100);
          
     } 
        if (param.asInt() == 0){ 
     }
    }

    BLYNK_WRITE(V19) 
    //attach Button on virtual V19,  
    //This will reset Coil/Fuel Status
    { 
        if (param.asInt() == 1){ 
          Blynk.virtualWrite(V1, 0);
          led1.off();
          Blynk.virtualWrite(V9, 0);
          led2.off();
          delay(100);
          Blynk.setProperty(V16, "label", "Previous Run Time");
          Blynk.setProperty(V17, "label", "Previous Fuel Consumption");
          delay(100);
          Blynk.logEvent("generator_off");
          Timerstate = 0;
          CEBstate = 0;
     } 
      if (param.asInt() == 0){ 
     }
    } 

    void CEBsensor1() 
    //Run every second 
    {
      CEBsensor = digitalRead(D1); //LDR Sensor 
      Blynk.virtualWrite(V12, CEBsensor);
       
       //If COIL ON and CEBsensor LOW, Trigger "Grid Restored" Blynk Automation  
       if(CEBsensor == LOW && CEBstate == HIGH){ 
       led13.on(); //Shutoff Indicator ON
       yield();
       } else {
       led13.off(); //Shutoff Indicator OFF
       yield();
       }

       //CEB STATUS LED
       if(CEBsensor == HIGH){
       led14.on(); 
       Blynk.setProperty(V14, "color", "#D3435C"); //CEB Status (ON) RED
       Blynk.logEvent("grid_failure");
       Blynk.setProperty(V23, "isDisabled", false);
       Blynk.setProperty(V22, "isDisabled", false);
       yield();
       } else {
       Blynk.setProperty(V14, "color", "#23C48E"); //CEB Status (ON) GREEN
       Blynk.setProperty(V23, "isDisabled", true);
       Blynk.setProperty(V22, "isDisabled", true);
       yield();
       }  
       
    }

    void Voltagesensor1() 
    //Run every 10 sec
    {
       int sdata = 0; 
      
       value = analogRead(Vsensor); 
       vout = (value * 5.0) / 1024.0; 
       vin = vout / (R2/(R1+R2));
     
       vin = vin - correctionfactor; 
        
       Blynk.virtualWrite(V5, vin);
       yield();

       if(vin < 12.0){
        Blynk.setProperty(V5, "color", "#D3435C"); //If UPS Voltage < 12.5v, Gauge RED
       }else{
        Blynk.setProperty(V5, "color", "#F7CE46"); //If UPS Voltage > 12.5v, Gauge ORANGE
       } 
    } 

    //BETA
    BLYNK_WRITE(V22) 
    //attach Button on virtual V22,  
    //it will control the GENtoINV 
    { 
       if(param.asInt()){
        newTimer = timer.setTimeout(2000,GENtoINV); // button pressed for >2Sec
      } 
      else {
        timer.disable(newTimer);
      }
    }

    void GENtoINV() 
    {
      
      if(inverterstate == LOW){ 
      { 
        led17.on(); 
        //FUEL
        Blynk.virtualWrite(V1, 0);
        led1.off();
        digitalWrite(D6,HIGH); //COIL RELAY OFF
        delay(100);
        CEBstate = 0;
        Blynk.setProperty(V16, "label", "Previous Generator Run Time");
        Blynk.setProperty(V17, "label", "Previous Fuel Consumption");
        delay(100);
        Blynk.logEvent("generator_off");  
      }
      delay(1500); 
      {
        //COIL
         Blynk.virtualWrite(V9, 0);
         led2.off();
         digitalWrite(D5,HIGH); //FUEL RELAY OFF
         delay(100);
         Timerstate = 0;
      }
      
      delay(2000);
      {
        //INV Relay
         Blynk.virtualWrite(V10, HIGH);
         inverterstate = 1;
         msec2 = millis();
         InvTimerstate = 1;
         Blynk.logEvent("inverter_on");
         led17.off();
      }
      
      }else{
      }
    }

    BLYNK_WRITE(V23) 
    //attach Button on virtual V23,  
    //it will control the INVtoGEN 
    { 
       if(param.asInt()){
        newTimer = timer.setTimeout(2000,INVtoGEN); // button pressed for >2Sec
      } 
      else {
        timer.disable(newTimer);
      }
    }

    void INVtoGEN() 
    {
      
      {
        //INV RELAY OFF
        led17.on();
        inverterstate = 0;
        InvTimerstate = 0;
        Blynk.logEvent("inverter_off");
        {
        Blynk.virtualWrite(V10, 0);
        Blynk.setProperty(V10, "color", "#ED9D00");
        Blynk.setProperty(V18, "color", "#ED9D00"); //Inverter Status (OFF) Yellow
        digitalWrite(D7,LOW); //INV RELAY OFF
        delay(100);
        Blynk.setProperty(V2, "offLabel", "Hold to Start");
        Blynk.setProperty(V2, "onLabel", "Release");
        }
        Blynk.setProperty(V22, "isDisabled", false);
      }
      delay(3000);
      {  
        //FUEL
        Blynk.virtualWrite(V9, 1);
        digitalWrite(D5,LOW); //FUEL RELAY ON
        led2.on();
        Timerstate = 1;  
      }
      delay(1500); 
      {
        //COIL
        Blynk.virtualWrite(V1, 1);
        digitalWrite(D6,LOW); //COIL RELAY ON
        led1.on();
        msec = millis();
        Blynk.setProperty(V23, "isDisabled", true);
        CEBstate = 1;
      }
      delay(2000);
      {
        //STARTER
        if(inverterstate == LOW){ 
        led3.on();
        digitalWrite(D0,LOW); //STARTER CRANK ON
        delay(1200); //CRANK DURATION
        digitalWrite(D0,HIGH); //STARTER CRANK OFF
        led3.off();
        Blynk.logEvent("generator_on");
        led17.off();
      }
      }
      
    }

Why do you have this in your void loop?
What do you think it achieves?

Pete.

Greetings Pete,
My bad I have pasted an outdated code, thank you for bringing it to my attention.
I came across another thread where that piece of code apparently helped but in my case it didnt. It was a trial and error attempt and at this point I am clueless to what is causing the issue.

Okay, if you post the ACTUAL code you are running I’ll take a look at it.

Having your serial output at the point when the device goes offline would also be useful, along with your Settings.h file if you’ve modified it at all.

Pete.

Pete, I have updated Post#2 with the up-to date code that is currently running on the D1 Mini.
Currently the board is powered using a 12V suppy and set down to 5Vs.
At the moment I am not at the device but when I get back, I will connect it to my computer and leave the serial monitor open and will attach the output.

As for the settings.h file, the only changes I’ve made is increase the timeout values and reset pins
#define WIFI_NET_CONNECT_TIMEOUT 160000
#define WIFI_CLOUD_CONNECT_TIMEOUT 160000

Full Settings.h

     #if defined(USE_NODE_MCU_BOARD) || defined(USE_WEMOS_D1_MINI)

      #if defined(USE_WEMOS_D1_MINI)
        #warning "This board does not have a button. Connect a button to gpio0 <> GND"
      #endif

      #define BOARD_BUTTON_PIN            D8
      #define BOARD_BUTTON_ACTIVE_LOW     true

      #define BOARD_LED_PIN               2
      #define BOARD_LED_INVERSE           true
      #define BOARD_LED_BRIGHTNESS        255

    #elif defined(USE_SPARKFUN_BLYNK_BOARD)

      #define BOARD_BUTTON_PIN            D8
      #define BOARD_BUTTON_ACTIVE_LOW     true

      #define BOARD_LED_PIN_WS2812        D7
      #define BOARD_LED_BRIGHTNESS        64

    #elif defined(USE_WITTY_CLOUD_BOARD)

      #define BOARD_BUTTON_PIN            D7
      #define BOARD_BUTTON_ACTIVE_LOW     true

      #define BOARD_LED_PIN_R             15
      #define BOARD_LED_PIN_G             12
      #define BOARD_LED_PIN_B             13
      #define BOARD_LED_INVERSE           false
      #define BOARD_LED_BRIGHTNESS        64

    #else

      #warning "Custom board configuration is used"

      #define BOARD_BUTTON_PIN            D8                     // Pin where user button is attached
      #define BOARD_BUTTON_ACTIVE_LOW     true                  // true if button is "active-low"

      //#define BOARD_LED_PIN             D7                     // Set LED pin - if you have a single-color LED attached
      //#define BOARD_LED_PIN_R           15                    // Set R,G,B pins - if your LED is PWM RGB
      //#define BOARD_LED_PIN_G           12
      //#define BOARD_LED_PIN_B           13
      //#define BOARD_LED_PIN_WS2812      4                     // Set if your LED is WS2812 RGB
      #define BOARD_LED_INVERSE           false                 // true if LED is common anode, false if common cathode
      #define BOARD_LED_BRIGHTNESS        64                    // 0..255 brightness control

    #endif


    /*
     * Advanced options
     */

    #define BUTTON_HOLD_TIME_INDICATION   3000
    #define BUTTON_HOLD_TIME_ACTION       10000
    #define BUTTON_PRESS_TIME_ACTION      50

    #define BOARD_PWM_MAX                 1023

    #if !defined(CONFIG_DEVICE_PREFIX)
    #define CONFIG_DEVICE_PREFIX          "Blynk"
    #endif
    #if !defined(CONFIG_AP_URL)
    #define CONFIG_AP_URL                 "blynk.setup"
    #endif
    #if !defined(CONFIG_DEFAULT_SERVER)
    #define CONFIG_DEFAULT_SERVER         "blynk.cloud"
    #endif
    #if !defined(CONFIG_DEFAULT_PORT)
    #define CONFIG_DEFAULT_PORT           443
    #endif

    #define WIFI_CLOUD_MAX_RETRIES        500
    #define WIFI_NET_CONNECT_TIMEOUT      160000
    #define WIFI_CLOUD_CONNECT_TIMEOUT    160000
    #define WIFI_AP_IP                    IPAddress(192, 168, 4, 1)
    #define WIFI_AP_Subnet                IPAddress(255, 255, 255, 0)
    //#define WIFI_CAPTIVE_PORTAL_ENABLE

    #define USE_TICKER
    //#define USE_TIMER_ONE
    //#define USE_TIMER_THREE
    //#define USE_TIMER_FIVE
    //#define USE_PTHREAD

    #define BLYNK_NO_DEFAULT_BANNER

    #if defined(APP_DEBUG)
      #define DEBUG_PRINT(...)  BLYNK_LOG1(__VA_ARGS__)
      #define DEBUG_PRINTF(...) BLYNK_LOG(__VA_ARGS__)
    #else
      #define DEBUG_PRINT(...)
      #define DEBUG_PRINTF(...)
    #endif

What confuses me more is why this same issue occurs even when I upload a blank BlynkEdgent file from the examples folder. Is it safe to assume that the my code isn’t casuing this issue?

Are you powering the board via the 5v and GND pins, or via the USB port?

Pete.

USB Port
The issue also happens when I power the board directly from the computer

So you’re always powering it via USB.
Have you tried a different USB cable?

Is thee a reason why you’ve not kept the defaults and connected a push bottom between GPIO0 (the pin labelled D3) and GND ?
When you used a clean Edgent example did you keep Settings.h in its original state and add this button?

I don’t like to see “D” numbers used in code, especially when you also use GPIO numbers in other places too.

The blocking delays, and the timers that all attempt to run at the same time probably don’t help with your device stability.

Pete.

Pete,
Yes I have tried a different USB cable in hopes it will solve the problem

I will copy and paste the default Settings.h file and use the GPIO pin numbers instead of “D” pins as suggested.

When you used a clean Edgent example did you keep Settings.h in its original state and add this button?

I made zero changes to the Settings.h and the other configuration files.

The blocking delays, and the timers that all attempt to run at the same time probably don’t help with your device stability.

Unfortunately with my limited knowledge I don’t know how to make them run one after eachother :c

Take a look at the “Staggering Timers” section…

TBH, you’d be better putting the untouched Edgent example sketch (untouched except for adding-in the two lines of firmware configuration and un-commenting the correct board type) onto a different Wemos and testing that way.

Do you actually need the Edgent functionality? If so, is it just the Blynk.Ait functionality of dynamic provisioning too?

Pete.

Thank you for the Guide to use BlynkTimer, I will have a look and firgure out how to incopparate it in my existing code. I’m a bit hesistant though as I have so many delay() functions to replace…

TBH, you’d be better putting the untouched Edgent example sketch (untouched except for adding-in the two lines of firmware configuration and un-commenting the correct board type) onto a different Wemos and testing that way.

I am doing exactly this. I initially thought it was a bad D1 mini with the notorious underpowered voltage regulator (100mA peak current as opposed to the correct 500mA), but I verified that and my boards have the correct VR.

Do you actually need the Edgent functionality? If so, is it just the Blynk.Ait functionality of dynamic provisioning too?
I’m sorry but what do you mean by needing the edgent function?

You’ve chosen to use the Edgent example as the basis for your sketch.
Edgent is an extremely complex example which provides Blynk.Air (OTA updates) and Dynamic Provisioning (WiFi credentials are enter via the app, and the Auth token is allocated dynamically) as opposed to static provisioning where the WiFi credentials are hard-coded in your sketch along with your Auth token.

Why have you chosen the Edgent example as the basis for your sketch, instead of a much simpler static provisioning example?

Pete.

Interesting!
I assumed for many years now that BlynkEdgent is the libary for Blynk 2.0 and that the other examples were for Blynk Legacy… My bad for the assumption.

I do occasionally use OTA since the D1 mini is housed in a water tight encloser but I don’t mind loosing that function if it means for a more reliable system!

I don’t mind testing it with an alternate libary. Would you recommend the use of example “ESP8266_Standalone” instead? Can I simply paste the main part of my code from Edgent to this?

Yes.

If you’re careful yes, but avoid all the Edgent related stuff.
Personally, I’d start with the standalone example and get it online before going any further. Basically, if it’s not code that you’ve written then leave it out.

It’s possible to add Blynk.Air functionality into the standalone sketch, but I’d do this last of all, once everything else is working correctly.
Details here…

Pete.

Understood, This is my code and I just copy pasted the main section, avoiding Edgent code and it complied succesfully. I will flash it when I get back home and give you an update soon.
Thank you

1 Like

Greetings!
Apologies for the dissapearance, I have been busy trying as suggested and wanted to test and be absolutly sure before giving an update on my situation.

Unfortunately even after convering D pins to GPIO number and reducing the number of delays to the absoulute bare minimum, my device still goes offline. I am still trying to understand millis function which I am practicing to incoperate on another project before doing so on this project, which I can’t risk anymore failure.

I tried moving to “ESP8266_Standalone” but that too goes offline randomly and for many many hours if not days, until I unplug the power. I tried with a blank sketch, just the skeleton code with credential only ,and it still crashes (therefore hopefully concluding that it isn’t the code that is making my device go offline).

I now removed the board from its enclosure and connected it to my computer with the serial monitor open. I will leave it like this till it goes offline again and will upload any crash messages displayed.
Thank you.

You shouldn’t need to use delays at all in the vast majority of situations.

Doing a millis comparison to figure-out if an amount of time has passed isn’t the solution either, in most cases.
millis comparisons only work inside a loop, and the BLYNK_WRITE callbacks don’t loop. You could create a loop, but this would just block code executor be no better than delays, or you could do the millis comparison in the void loop, but that just clutters your void loop, which isn’t what you want either - if you want to avoid disconnections.

Using BlynkTimer is the preferred solution.

So far you’ve been talking about the device going offline, not crashing.
When it crashes what crash dump data do you see in the serial monitor, and have you tried decoding this with the ESP Exception Decoder?

Thats a sensible approach.

Is the device crashing, or simply going offline?
Have you added any code to check when it goes offline, and attempt to re-connect?

This all seems very hypothetical at the moment, because you aren’t providing hard facts and posting the code and full details of the symptoms.

Pete.

Hello Pete!
Up until today I have not logged the serial monitor as the board was in a sealed box, powered with its own power supply. As mensioned I have removed the board and currently monitoring the serial output.

I am yet to comfirm from the serial monitor output whether board is crashing or the simply going offline. However looking at the blynk app timeline, the device is mojority of the time offline for exactly 7 Hours and 42 Minutes and comes back online. Its even gone offline for 2 Days and 8 Hours.

But as I mensioned in my first post, the board is still connected to my router, I confirmed this by viewing the router admin portal.

Also the time displayed in the serial monitor is not my current time where I am living, could that possibly cause any issues?

Please see attached serial monitor when the device booted a couple of hours ago, and the app timeline.

So you’re using the Edgent example againn. Why?

Pete.