A problem that did not happen to me in blynk 1.0

This is the code after modification, but the problem is still there

#define BLYNK_TEMPLATE_ID "TMPLJdwoGQJZ"
#define BLYNK_DEVICE_NAME "ULTRA TECH"
#define BLYNK_FIRMWARE_VERSION        "0.3.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#include <ModbusMaster.h>
#include <SoftwareSerial.h>
#include "BlynkEdgent.h"
#include <TimeLib.h>
#include <ESP8266Ping.h>

#define VT_PIN A0
#define vPIN_LedRelay1                V0   // ليد ريلي 1
#define vPIN_Relay1                   V1   // فيرجوال ريلي 1
#define vPIN_LogTerminal              V2   // terminal
#define vPIN_OnOffTimr1               V3   // تفعيل وتعطيل مؤقت 1
#define vPIN_BatteryVoltage           V4  // فيرجوال الفولت 
#define vPIN_LowVoltage               V5   //فيرجوال انخفاض الفولط للرسالة
#define vPIN_XVoltage                 V6   // معايرة الفولت
#define vPIN_LogTerminalPing          V7   // تيرمنال البينغ
#define vPIN_OnOffPing                V8   // تفعيل وتعطيل البينغ
#define vPIN_Timer1                   V15  // مؤقت 1
#define vPIN_Time                     V16  // الساعة
#define vPIN_Date                     V17  // التاريخ

BlynkTimer UltraTimer;

WidgetLED LedRelay1(vPIN_LedRelay1);

const int Relay1  = D5;
const int Switsh1  = D6;
bool  OnOffTimr1 =LOW;
bool  OnOffPing =LOW;
bool buttonStatus1 = 0;
bool buttonTemp1 = 0;
bool IsFirstRun = 1;
float XVolt = 0;
int vt_read = 0;
float Voltage = 50;
float LowVolt = 0;
bool AlertMsgLowVolt = 0;
const char* remote_host = "8.8.8.8"; // ايبي لعمل بينغ عليه
int WaitBlynk1 = 60;
int Wait1 = 0;



int StartH1;
int StartM1;
int StartS1;
int StopH1;
int StopM1;
int StopS1;

int start_time;       // وقت البدء المجدول (بالثواني)
int active_duration;  // مدة التنشيط (بالثواني)
int weekdays[8];      // أيام الأسبوع المجدولة (الصفيف 8: 0 غير مستخدم)

BLYNK_CONNECTED()                     // استعادة القيم من السيرفر بعد اعادة اقلاع الجهاز
{
  Blynk.sendInternal("rtc", "sync");
  if (IsFirstRun==1)
  {
  delay(200);
  Blynk.syncVirtual(vPIN_Timer1,vPIN_OnOffTimr1,vPIN_Relay1,vPIN_OnOffPing,vPIN_XVoltage,vPIN_LowVoltage);  
}}



///////////////// BLYNK_WRITES ////////////////////////////



BLYNK_WRITE(vPIN_Relay1)                        // اداة التحكم في الريلي
{
  if (param.asInt() == 1)
  {
    digitalWrite(Relay1, HIGH);
    LedRelay1.on();
    Serial.println("1 تم التشغيل من التطبيق");
    Blynk.notify("1 تم التشغيل من التطبيق");
   // Blynk.virtualWrite(vPIN_LogTerminal,"تم التشغيل من الموبايل الساعة: "+String(hour()) + ":" + minute() + ":" + second()+"  بتاريخ:  " +String (day()) + "-" + month() + "-" + year());
     
  }
  else
  {
    digitalWrite(Relay1, LOW);
    LedRelay1.off();
    Serial.println("1 تم الايقاف من التطبيق");
    Blynk.notify("1 تم الايقاف من التطبيق");
   // Blynk.virtualWrite(vPIN_LogTerminal,"تم الإيقاف من الموبايل الساعة: "+String(hour()) + ":" + minute() + ":" + second()+"  بتاريخ:  " +String (day()) + "-" + month() + "-" + year());
    
   
  }
}


BLYNK_WRITE(vPIN_XVoltage)              // اداة معايرة فولت البطاريات
{
  XVolt=param.asFloat();
}


BLYNK_WRITE(vPIN_LowVoltage)             // اداة ارسال اشعار عند انخفاض الفولت
{
  LowVolt=param.asFloat();
  Serial.println("تم تغيير الحد الأدنى للفولط");
}



