Device hangs/drops connection - ESP32 - Wifi

I’m running into an issue with my project. For some reason it drops connection after a certain amount of time (usually between 30mins to 1.5hrs). We believe the issue could be 3 potential issues, all though one seems unlikely.

  1. Connections to our Wifi could be the issue. But we’re testing on two different wifi locations so again, could be the issue, but seems unlikely.
  2. ESP32 is hanging up for some reason.
  3. Connection to the Blynk Server.

I’ve posted the code below.

Any help you can provide would be greatly appreciated.

Thanks.

#include <WiFi.h>
#include <WiFiClient.h>
#include <math.h>
#include <BlynkSimpleEsp32.h>
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
uint8_t temprature_sens_read();
static int battery_level = 100;
#define uS_TO_S_FACTOR 1000000  /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP  60        /* Time ESP32 will go to sleep (in seconds) */
RTC_DATA_ATTR int bootCount = 0;
float cap_in_piko1;
float cap1;
float cap_in_piko2;
float cap2;
float cap_in_piko3;
float cap3;
char i;

#define B 4334
#define THERMISTOR_R 100000 
#define NOMINAL_T 25


#define TEMP_VP        V0
#define SENS_1_VP      V1
#define SENS_2_VP      V2
#define SENS_3_VP      V3
#define BAT_VP         V4
/*****************//*PWM*//********************/


int freq_ch = 1000000;
char resolution = 2;

/*CANNEL_1*/
char PWMChannel_1 = 0;
char PWM_pin_1 = 33;
/*CANNEL_2*/
char PWMChannel_2 = 1;
char PWM_pin_2 = 26;
/*CANNEL_3*/
char PWMChannel_3 = 2;
char PWM_pin_3 = 17;

/*****************//*ADC*//********************/


char adc_resolution = 10;
/*CANNEL_1*/
char analogPin_ch1 = 32;  
int sensorValue_ch1 = 0;  
/*CANNEL_2*/
char analogPin_ch2 = 35;
int sensorValue_ch2 = 0; 
/*CANNEL_3*/
char analogPin_ch3 = 34;  
int sensorValue_ch3 = 0;  
/*Battery*/
char analogPin_bat = 36;  
int    batValue = 0; 
/*Temperature */
char analogPin_temp = 39;  
int    tempValue = 0;  

/*****************//*Blynk Settings*//********************/
char auth[] = "4c36919faa194a9d9573e6e34f0aaad2"; //Token
char ssid[] = "SaShOk";                           //Network name
char pass[] = "01271992s";                        //Pasword 
BlynkTimer timer;



void print_wakeup_reason(){
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();

  switch(wakeup_reason)
  {
    case 1  : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case 2  : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case 3  : Serial.println("Wakeup caused by timer"); break;
    case 4  : Serial.println("Wakeup caused by touchpad"); break;
    case 5  : Serial.println("Wakeup caused by ULP program"); break;
    default : Serial.println("Wakeup was not caused by deep sleep"); break;
  }
}



int battery_measure()
{
  analogSetAttenuation(ADC_0db);
  batValue = analogRead(analogPin_bat); 
 if (batValue >= 1020)
   {
    battery_level = 100;
   }
 else if (batValue <= 614)
   {
    battery_level = 0;
   }
 else
   {
    battery_level = ((batValue-614)*25+102)/103;
   }
 return battery_level;
}


