ESP8266 Not reconnecting to 80

Very simple program and while testing the WiFi reconnect process the ESP reconnects to WiFi and Blynk every time except when power cycle occurs before WiFi is back up. If I disable and then enable Wifi on my router the ESP will reconnect. If I reboot my router the ESP reconnects.

It’s only when the ESP power is turned off and back on while WiFI is out that it never reconnects to blynk. As you can see from the serial print below the ESP reconnects to my WiFi but not to Blynk. I just get an endless series of “Connecting to blynk-cloud”. While this is going on I can “telnet” to 80.

Any ideas?

[5040] Connecting to Murphylan2
[49547] Connected to WiFi
[49547] IP:
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.4 on ESP-12

[49554] Connecting to
[54555] Connecting to

The program:
#define BLYNK_PRINT Serial

//debug options
bool debug = true;
bool blynkdebug = false;

const char* PgmId = "TestBlynkReconnect";
//const char* PgmNotes = "V=1 current Blynk Lib ";
const char* PgmNotes = "V=6.2 HeatControlMaster runs on ESP8266 this Master plus 2 temp sensors (outside temperture)";
char ssid[] = "Murphylan2";
char password[] = "shantihbaba";
char authtoken[] = "79b122f93b244987b60d8c1e0942ed05";

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

IPAddress staticIPAddr(192, 168, 0, 81);// IP address of this server
IPAddress gateway(192, 168, 0, 1);// gateway of your network
IPAddress subnet(255, 255, 255, 0);

void setup()
	Serial.print("Program ");
	bool isfirst = false;
	WiFi.config(staticIPAddr, gateway, subnet);// forces  use of a fixed IP Address);
	Blynk.begin(authtoken, ssid, password);//starts wifi and Blynk
	if (Blynk.connected()) {
		if (debug) Serial.println("WiFi connected");
		byte mac[6];
		if (debug) Serial.println("IP address: ");
		if (debug) Serial.println(WiFi.localIP());
		if (debug) Serial.println("Mac Address: ");
		if (debug) Serial.print(mac[0], HEX);
		if (debug) Serial.print(":");
		if (debug) Serial.print(mac[1], HEX);
		if (debug) Serial.print(":");
		if (debug) Serial.print(mac[2], HEX);
		if (debug) Serial.print(":");
		if (debug) Serial.print(mac[3], HEX);
		if (debug) Serial.print(":");
		if (debug) Serial.print(mac[4], HEX);
		if (debug) Serial.print(":");
		if (debug) Serial.println(mac[5], HEX);
void loop()

Blynk - FTFC

Aside from failing to properly format your code for forum viability, as requested in the directions you erased when posting… :stuck_out_tongue_winking_eye:

You seem to be running your ESP as a server as well as Blynk client? EDIT - possibly just for the static IP

If the ESP is dictating it’s own settings, perhaps that is part of the issue when the router/esp boot order is unique.

If you are using your own WiFi setup, then try Blynk.config() instead… as well as some connection checks and re-connection routines.

Thank you Gunner you hit on the exact problem… the static IP address. At first I didn’t think it was a problem because I could see it was connected to my LAN but in testing it without the static IP it reconnected to Blynk just fine. I thought I needed the static address because in the actual program this ESP connects to 2 other ESPs (not running Blynk) in a master/slave relationship over my LAN.

I’m lucky my Router can assign IP addresses to MAC addresses so I was able to assign specific IP addresses to all. It’s funny though that static IP addresses work on the other ESPs just fine, so it’s curious that Blynk doesn’t handle it. Oh well. Thanks again.

It probably would with proper re-connection routines.