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?