void Event()
{ 
  static float bits = 1023;
  static short res = 10000;
  static float time = 0.0000001;
  static int nano = 1000000000;
  static int RES = 100000;
//  ledcSetup(PWMChannel_1, freq_ch, resolution);
//  ledcSetup(PWMChannel_2, freq_ch, resolution);
//  ledcSetup(PWMChannel_3, freq_ch, resolution);
//  ledcAttachPin(PWM_pin_1, PWMChannel_1);
//  ledcAttachPin(PWM_pin_2, PWMChannel_2);
//  ledcAttachPin(PWM_pin_3, PWMChannel_3);
  analogReadResolution(adc_resolution);
  analogSetAttenuation(ADC_11db);
  delay(200);
   
 
  ledcWrite(PWMChannel_1, 2);
  ledcWrite(PWMChannel_2, 2);
  ledcWrite(PWMChannel_3, 2);  
  
  sensorValue_ch1 = analogRead(analogPin_ch1); 
  Serial.print("sensor_1 = ");
  Serial.println(sensorValue_ch1);
  if(sensorValue_ch1 != 0)
  {
    cap1=(time/res*log10(bits/sensorValue_ch1));
    cap_in_piko1=cap1*nano*100000;
    Serial.print("CAP_1 = ");
    Serial.println(cap_in_piko1,10);
  }
  else 
  {
    Serial.print("CAP_1 = ");
    cap_in_piko1 = 0;
    Serial.println(cap_in_piko1);  
  }
  
  Blynk.virtualWrite(SENS_1_VP, cap_in_piko1);
  
  sensorValue_ch2 = analogRead(analogPin_ch2); 
  Serial.print("sensor_2 = ");  
  Serial.println(sensorValue_ch2);
  if(sensorValue_ch2 != 0)
  {
    cap2=(time/res*log10(bits/sensorValue_ch2));
    cap_in_piko2=cap2*nano*100000;
    Serial.print("CAP_2 = ");
    Serial.println(cap_in_piko2,10);
  }
  else
  {
    Serial.print("CAP_2 = ");
    cap_in_piko2 = 0;
    Serial.println(cap_in_piko2);  
  }  
  Blynk.virtualWrite(SENS_2_VP, cap_in_piko2);  
  
  sensorValue_ch3 = analogRead(analogPin_ch3); 
  Serial.print("sensor_3 = ");  
  Serial.println(sensorValue_ch3);
  if(sensorValue_ch3 != 0)
  {
    cap3=(time/res*log10(bits/sensorValue_ch3));
    cap_in_piko3=cap3*nano*100000;
    Serial.print("CAP_3 = ");
    Serial.println(cap_in_piko3,10);  
  }
  else 
  {
    Serial.print("CAP_3 = ");
    cap_in_piko3 = 0;
    Serial.println(cap_in_piko3);  
  }
  Blynk.virtualWrite(SENS_3_VP, cap_in_piko3);

  tempValue = analogRead(analogPin_temp);
  Serial.print("tempValue = ");  
  Serial.println(tempValue); 
  float tr = bits/tempValue-1;
  tr = RES/tr;
  Serial.print("RES = ");  
  Serial.println(tr); 
  float calc;
  calc = tr / THERMISTOR_R;
  calc = log(calc);
  calc /= B;
  calc += 1.0/(NOMINAL_T+273.15);
  calc = 1.0/calc;
  calc -= 273.15+14;
  Serial.print("TEMP = ");  
  Serial.println(calc); 
   
  Blynk.virtualWrite(TEMP_VP, calc);   

   

  
  battery_measure();
  Serial.print("batValue = ");  
  Serial.println(battery_level);  
  Blynk.virtualWrite(BAT_VP, battery_level);
  
 
  Blynk.virtualWrite(V5,(temprature_sens_read() - 32) / 1.8);
  Serial.print((temprature_sens_read() - 32) / 1.8);
  Serial.println(" C");
  delay(500);
  i++; 
  if (i >= 3)
  {
    Blynk.virtualWrite(SENS_1_VP, cap_in_piko1);
    Blynk.virtualWrite(SENS_2_VP, cap_in_piko2);
    Blynk.virtualWrite(SENS_3_VP, cap_in_piko3);
    Blynk.virtualWrite(TEMP_VP, calc); 
    Blynk.virtualWrite(BAT_VP, battery_level);
    Blynk.virtualWrite(V5,(temprature_sens_read() - 32) / 1.8);
    i=0;
    Serial.println("Going to sleep now");
    esp_deep_sleep_start();
    Serial.println("This will never be printed");
  }
  
  
}

void setup()
{
  // Debug console
  Serial.begin(115200);
  //Increment boot number and print it every reboot
  ++bootCount;
  Serial.println("Boot number: " + String(bootCount));
  print_wakeup_reason();
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +" Seconds");
  
  ledcSetup(PWMChannel_1, freq_ch, resolution);
  ledcSetup(PWMChannel_2, freq_ch, resolution);
  ledcSetup(PWMChannel_3, freq_ch, resolution);
  ledcAttachPin(PWM_pin_1, PWMChannel_1);
  ledcAttachPin(PWM_pin_2, PWMChannel_2);
  ledcAttachPin(PWM_pin_3, PWMChannel_3);
  analogReadResolution(adc_resolution);
  analogSetAttenuation(ADC_11db);
  //blymk connect 
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, Event);
}

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

I’m not really sure what your code does, but it looks like it could be a lot of stuff.

You could try seperating the Blynk process and everything else by making use of the two cores the ESP32 has to offer you. There is very quick example here: Three LEDs with Dirty Delay (ESP32) on how to run tow void loops at the same time. Maybe it will be more stable if you assign Blynk it’s own core.

Word of caution: I have absolutely no idea how this works with the sleep mode of the ESP32. It could be bugged for all I know :slight_smile:

Here is a log file as well:

[2018-02-10_22:34:17][2538] Connected to WiFi

[2018-02-10_22:34:17][2538] IP: 192.168.0.37

[2018-02-10_22:34:17][2538] 
[2018-02-10_22:34:17]    ___  __          __
[2018-02-10_22:34:17]   / _ )/ /_ _____  / /__
[2018-02-10_22:34:17]  / _  / / // / _ \/  '_/
[2018-02-10_22:34:17] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:34:17]        /___/ v0.5.0 on ESP32


[2018-02-10_22:34:17][2543] Connecting to blynk-cloud.com:8442

[2018-02-10_22:34:17][2655] Ready (ping: 52ms).

[2018-02-10_22:34:18]sensor_1 = 0

[2018-02-10_22:34:18]CAP_1 = 0.00

[2018-02-10_22:34:18]sensor_2 = 0

[2018-02-10_22:34:18]CAP_2 = 0.00

[2018-02-10_22:34:18]sensor_3 = 0

