EPS8266-12E Constantly connecting when app running

I have an EPS8266 that is running and I am monitoring the Serial data for all activities. The

Without APP running:

[23410] Connecting to Default
[29927] Connected to WiFi
[29927] My IP: 158.238.10.37
[29927] Blynk v0.3.1
[29928] Connecting to cloud.blynk.cc:8442
[30142] Ready (ping: 23ms).
S0 21.44 C 70.59 F
S1 19.56 C 67.21 F
Difference -3F
Battery = 63.2%
Moderate

S0 21.37 C 70.47 F
S1 19.87 C 67.78 F
Difference -3F
Battery = 62.0%
Moderate

S0 21.37 C 70.47 F
S1 20.12 C 68.22 F
Difference -2F
Battery = 62.6%
Moderate

With App running:

[2590438] Connecting to cloud.blynk.cc:8442
[2596626] Ready (ping: 6001ms).
S0 23.50 C 74.30 F
S1 16.44 C 61.59 F
Difference -13F
Battery = 60.2%
Cold

[2619311] Connecting to cloud.blynk.cc:8442
[2625464] Ready (ping: 6001ms).
[2664308] Connecting to cloud.blynk.cc:8442
[2664973] Ready (ping: 22ms).
S0 23.12 C 73.62 F
S1 16.50 C 61.70 F
Difference -12F
Battery = 60.8%
Cold

S0 22.81 C 73.06 F
S1 16.50 C 61.70 F
Difference -12F
Battery = 60.8%
Cold

[2737573] Connecting to cloud.blynk.cc:8442
[2743835] Ready (ping: 6001ms).
[2782701] Connecting to cloud.blynk.cc:8442
[2788894] Ready (ping: 6000ms).
S0 22.62 C 72.72 F
[2800221] Connecting to cloud.blynk.cc:8442
S1 16.50 C 61.70 F
[2800510] Ready (ping: 108ms).
Difference -11F
Battery = 61.1%
Cold

The app can run on any device and have the same result. Phone over 4g, work WIFI, home WIFI (same as device)

I have tried setting all of the widgets to Push all the way up to 59sec for update frequency with no differences.

I thought it was a power issue so increased power supply to a 10A 3.3v supply running at 3.4v under load.

Tried removing all other devices from my home wifi to reduce any network issues.

any help would be appreciated.

Here is my code so far:

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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "#####################";
OneWire  ds(5);  // on pin 5 (a 4.7K resistor is necessary)

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "Default", "############");
}

void loop()
{
  Blynk.run();
  byte i;
  byte c;
  byte t;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float fe[8];
  float Battv;
  int Batt;

for( c = 0; c < 8; c++) {
  if ( !ds.search(addr)) {
    ds.reset_search();
    Battv = (((analogRead(A0)/238.53923)-2.8)/1.4)*1000;
    Serial.print("Bat ");
    Batt = Battv;
    String str;
    char result[5];
    result[0]=(Batt/100)+'0';
    result[1]=((Batt/10)%10)+'0';
    result[2]='.';
    result[3]=(Batt%10)+'0';
    result[4]='\0';
    str +=result;
    str +="%";
    char buf[8];
    str.toCharArray(buf,sizeof(buf));
    Blynk.virtualWrite(V11,buf);
    Serial.println(buf);
    Serial.println("wait");
    for(t=0; t < 30; t++){
      delay(1000);
      Serial.print("-");
    }
    
    Serial.println();
    return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
  delay(750);
  Blynk.run(); 
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
     }


  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } 
  else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  fe[c] = ((float)raw / 16.0)*1.8+32;
  

  Serial.print("S");
  Serial.print(c);
  Serial.print(" ");
  Serial.print(fe[c]);
  Serial.println(" F");

  switch (c) {
    case 0:
      Blynk.virtualWrite(V0, fe[c]);
      Blynk.run();
      break;
    case 1:
      Blynk.virtualWrite(V1, fe[c]);
      Blynk.virtualWrite(V10, (fe[1]-fe[0]));
      Serial.print("Dif ");
      Serial.println(fe[1]-fe[0]);
      Blynk.run();
      break;
    case 2:
      Blynk.virtualWrite(V2, fe[c]);
      Blynk.run();
      break;
    case 3:
      Blynk.virtualWrite(V3, fe[c]);
      Blynk.run();
      break;
    case 4:
      Blynk.virtualWrite(V4, fe[c]);
      Blynk.run();
      break;
    case 5:
      Blynk.virtualWrite(V5, fe[c]);
      Blynk.run();
      break;
    case 6:
      Blynk.virtualWrite(V6, fe[c]);
      Blynk.run();
      break;
    case 7:
      Blynk.virtualWrite(V7, fe[c]);
      Blynk.run();
      break;
      
    default: 
      // if nothing else matches, do the default
      // default is optional
    break;
  }
}
}

Chris

Have the same problem. But unlike yours, i have time out messages about my WiFi connection with cloud server.
The problem starts from using too many widgets, which ask for data in functions BLYNK_READ(). In my code i tried not to use that functions. I use directly procedure blynk.virtualWrite (Vpin,value) in certain frequency.
How you pointed in your post. If i don’t use app connection is stable. If i use app then connection becomes unstable.

The only commands I use are below and iv tried updates as fast as 5 per second to 5 per minute, all give same result.

Blynk.begin
Blynk.run
Blynk.virtualWrite

Got it!!!
I think…

So I decreased many lines of code and so far it is not disconnecting.
Ill add in some delays and see how slow it can run. right now its going to kill my battery at a refresh rate of 5 data sets a second. I hope to get down to updates only every 15-30 seconds.

tried adding the below code for a delay but its still disconnecting

    for(t=0; t < 11; t++){
      delay(3000);
      Blynk.run();
    }

Guys, please post your code and maybe project screenshot. It’s really hard to guess what’s going on.

1 Like

I think you’ll find that minimising what you have in your loop, (put code in functions within setup) , and not using delays will sort your problems.
Use the SimpleTimer to make periodic function calls … #include<SimpleTimer.h> etc , This is described in the Documentation.

This is a simple, and very useful way to call functions with set time periods which will not interrupt the connection.

Or use … millis() as a time comparison for when to trigger an event.

who is can correct this problem pls…

I experience this situation whenever I use several widgets with differing reading frequencies. I now set all widgets to ‘PUSH’ and do not experience the issue.

You may want to experiment with other frequencies, see if when they are all set to the same interval you still experience the problem. Please let us know if this solves your issue.

And don’t forget there is currently the bug with the PUSH setting so sometimes if you don’t double check it will actually be 250ms not actually PUSH.

Worth checking all your frequencies. For testing you should set up debug and see just what you are sending to the server as sometimes it highlights problems with your sketch. Remember to kill debug though as soon as you are happy with your sketch as it can slow down the system by a factor of 10.

@Costas

You are not fully right:
PUSH is for Virtual Pins only, because you can’t push from Analog or Digital Pin. So when you change V pin to A/D, then app automatically changes frequency to 250 (or 1sec, I don’t remember exactly ).

@Pavel the PUSH bug was confirmed by @Dmitriy earlier today at New display widget- reading frequency bug