ESP8266 won't connect to Blynk Server

I’ve spent a lot of time searching and working on this today, and I’ve worked myself into a wall.

I know that my ESP is connecting to the wireless okay, and I know that it and the Blynk server can communicate (pinging back and forth).

This is a Adafruit Feather HUZZAH ESP8266 and the server is running on a Raspberry Pi Zero W, running server server-0.34.2-java8.jar

I previously had this working with these two pieces of hardware. I had to work on the code on the ESP to get it to do something differently, but it was working previously. I also upgraded from server-0.30.2-java8.jar today. I may try rolling that back and seeing it helps?

here is the dummy code I am using right now to try and figure out what’s goign on:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;

char auth[] = "[REDACTED]";
char ssid[] = "[REDACTED]";
char pass[] = "[REDACTED]";
bool Connected2Blynk = false;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, pass);  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");  
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());  
  
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,104));
  Blynk.connect(3333);  // timeout set to 10 seconds and then continue without Blynk
  while (Blynk.connect() == false) {
    // Wait until connected
  }
  Serial.println("Connected to Blynk server");
  timer.setInterval(11000L, CheckConnection); // check if still connected every 11 seconds 
}

void CheckConnection(){
  Connected2Blynk = Blynk.connected();
  if(!Connected2Blynk){
    Serial.println("Not connected to Blynk server"); 
    Blynk.connect(3333);  // timeout set to 10 seconds and then continue without Blynk  
  }
  else{
    Serial.println("Connected to Blynk server");     
  }
}

void loop() {
  if(Connected2Blynk){
    Blynk.run();
  }
  timer.run();
}

And here is the output from the serial monitior:

WiFi connected
IP address: 
192.168.1.110
[29187] Connecting to [REDACTED]
[29687] Connected to WiFi
[29687] IP: 192.168.1.110
[29687] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.2 on ESP-12

[29693] Connecting to 192.168.1.104
[34694] Connecting to 192.168.1.104
[39695] Connecting to 192.168.1.104
[44696] Connecting to 192.168.1.104
[49697] Connecting to 192.168.1.104
[54698] Connecting to 192.168.1.104
[59699] Connecting to 192.168.1.104
[64700] Connecting to 192.168.1.104
[69701] Connecting to 192.168.1.104

Try upgrading everything, App, Server and Library (and re-flashing the devices) and take note of the recent port changes when using Local Server. App needs to be 9443, devices need to use 8080

1 Like

Hey Gunner,

Thank you for the suggestion.

The Library is running 0.5.2 which I believe is the latest. The server is also the latest (0.34.2), and I just verified the app on my phone has no updates eitherr.

Because the local server (RPI-ZW) and the device (ESP8266) are on the same network, there shouldn’t be any issues with ports.

Anything else I could try?

Did you try at least? This is not a port forwarding thing… that is something different.

I suggest a simpler sketch such as this and report results with Serial Monitor printout… you might also enable Debug for further analysis.

Create a new blank project and use that AUTH, if it connects then that is all we need to know to confirm that your server and networking is correct. If not, then post the Debug Serial Monitor output here.

#define BLYNK_PRINT Serial  // This prints to Serial Monitor
#define BLYNK_DEBUG  // Optional, this enables more detailed prints
#include <ESP8266WiFi.h>  // for ESP8266
#include <BlynkSimpleEsp8266.h>  // for ESP8266

char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
char server[] = "xxx.xxx.xxx.xxx";  // IP for your Local Server
int port = 8080;



void setup() {
  Serial.begin(9600);  // BLYNK_PRINT data
  WiFi.begin(ssid, pass); 
  Blynk.config(auth, server, port);
  Blynk.connect();
}



void loop() {
  Blynk.run();
}

Hey @Gunner your code helped me figure it out. I merged what worked from that into my system. I’m having a different issue but I will open a new topic for that.

Cheers

3 posts were split to a new topic: Adafruit Huzzah ESP8266 it will not connect to the local server (Raspberry Pi Zero (W)