[2018-02-10_22:34:18]CAP_3 = 0.00

[2018-02-10_22:34:18]tempValue = 435

[2018-02-10_22:34:18]RES = 73979.59

[2018-02-10_22:34:18]TEMP = 17.31

[2018-02-10_22:34:18]batValue = 100

[2018-02-10_22:34:19]22.78 C

[2018-02-10_22:34:19]sensor_1 = 423

[2018-02-10_22:34:19]CAP_1 = 383.5352478027

[2018-02-10_22:34:19]sensor_2 = 423

[2018-02-10_22:34:19]CAP_2 = 383.5352478027

[2018-02-10_22:34:19]sensor_3 = 419

[2018-02-10_22:34:19]CAP_3 = 387.6615905762

[2018-02-10_22:34:19]tempValue = 435

[2018-02-10_22:34:19]RES = 73979.59

[2018-02-10_22:34:19]TEMP = 17.31

[2018-02-10_22:34:19]batValue = 100

[2018-02-10_22:34:20]22.78 C

[2018-02-10_22:34:20]sensor_1 = 423

[2018-02-10_22:34:20]CAP_1 = 383.5352478027

[2018-02-10_22:34:20]sensor_2 = 423

[2018-02-10_22:34:20]CAP_2 = 383.5352478027

[2018-02-10_22:34:20]sensor_3 = 419

[2018-02-10_22:34:20]CAP_3 = 387.6615905762

[2018-02-10_22:34:20]tempValue = 435

[2018-02-10_22:34:20]RES = 73979.59

[2018-02-10_22:34:20]TEMP = 17.31

[2018-02-10_22:34:20]batValue = 100

[2018-02-10_22:34:21]22.78 C

[2018-02-10_22:34:21]Going to sleep now

[2018-02-10_22:35:21]ets Jun  8 2016 00:22:57



[2018-02-10_22:35:21]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:35:21]configsip: 0, SPIWP:0xee

[2018-02-10_22:35:21]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:35:21]mode:DIO, clock div:1

[2018-02-10_22:35:21]load:0x3fff0018,len:4

[2018-02-10_22:35:21]load:0x3fff001c,len:956

[2018-02-10_22:35:21]load:0x40078000,len:0

[2018-02-10_22:35:21]load:0x40078000,len:13076

[2018-02-10_22:35:21]entry 0x40078a58

[2018-02-10_22:35:21]Boot number: 30

[2018-02-10_22:35:21]Wakeup caused by timer

[2018-02-10_22:35:21]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:35:21][19] Connecting to SaShOk

[2018-02-10_22:35:24][2536] Connected to WiFi

[2018-02-10_22:35:24][2536] IP: 192.168.0.37

[2018-02-10_22:35:24][2536] 
[2018-02-10_22:35:24]    ___  __          __
[2018-02-10_22:35:24]   / _ )/ /_ _____  / /__
[2018-02-10_22:35:24]  / _  / / // / _ \/  '_/
[2018-02-10_22:35:24] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:35:24]        /___/ v0.5.0 on ESP32


[2018-02-10_22:35:24][2541] Connecting to blynk-cloud.com:8442

[2018-02-10_22:35:24][2629] Ready (ping: 42ms).

[2018-02-10_22:35:25]sensor_1 = 0

[2018-02-10_22:35:25]CAP_1 = 0.00

[2018-02-10_22:35:25]sensor_2 = 0

[2018-02-10_22:35:25]CAP_2 = 0.00

[2018-02-10_22:35:25]sensor_3 = 0

[2018-02-10_22:35:25]CAP_3 = 0.00

[2018-02-10_22:35:25]tempValue = 436

[2018-02-10_22:35:25]RES = 74275.98

[2018-02-10_22:35:25]TEMP = 17.23

[2018-02-10_22:35:25]batValue = 100

[2018-02-10_22:35:25]22.22 C

[2018-02-10_22:35:26]sensor_1 = 422

[2018-02-10_22:35:26]CAP_1 = 384.5632019043

[2018-02-10_22:35:26]sensor_2 = 423

[2018-02-10_22:35:26]CAP_2 = 383.5352478027

[2018-02-10_22:35:26]sensor_3 = 419

[2018-02-10_22:35:26]CAP_3 = 387.6615905762

[2018-02-10_22:35:26]tempValue = 436

[2018-02-10_22:35:26]RES = 74275.98

[2018-02-10_22:35:26]TEMP = 17.23

[2018-02-10_22:35:26]batValue = 100

[2018-02-10_22:35:26]22.78 C

[2018-02-10_22:35:27]sensor_1 = 422

[2018-02-10_22:35:27]CAP_1 = 384.5632019043

[2018-02-10_22:35:27]sensor_2 = 424

[2018-02-10_22:35:27]CAP_2 = 382.5097961426

[2018-02-10_22:35:27]sensor_3 = 419

[2018-02-10_22:35:27]CAP_3 = 387.6615905762

[2018-02-10_22:35:27]tempValue = 435

[2018-02-10_22:35:27]RES = 73979.59

