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?

1 Like

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

/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <MQUnifiedsensor.h> //
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space


char auth[] = "UYKWTTj0ON4QLTIlPFdqOJQTV16cuv6F";

/* WiFi credentials */
char ssid[] = "Glide";
char pass[] = "";

BlynkTimer timer;

int mq135 = A0; // smoke sensor is connected with the analog pin A0 
int data = 0; 
void setup() 
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass,"blynk-cloud.com", 8442);
  timer.setInterval(1000L, getSendData);
}

void loop() 
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
data = analogRead(mq135); 
  Blynk.virtualWrite(V2, data); //virtual pin V3

  if (data > 600 )
  {
    Blynk.notify("Smoke Detected!!!"); 
  }

}

[/quote]

Hello, I’m using NodeMCU on the Arduino software for my project on the gas detecting part, and i am trying to get the data from Blynk application… but i keep receiving on Blynk (Connected then after few seconds disconnected) and when i press the play button it gives me offline ? does anyone has any idea what could be the problem?

@Alaa98 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Thank you for responding, done i edited it.

I don’t see any Blynk connected or disconnected messages in your serial monitor screenshot (BTW, it’s much better to copy/paste the contents of the serial monitor and use triple backticks when posting this data as well).

Why are you using port 8443?

Have you tried port 8080 instead?

Pete.

18:26:31.743 -> IT⸮⸮)⸮⸮
18:26:31.857 -> SDK:2.2.2-dev(38a443e)/Core:2.7.3-3-g2843a5ac=20703003/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
18:26:31.967 -> scandone
18:26:34.774 -> scandone
18:26:34.774 -> state: 0 -> 2 (b0)
18:26:34.808 -> state: 2 -> 3 (0)
18:26:34.808 -> state: 3 -> 5 (10)
18:26:34.842 -> add 0
18:26:34.842 -> aid 1
18:26:34.842 -> 
18:26:34.842 -> connected with Glide, channel 6
18:26:34.877 -> dhcp client start...
18:26:34.912 -> cnt 
18:26:36.395 -> ip:100.81.30.33,mask:255.255.254.0,gw:100.81.30.1

and i changed the port to 8080 but still the application is offline, but i also do not know why when it is paused, the application keeps sending like a notification saying: connected then disconnected every 6 seconds approximately

I don’t really understand what you mean when you say "the application keeps sending`. Is this appearing in the app, or the serial monitor?
If it’s the serial monitor then you’ve not shown those messages in the data you’ve provided.

What debug level did you select when you compiled the sketch?

Pete.

i did not select any debug level, what should i pick?
and this is what i meant about connected, disconnected …

The serial monitor output isn’t what you’d normally see, unless you selected something like WIFI for your debug level.

Can you post a screenshot of your Tools settings in the IDE?

Pete.

Very strange!
Do you have another NodeMCU you can try?

Pete.

i have many and i tried them all but i am still having the same problem unfortunately…

Do you see the same information in the serial monitor?

Normal Blynk serial output looks very different to this, and the only time I’ve seen this type of output is when a debug level is chosen. If you have ‘none’ selected as your debug level then something strange is happening.

Pete.

i didn’t type anything to appear for me in the serial monitor, it’s either the application problem or something in the tools bar is missing somehow…