#include <HttpClient.h> doesn't work anymore

Hi!

I had a working project with Arduino Mega + ethernet . The device is sending spin readings to another board with http client but it seems that it doesn’t work anymore.

> #include <HTTPClient.h> says exit status 1
HTTPClient.h: No such file or directory

so now I need to push data to pin of another device (or read from the other device the needed virtual pin)

Any suggestion?

I would have expected you to be using the Arduino HTTP client version 2.2.0, which is included using…

#include <HttpClient.h>

not…

The case is important!

Pete.

my working version is using :

void api_bridge(String token, int virtual_pin, float value_to_send)
{
 HTTPClient http;

  String server_path = server_name + "update?token=" + token + "&pin=v" + String(virtual_pin) + "&value=" +  float(value_to_send);

  // Your Domain name with URL path or IP address with path
  http.begin(server_path.c_str());
  
  // Send HTTP GET request
  Serial.println("Sending ");
  Serial.print(value_to_send);
  Serial.print(" to pin V");
  Serial.println(virtual_pin); 
  
  long request_time = millis();
  int httpResponseCode = http.GET();
  
  if (httpResponseCode>0)
  {
    Serial.print("HTTP Response code: ");
    Serial.println(httpResponseCode);
    String payload = http.getString();
  }
  else
  {
    Serial.print("Error code: ");
    Serial.print(httpResponseCode);
    Serial.print(" <-----------------------------------");    
  }
 
  Serial.print("Response time = ");
  Serial.print(millis() - request_time);
  Serial.println(" milliseconds");
  Serial.println(); 

  // Free resources
  http.end();
}

Well, that’s my code, that I wrote for the ESP32, and has this line near the top…

When you choose an ESP32 board type in the IDE then the compiler uses the file paths that include the core files for that board type.

If you choose an Arduino AVR board type, then different file path are used, and your compiler can’t find a file called HTTPClient.h in the AVR core files.
That’s because the standard Arduino AVR HTTP file is called HttpClient.h not HTTPClient.h.

Changing to the correct header file name for the type of board you are using should allow the compiler to find the correct file.

Pete.

1 Like

Hi ,
I am having the same issue. “HTTPClient.h: No such file or directory”
I am using Arduino IDE 1.8.19 and the selected board is NodeMCU 0.9 (“ESP-12 module”)
Thanks

You should be using #include <ESP8266HTTPClient.h> with the ESP8266 based boards,

Pete.

Hi

I have the same issue with Mega, as shown below. any advice will be appreciated
image

I’m not aware of any way to use an HTTP client with the BlynkSimpleStream library - which is what I assume you are using with a Mega + ESP-01.

Pete.

Thank you, Pete, for your quick reply.
I was supposed to use esp32, but it doesn’t work (is not recognized by the PC)! therefore I used my old Arduino Mega, only to check temperature reading and upload them into server

Have you installed the driver and the ESP32 core?

Pete.