How to arduino mega can work without internet

• My device Arduino Mega with Ethernet Shield W5100
PS. Sorry for my English…

Hi. How i can use arduino (+blynk) when without internet connection?
My program ends with “Blynk.begin”…
I managed to bypass it (code below) and everything works with and without Internet.
I would like if run arduino without internet,
then it connect to the blynk network immediately after detecting the connection to the Internet.

#define BLYNK_PRINT Serial

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

char auth[] = "xxx"; // Auth Token od Blynk
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

#define W5100_CS  10 //Ethernet shield pin
#define SDCARD_CS 4 //SDcard pin

BlynkTimer timer;

void setup()

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

  } else Serial.println("No connect");
  timer.setInterval(600000L, reconnect);

void loop()

void reconnect(){
  } else Serial.println("Connect OK");

Ok the code works (UP).
I have edited this post, maybe someone will need it.

As per the directions, that you deleted in-order to post your topic… I have formatted your code for proper viewing.

Search this forum for other examples of functioning code without internet connection… many topics about this issue already.

For the needs of the project, I was editing the timeout in the Ethernet.h library so that the waiting time was not that long and other functions were running smoother.

timeout = 2000 (default 30000)
responseTimeout = 1000 (default 5000)

Ethernet.h file:

#ifndef ethernet_h
#define ethernet_h

#include <inttypes.h>
//#include "w5100.h"
#include "IPAddress.h"
#include "EthernetClient.h"
#include "EthernetServer.h"
#include "Dhcp.h"

#define MAX_SOCK_NUM 4

class EthernetClass {
  IPAddress _dnsServerAddress;
  DhcpClass* _dhcp;
  static uint8_t _state[MAX_SOCK_NUM];
  static uint16_t _server_port[MAX_SOCK_NUM];
  // Initialise the Ethernet shield to use the provided MAC address and gain the rest of the
  // configuration through DHCP.
  // Returns 0 if the DHCP configuration failed, and 1 if it succeeded
  int begin(uint8_t *mac_address, unsigned long timeout = 2000, unsigned long responseTimeout = 1000);
  void begin(uint8_t *mac_address, IPAddress local_ip);
  void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
  void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
  void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
  int maintain();

  IPAddress localIP();
  IPAddress subnetMask();
  IPAddress gatewayIP();
  IPAddress dnsServerIP();

  friend class EthernetClient;
  friend class EthernetServer;

extern EthernetClass Ethernet;


2 posts were merged into an existing topic: Mã không hoạt động cho các nút bấm vật lý khi mất kết nối với internet

I want to do the same thing but new library 0.6.1 has different Ethernet.h . Could you help me to update accordingly.