I recently stumbled across Blynk and am now trying to get some of the examples to work with my Arduino Nano using ESP8266 as wifi shield. However, no matter which example I try (the ESP8266_Shield one for example) after the connection is established, I always receive a “Cmd error” as shown in the serial output below (using BLYNK_DEBUG and I replaced ssid, auth token etc.). After the error it reconnects until a few seconds later the next “Cmd error” occurs and so on.
This is the sketch causing this (although it also appears with every other example I tried), the ESP8266_Shield.ino adapted to my setup:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "XXXX";
char pass = "XXXXXXXXXX";
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
SoftwareSerial EspSerial(11, 12); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 19200
// Set console baud rate
// Set ESP8266 baud rate
Blynk.begin(auth, wifi, ssid, pass);
As the firmware seems to be the correct one and the initial connection works (so ssid, password and auth token are correct) I tried several possible solutions (given by this community or generally linked to ESP8266 problems) including
changing the channel used by my network in order to avoid overlapping with others
changing the power source for Arduino and ESP8266
assuring that the sketch leaves enough dynamic memory
changing baud rate
using different values for delay().
I even set up my own local Blynk server and tried it all over again but that did not fix the problem. If I set up a project without Blynk using only the built-in AT commands of ESP8266, everything works fine and my wifi connection is stable.
So I would really appreciate if anyone gave me a hint towards what else could cause this problem.
@Costas thanks for the quick answer. For the ESP I’m currently using an external 3V3, 1A power supply.
I tried disabling BLYNK_DEBUG but still my connection constantly fails.
Sorry, for the ESP baud rate I forgot to mention that every other value than 19200 gives me a “Failed to disable echo” error message, so in these cases there isn’t even a connection established in the first place.
@Costas: thanks, I didn’t know that. But the weird thing is, syncAll() works fine, syncing ALL needed pins!? AND the error is also weird - what does it means Cmd error?.. but let’s not mess marco’s topic. My problem gone after changing to syncAll()…
@marvin7 glad to here that your problem was solved!
Out of interest, did you also just receive the “Cmd error”? Because that’s what irritates me most, every other problem related to cmd I found here always includes some “Cmd skipped” or other message following the error. Meanwhile all I get is the “Cmd error” without any further information.
I wonder… Maybe upgrading ESP AT firmware will help?
exactly! That is why your topic got my attention! There was cmd error, then blynk disconnected. I was sure I had the output log saved, but can’t find it now. The ‘cmd skipped’ I had later on, after some messing with code. But only after changing code as above, error(s) had gone
@Costas unfortunately this didn’t solve it either, however I figured it out and it turns out the error is not related to Blynk:
Yesterday I had the opportunity to try my whole setup at a friend’s house and it just worked “out of the box”. I was really confused because with my router I literally tried changing every single option there was, so to compare, we took a deeper look into his router settings.
Now it turns out that he uses exactly the same settings as me (WPA2, 802.11n only mode, etc.), we could not find a single difference! We were however capable of reconstructing my error by simply shortly deactivating his network and then activating it again. This produced the “cmd error” without any further information and afterwards reconnects again.
So for testing purposes I noted all of his settings, went home and made sure my router is configured exactly the same way, even using the ssid and password of his network to make sure there wasn’t some kind of special character or else messing the whole thing up.
But again the same behavior, connecting, “Cmd error”, reconnecting and so on.
So for now I am unfortunately not capable of locating the exact cause (there are no more settings I can change) but it seems to be a router specific issue (maybe a hidden setting I cannot change?).
So for everyone who runs into similar problems I would just advise: Make sure that after checking all your setup, hardware etc., you also try connecting with a different router even if there are no apparent differences in configuration etc.!
This MAY BE a router specific issue (though it’s weird). I do remember one APoint made by D-Link, which had serious connection issue with JUST ONE device. All in all I was forced to buy another… And what about DNS servers config, tryed 184.108.40.206?
I am at this point 99% sure it is a router specific issue.
Unfortunately I can’t change the DNS settings in my router (the available options overall are pretty poor) so I can’t try this out but it could be a factor although my ESP is the only device facing this kind of trouble connecting to my network.
For now I found a pretty neat solution by simply configuring my Raspberry Pi as a wifi router/access point. Of course this is not really the preferable way to go when it comes to everyday usage of Blynk and the ESP but for experimenting around and trying some stuff it is actually quite nice to have a network you can simply mess around with.
By the way this is also configured exactly like my “normal” router with WPA2 and everything but it works perfectly!