[2018-02-10_22:35:27]TEMP = 17.31

[2018-02-10_22:35:27]batValue = 100

[2018-02-10_22:35:27]23.33 C

[2018-02-10_22:35:28]Going to sleep now

[2018-02-10_22:36:28]ets Jun  8 2016 00:22:57



[2018-02-10_22:36:28]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:36:28]configsip: 0, SPIWP:0xee

[2018-02-10_22:36:28]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:36:28]mode:DIO, clock div:1

[2018-02-10_22:36:28]load:0x3fff0018,len:4

[2018-02-10_22:36:28]load:0x3fff001c,len:956

[2018-02-10_22:36:28]load:0x40078000,len:0

[2018-02-10_22:36:28]load:0x40078000,len:13076

[2018-02-10_22:36:28]entry 0x40078a58

[2018-02-10_22:36:28]Boot number: 31

[2018-02-10_22:36:28]Wakeup caused by timer

[2018-02-10_22:36:28]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:36:28][20] Connecting to SaShOk

[2018-02-10_22:36:31][2540] Connected to WiFi

[2018-02-10_22:36:31][2540] IP: 192.168.0.37

[2018-02-10_22:36:31][2540] 
[2018-02-10_22:36:31]    ___  __          __
[2018-02-10_22:36:31]   / _ )/ /_ _____  / /__
[2018-02-10_22:36:31]  / _  / / // / _ \/  '_/
[2018-02-10_22:36:31] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:36:31]        /___/ v0.5.0 on ESP32


[2018-02-10_22:36:31][2545] Connecting to blynk-cloud.com:8442

[2018-02-10_22:36:31][2630] Ready (ping: 35ms).

[2018-02-10_22:36:32]sensor_1 = 0

[2018-02-10_22:36:32]CAP_1 = 0.00

[2018-02-10_22:36:32]sensor_2 = 0

[2018-02-10_22:36:32]CAP_2 = 0.00

[2018-02-10_22:36:32]sensor_3 = 0

[2018-02-10_22:36:32]CAP_3 = 0.00

[2018-02-10_22:36:32]tempValue = 435

[2018-02-10_22:36:32]RES = 73979.59

[2018-02-10_22:36:32]TEMP = 17.31

[2018-02-10_22:36:32]batValue = 100

[2018-02-10_22:36:32]22.22 C

[2018-02-10_22:36:33]sensor_1 = 423

[2018-02-10_22:36:33]CAP_1 = 383.5352478027

[2018-02-10_22:36:33]sensor_2 = 423

[2018-02-10_22:36:33]CAP_2 = 383.5352478027

[2018-02-10_22:36:33]sensor_3 = 420

[2018-02-10_22:36:33]CAP_3 = 386.6263122559

[2018-02-10_22:36:33]tempValue = 436

[2018-02-10_22:36:33]RES = 74275.98

[2018-02-10_22:36:33]TEMP = 17.23

[2018-02-10_22:36:33]batValue = 100

[2018-02-10_22:36:33]22.78 C

[2018-02-10_22:36:34]sensor_1 = 422

[2018-02-10_22:36:34]CAP_1 = 384.5632019043

[2018-02-10_22:36:34]sensor_2 = 423

[2018-02-10_22:36:34]CAP_2 = 383.5352478027

[2018-02-10_22:36:34]sensor_3 = 420

[2018-02-10_22:36:34]CAP_3 = 386.6263122559

[2018-02-10_22:36:34]tempValue = 436

[2018-02-10_22:36:34]RES = 74275.98

[2018-02-10_22:36:34]TEMP = 17.23

[2018-02-10_22:36:34]batValue = 100

[2018-02-10_22:36:34]22.78 C

[2018-02-10_22:36:35]Going to sleep now

[2018-02-10_22:37:35]ets Jun  8 2016 00:22:57



[2018-02-10_22:37:35]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:37:35]configsip: 0, SPIWP:0xee

[2018-02-10_22:37:35]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:37:35]mode:DIO, clock div:1

[2018-02-10_22:37:35]load:0x3fff0018,len:4

[2018-02-10_22:37:35]load:0x3fff001c,len:956

[2018-02-10_22:37:35]load:0x40078000,len:0

[2018-02-10_22:37:35]load:0x40078000,len:13076

[2018-02-10_22:37:35]entry 0x40078a58

[2018-02-10_22:37:35]Boot number: 32

[2018-02-10_22:37:35]Wakeup caused by timer

[2018-02-10_22:37:35]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:37:35][19] Connecting to SaShOk

[2018-02-10_22:37:37][2539] Connected to WiFi

[2018-02-10_22:37:37][2539] IP: 192.168.0.37

[2018-02-10_22:37:37][2539] 
[2018-02-10_22:37:37]    ___  __          __
[2018-02-10_22:37:37]   / _ )/ /_ _____  / /__
[2018-02-10_22:37:37]  / _  / / // / _ \/  '_/
[2018-02-10_22:37:37] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:37:37]        /___/ v0.5.0 on ESP32


[2018-02-10_22:37:37][2544] Connecting to blynk-cloud.com:8442

