Code isn't working without connected Blynk

The problem might be when the Arduino is using an ESP shield. With Ethernet you can connect to the internet before Blynk. I guess technically you can with an “ESP shield” but it’s not very straightforward and most people use Blynk.begin().

I try to change (3333) to () without any success.

The problem is that if arduino stay offline for two minutes the code reset it.
Thanks to you @Costas !!!

if (disconnects > 12) {
Blynk.begin(auth);
}
if (disconnects > 24) {
if (pinV50 == 0) {
Blynk.virtualWrite(V50, 255);
pinV50 = 1;
resetFunc();
}
}
But sometimes about two or three per month arduino stuks maybe to “blynk.begin(auth)”
and i must to reset it manualy…I try to put “wdt_enable(WDTO_8S);” before “blynk.begin(auth)”
but 8 secs many times isn’t enough το connect…
So i need after specific time to escape from “blynk.begin(auth)” loop and reset again…

Sorry im using ethernet shield…Not esp…

@Spyrosgreece can you post a stripped down version of your sketch that just includes the connect / reconnect / WDT routines (plus the associated Blynk stuff) and I’ll try to take a look at it.

Ethernet is the only connection method I currently use with Blynk and Arduino’s.

Hi Guys,

I am work with ESP8266 and I have the same problem. I have built a smart swich system with local (physical buttons) and remote control (app Blynk),
When the ESP is connected to the WIFI, everything works fine, I can control the lights from my phone and also with the physical buttons.
The problem is, when I turn on the ESP with the router turn off or without internet, the system is not working and I can not use the physical buttons. The system hangs in the setup(), at the Blynk.begin(auth);
If the ESP turn on with wifi signal and internet and after the cable is unplugged of the internet on the router
the code reconnect and work fine. To do this, I use a simple timer for check the reconnection. Sketch of Costas.
Thank for yours helps.

Look up the alternatives for Blynk.begin() in Connection Management section of the docs.

Thanks Costas,
It is convenient to divide the function blynk.begin into 2 parts, 1-connect wifi and 2 connect to the server, both with the break statement after a few seconds. What do you think?

Yes if you want to cover all possibilities and then set timeouts and reconnects separately for both.

Thanks, I will try it

1 Like

Hello friends,

I have the same problem. I have a arduino due and wifi shield esp8266.
When the Internet or Wi-Fi router is active everything works fine, however if restart the arduino at the time when the Internet or router is absent, then the arduino hangs. Arduino hangs in void setup on the line : Blynk.begin(auth, wifi, ssid, pass);
When I try to use “Blynk.connect()” , the arduino hangs in any case (with internet or without).

@kikilich over the last few days I have posted code for:

  1. ESP Blynk no block.
  2. Ethernet Blynk no block.

Unfortunately it’s much more difficult for ESP’s as WiFi shield. See this post for possible solutuons Brown outs or reboots

I read that thread, but I dont understood how it may help me. While I was reading the forum I understood that all users on different device have (or had) a problem with controller hang when the function blynk.begin () is executed while the internet is absent. It is true? When this problem will be solved on the Arduino + ESP ?

In addition, I have a problem with the function blynk.connect (). It dont work. When I call this function my controller is hang ( even in the case of the presence of the Internet). Therefore I can’t reconnect to the internet.

(my controller arduino due + esp , I use library “BlynkSimpleShieldEsp8266.h” version v0.4.8)

Offtopic. In addition, there is Still a stupid question. I built my big project on Arduino DUE. Is it possible to run blynk server on Rasberry and connect to it arduino due via USB or serial port (without network)?

If this means you are using the ESP hooked up to give WiFi to an Arduino the short answer is there is no easy fix.
If you use the ESP for it’s intended purpose, a MCU with WiFi, then I posted the code, again, in the last few days to bypass the Blynk.begin() code blocking routine.
If your seasoned coder looked closely at the Blynk libraries for Blynk.config() and Blynk.connect() they might be able to port them from an ESP to an Arduino.
Alternatively if you really need an Arduino in your project you could go ESP with Arduino shield route, rather than Arduino with ESP shield.

Needs porting to AT format for Arduino with ESP shield.

Dunno but you could add Ethernet to the Due for a couple of dollars and with the right Ethernet board it will recover from internet failures.

A post was split to a new topic: Program not working when device is ofline