BLYNK_WRITE(vPIN_OnOffPing)            // اداة تفعيل وتعطيل البينغ
{
  OnOffPing=param.asFloat();
  if (OnOffPing==HIGH){
   // Blynk.virtualWrite(vPIN_LogTerminal1,"تم تفعيل الاتصال الذكي الوقت:  " +String(hour()) + ":" + minute() + ":" + second()+"  " +String (day()) + "-" + month() + "-" + year() );
  } 
    if(OnOffPing==LOW){
    //Blynk.virtualWrite(vPIN_LogTerminal1,"تم تعطيل الاتصال الذكي الوقت:  " +String(hour()) + ":" + minute() + ":" + second()+"  " +String (day()) + "-" + month() + "-" + year() );
  }
}


BLYNK_WRITE(vPIN_OnOffTimr1)                    // ادا تفعيل وتعطيل المؤقت الزمني
{
  OnOffTimr1=param.asFloat();
  if (OnOffTimr1==HIGH){
    Blynk.virtualWrite(vPIN_LogTerminal,"تم تفعيل المؤقت1 الوقت:  " +String(hour()) + ":" + minute() + ":" + second()+"  " +String (day()) + "-" + month() + "-" + year() );
  }
  
    if(OnOffTimr1==LOW){
    Blynk.virtualWrite(vPIN_LogTerminal,"تم تعطيل المؤقت1 الوقت:  " +String(hour()) + ":" + minute() + ":" + second()+"  " +String (day()) + "-" + month() + "-" + year() );
  }
}



BLYNK_WRITE(vPIN_Timer1)                                   // اداة ادخال الوقت في المؤقت رقم 1
{
  setTime(param);
}



BLYNK_WRITE(InternalPinRTC)                           // يتحقق من قيمة InternalPinRTC عند المزامنة مع Blynk
{
  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
  unsigned long blynkTime = param.asLong();
  
  if (blynkTime >= DEFAULT_TIME) // تحقق من أن العدد الصحيح وقت صالح (أكبر من 1 كانون الثاني (يناير) 2013)
  {
   setTime(blynkTime);                      // مزامنة الساعة في مكتبة TimeLib مع القيمة المستلمة من Blynk
   //Serial.println(blynkTime);
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "-" + month() + "-" + year();
  Serial.println(" التاريخ: "+String(currentDate)+"الساعة:   "+String(currentTime));
  Blynk.virtualWrite(vPIN_Time, "الساعة:  "+String(currentTime));  
  Blynk.virtualWrite(vPIN_Date, "التاريخ:  "+String(currentDate));        
  }
}




/////////////////////// VOIDS /////////////////////////

void checkStatusButton1()   // تابع التشغيل من الطقة
{
  buttonStatus1 = digitalRead(Switsh1);

  if (buttonStatus1 != buttonTemp1)
  {
    if (buttonStatus1 == HIGH) {
      digitalWrite(Relay1, HIGH);
      Blynk.virtualWrite(vPIN_Relay1, 1);
      LedRelay1.on();
      Serial.println("1 تم التشغيل يدويا");
      Blynk.notify("1 تم التشغيل يدويا");
      Blynk.virtualWrite(vPIN_LogTerminal,"تم التشغيل من الطقة الساعة: "+String(hour()) + ":" + minute() + ":" + second()+"  بتاريخ:  " +String (day()) + "-" + month() + "-" + year());
      
    }
    else {
      digitalWrite(Relay1, LOW);
      Blynk.virtualWrite(vPIN_Relay1, 0);
      LedRelay1.off();
      Serial.println("1 تم الايقاف يدويا");
      Blynk.notify("1 تم الايقاف يدويا");
      Blynk.virtualWrite(vPIN_LogTerminal,"تم الإيقاف من الطقة الساعة: "+String(hour()) + ":" + minute() + ":" + second()+"  بتاريخ:  " +String (day()) + "-" + month() + "-" + year());
     
    }
    buttonTemp1 = buttonStatus1;
  }
}