[2018-02-10_22:37:37][2638] Ready (ping: 39ms).

[2018-02-10_22:37:39]sensor_1 = 0

[2018-02-10_22:37:39]CAP_1 = 0.00

[2018-02-10_22:37:39]sensor_2 = 0

[2018-02-10_22:37:39]CAP_2 = 0.00

[2018-02-10_22:37:39]sensor_3 = 0

[2018-02-10_22:37:39]CAP_3 = 0.00

[2018-02-10_22:37:39]tempValue = 435

[2018-02-10_22:37:39]RES = 73979.59

[2018-02-10_22:37:39]TEMP = 17.31

[2018-02-10_22:37:39]batValue = 100

[2018-02-10_22:37:39]22.22 C

[2018-02-10_22:37:40]sensor_1 = 422

[2018-02-10_22:37:40]CAP_1 = 384.5632019043

[2018-02-10_22:37:40]sensor_2 = 423

[2018-02-10_22:37:40]CAP_2 = 383.5352478027

[2018-02-10_22:37:40]sensor_3 = 420

[2018-02-10_22:37:40]CAP_3 = 386.6263122559

[2018-02-10_22:37:40]tempValue = 436

[2018-02-10_22:37:40]RES = 74275.98

[2018-02-10_22:37:40]TEMP = 17.23

[2018-02-10_22:37:40]batValue = 100

[2018-02-10_22:37:40]22.22 C

[2018-02-10_22:37:41]sensor_1 = 422

[2018-02-10_22:37:41]CAP_1 = 384.5632019043

[2018-02-10_22:37:41]sensor_2 = 422

[2018-02-10_22:37:41]CAP_2 = 384.5632019043

[2018-02-10_22:37:41]sensor_3 = 419

[2018-02-10_22:37:41]CAP_3 = 387.6615905762

[2018-02-10_22:37:41]tempValue = 436

[2018-02-10_22:37:41]RES = 74275.98

[2018-02-10_22:37:41]TEMP = 17.23

[2018-02-10_22:37:41]batValue = 100

[2018-02-10_22:37:41]22.78 C

[2018-02-10_22:37:42]Going to sleep now

[2018-02-10_22:38:41]ets Jun  8 2016 00:22:57



[2018-02-10_22:38:41]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:38:41]configsip: 0, SPIWP:0xee

[2018-02-10_22:38:41]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:38:41]mode:DIO, clock div:1

[2018-02-10_22:38:41]load:0x3fff0018,len:4

[2018-02-10_22:38:41]load:0x3fff001c,len:956

[2018-02-10_22:38:41]load:0x40078000,len:0

[2018-02-10_22:38:41]load:0x40078000,len:13076

[2018-02-10_22:38:41]entry 0x40078a58

[2018-02-10_22:38:42]Boot number: 33

[2018-02-10_22:38:42]Wakeup caused by timer

[2018-02-10_22:38:42]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:38:42][19] Connecting to SaShOk

[2018-02-10_22:38:44][2538] Connected to WiFi

[2018-02-10_22:38:44][2538] IP: 192.168.0.37

[2018-02-10_22:38:44][2538] 
[2018-02-10_22:38:44]    ___  __          __
[2018-02-10_22:38:44]   / _ )/ /_ _____  / /__
[2018-02-10_22:38:44]  / _  / / // / _ \/  '_/
[2018-02-10_22:38:44] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:38:44]        /___/ v0.5.0 on ESP32


[2018-02-10_22:38:44][2543] Connecting to blynk-cloud.com:8442

[2018-02-10_22:38:44][2684] Ready (ping: 80ms).

[2018-02-10_22:38:46]sensor_1 = 0

[2018-02-10_22:38:46]CAP_1 = 0.00

[2018-02-10_22:38:46]sensor_2 = 0

[2018-02-10_22:38:46]CAP_2 = 0.00

[2018-02-10_22:38:46]sensor_3 = 0

[2018-02-10_22:38:46]CAP_3 = 0.00

[2018-02-10_22:38:46]tempValue = 435

[2018-02-10_22:38:46]RES = 73979.59

[2018-02-10_22:38:46]TEMP = 17.31

[2018-02-10_22:38:46]batValue = 100

[2018-02-10_22:38:46]22.78 C

[2018-02-10_22:38:47]sensor_1 = 422

[2018-02-10_22:38:47]CAP_1 = 384.5632019043

[2018-02-10_22:38:47]sensor_2 = 422

[2018-02-10_22:38:47]CAP_2 = 384.5632019043

[2018-02-10_22:38:47]sensor_3 = 420

[2018-02-10_22:38:47]CAP_3 = 386.6263122559

[2018-02-10_22:38:47]tempValue = 436

[2018-02-10_22:38:47]RES = 74275.98

[2018-02-10_22:38:47]TEMP = 17.23

[2018-02-10_22:38:47]batValue = 100

[2018-02-10_22:38:47]22.78 C

[2018-02-10_22:38:48]sensor_1 = 420

[2018-02-10_22:38:48]CAP_1 = 386.6263122559

[2018-02-10_22:38:48]sensor_2 = 422

