Trouble compiling code for Arduino Mega/ESP8266 wifi shield and Blynk App

I am trying to interface an ESP8266 - ESP 01 wifi shield with my Arduino Mega AND to control in with the Blynk App. I have downloaded and installed the Blynk App libraries (v 1.0.0) manually (placing folders from libraries folder and folders from tools folder into their namesake counterparts in my sketchbook). I have also added ESP8266 into my Boards Manager. The Blynk App autogenerates the code for me to be used for Arduino Mega/ESP8266 wifi shield duo, however when I try to compile it it keeps failing every time. Any help is much appreciated. Here’s the code:

#define BLYNK_PRINT Serial


#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[] = "nFLX-YJNHOEFYbx6SAzJ_n1TVaJOEkED";

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

// 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);

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

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

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

Here’s the error message I get:


In file included from C:\Users\Sino\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:38:0,
                 from C:\Users\Sino\Documents\Arduino\libraries\Blynk\src/BlynkApiArduino.h:14,
                 from C:\Users\Sino\Documents\Arduino\libraries\Blynk\src/BlynkSimpleShieldEsp8266.h:29,
                 from C:\Users\Sino\Documents\Arduino\blynk_app_simple_sketch\blynk_app_simple_sketch.ino:40:
C:\Users\Sino\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkConsole.h:20:10: fatal error: functional: No such file or directory
 #include <functional>
          ^~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Mega or Mega 2560.

BlynkConsole.h does exist in C:\Users\Sino\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkConsole.h

Read this…

Pete.

Thank you! This got me up and running with compiling the code and uploading it to my Mega. Now I’m having trouble running it…I have changed my code slightly (just the baud rate of the esp8266)

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


#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[] = "nFLX-YJNHOEFYbx6SAzJ_n1TVaJOEkED";

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

// 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 115200//38400

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

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

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

This is what I get on the Serial Monitor:

20:08:15.434 -> [9] 
20:08:15.434 ->     ___  __          __
20:08:15.434 ->    / _ )/ /_ _____  / /__
20:08:15.434 ->   / _  / / // / _ \/  '_/
20:08:15.434 ->  /____/_/\_, /_//_/_/\_\
20:08:15.434 ->         /___/ v1.0.0 on Arduino Mega
20:08:15.434 -> 
20:08:15.917 -> [517] Connecting to Pixel_9410
20:08:16.972 -> [1527] ESP is not responding

Here’s how I’ve wired up everything:

Things I’ve already tried:

  • Uploading a WiFi scan sketch to the ESP8266 with this wiring scheme - it does upload but then shows nothing onto the serial monitor

  • Since many users of the ESP8266 wifi shield emphasized using an external power source, I tried powering the ESP8266 with external 3.3V power source while keeping everything else the same in terms of wiring - did not make a difference

I’m new to this so please bare with me

Your code says Serial1 (18/19) but your wiring diagram shows different.
You want to use the Serial1 for the ESP link, as Serial/USB is in use for programming, serial monitor and debug.

And TX from one must go to RX of the other!!

You can run 19200 or 115200 easily on a hardware serial connection. But BOTH the code and the ESP must be the same

Also, your diagram shows the Mega’s Reset pin being connected to GND.
I’m fairly sure that if you did that then your Mega would be in a constant reboot cycle.

Pete.

@Gunner changed back to Serial1, wired TX to RX and RX to TX, made sure that baud rate was the same in code and for esp - the esp is still not responding

@PeteKnight I have removed this but my problem remains

Are you intending to run the new BlynkIoT or the older, maker friendly, Blynk (legacy). If the later then you need the 0.6.1 library version

Good afternoon
Did you find a solution ?
I facing to the exactly same problem and I can’t fix it.
Withe the wiring on
always the same message : [1527] ESP is not responding.
I watch lot of YouTube video and website pages, no way :frowning:(

@titi I’d suggest that you start by reading this:

and if you are still having problems I’d suggest that you create a new “Need help with my project” topic and provide ALL of the information that is requested when you create the topic, along with full details of how you have connected your two boards together, and whether or not you have ever uploaded a sketch to the ESP-01.

Pete.