BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

ESP8266 connects to wifi but Blynk app is offline

Hey everyone!

About a year ago I’ve created a garden watering system that was activatable through the Blynk app. It was all going well until recently the ESP8266 stopped working and I bought a new one to replace it. I flashed the updated firmware and got positive results when typing AT. Though when I try to run the code I once had, Blynk never manages to come back online on the app.

The problems I’m currently facing are the following:

  1. ESP8266 is very inconsistent. Sometimes Blynk starts and says [1623] ESP is not responding , sometimes the ESP responds, tries to connect to wifi, but returns [14039] Failed to connect WiFi, and sometimes it actually connects to wifi [11145] Connected to WiFi.
  2. Whenever the ESP actually manages to connect to the wifi, nothing else happens. [11145] Connected to WiFi is the last line printed to Serial and the Blynk app keeps on displaying offline.

A bit more info I have:

  • The ESP that worked for this past year was a ESP8266-01S, the one I have now is a ESP8266EX.
  • The AT versions were different. The ESP-01S was running AT version:1.1.0.0(May 11 2016 18:09:56), the current ESPEX is running AT version:1.7.4.0(May 11 2020 19:13:04)
  • I know the ESPEX has no problem at all at connecting to my wifi, and even connecting to the internet. I successfully managed to connect to my wifi every time when trying to ping google.com on a custom script for the ESPEX.
  • It feels like individually, every hardware piece works correctly, but when I connect the ESP to the Arduino Uno and try to connect to Blynk, it doesn’t work as expected. Which means it could either be a Blynk problem (libraries / connection to app), an ESP problem (AT version), or even a problem related to connections (cables).

Any help or guide in the right direction is greatly appreciated!

ESP8266EX AT+GMR output:

AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
OK

I assume that your using SoftwareSerial to create a software UART to connect your Uno and ESP?
What baud rate are you using for this connection?

The lack of connection to the Blynk server could be down to your ISP blocking the Blynk traffic, or port 80.
One way around this may be to change your connection string so that you force it to use port 8080 instead.
It may also be worth re-generating the auth code for your project in the app and using this new auth code in your sketch.

Quite a but of guesswork here though, without knowing more about your sketch and the hardware setup

It could also be a power issue, so knowing how your ESP is powered (hopefully not from your Uno) may provide some pointers.

Pete.

Thank you for your comment.

I am indeed using SoftwareSerial to connect to my UNO and ESP. Baud rate is at 9600, since I’ve read somewhere on the internet ESPs work better on 9600 than 115200.

I doubt my ISP is blocking the Blynk traffic, as it has always been working for a year now.

How could I change my connection string? The way I’m connecting to Blynk is through Blynk.begin(auth, wifi, ssid, pass); and I do not a see a way to change such a string. The best would be to test this through another device like my computer to make sure it works.

I’ll try to regenerate an auth code, as that has not been changed once since setup last year.

The sketch is way too long to post here, but here is a trimmed version that tries to connect to wifi, and then connect to Blynk:

#define BLYNK_PRINT Serial
#define BLYNK_DEBUG

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = "authtoken";
char ssid[] = "ssid";
char pass[] = "password";

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(6, 7); // RX, TX

#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(9600);
  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  //Serial.println(Blynk.connect());
  Blynk.begin(auth, wifi, ssid, pass);
}

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

It could be a power issue indeed, but I also doubt that. I’m running the ESP from an adapter for the ESP that runs off of 5V from the Uno. Again, it has always worked for a year, I doubt that is the case. I’d like to try other solutions first.

Do you think the AT versions might be related to this?

Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8080);

I’d start by trying this, as blocking port 80 is quite common. Restarting your router if you’re having issues is also a good move.

Pete.

I’ve updated the token and added your change. Last line prints [8145] Connected to WiFi , but Blynk app is still offline.

I also just remembered I managed to get Blynk to be online once some days ago. So I guess the connection string shouldn’t bea problem, unless the connection got interrupted by the ISP or something else. Unfortunately I did not see the app online, but I could see the Offline since had updated to the day and time I was testing things out with the new ESP.

Just so I know: if Blynk manages to connect, does it print something else to Serial or will Connected to wifi always be the last info?

Yes, with #define BLYNK_PRINT Serial enabled you should see something like this:

[26920] Connected to WiFi
[26920] IP: 192.168.1.xx
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[26993] Connecting to blynk-cloud.com:80
[27153] Ready (ping: 103ms).

Try commenting-out this line and see what changes:

Pete.

Unfortunately, this is all I’ve been getting lately, even with that line commented:

[19] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[609] Connecting to ssid
[3826] AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
OK
[11136] +CIFSR:STAIP,"192.168.xxx.xxx"
+CIFSR:STAMAC,"xx:xx:xx:xx:xx:xx"
[11145] Connected to WiFi