[2018-02-10_22:38:48]CAP_2 = 384.5632019043

[2018-02-10_22:38:48]sensor_3 = 420

[2018-02-10_22:38:48]CAP_3 = 386.6263122559

[2018-02-10_22:38:48]tempValue = 435

[2018-02-10_22:38:48]RES = 73979.59

[2018-02-10_22:38:48]TEMP = 17.31

[2018-02-10_22:38:48]batValue = 100

[2018-02-10_22:38:48]22.78 C

[2018-02-10_22:38:49]Going to sleep now

[2018-02-10_22:39:48]ets Jun  8 2016 00:22:57



[2018-02-10_22:39:48]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:39:48]configsip: 0, SPIWP:0xee

[2018-02-10_22:39:48]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:39:48]mode:DIO, clock div:1

[2018-02-10_22:39:48]load:0x3fff0018,len:4

[2018-02-10_22:39:48]load:0x3fff001c,len:956

[2018-02-10_22:39:48]load:0x40078000,len:0

[2018-02-10_22:39:48]load:0x40078000,len:13076

[2018-02-10_22:39:48]entry 0x40078a58

[2018-02-10_22:39:48]Boot number: 34

[2018-02-10_22:39:48]Wakeup caused by timer

[2018-02-10_22:39:48]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:39:48][19] Connecting to SaShOk

[2018-02-10_22:39:51][2537] Connected to WiFi

[2018-02-10_22:39:51][2537] IP: 192.168.0.37

[2018-02-10_22:39:51][2537] 
[2018-02-10_22:39:51]    ___  __          __
[2018-02-10_22:39:51]   / _ )/ /_ _____  / /__
[2018-02-10_22:39:51]  / _  / / // / _ \/  '_/
[2018-02-10_22:39:51] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:39:51]        /___/ v0.5.0 on ESP32


[2018-02-10_22:39:51][2542] Connecting to blynk-cloud.com:8442

[2018-02-10_22:39:51][2640] Ready (ping: 37ms).

[2018-02-10_22:39:52]sensor_1 = 0

[2018-02-10_22:39:52]CAP_1 = 0.00

[2018-02-10_22:39:52]sensor_2 = 0

[2018-02-10_22:39:52]CAP_2 = 0.00

[2018-02-10_22:39:52]sensor_3 = 0

[2018-02-10_22:39:52]CAP_3 = 0.00

[2018-02-10_22:39:52]tempValue = 435

[2018-02-10_22:39:52]RES = 73979.59

[2018-02-10_22:39:52]TEMP = 17.31

[2018-02-10_22:39:52]batValue = 100

[2018-02-10_22:39:53]22.78 C

[2018-02-10_22:39:53]sensor_1 = 421

[2018-02-10_22:39:53]CAP_1 = 385.5935668945

[2018-02-10_22:39:53]sensor_2 = 423

[2018-02-10_22:39:53]CAP_2 = 383.5352478027

[2018-02-10_22:39:53]sensor_3 = 419

[2018-02-10_22:39:53]CAP_3 = 387.6615905762

[2018-02-10_22:39:53]tempValue = 431

[2018-02-10_22:39:53]RES = 72804.05

[2018-02-10_22:39:53]TEMP = 17.66

[2018-02-10_22:39:53]batValue = 100

[2018-02-10_22:39:54]22.78 C

[2018-02-10_22:39:54]sensor_1 = 423

[2018-02-10_22:39:54]CAP_1 = 383.5352478027

[2018-02-10_22:39:54]sensor_2 = 423

[2018-02-10_22:39:54]CAP_2 = 383.5352478027

[2018-02-10_22:39:54]sensor_3 = 420

[2018-02-10_22:39:54]CAP_3 = 386.6263122559

[2018-02-10_22:39:54]tempValue = 436

[2018-02-10_22:39:54]RES = 74275.98

[2018-02-10_22:39:54]TEMP = 17.23

[2018-02-10_22:39:54]batValue = 100

[2018-02-10_22:39:55]22.78 C

[2018-02-10_22:39:55]Going to sleep now

[2018-02-10_22:40:55]ets Jun  8 2016 00:22:57



[2018-02-10_22:40:55]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:40:55]configsip: 0, SPIWP:0xee

[2018-02-10_22:40:55]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:40:55]mode:DIO, clock div:1

[2018-02-10_22:40:55]load:0x3fff0018,len:4

[2018-02-10_22:40:55]load:0x3fff001c,len:956

[2018-02-10_22:40:55]load:0x40078000,len:0

[2018-02-10_22:40:55]load:0x40078000,len:13076

[2018-02-10_22:40:55]entry 0x40078a58

[2018-02-10_22:40:55]Boot number: 35

[2018-02-10_22:40:55]Wakeup caused by timer

[2018-02-10_22:40:55]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:40:55][20] Connecting to SaShOk

[2018-02-10_22:40:58][2538] Connected to WiFi

[2018-02-10_22:40:58][2538] IP: 192.168.0.37

