String requestURL = String(apiURL) + "?key=" + apikey + "&q=" + city;
HTTPClient http;
int httpCode = http.begin(requestURL);
int httpResponseCode = http.GET();
Serial.print("error code: ");
Serial.println(httpResponseCode);
if (httpResponseCode == 200) {
String payload = http.getString();
StaticJsonDocument<384> doc;
DeserializationError error = deserializeJson(doc, payload);
if (error) {
Serial.print("deserializeJson() failed: ");
Serial.println(error.c_str());
return;
}
JsonObject current = doc["current"];
int current_humidity = current["humidity"];
Serial.print(current_humidity);
http.end();
}
[ 1140][D][HTTPClient.cpp:303] beginInternal(): protocol: http, host: api.weatherapi.com port: 80 url: /v1/current.json?key=mykey&q=Tieno
[ 1145][D][HTTPClient.cpp:598] sendRequest(): request type: 'GET' redirCount: 0
[ 1417][D][HTTPClient.cpp:1156] connect(): connected to api.weatherapi.com:80
[ 1668][D][HTTPClient.cpp:1307] handleHeaderResponse(): code: 200
[ 1668][D][HTTPClient.cpp:1314] handleHeaderResponse(): Transfer-Encoding: chunked
[ 1670][D][HTTPClient.cpp:628] sendRequest(): sendRequest code=200
error code: 200
[ 1687][D][HTTPClient.cpp:922] writeToStream(): read chunk len: 224
[ 1688][D][HTTPClient.cpp:1446] writeToStreamDataBlock(): connection closed or file end (written: 224).
[ 1693][D][HTTPClient.cpp:922] writeToStream(): read chunk len: 0
[ 1699][D][HTTPClient.cpp:388] disconnect(): still data in buffer (2), clean up.
[ 1707][E][WiFiClient.cpp:517] flush(): fail on fd 48, errno: 11, "No more processes"
[ 1717][D][HTTPClient.cpp:393] disconnect(): tcp keep open for reuse
61[ 1721][D][HTTPClient.cpp:408] disconnect(): tcp is closed
Can't read data from JSON file, and flush seems to report an error again.