Connections and Continuous Disconnection from Blynk

Hi, I’m having a problem connecting to Blynk with the NODEMCU ESP8266 card.

I have already read several posts, but I have not found my problem.

When I load the Blynk base sketch (only connection to the Blynk server) everything is perfect.
When the SKETCH BUILDER selects and copies the sketch “Sync Physical Button” (with connection to the Blynk server), the card connects and disconnects continuously every 4/5 seconds.
Is it a bug?
How can I solve?

Thank you!

Even though you say it is from the examples, please post the actual code (properly formatted as per the Welcome Topic) that you used here (just block out the WiFi credentials and auth code)

Then clearly document any physical connections to your ESP (which pin, how the button is wired, resistor values, etc), powersource, serial monitor output, and any relevant details about your WiFi setup… (you might simply have a week connection… or a very crowded WiFi signal range).

#define BLYNK_PRINT Serial

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

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxxxxxxx";
char pass[] = "xxxxxxxxxxxx";

// Set your LED and physical button pins here
const int ledPin = 5;
const int btnPin = 6;

BlynkTimer timer;
void checkPhysicalButton();

int ledState = LOW;
int btnState = HIGH;

// Every time we connect to the cloud...
  // Request the latest state from the server

  // Alternatively, you could override server state using:
  //Blynk.virtualWrite(V2, ledState);

// When App button is pushed - switch the state
  ledState = param.asInt();
  digitalWrite(ledPin, ledState);

void checkPhysicalButton()
  if (digitalRead(btnPin) == LOW) {
    // btnState is used to avoid sequential toggles
    if (btnState != LOW) {

      // Toggle LED state
      ledState = !ledState;
      digitalWrite(ledPin, ledState);

      // Update Button Widget
      Blynk.virtualWrite(V11, ledState);
    btnState = LOW;
  } else {
    btnState = HIGH;

void setup()
  // Debug console

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  pinMode(ledPin, OUTPUT);
  pinMode(btnPin, INPUT_PULLUP);
  digitalWrite(ledPin, ledState);

  // Setup a function to be called every 100 ms
  timer.setInterval(100L, checkPhysicalButton);


void loop()

This is the code that is not working.
The NODEMCU ESP8266 board is powered by the USB (5V) connector,
and the problem gives it both that the button and the relay are connected, or not connected.

1000L will be better , am I wrong ?

is the sketch copied directly from the BLYNK examples.
For Arduino UNO with Ethernet Shield is fine, with Arduino YUN in WIFI connection goes well, but with Nodemcu ESP8266 does not work … the board connects and disconnects every 5 seconds.

But it is still just an example sketch… your uses and hardware choices will require changes as necessary.

Possibly the pins you are using… ESPs have particular issues with certain pins… Google for more info on ESP and NodeMCU GPIO pins, there numbering methods (they are different then Arduino) and how some should not be pulled HIGH or LOW when booting the board. Which is why I asked for details on how you have the pins wired to whatever :wink:

No pin 6 on an ESP.

1 Like

3 posts were split to a new topic: Disconnection Problems with Wemos Board