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

Device sporadically working, connection problem Blynk 2.0

hi everyone
i’m trying to move to Blynk 2.0, i found quite easy to create an application from boot website and the app.
The problem is that my device sporadically succeed to connect.
The first time that i loaded the code it’s connected fine, then i tried to update the code and it suddenly stopped to work.
So i tried to reupload the original code, and nothing.
After some attempt it started again to work, and now nothing again :frowning:

I don’t know what could it be, recently i had some problem with the Serial function (in others applications), like the program got stuck in the setup().
Then if i try to open the serial monitor while the device is running the code, it don’t reset.

Here my procedure:

I’ve created a simple template
create a new device associated to that template.
i upload this code in my ESP8266 01

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "***********"
#define BLYNK_DEVICE_NAME "******"


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//WIFI
char auth[] = "*********";
char ssid[] = "***********";
char pass[] = "*******************************";
void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
}
void loop()
{
  Blynk.run();
}

a thing which i’m not sure is if in:
#define BLYNK_DEVICE_NAME
i have to define the Device name or the template name, because one of that time when it’s connected i used the template name.

Device: ESP8266 01
Blynk Lyb: 1.0.1

You’ll need to copy the Device Name, Template ID and Blynk Auth Token from the web consule (Device info).
For Esp8266 you’ll need to use bautrate 9600 instead of 115200 for working properly. Maybe you’ll need to flash your esp8266 again with right settings…

nothing…
from the serial monitor the execution got stuck at:
Connecting to MYSSID (which is correct)

Just to be sure… The 3 lines (device name etc.) need to be on top of your code.
Can you share the output of your serail monitor (between the 3 backticks)?

yes they are

actually the serial output is quite weird:
each line came out after a reset from the RST pin.

2dn,4⸮BGH,D:n⸮3⸮[65] Connecting to TIM-20081436
2DOz4⸮CGH⸮xO⸮⸮[65] Connecting to TIM-20081436
⸮Hl⸮⸮⸮$0z⸮$⸮⸮E⸮[64] Connecting to TIM-20081436
⸮EO⸮v⸮H⸮⸮ayOi⸮[65] Connecting to TIM-20081436

from blynk documentation i would expect something like this:
Blynk v.X.X.X
Your IP is 192.168.0.11
Connecting to…
Ready (ping: 40ms)

According to your first post not! Blynk Print Serial is the first line there…

If you get weird output in the serialmonitor your bautrate is not correct. For properly working with a esp8266 it will need to be 9600. So you have to be sure it’s flashed with 9600 and you’ll need to use 9600 in your code like Serial.begin(9600).

Ok, I’ll try this later, but even commenting out that line and the serial.begin() the problem persist.

No the serial monitor baudrate is ok, I think that thing is from hardware side problem…

Ok, good luck…

Nothing

this is the updated code:

#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "ESP1"
#define BLYNK_AUTH_TOKEN "***"
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "TIM-20081436";
char pass[] = "***";

void setup()

{

  Serial.begin(9600);
  delay(500);
  Blynk.begin(auth, ssid, pass);
}

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

i’ve added a delay before Blynk.begin and now the output is:

⸮Hp⸮<⸮hl$⸮pd:I⸮[566] Connecting to TIM-20081436
$l⸮⸮⸮ fS[⸮@>l⸮⸮[565] Connecting to TIM-20081436
⸮txW⸮⸮l$⸮l`:I⸮[565] Connecting to TIM-20081436

like that number is the time from the reset…
i’ll try to connect the wifi just with the ESP8266WiFi.h, like explained here

EDID

i can successfully connect the ESP using this code, so i guess it isn’t a problem of that library or the hardware, rather is a problem of blynk.

These characters…

are messages from your hardware, which you can’t read because your serial monitor is set to 115200 and your hardware is sending its system messages at a different baud rate.
Change the serial monitor baud rate until the first part of the message is legible (the Blynk messages will be illegible) then update your sketch to use that baud rate.

Pete.

I’m quite sure both baudrates are correct, in fact after the wrong reception characters the message is ok.
I think is because after the reset there’s some kind of signal on tx pin, not correlated with Serial transmissions.

Tomorrow I’ll make more tests and show the results.

the top of you code should follow this format

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

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

You would input your Template ID, Device Name, and Auth Token to the top three fields, and input your SSID and Password in the bottom two. leave char auth[] = BLYNK_AUTH_TOKEN; as is.

Also make sure you have the most up to date library for BLYNK.

ok i successfully connected my device to the blynk cloud.
Note that this has been the first attempt after the pc reboot.

This is my code:

#define BLYNK_TEMPLATE_ID "TMPL*****"
#define BLYNK_DEVICE_NAME "ESP1"
#define BLYNK_AUTH_TOKEN "*****"
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "TIM-20081436";
char pass[] = "**************";

void setup()

{

  Serial.begin(115200);
  delay(100);
  Blynk.begin(auth, ssid, pass);
}

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

This is the serial output:

⸮@⸮⸮#⸮⸮?⸮⸮0⸮⸮⸮⸮⸮R⸮-⸮!!⸮⸮⸮⸮i⸮⸮⸮{l[164] Connecting to TIM-20081436
[6167] Connected to WiFi
[6167] IP: *************
[6167] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on ESP8266

[6173] Connecting to blynk.cloud:80
[6291] Ready (ping: 35ms).

as you can see still persist a weird message at the start, even if the serial monitor baudrate IS 115200 baud.

Now i’m at the same initial point of yesterday, i hope that reuploading again this code still work.
I suppose is some problem with my serial interface (???), since after restarting my PC everything worked fine.

Now i’ll try to re-flash this exact same code and see what happen, then i’ll try to add a push button…

EDIT

Nothing, i reflashed the exact same code and i’m again with the same problem, stuck at connecting to…
this is really weird!

I don’t think you are comprehending the baud rate issue.
These messages are from the device when it boots up, and are at the board’s default baud rate.
The baud rate you specify in the Serial.begin command are actioned much later in the process, so what you specify there has no impact on the boot messages coming from the ESP8266.
I’d suggest that you re-read this, and follow the steps I suggeted…

Once you’ve done this you will be able to understand what the ESP8266 us telling you, and this may give you an insight into your underlying issue.

Pete.

1 Like

ok thanks you Pete, i misunderstood your post.
I don’t know my ESP’s default baud rate, standard ones seems not work (9600, 115200), i’ll try with different ones…
could it be some kind of random message unreadable with UART protocol?

PS:
I switched USB port, from 3.0 to a 2.0 one, and i’m able to flash again the code and get the ESP connected without problems.

EDIT

reading here, especially the last post…

74880 is usually the one that works.

Pete.

Check this out :

https://docs.blynk.io/en/legacy-platform/legacy-articles/esp8266-with-at-firmware

I remember when I was using this module I was using baud rate 115200 with no problem

Cool, i got this.

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3584, room 16 
tail 0
chksum 0xb0
csum 0xb0

however i solved the initial problem by programming my device through USB 2.0

thanks you all guys for your support!

1 Like