Run a code without blynk connected service at first boot device

This is my ESp Sserial print :slight_smile:


[1756] Connected to WiFi
[1756] IP: 192.168.1.3
[1756] 

[5001] Connecting to 192.168.1.2
[11224] Connecting to 192.168.1.2
[17574] Connecting to 192.168.1.2
[23823] Connecting to 192.168.1.2
[30073] Connecting to 192.168.1.2
[36323] Connecting to 192.168.1.2

i have this Problem that at first boot the ESP after connected to network hardware search for blynk host and any code dose not capable to run!!! how can run a code at this time ???

but when hardware is coonected to host and after an error hardware will be disconnected from host my code run on disconnected hardware from host so whay this code work but at first connection does not run?
i write my code according @Costas said (Timer).

1 Like

i research again community but couldn’t fix this .

Show us the code (formatted for forum viewing) that you wrote…

Blynk - FTFC


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "AUTH";

char ssid[] = "SSID";
char pass[] = "PASS";

void setup()
{
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass, IPAddress(xxx,xxx,x,x), 8442);
}

void loop()
{
if(Blynk.connected()){
    Blynk.run();
  }
else {
Serial.println("Code is Running");
}
}

Try this instead:

Blynk.begin(auth, ssid, pass, "xxx.xxx.xxx.xxx", 8442);  // The IP for your Local Server - keep the " "

Or this:

char server[] = "xxx.xxx.xxx.xxx";  // The IP for your Local Server - keep the " "

Blynk.begin(auth, ssid, pass, server, 8442);

didn’t fix

To confirm, you are running a Local Server and this is it’s correct address?

Do you have other devices and projects running on this server?

yeap

yeap

i want run a code when device trying connect to the server.

Oh, bother… and here I was troubleshooting a connection issue :stuck_out_tongue:

Issue lost in translation I guess.

OK, to continue running your script when Blynk is NOT connected, you have to use Blynk.config() instead of Blynk.begin() along with your connection checks etc…

http://docs.blynk.cc/#blynk-firmware-configuration-blynkconfig

after disconnected device it should write some code to recoonnect again or its will be reconnected again to server?

There are a few ways of writing that code… search this forum for the terms Connection Management