BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Stuck in connecting to blynk in the serial monitor

Hello, I have a problem related to stuck [527] connecting to the wifi on the serial monitor when I want to connect to blynk, can you please help me? I’ve been stuck for hours on this issue and haven’t found a solution yet.

I’m using
• Hardware model + communication type : Arduino Mega 2560 R3 + ESP8266 Wifi + Micro USB Cable | IoT - CH340G
• Blynk server
• Blynk Library version 0.3.8

the problem
messageImage_1641463774297

And here is my sketch code

//  LIBRARY
//====================================================
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
//====================================================

//  DEKLARASI AWAL
//====================================================
char auth[] = "-xx";
char ssid[] = "Tenda_16";
char pass[] = "war140500";
#define EspSerial Serial3
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);

//====================================================

BLYNK_WRITE(V2) {
  if (param.asInt()) {
    digitalWrite(10, HIGH);
  }
  else {
    digitalWrite(10, LOW);
  }

}
//====================================================


void setup()
{
  pinMode(10, OUTPUT);
  Serial.begin(115200);
  Serial3.begin(115200);

  delay(10);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);                          //Reguler server
//  Blynk.begin(auth, wifi, ssid, pass, "192.168.1.21", 8080);    //Local server
}

void loop()
{
  Blynk.run();
  if ( Serial3.available() )   {
    Serial.write( Serial3.read() );
  }
  if ( Serial.available() )       {
    Serial3.write( Serial.read() );
  }

}

I have checked my SSID and pass, and there is no problem with that.

Hey there,
are you using blynk IOT or legacy ?

I’m using blynk IOT

Okay, check this
https://docs.blynk.io/en/blynk-1.0-and-2.0-comparison/migrate-from-1.0-to-2.0

and this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

and use baud rate 9600 instead of 115200

Your sketch isn’t stuck connecting to Blynk, it’s stuck connecting to your WiFi.

This line of code is redundant

as you’ve already defined Serial3 the alias of EspSerial and you then go-on to re-initialise that port…

You certainly shouldn’t have this in your void loop…

The baud rate you use to communicate with your ESP-01 needs to match what your ESP-01 is expecting. That varies depending on the version of the AT firmware that your ESP-01 is running, and whether you’ve overridden those defaults with an AT command.

You also need to check that the Tx pin on Serial3 is connected to the Rx pin on your ESP-01 and vice-versa.

Pete.

1 Like

this is the code after changing and I’m still having problems connecting
the baud rate already match with the wifi, TX and RX in serial 3

#define BLYNK_TEMPLATE_ID "TMPLoBQRKMQ3"
#define BLYNK_DEVICE_NAME "Arduino Mega ESP8266"
#define BLYNK_AUTH_TOKEN "xx"
//  LIBRARY
//====================================================
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
//====================================================

//  DEKLARASI AWAL
//====================================================
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Tenda_16";
char pass[] = "war140500";
#define EspSerial Serial3
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);

//====================================================

BLYNK_WRITE(V2) {
  if (param.asInt()) {
//    digitalWrite(10, HIGH);
    Serial.println('Masuk Switch');
  }
  else {
//    digitalWrite(10, LOW);
    Serial.println('Ganti Switch');
  }

}
//====================================================


void setup()
{
//  pinMode(10, OUTPUT);
  Serial.begin(115200);
  
  Serial.println("Test Setup");
  delay(10);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);                          //Reguler server
}

void loop()
{
  Blynk.run();

}

How do you know this, what diagnostic process have you used?
What AT firmware version is your ESP-01 running?

Are you trying to connect to a 2.4 or 5 GHz network?

Pete.

I already try to program the esp8266 earlier, and the serial is running at 115200 baud

this my AT firmware version


AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin

MD5: 8E9E9252317A9BCA67673C17B9E3E075

FirmWare Infomation:
SPI MODE: DIO
Flash Size: 8Mbit
File Size: 8Mbit
SPI SPEED: 40MHz
SDK Version: V1.5.4
Release Date: 2016.6.15

I’m confused by the information you’ve just posted.
This doesn’t seem to be AT firmware.

Do you have a USB Adapter that allows you to plug the ESP-01 directly into your computer? If so, what serial output does it show when you boot it up?

Pete.

To clarify, I’m using Arduino Mega with built-in ESP8266 on the board. To flash the firmware, I need to change some switches on the board. The firmware I use was from this video tutorial BLYNK ON MEGA+WiFi R3 ATmega2560+ESP8266 - YouTube The ESP8266 is running and communicating with the board because it doesn’t show the “ESP not responding” error in the serial monitor. Yet the ESP8266 is stuck connecting to my wifi.

Oh, one of those!

Okay, good luck with that one.

Pete.