[2018-02-10_22:40:58][2538] 
[2018-02-10_22:40:58]    ___  __          __
[2018-02-10_22:40:58]   / _ )/ /_ _____  / /__
[2018-02-10_22:40:58]  / _  / / // / _ \/  '_/
[2018-02-10_22:40:58] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:40:58]        /___/ v0.5.0 on ESP32


[2018-02-10_22:40:58][2543] Connecting to blynk-cloud.com:8442

[2018-02-10_22:40:58][2634] Ready (ping: 38ms).

[2018-02-10_22:40:59]sensor_1 = 0

[2018-02-10_22:40:59]CAP_1 = 0.00

[2018-02-10_22:40:59]sensor_2 = 0

[2018-02-10_22:40:59]CAP_2 = 0.00

[2018-02-10_22:40:59]sensor_3 = 0

[2018-02-10_22:40:59]CAP_3 = 0.00

[2018-02-10_22:40:59]tempValue = 435

[2018-02-10_22:40:59]RES = 73979.59

[2018-02-10_22:40:59]TEMP = 17.31

[2018-02-10_22:40:59]batValue = 100

[2018-02-10_22:40:59]22.78 C

[2018-02-10_22:41:00]sensor_1 = 422

[2018-02-10_22:41:00]CAP_1 = 384.5632019043

[2018-02-10_22:41:00]sensor_2 = 423

[2018-02-10_22:41:00]CAP_2 = 383.5352478027

[2018-02-10_22:41:00]sensor_3 = 420

[2018-02-10_22:41:00]CAP_3 = 386.6263122559

[2018-02-10_22:41:00]tempValue = 435

[2018-02-10_22:41:00]RES = 73979.59

[2018-02-10_22:41:00]TEMP = 17.31

[2018-02-10_22:41:00]batValue = 100

[2018-02-10_22:41:00]22.78 C

[2018-02-10_22:41:01]sensor_1 = 422

[2018-02-10_22:41:01]CAP_1 = 384.5632019043

[2018-02-10_22:41:01]sensor_2 = 423

[2018-02-10_22:41:01]CAP_2 = 383.5352478027

[2018-02-10_22:41:01]sensor_3 = 420

[2018-02-10_22:41:01]CAP_3 = 386.6263122559

[2018-02-10_22:41:01]tempValue = 436

[2018-02-10_22:41:01]RES = 74275.98

[2018-02-10_22:41:01]TEMP = 17.23

[2018-02-10_22:41:01]batValue = 100

[2018-02-10_22:41:01]22.78 C

[2018-02-10_22:41:02]Going to sleep now

[2018-02-10_22:42:02]ets Jun  8 2016 00:22:57



[2018-02-10_22:42:02]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:42:02]configsip: 0, SPIWP:0xee

[2018-02-10_22:42:02]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:42:02]mode:DIO, clock div:1

[2018-02-10_22:42:02]load:0x3fff0018,len:4

[2018-02-10_22:42:02]load:0x3fff001c,len:956

[2018-02-10_22:42:02]load:0x40078000,len:0

[2018-02-10_22:42:02]load:0x40078000,len:13076

[2018-02-10_22:42:02]entry 0x40078a58

[2018-02-10_22:42:02]Boot number: 36

[2018-02-10_22:42:02]Wakeup caused by timer

[2018-02-10_22:42:02]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:42:02][19] Connecting to SaShOk

[2018-02-10_22:42:05][2536] Connected to WiFi

[2018-02-10_22:42:05][2536] IP: 192.168.0.37

[2018-02-10_22:42:05][2536] 
[2018-02-10_22:42:05]    ___  __          __
[2018-02-10_22:42:05]   / _ )/ /_ _____  / /__
[2018-02-10_22:42:05]  / _  / / // / _ \/  '_/
[2018-02-10_22:42:05] /____/_/\_, /_//_/_/\_\
[2018-02-10_22:42:05]        /___/ v0.5.0 on ESP32


[2018-02-10_22:42:05][2541] Connecting to blynk-cloud.com:8442

[2018-02-10_22:42:05][2697] Ready (ping: 69ms).

[2018-02-10_22:42:06]sensor_1 = 0

[2018-02-10_22:42:06]CAP_1 = 0.00

[2018-02-10_22:42:06]sensor_2 = 0

[2018-02-10_22:42:06]CAP_2 = 0.00

[2018-02-10_22:42:06]sensor_3 = 0

[2018-02-10_22:42:06]CAP_3 = 0.00

[2018-02-10_22:42:06]tempValue = 434

[2018-02-10_22:42:06]RES = 73684.20

[2018-02-10_22:42:06]TEMP = 17.40

[2018-02-10_22:42:06]batValue = 100

[2018-02-10_22:42:06]22.78 C

[2018-02-10_22:42:07]sensor_1 = 423

[2018-02-10_22:42:07]CAP_1 = 383.5352478027

[2018-02-10_22:42:07]sensor_2 = 423

[2018-02-10_22:42:07]CAP_2 = 383.5352478027

[2018-02-10_22:42:07]sensor_3 = 420

[2018-02-10_22:42:07]CAP_3 = 386.6263122559

[2018-02-10_22:42:07]tempValue = 436

