When device turn off , and then turn on again the Blynk app on mobile tell me the device is offline

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


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

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

#define W5100_CS  10
#define SDCARD_CS 4

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

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8442);
  // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example
}

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

Welcome,

First, I formatted your pasted code as per directions in the Welcome Topic… which you have read. correct? :wink:

As for your issue, yes… that is “normal” with Ethernet; You would need to physically reset the device to reconnect, possibly a few times as many Ethernet adapters are basically flaky.

You can code in various connection detection and reset routines if you wanted to have the code try to automatically reset and reconnect.

Read up on, and search this site for more information on, connection management and WDT (watchdog timer)

thx u for yr reply , but where i put this ? in void setup or void loop ??

# This functions will try connecting to Blynk server.
# Returns true when connected, false if timeout reached.
# Default timeout is 30 seconds.
bool result = Blynk.connect();
bool result = Blynk.connect(timeout);

and which Connection management is useful to copy in my code ??

You can’t just copy paste everything, much will depend on how you want things to react in your situation and how well you can program.

As I recommended, search this forum for other topics regarding Connection Management, WDT, Ethernet, etc… spend lots of time reading and testing and you will start to see how you can implement similar techniques into your own code.

This talk encourages me a lot especially can not copy and paste everything and actually see the solution,
Thank you for giving me the beginning of the plan

1 Like

No problem… Lots of reading and research is the key that worked for me as well :smiley:

I found this recent post I made, that while not exactly in reference to your situation, it should give you an idea of one way to implement some of the connection management routines.

1 Like