Help with missing HTTPClient library

Hi everyone!

I’m trying to parse a JSON file to show some live data on the Serial monitor of an Arduino MKR WiFi 1010. This is the code:

#include <ArduinoJson.h>
#include <ArduinoJson.hpp>
#include <HTTPClient.h> #this is the problematic library
#include <WiFi.h>

const char* ssid = "...";
const char* password = "...";

void setup() {
  // Connessione WIFI
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  while(WiFi.status() != WL_CONNECTED) {
    delay(100);
    Serial.print("=");
  }

  Serial.println("CONNESSO");
}

void loop() {
  // Ricevi file JSON da open-meteo
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;
    http.begin(https://api...);
    int httpCode = http.GET();

    if (httpCode > 0) {
      String payload = http.getString();
      Serial.println(payload);

      parseJSON(payload);
    } else {
      Serial.println("Errore HTTP");
    }

    http.end();
  }

  delay(60*1000); // Aggiorna 1 volta al minuto
}

// Interpreta JSON

void parseJSON(String json) {
  DynamiccJsonDocument doc(20000); // Imposta memoria buffer abbastanza grande
  DeserializationError error = deserializeJSon(doc, json); // Imposta allerta errori

  if (!error) {
    float temp = doc["hourly"]["temperature_2m"][0];
    float humidity = doc["hourly"]["relative_humidity_2m"][0];
    Serial.print("Temperatura: "); Serial.print(temp + "\t"); Serial.print("Umidità: "); Serial.println(humidity);
  } else {
    Serial.println("Errore parsing JSON");
  }
}

(I replaced sensitive info with “…”) I don’t know why there is this error:

Compilation error: HTTPClient.h: No such file or directory

I couldn’t find the exact library on the arduino official library manager, where is it? How can I replace the code with another library?

HTTPClient seems to be an ESP32 library; at least that's the only place where I can find it on my system.

[s]There are a WebClient and WebServer examples for the MKR1010 WiFi in the IDE.[s]

// Edit
Wrong board selected :frowning:

Thanks @sonofcy :wink:

Here are the only libraries included with the board. As you can see, HTTPClient is NOT included, so you will need to find a 3rd party library. Pick one and check its compatibility; if it doesn't work, pick another, etc. Sometimes the Arduino Docs list compatible libraries.


Here is the MKR WiFi 1010 Hardware page
https://store.arduino.cc/products/arduino-mkr-wifi-1010
on it is this

Click that and it goes to
https://docs.arduino.cc/hardware/mkr-wifi-1010/
You will see this

Then yiu will see this