void Timr1()                                         // تابع المؤقت رقم 1
{
 
    
    if ((hour() == StartH1) and (minute() == StartM1) and (second() > StartS1)and(digitalRead(Relay1)==LOW)and(OnOffTimr1==HIGH))
    {
      digitalWrite(Relay1, HIGH );
      Serial.println("تم التشغيل");
      Blynk.virtualWrite(V1,1);
      LedRelay1.on();
      Serial.println("تم التشغيل من المؤقت الساعة: ");
      Blynk.virtualWrite(vPIN_LogTerminal,"تم التشغيل من المؤقت الساعة: "+String(hour()) + ":" + minute() + ":" + second()+"  بتاريخ:  " +String (day()) + "-" + month() + "-" + year());

      
    }

    if ((hour() == StopH1) and (minute() == StopM1) and (second() > StopS1)and(digitalRead(Relay1)==HIGH)and(OnOffTimr1==HIGH))
    {
      
      digitalWrite(Relay1, LOW );
      Serial.println("تم الايقاق");
      Blynk.virtualWrite(V1,0);
      LedRelay1.off();
      Serial.println("تم الإيقاف من المؤقت الساعة: ");
      Blynk.virtualWrite(vPIN_LogTerminal,"تم الإيقاف من المؤقت الساعة: "+String(hour()) + ":" + minute() + ":" + second()+"  بتاريخ:  " +String (day()) + "-" + month() + "-" + year());

    }
    
  }




void ping1()                                                // تابع البينغ
{
  if(OnOffPing==HIGH){
  if(Ping.ping(remote_host)) {
    Serial.println("PIN:  "+String(Ping.averageTime()) + "ms" );
    Blynk.virtualWrite(vPIN_LogTerminalPing,"البينغ: "+String(Ping.averageTime()) + "ms" );
    
  } else {
    Serial.println("انقطع البينغ");
    Blynk.virtualWrite(vPIN_LogTerminalPing, "انقطع البينغ" );
       
  }

  if (( Ping.averageTime() < 1 ) and ( Wait1<WaitBlynk1 ))
    { 
      
      Blynk.run(); 
      delay(1000);
      Wait1++;
      Serial.println("انقطع البينغ");
      Serial.println(Wait1);  
    }
       
    if ((Ping.averageTime() < 1 ) and ( Wait1==WaitBlynk1 ))
  {
    //Blynk.run();
    Wait1 = 0;
  }
} }

  

void checkTime()                              // تابع تحديث الوقت من السيرفر
{ 
  Blynk.sendInternal("rtc", "sync"); 

  }





void VoltageS()                             // تابع فولت البطاريات
{
  vt_read = analogRead(VT_PIN);
  Voltage = vt_read * (XVolt / 1023.0) * 3.0;
  delay(100);
  Blynk.virtualWrite(vPIN_BatteryVoltage, Voltage);
  Serial.print("Volts: "); 
  Serial.println(Voltage, 3);
  if ((Voltage>LowVolt)&& (AlertMsgLowVolt==1))
  {
   AlertMsgLowVolt=0; 
  }
  if ((Voltage<LowVolt) && (AlertMsgLowVolt==0))
  {
    //Blynk.logEvent("فولط البطاريات أقل من الحد المحدد ""\n"+String(LowVolt));
   // Blynk.virtualWrite(vPIN_LogTerminal,"فولط البطاريات أقل من الحد المحدد الوقت:  " +String(hour()) + ":" + minute() + ":" + second()+"  " +String (day()) + "-" + month() + "-" + year() );

    AlertMsgLowVolt=1;
  }
}





void setTime(BlynkParam param)                // الحصول على البيانات من اداة إدخال الوقت وتخزينها في المتغيرات
{

  TimeInputParam t(param);

  if (t.hasStartTime()) {
    Serial.println(String("وقت التشغيل: ") +
    t.getStartHour() + ":" +
    t.getStartMinute() + ":" +
    t.getStartSecond());
    StartH1 = t.getStartHour() ;
    StartM1 = t.getStartMinute() ;
    StartS1 = t.getStartSecond() ;
    Serial.println("StartH1: "+String(StartH1));
    Serial.println("StartM1: "+String(StartM1));
    Serial.println("StartS1: "+String(StartS1));
                        
  }

  if (t.hasStopTime()) {
    Serial.println(String("وقت الايقاف: ") +
    t.getStopHour() + ":" +
    t.getStopMinute() + ":" +
    t.getStopSecond());
    StopH1 = t.getStopHour() ;
    StopM1 = t.getStopMinute() ;
    StopS1 = t.getStopSecond();
    Serial.println("StopH1: "+String(StopH1));
    Serial.println("StopM1: "+String(StopM1));
    Serial.println("StopS1: "+String(StopS1));
    Blynk.virtualWrite(vPIN_LogTerminal,"تم ضبط المؤقت 1 تشغيل الساعة:  "+String(StartH1)+":"+String(StartM1)+":"+String(StartS1)+"  -ايقاف الساعة:  "+String(StopH1)+":"+String(StopM1)+":"+String(StopS1));
 
  }

                           
  for (int i = 1; i <= 7; i++)            // يتم تشغيله كل يوم من أيام الأسبوع (1 الاثنين ، 2 الثلاثاء ، 3 الأربعاء ، إلخ.)
  {
    if (t.isWeekdaySelected(i)) {
      Serial.println(String("Day ") + i + " is selected");
    }
  }
}




  

