Communication between ESP8266 and Arduino Mega for HTTP get request.

Hello, I am new to this site, hope I selected the forum session correctly.
Currently, I have a hard time on HTTP get request.
The version of ESP8266 is that I am using is ESP and a MEGA 2560.

The library I am using :[](http://
The reference website : ESP8266: HTTP GET Requests - techtutorialsx
The ESP8266 ESP-01:

It shows that ESP-01 is not compatible with code, is there any way to solve this?? Any suggestion is appreciated.
Thank you!

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPassword";
void setup () {
  Serial1.begin(115200);  // I connected   Serial1(19, 18); // RX, TX
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
void loop() {
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
    HTTPClient http;  //Declare an object of class HTTPClient
    http.begin("");  //Specify request destination
    int httpCode = http.GET();                                  //Send the request
    if (httpCode > 0) { //Check the returning code
      String payload = http.getString();   //Get the request response payload
      Serial.println(payload);             //Print the response payload
    http.end();   //Close connection
  delay(30000);    //Send a request every 30 seconds

The output

Arduino: 1.8.13 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from C:\Users\Castaway\Desktop\WIFI_test\WIFI_test.ino:1:0:

C:\Users\Castaway\Documents\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:28:10: fatal error: wl_definitions.h: No such file or directory

 #include <wl_definitions.h>


compilation terminated.

exit status 1

Error compiling for board Arduino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The ESP8266WiFi library is written specifically to be used only in sketches that will be uploaded to the ESP8266 directly. You can’t use it in sketches that will be uploaded to the Mega 2560. So for the application where you are using the ESP-01 as a WiFi adapter for a different Arduino board, controlled via AT commands over serial, this library can not be used.

Your first clue should have been when you found it was very difficult to install the library. This is because it’s not intended to be installed on its own. It comes bundled with the ESP8266 boards platform you install via Boards Manager. Having it installed separately might cause you problems if you ever decide to start programming ESP8266 directly so I recommend you to delete the C:\Users\Castaway\Documents\Arduino\libraries\ESP8266WiFi folder.

For the application of using the ESP-01 as a WiFi adapter for another Arduino board, I recommend this library:

Thank you for your detailed suggestion!

You're welcome. I'm glad if I was able to be of assistance. Enjoy!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.