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

CMD error on Blynk


#1

Hi there, I am a newbie here.
I am turning LED on and OFF using ESP8266( esp01) wifi module connected with Arduino UNO.
I am getting CMD error after sending multiple requests to the server.
After CMD error it disconnects and without being reset,it cant be connected again!

How do I solve it?

I am using Blynk library 0.5.4
Arduino IDE version 1.8.7
Using the Blynk Server and Blynk android app

Here is the code

#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
int counter = 0;
#include <ESP8266_Lib.h>
//#include<ESP8266WiFi.h>
#include <BlynkSimpleShieldEsp8266.h>


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxx"; 

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

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
BlynkTimer timer;

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);
void doTheWork()
{ 
  Blynk.run();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  timer.setInterval(500L,doTheWork);
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
 if(Blynk.connected())
  {
    timer.run();
  }
  else if(!Blynk.connected())
  {
      //I am resetting here, because without this error wont go and cant connect again
      Blynk.begin(auth, wifi, ssid, pass);
  } 
}

Here is the Serial Monitor debugging log

1028023] >[14|00] [00|06]
[1028023] >dw[00]6[00]1
[1028034] >[14|00]![00|06]
[1028040] >dw[00]6[00]0
[1028075] >[14|00]"[00|06]
[1028096] >dw[00]6[00]1
[1037012] <[06|00]V[00|00]
[1042038] Cmd error


#2

Nope, nope, nope, nope… :slight_smile:

When using Blynk.begin() don’t worry to much about re-connection routines until you have better understanding… then look here and at the Documentation about Blynk.config()

Otherwise… just keep a basic void loop()

void loop() {
Blynk.run();  // needed here for Blynk stuff... can be excluded (via logic check) if connection fails, in-order to expedite non connected functionality until re-connection occurs.
timer.run();  // needed here for timers (if used)... never exclude! (if using timers)
}

#3

Even using the simple loop like that it gives CMD error.
I am not able to understand why such error.Not using timer now.

Also how do I use Blynk.config ?


#4

where is the code with Blynk.virtualWrite V0 and Digital write ?? :stuck_out_tongue:


#5

I have added a button on Blynk app for controlling the D6 pin on arduino. Blynk.run() is taking care of all the things. i.e reading data from server and updating the same on arduino pins.


#6

this is this part of your code that cause the CMD

please post your full code


#7
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
int counter = 0;
#include <ESP8266_Lib.h>
//#include<ESP8266WiFi.h>
#include <BlynkSimpleShieldEsp8266.h>


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxx"; 

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

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
BlynkTimer timer;

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

void doTheWork()
{ 
  Blynk.disconnect();
  Blynk.config(wifi,auth);
  Blynk.connect();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

timer.setInterval(20000l,doTheWork);
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
 Blynk.run();
 if(!Blynk.connected())
 {
  timer.run();
 }
}

I am just trying to turn LED on and Off, CMD error comes and connection to Blynk server drops.


#8

I all you are doing is using Blynk and App in direct pin control (AKA no virtual pins) then just stick with the Blynk Blink sketch without modifying all the needed stuff.

If however you want to learn how to program more advanced things, then keep reading the Docs and Help Center on how to do it properly.

CMD error (aka bad command, no sprechen Sie binary, wait? what?.. etc. ) may be due to a bad network, possibly even a glitch Serial connection between your Arduino and ESP … who knows.


#9

I don’t see any virtual button no more D6 output


#10

Arrgg… backticks NOT commas… :stuck_out_tongue_winking_eye:

Blynk%20-%20FTFC


#11

You are STILL breaking how Blynk works :unamused:


#12

I know, bad editing of code


#13

I changed my code to this, and it still gives CMD error.
Please tell me
What am I doing wrong here

After CMD error, it simply hangs there, I am on a stable Wifi connection,So I think no issues there!
Doesnt even try to reconnect

#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>


char auth[] = "xxx"; 

char ssid[] = "Hakunamatata";
char pass[] = "274987079";

#define EspSerial Serial1
SoftwareSerial EspSerial(2, 3); // RX, TX

#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  Blynk.begin(auth, wifi, ssid, pass);
}

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

#14

This is in conflict… there is NO Serial1 (a 2nd hardware UART) on an Arduino UNO


#15

I am using the software serial UART

https://www.arduino.cc/en/Tutorial/SoftwareSerialExample


#16

To do so you only use this:

...
#include <SoftwareSerial.h>
...
SoftwareSerial EspSerial(2, 3); // RX, TX
...

I.e., delete this line from your code (as @Gunner implicitly said):

#define EspSerial Serial1

#17

Alright changed that too

CMD error still remains