[2018-02-10_22:42:07]RES = 74275.98

[2018-02-10_22:42:07]TEMP = 17.23

[2018-02-10_22:42:07]batValue = 100

[2018-02-10_22:42:07]22.78 C

[2018-02-10_22:42:08]sensor_1 = 423

[2018-02-10_22:42:08]CAP_1 = 383.5352478027

[2018-02-10_22:42:08]sensor_2 = 424

[2018-02-10_22:42:08]CAP_2 = 382.5097961426

[2018-02-10_22:42:08]sensor_3 = 419

[2018-02-10_22:42:08]CAP_3 = 387.6615905762

[2018-02-10_22:42:08]tempValue = 435

[2018-02-10_22:42:08]RES = 73979.59

[2018-02-10_22:42:08]TEMP = 17.31

[2018-02-10_22:42:08]batValue = 100

[2018-02-10_22:42:08]23.33 C

[2018-02-10_22:42:09]Going to sleep now

[2018-02-10_22:43:09]ets Jun  8 2016 00:22:57



[2018-02-10_22:43:09]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:43:09]configsip: 0, SPIWP:0xee

[2018-02-10_22:43:09]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:43:09]mode:DIO, clock div:1

[2018-02-10_22:43:09]load:0x3fff0018,len:4

[2018-02-10_22:43:09]load:0x3fff001c,len:956

[2018-02-10_22:43:09]load:0x40078000,len:0

[2018-02-10_22:43:09]load:0x40078000,len:13076

[2018-02-10_22:43:09]entry 0x40078a58

[2018-02-10_22:43:09]Boot number: 37

[2018-02-10_22:43:09]Wakeup caused by timer

[2018-02-10_22:43:09]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:43:09][19] Connecting to SaShOk

It is hanging up after:

[2018-02-10_22:43:09]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

[2018-02-10_22:43:09]configsip: 0, SPIWP:0xee

[2018-02-10_22:43:09]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

[2018-02-10_22:43:09]mode:DIO, clock div:1

[2018-02-10_22:43:09]load:0x3fff0018,len:4

[2018-02-10_22:43:09]load:0x3fff001c,len:956

[2018-02-10_22:43:09]load:0x40078000,len:0

[2018-02-10_22:43:09]load:0x40078000,len:13076

[2018-02-10_22:43:09]entry 0x40078a58

[2018-02-10_22:43:09]Boot number: 37

[2018-02-10_22:43:09]Wakeup caused by timer

[2018-02-10_22:43:09]Setup ESP32 to sleep for every 60 Seconds

[2018-02-10_22:43:09][19] Connecting to SaShOk

This is last messages from debug.

I’m not seeing anything weird, but I have no experience using deep sleep on ESP. It looks like it has trouble connecting to your Wifi when waking from deepsleep, but I’m not sure.

Can you raise the deepsleep period? Maybe your Wifi network doesn’t like the ESP connecting every 60 seconds.

When you say raise, you mean make the time between wake up longer? The plan is to have this much longer later on, but it is hard to test other functions with long sleep periods.

Lol, yeah I can imagine so. Try raising it to five minutes I think for starters. Maybe the “reset” time goes times 5 to. Could be worth a shot.

We are testing this change btw. So far it’s been 6hrs which is good. But the number of connections isn’t much higher then the 1min sleep yet. So we will see what happens. Hopefully this works though!

https://esp32.com/viewtopic.php?f=14&t=662

This mentions to gracefully disconnect from the AP, which probably can be done (wifi.disconnect() or something similar I guess) and reconnect when waking again. Could be worth a shot.

@Lichtsignaal

Thanks for the help with this!

The 5min deepsleep didn’t fix it. After 12hrs it stopped again.

I’ll take a look at the link you mentioned and see if it might work for us.

What we are looking into is adding something that resets the device if there is no connection. We know that if we disconnect the power and connect again the device works again. So if we can do something like that without removing the power it might be an OK work around. And with long deepsleep times some disconnections here and there won’t negatively affect the user experience.

We shall see!

1 Like

Hi @dksmc

I’ve met similar issue with three different esp32 models. Both using time or external wake up after deep sleep, after random number of reboots the esp32 hang up.
How do you solved this issue?

Hi @dksmc

I too have ESP32 dropouts which don’t reconnect, and am trying to determine if it is my WiFi router connection or something else. I’m interested to know if you found an ESP32 reboot or reinitialise routine to restore the connection.

Go to the tools…set verbose output output… you’ll get the exact reason behind auto boot of ESP

1 Like

@dksmc - hope you don’t mind me reaching out here. I have one of your old commercial products, which I understand is disconnected from Blynk (hence bricked for users). Any chance you can share the above code, or more final version of it?
Hope all is well in the new ventures.
Neal.

@neal_tommy I’d suggest you to create a new " need help with my project " topic, and provide as much details as possible.

@John93 - query relates directly to code at the top of this thread (and confirming if there’s an update), hence keeping it here.

It’s up to you but this is a very old topic, that’s why I recommend you to create a new one :slightly_smiling_face:.

1 Like