Connection Stability Issues

Hi,

Thanks to help on this forum, I’ve solved some of my logical issues but still seem to have issues maintaining connection to the Blynk Server.

I’m running it on the ESP288 SparkFun Thing, with a backup battery. Iphone IOS 9.0.2 dashboard.

Monitoring temperature on V0 every 5 seconds, Switches and controlling LED on action or demand.

Everything works, even the reconnect worked well Sunday night after I got the most recent library installed, but then today I restarted and it had a fatal crash after a few hours, no restart as it had on Sunday night.

Code listing.

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example runs directly on ESP8266 chip.
 *
 * You need to install this for ESP8266 development:
 *   https://github.com/esp8266/Arduino
 *
 * Change WiFi ssid, pass, and Blynk auth token to run :)
 *
 **************************************************************/

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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

//#define TEMP V0
//#define BUTTON1 V2
//#define BUTTON2 V3

//#define TEMP_P A0
//#define BUTTON1_P 4
//#define BUTTON2_P 13

boolean RE = false;
boolean BK = false;

Ticker ChkCon;

void setup()
{
  pinMode(4,INPUT_PULLUP);
  pinMode(13,INPUT_PULLUP);
  
  Serial.begin(9600);
  Blynk.begin(auth, "", "");
  ChkCon.attach(30, reconnectBlynk);
}

BLYNK_READ(TEMP)
{
  Blynk.virtualWrite(TEMP,((analogRead(TEMP_P)-883)/3));
}

void reconnectBlynk() {
  RE = true;
}

int prev1 = -1;
int B1V;
int prev2 = -1;
int B2V;

void loop(){
  Blynk.run();

  B1V = digitalRead(BUTTON1_P);
  if (B1V != prev1) {
    if (B1V) {
      Blynk.virtualWrite(BUTTON1, 255);
    } else {
      Blynk.virtualWrite(BUTTON1, 0);
    }
  }
 prev1 = B1V;
 
  B2V = digitalRead(BUTTON2_P);
  if (B2V != prev2) {
    if (B2V) {
      Blynk.virtualWrite(BUTTON2, 255);
    } else {
      Blynk.virtualWrite(BUTTON2, 0);
      Blynk.notify("Button 2 Pressed");
    }
  }
  prev2 = B2V;
  
  if (RE)
  {
    BK=!BK;
    digitalWrite(5,BK);
    if (!Blynk.connected()) {
      if(Blynk.connect()) {
      Blynk.notify("Blynk Reconnected");
      } 
    }
    RE=false;
  }
}

it had a fatal crash

What do you mean by that? Maybe this is a reason why code was not executed?

ALWAYS wrap your code by pressing this magic button (Backtick`) 3 times (before the code and after it):

This makes your code beautiful with highlighted syntax, like this:

//comment goes here
void helloWorld() {
   String message =  "hello" + "world";
}

You can also select the code and press </> button in the top menu:

Thanks for looking at this.

I mean that the device locked up and is no longer executing code.

The ticker loop should toggle the LED (green) every 30 seconds.

Thanks, was trying to figure out how to do this. Will remember for future posts.

Blynk should reconnect automatically. Try to remove reconnection code.