[SOLVED] App continuously says device was disconnected

Hi guys, im also facing the same issue. serial monitor is showing device is connected to server and app shows it as online. however, mobile phone app says device was disconnected continuously at the bottom.

@Junaid_Dar did you solve your issue?

@Malaka_Perera Hello and welcome to the Blynk forum.

As not all situations are the same, even if the error msg is, I have moved you into your own topic.

Let’s start with some details such as what type of MCU device; Cloud or Local Server; Connection method to server; First time using it, or has it been running for awhile then failed; App and library versions; etc.

Hi Gunner,
im using Lolin new NodeMCU V3
im connected in to local server,
connection method wifi
it is my first time using this device and its not working from beginning.
hope you can help me with this.Thank you!

@Malaka_Perera post your formatted sketch. Android or ioS and what version of the Blynk libraries and Blynk server are you using?

Android 6.0.1
blynk version v0.4.7
my serial monitor showing me this
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
/
//_, /////_
/
__/ v0.4.7 on NodeMCU

[19982] Connecting to blynk-cloud.com:8442
[20535] Ready (ping: 0ms).
[26296] Connecting to blynk-cloud.com:8442
[26555] Ready (ping: 1ms).
[32028] Connecting to blynk-cloud.com:8442
[32428] Ready (ping: 0ms).
[38147] Connecting to blynk-cloud.com:8442
[38470] Ready (ping: 1ms).
[44187] Connecting to blynk-cloud.com:8442
[44511] Ready (ping: 0ms).

and my code is quite simple

#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[] = "xxxxxxxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Malaka_Perera";
char pass[] = "";
int GP=D0;

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

  Blynk.begin(auth, ssid, pass);
   pinMode(GP, OUTPUT);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  
}

void loop()
{
  Blynk.run();
    Blynk.virtualWrite(GP,HIGH);
  Blynk.setProperty(GP,"onLable","ON");
  Blynk.setProperty(GP,"offLable","OFF");
  Blynk.setProperty(GP,"color","#D3435C");}
  BLYNK_CONNECTED(){
    Blynk.syncVirtual(GP);
  }
  BLYNK_WRITE(GP){
    int buttonState=param.asInt();
}

Presumably you were mistaken when you wrote this as it appears you are using Blynk’s cloud server not a local server.

Comment everything out of loop() except Blynk.run() and the disconnects will stop.

2 Likes

Thank you very much, I just start my learning and im very new to this.

It might be quite simple but it’s one of the worst I have ever seen.

Don’t post your tokens on an open forum.

You have GP as a digital pin D0 and then you try to use virtual pin commands with it. Study virtual pins in the docs.

BLYNK_CONNECTED() and BLYNK_WRITE() are functions in their own right and must be kept separate in your sketch (not in loop() or setup()).

Blynk uses the mis-spelling of colour as color for setProperty but they use the regular term for Label not your Lable.

loop() is what the name suggests, repeat thousands of times per second and no code needs to do that, study PUSH_DATA example for how you call functions with a timer.

Suggest you start with simple blink an LED examples before moving on to anything else. I would also recommend that you read the docs from start to finish several times, making notes of what you learn along the way.