Esp 8266 failing to connect (but only on some templates!)

I’ve connected my esp8266 through wifi just fine with the quickstart, but it doesn’t work (repeated:

Connecting to
[4307] Connected to WiFi
[4307] IP: 192.168.0.101
[4307]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v1.0.1 on ESP8266

[4384] Connecting to blynk.cloud:80
[4969] Redirecting to fra1.blynk.cloud:80
[4970] Connecting to fra1.blynk.cloud:80

and start over again)

the issue is that, other than BLYNK_TEMPLATE_ID, BLYNK_DEVICE_NAME, BLYNK_AUTH_TOKEN, on the same device, it connects when using the quick start template (and goes to “ready”), but not when using other templates (where it repeats this segment. I’ve narrowed the code to the bare minimum, so it should do nothing but connect. and they are the same, why one works and the others don’t?

Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.

//here are the def etc..
BLYNK_CONNECTED()
{
}
void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
}

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

Please post your full sketch, and clarify exactly what this means…

Pete.

full sketch (sensitive info redacted), it’s the same when working and when not working, besides BLYNK_TEMPLATE_ID, BLYNK_DEVICE_NAME, BLYNK_AUTH_TOKEN, once copied from the device page when creating new device from template (not working) and once when creating new device from quickstart (working):

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID REDACTED
#define BLYNK_DEVICE_NAME REDACTED
#define BLYNK_AUTH_TOKEN REDACTED



// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = REDACTED;
char pass[] = REDACTED;

BlynkTimer timer;


// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);
}

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

what I mean by not working:
in the device page it goes online-offline in alteration constantly and on the serial monitor I see

[4307] Connected to WiFi
[4307] IP: 192.168.0.101
[4307] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP8266

[4384] Connecting to blynk.cloud:80
[4831] Redirecting to fra1.blynk.cloud:80
[4833] Connecting to fra1.blynk.cloud:80
⸮⸮⸮Ԝ[71] Connecting to REDACTED

on repeat every 30 seconds.
In the quick start version the last line is

[5052] Ready (ping: 85ms).

full sketch (sensitive info redacted), it’s the same when working and when not working, besides BLYNK_TEMPLATE_ID, BLYNK_DEVICE_NAME, BLYNK_AUTH_TOKEN, once copied from the device page when creating new device from template (not working) and once when creating new device from quickstart (working):

#define BLYNK_TEMPLATE_ID REDACTED
#define BLYNK_DEVICE_NAME REDACTED
#define BLYNK_AUTH_TOKEN REDACTED



// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = REDACTED;
char pass[] = REDACTED;

BlynkTimer timer;


// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
}
[4307] Connected to WiFi
[4307] IP: 192.168.0.101
[4307] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP8266

[4384] Connecting to blynk.cloud:80
[4831] Redirecting to fra1.blynk.cloud:80
[4833] Connecting to fra1.blynk.cloud:80
⸮⸮⸮Ԝ[71] Connecting to REDACTED

on repeat every 30 seconds.
In the quick start version the last line is (with no repeat)
[5052] Ready (ping: 85ms).