void setup()
{
  BlynkEdgent.begin();
  Serial.begin(115200);
  
  pinMode(Relay1,OUTPUT);
  pinMode(Switsh1, INPUT);
  UltraTimer.setInterval(1000L, checkTime);
  UltraTimer.setInterval(1000L, Timr1);
  UltraTimer.setInterval(1000L, checkStatusButton1);
  UltraTimer.setInterval(1000L, ping1);
  UltraTimer.setInterval(1000L, VoltageS);

}


void loop()
{
  
 BlynkEdgent.run();
 UltraTimer.run();


 
} 

Remove all your code. And start with bare min sketch (edgent example) see if the esp still crashes.

Btw is your power supply capable of providing sufficient power to your esp ? No loose wires ? Is it a dev board ? If not do you have all the resistors to boot the esp ?

Change the interval. All the functions are called at the same time. This may be also one of the reasons.
Give a 2 or 3 second gap between function call’s.

I’m using node mcu to test without the development board and the power source is directly from the laptop @Madhukesh

Start doing this.

@wasemooo4 please do not tag Blynk staff in your posts like this. If you do then your Blynk community account will be suspended.

Pete.

Dear @Madhukesh , I have commented on Blynk.virtualWrite(vPIN_BatteryVoltage, Voltage);
Problem solved, what do you think could be the cause?

Uploading: 13.PNG…

I’m sorry @PeteKnight , I didn’t know it wasn’t allowed

Problem solved, thanks everyone, I canceled BlynkTimer and replaced it with SimpleTimer. After all failed attempts, SimpleTimer managed to solve the problem. It seems that there is a problem with BlynkTimer. Please look into this matter from the founding company

Even i faced this issue. But i thought that would be because of my poor coding knowledge and wrong coding practices.

Thanks for the info. I’ll create the ticket @vshymanskyy FYI.

BlynkTimer vs SimpleTimer should be equivalent, the only real difference is that BlynkTimer allocates more timers (and thus uses a bit more of the memory).

Could you reduce MAX_TIMERS and see if it helps?

How ever this particular lib seems to crash. Just to prove this I changed the timer lib with others and left the rest of the code untouched ! And the code works just fine. As soon as i switch back to Blynk timer the code starts to crash.

So it seems like something is wrong with blynk timer. May be i am wrong !!

What happens if you use a different object name for your Blynk timer - something other than timer, maybe mytimer ?

Pete.

Yeah i remember you said me to fo the same in the previous post i had created. And yes i did as per your instruction but no use. Still crashes.

This:

Thank you dear @vshymanskyy unfortunately I was not able to solve the problem, it reappeared, but the strange thing is that I changed the code and built a new code that contains two resistors to read the voltage of the batteries and I used pzem-004t and this code also causes the nodemcu to collapse. I don’t know why, but I tried the code on blynk legacy It works without any problem

When writing a code that controls the relay, there is no problem, but when adding void and calling it in timer, problems and crashes occur sometimes. The code works correctly, but when I turn the relay on or off, the noemcu crashes directly. I hope you understood what I mean because I do not speak English well @vshymanskyy

I also have this problem. Suddenly wemos d1 mini crashes and I haven’t found a solution for it

@ebda3 please create your own “need help with my project” topic and provide all of the requested information, along with the information that is outputted to your serial monitor when the device boots then crashes,

Pete.

I think there is a power issue. Place a 100uf cap across Vin n Gnd. Seems like the new Blynk is power hungry, even though the code is same.

Is it because we have many header files ? Sounds silly though :confused:.