1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| if (weather_client.connect("api.seniverse.com", 80)) { weather_client.print(high_low_https); while (weather_client.connected() || weather_client.available()) { if (weather_client.available()) { String line = weather_client.readStringUntil('\n'); Serial.println(line); DynamicJsonDocument doc(capacity); deserializeJson(doc, line); JsonObject results_0_daily_0 = doc["results"][0]["daily"][0]; tem_high = results_0_daily_0["high"].as<int>(); tem_low = results_0_daily_0["low"].as<int>(); } } weather_client.stop(); }
if (weather_client.connect("api.seniverse.com", 80)) { weather_client.print(now_https); while (weather_client.connected() || weather_client.available()) { if (weather_client.available()) { String line = weather_client.readStringUntil('\n'); Serial.println(line); DynamicJsonDocument doc(capacity); deserializeJson(doc, line); JsonObject now = doc["results"][0]["now"]; tem_now = now["temperature"].as<int>(); update_time = doc["results"][0]["last_update"].as<String>(); position = doc["results"][0]["location"]["name"].as<String>(); weather_condition = now["text"].as<String>(); } } weather_client.stop(); }
if (weather_client.connect("api.seniverse.com", 80)) { weather_client.print(air_https); while (weather_client.connected() || weather_client.available()) { if (weather_client.available()) { String line = weather_client.readStringUntil('\n'); Serial.println(line); DynamicJsonDocument doc(capacity); deserializeJson(doc, line); JsonObject now = doc["results"][0]["air"]; air = now["city"]["quality"].as<String>(); } } weather_client.stop(); }
|