Hi,
You can add few lines as the code shown below. This is to reset the ESP8266 module before starting the program to solve "Failed to enable MUX" issue.
If it shows "Failed to disable echo" issue, it is pin selection problem for UART, so you need to double check either the mini jumpers or at the coding.
- CODE: SELECT_ALL_CODE
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "your auth token";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "your ssid";
char pass[] = "your pass";
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(10, 11); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
EspSerial.println("AT+RST"); <-- add these 4 lines here
delay(1000);
while(EspSerial.available())
EspSerial.read();
Blynk.begin(auth, wifi, ssid, pass);
}
void loop()
{
Blynk.run();
}
Attached is also screenshot of my test, I used Uno, but it should work for Mega as well.
- blynk2.png (17.48 KiB) Viewed 12507 times