Need Help for my project

I need help for my projects. I am new using Blynk, there is a problem on my project. I can’t connect to the Blynk server. I already update the newest library and arduino.

#define BLYNK_DEBUG
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>  // Essential for all Blynk Projects

char auth[] = "2ed13df8a2334ff1923638d49069d8bc";
char ssid[] = "PLum";
char pass[] = "tanyaandre";
bool Connected2Blynk = false;

int port = 8080;

SimpleTimer timer;

void setup() {
  Serial.begin(115200);
  delay(10);
  timer.setInterval(11000L, CheckConnection); // check if still connected every 11 seconds
  Serial.println("\nStarted");
  MyWiFi();
}

void MyWiFi(){
  int mytimeout = millis() / 1000;
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    if((millis() / 1000) > mytimeout + 3){ // try for less than 4 seconds to connect to WiFi router
      break;
    }
  }

  if(WiFi.status() == WL_CONNECTED){  
    Serial.print("\nIP address: ");
    Serial.println(WiFi.localIP()); 
  }
  else{
    Serial.println("\nCheck Router ");    
  }
  Blynk.config(auth, port);
  Connected2Blynk = Blynk.connect(1000);  // 1000 is a timeout of 3333 milliseconds 
  mytimeout = millis() / 1000;
  while (Blynk.connect(1000) == false) { 
    if((millis() / 1000) > mytimeout + 3){ // try for less than 4 seconds
      break;
    }
  }  
}

void CheckConnection(){
  Connected2Blynk = Blynk.connected();
  if(!Connected2Blynk){
    Serial.println("Not connected to Blynk server");
    MyWiFi();  
  }
  else{
    Serial.println("Still connected to Blynk server");    
  }
}

void loop() {
  if(Connected2Blynk){
    Blynk.run();  // only process Blyk.run() function if we are connected to Blynk server
  }
  timer.run();
}
19:47:01.887 -> IP address: 192.168.1.3
19:47:01.887 -> [39325] 
19:47:01.887 ->     ___  __          __
19:47:01.887 ->    / _ )/ /_ _____  / /__
19:47:01.887 ->   / _  / / // / _ \/  '_/
19:47:01.887 ->  /____/_/\_, /_//_/_/\_\
19:47:01.887 ->         /___/ v0.5.4 on ESP8266
19:47:01.887 -> 
19:47:01.887 -> [39330] Connecting to 144.31.0.0
19:47:01.887 -> [39340] <[1D|00|01|00] 2ed13df8a2334ff1923638d49069d8bc
Not connected to Blynk server

Please edit your post (using the pencil icon at the bottom) and insert backticks so that the code, and serial output, display correctly…

Blynk%20-%20FTFC

Pete.

First I fixed your post as required and mentioned above… please follow the required methods next time or topic many be deleted.

Second… this doesn’t look like a proper IP for Blynk’s Cloud server?

And finally, this looks like you are copying some older example from the web or somewhere (BlynkTimer has replaced SimpleTimer for a long time now…)

If you are just starting out, then stick with the simpler official Blynk Blink example. Worry about connection management once you can actually get connected :smiley:

1 Like

I already done your suggestion, but it still cannot connect to the blynk server. what should i do next?

5074] Connected to WiFi
20:03:16.779 -> [5074] IP: 192.168.1.3
20:03:16.813 -> [5074] 
20:03:16.813 ->     ___  __          __
20:03:16.847 ->    / _ )/ /_ _____  / /__
20:03:16.881 ->   / _  / / // / _ \/  '_/
20:03:16.915 ->  /____/_/\_, /_//_/_/\_\
20:03:16.950 ->         /___/ v0.5.4 on Arduino
20:03:16.983 -> 
20:03:16.983 -> [5149] Connecting to 192.168.1.100
[10149] Connecting to 192.168.1.100
[15150] Connecting to 192.168.1.100
[20151] Connecting to 192.168.1.100
[25152] Connecting to 192.168.1.100
[30153] Connecting to 192.168.1.100
[35154] Connecting to 192.168.1.100
[40155] Connecting to 192.168.1.100
[45156] Connecting to 192.168.1.100
[50157] Connecting to 192.168.1.100

So… now you are using a Local Server?? That is an advanced setup… how did you get that but not this?

1 Like

Yes, i try to follow the example from the blynk library, for the first code, i just copy somebody code

could you check this one

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  You’ll need:
   - Blynk App (download from AppStore or Google Play)
   - ESP8266 board
   - Decide how to connect to Blynk
     (USB, Ethernet, Wi-Fi, Bluetooth, ...)

  There is a bunch of great example sketches included to show you how to get
  started. Think of them as LEGO bricks  and combine them as you wish.
  For example, take the Ethernet Shield sketch and combine it with the
  Servo example, or choose a USB sketch and add a code from SendData
  example.
 *************************************************************/

/* Comment this out to disable prints and save space */
#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[] = "575fd8241aa746558837304ab425cfb2";

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

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

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

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

and i get the result like this

[4576] Connected to WiFi
15:09:23.875 -> [4576] IP: 192.168.1.2
15:09:23.909 -> [4576] 
15:09:23.909 ->     ___  __          __
15:09:23.942 ->    / _ )/ /_ _____  / /__
15:09:23.976 ->   / _  / / // / _ \/  '_/
15:09:24.009 ->  /____/_/\_, /_//_/_/\_\
15:09:24.043 ->         /___/ v0.5.4 on Arduino
15:09:24.078 -> 
15:09:24.078 -> [4651] Connecting to blynk-cloud.com:80
[7708] Login timeout
[9708] Connecting to blynk-cloud.com:80
[12713] Login timeout
[14713] Connecting to blynk-cloud.com:80

Can you ping “blynk-cloud.com” ?

Try Blynk.begin(auth, ssid, pass); to start with.

hi idb…
i already followed your suggestion and it worked

thank you so much for your suggestion