Open AndreyVys opened 3 years ago
Function MakehttpRequest
if (httpCode == 200) // Checking the returning code { String payload = http.getString(); // Getting the request response payload StaticJsonDocument<1024> doc; // Parse JSON object DeserializationError error = deserializeJson(doc, payload); if (error) { return; } else { JsonObject main = doc["main"]; temp = (float)main["temp"]-273.15; // Get temperature in °C humidity = (uint_fast8_t)main["humidity"]; // Get humidity in % pressure = (uint_fast8_t)main["pressure"]; // Get pressure in bar visibility = (float)doc["visibility"]; // Get visibility in m weatherCity = (const char*)doc["name"]; JsonObject wind = doc["wind"]; wind_speed = (float)wind["speed"]; // Get wind speed in m/s wind_degree = (float)wind["deg"]; // Get wind degree in ° JsonObject weather = doc["weather"][0]; weatherDesc = (const char*)weather["description"]; weatherIcon = (const char*)weather["icon"]; JsonObject sys = doc["sys"]; sunrise = (time_t)sys["sunrise"]; sunset = (time_t)sys["sunset"]; weatherCountry = (const char*)sys["country"]; }
Forgiveness. Right now I can't check anything. I had a traffic accident
Function MakehttpRequest