Arduino Mega Cant connect to Blynk

Hi, I am currently trying to connect my Arduino Mega to Blynk server using ESP8266 WiFi Shield that I stacked directly on my Arduino Mega. However, when I uploaded my coding, the serial monitor shows error Fail2Rst and FailW as shown below.


Here is my coding. I didn’t know what is wrong with the coding, I used the same coding and same WiFi shield on Arduino UNO, and its working but not with MEGA.

#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[] = "KWZCWLkZKfUuJZgy-LM6C5WlLjSgL3";

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

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

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

// Your ESP8266 baud rate:
#define ESP8266_BAUD 38400

ESP8266 wifi(&EspSerial);

void setup()
  // Debug console

// Set ESP8266 baud rate

Blynk.begin(auth, wifi, ssid, pass);
 // You can also specify server:
 //Blynk.begin(auth, wifi, ssid, pass, "", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

void loop()
 // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!

Change your baud rate to 115200.

#define ESP8266_BAUD 115200

Change my Baud rate but still get the same error. Is it because of the board connection at the serial? Because when I used Arduino UNO, it work perfectly, but not with MEGA. Still confused why I am getting this Fail2Rst error message.

@Izzat_Azman please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:


Edited my coding in the reply above. I got the coding from Blynk Example Browser using my setup which is Mega with ESP8266 WiFi Shield as in this link

Exactly which ESP hardware are you using?
Does this device respond to AT commands?


I am using ESP8266 Wi-Fi Shield which is this one. Since it has all the pins aligned to Arduino Mega, I just stacked the WiFi shield on top of Mega. Tried it with UNO with same coding and it works but not with MEGA. I wonder if it’s actually the Mega serial connection?

From the image, it looks like it has an UNO form factor, and that there are no pins to engage with the 14-21 pins in the bottom right hand corner of the Mega board. If this is the case, then there are no pins to engage with the headers for pins 18 and 19, which are the Serial1 connections you are trying to use in your code.


So basically, how do I overcome this problem? Do I need to use jumper wire to connect those serial pins? Or do I need to change the coding?

I’ve no idea, I’m not familiar with the hardware.
My advice though would be to use a WiFi enabled board with some better processing power…


That could work… remove the selection jumpers (on the shield) and use two F-M jumper wires from the respective RX/TX side of the pin rows on the board… IF there is such pins :thinking: Hard to tell from images alone, to the RX/TX Serial1 pins on the Mega

EDIT… based on the Rev. 2 schematic, there is no user direct pin to the ESP32 RX/TX… However, those do go through a level shifter chip, then to the respective jumper pins. So then you should be able to go from one of them to the appropriate Mega RX/TX pins.

NOTE - I am not sure how this shield handled the needed crossover between devices (ESP32 RX to Mega TX and vice versa)… but if in your testing it doesn’t work, simply swap the wires on one or the other (shield or Mega).