irmecir

wunderground-telegram

Oct 3rd, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.72 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2. #include <WiFiClientSecure.h>
  3. #include <UniversalTelegramBot.h>
  4. #include <ArduinoJson.h>
  5.  
  6.  
  7.  
  8.  
  9. // Initialize Wifi connection to the router
  10. char ssid[] = "hooshmandsazan3"; // your network SSID (name)
  11. char password[] = "!q@w#e4r5t6y"; // your network key
  12.  
  13. // Initialize Telegram BOT
  14. #define BOTtoken "339475786:AAH7IjXu51xPom_sMx8IRnvQbcTD5FfO2Wc" // your Bot Token (Get from Botfather)
  15.  
  16.  
  17.  
  18. WiFiClientSecure client;
  19. UniversalTelegramBot bot(BOTtoken, client);
  20.  
  21. int Bot_mtbs = 1000; //mean time between scan messages
  22. long Bot_lasttime; //last time messages' scan has been done
  23. bool Start = false;
  24.  
  25. const int ledPin = 2;
  26. int ledStatus = 0;
  27.  
  28. void handleNewMessages(int numNewMessages) {
  29. Serial.println("handleNewMessages");
  30. Serial.println(String(numNewMessages));
  31.  
  32. for (int i=0; i<numNewMessages; i++) {
  33. String chat_id = String(bot.messages[i].chat_id);
  34. String text = bot.messages[i].text;
  35.  
  36. String from_name = bot.messages[i].from_name;
  37. if (from_name == "") from_name = "Guest";
  38.  
  39. if (text == "/ledon") {
  40. digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
  41. ledStatus = 1;
  42. bot.sendMessage(chat_id, "Led is ON", "");
  43. }
  44.  
  45. if (text == "/ledoff") {
  46. ledStatus = 0;
  47. digitalWrite(ledPin, LOW); // turn the LED off (LOW is the voltage level)
  48. bot.sendMessage(chat_id, "Led is OFF", "");
  49. }
  50.  
  51. if (text == "/status") {
  52. if(ledStatus){
  53. bot.sendMessage(chat_id, "Led is ON", "");
  54. } else {
  55. bot.sendMessage(chat_id, "Led is OFF", "");
  56. }
  57. }
  58.  
  59. if (text == "/start") {
  60. String welcome = "Welcome to Universal Arduino Telegram Bot library, " + from_name + ".\n";
  61. welcome += "This is Flash Led Bot example.\n\n";
  62. welcome += "/ledon : to switch the Led ON\n";
  63. welcome += "/ledoff : to switch the Led OFF\n";
  64. welcome += "/status : Returns current status of LED\n";
  65. bot.sendMessage(chat_id, welcome, "Markdown");
  66. }
  67. }
  68. }
  69.  
  70.  
  71. // Use your own API key by signing up for a free developer account.
  72. // http://www.wunderground.com/weather/api/
  73. #define WU_API_KEY "c0c5192e71ab0291"
  74.  
  75. // Specify your favorite location one of these ways.
  76. #define WU_LOCATION "IR/esfahan"
  77.  
  78. // US ZIP code
  79. //#define WU_LOCATION ""
  80. //#define WU_LOCATION "90210"
  81.  
  82. // Country and city
  83. //#define WU_LOCATION "Australia/Sydney"
  84.  
  85. // 5 minutes between update checks. The free developer account has a limit
  86. // on the number of calls so don't go wild.
  87. #define DELAY_NORMAL (5*60*1000)
  88. // 20 minute delay between updates after an error
  89. #define DELAY_ERROR (20*60*1000)
  90.  
  91. #define WUNDERGROUND "api.wunderground.com"
  92.  
  93. // HTTP request
  94. const char WUNDERGROUND_REQ[] =
  95. "GET /api/" WU_API_KEY "/forecast/q/" WU_LOCATION ".json HTTP/1.1\r\n"
  96. "User-Agent: ESP8266/0.1\r\n"
  97. "Accept: */*\r\n"
  98. "Host: " WUNDERGROUND "\r\n"
  99. "Connection: close\r\n"
  100. "\r\n";
  101.  
  102. String webpage, city, country, date_time, observationtime, wx_forecast,
  103. DWDay0, DMon0, DDateDa0, DDateMo0, DDateYr0, Dicon0, DHtemp0, DLtemp0, DHumi0, DPop0, DRain0, DW_spd0, DW_dir0, DW_dir_deg0, Condi0,
  104. DWDay1, DMon1, DDateDa1, DDateMo1, DDateYr1, Dicon1, DHtemp1, DLtemp1, DHumi1, DPop1, DRain1, DW_spd1, DW_dir1, DW_dir_deg1, Condi1,
  105. DWDay2, DMon2, DDateDa2, DDateMo2, DDateYr2, Dicon2, DHtemp2, DLtemp2, DHumi2, DPop2, DRain2, DW_spd2, DW_dir2, DW_dir_deg2, Condi2,
  106. DWDay3, DMon3, DDateDa3, DDateMo3, DDateYr3, Dicon3, DHtemp3, DLtemp3, DHumi3, DPop3, DRain3, DW_spd3, DW_dir3, DW_dir_deg3, Condi3;
  107.  
  108. // Astronomy
  109. //String DphaseofMoon, Sunrise, Sunset, Moonrise, Moonset, Moon_image, Moon_light;
  110. bool Centred = true, notCentred = false;
  111. bool Metric = true; // Set to false for Imperial units
  112. bool Hybrid = true; // Set to false to show 'kph' wind speed instead of 'mph' and rain in 'mm' instead of 'in'
  113.  
  114. void setup()
  115. {
  116. Serial.begin(115200);
  117.  
  118. // Set WiFi to station mode and disconnect from an AP if it was Previously
  119. // connected
  120. WiFi.mode(WIFI_STA);
  121. WiFi.disconnect();
  122. delay(100);
  123.  
  124. // attempt to connect to Wifi network:
  125. Serial.print("Connecting Wifi: ");
  126. Serial.println(ssid);
  127. WiFi.begin(ssid, password);
  128.  
  129. while (WiFi.status() != WL_CONNECTED) {
  130. Serial.print(".");
  131. delay(500);
  132. }
  133.  
  134. Serial.println("");
  135. Serial.println("WiFi connected");
  136. Serial.print("IP address: ");
  137. Serial.println(WiFi.localIP());
  138.  
  139. pinMode(ledPin, OUTPUT); // initialize digital ledPin as an output.
  140. delay(10);
  141. digitalWrite(ledPin, LOW); // initialize pin as off
  142. }
  143.  
  144. static char respBuf[10000];
  145.  
  146. void loop()
  147. {
  148.  
  149.  
  150.  
  151. // TODO check for disconnect from AP
  152.  
  153. // Open socket to WU server port 80
  154. Serial.print(F("Connecting to "));
  155. Serial.println(WUNDERGROUND);
  156.  
  157. // Use WiFiClient class to create TCP connections
  158. WiFiClient httpclient;
  159. const int httpPort = 80;
  160. if (!httpclient.connect(WUNDERGROUND, httpPort)) {
  161. Serial.println(F("connection failed"));
  162. delay(DELAY_ERROR);
  163. return;
  164. }
  165.  
  166. // This will send the http request to the server
  167. Serial.print(WUNDERGROUND_REQ);
  168. httpclient.print(WUNDERGROUND_REQ);
  169. httpclient.flush();
  170.  
  171. // Collect http response headers and content from Weather Underground
  172. // HTTP headers are discarded.
  173. // The content is formatted in JSON and is left in respBuf.
  174. int respLen = 0;
  175. bool skip_headers = true;
  176.  
  177. while (httpclient.connected() || httpclient.available()) {
  178. if (skip_headers) {
  179. String aLine = httpclient.readStringUntil('\n');
  180. //Serial.println(aLine);
  181. // Blank line denotes end of headers
  182. if (aLine.length() <= 1) {
  183. skip_headers = false;
  184. }
  185. }
  186. else {
  187. int bytesIn;
  188. bytesIn = httpclient.read((uint8_t *)&respBuf[respLen], sizeof(respBuf) - respLen);
  189. //Serial.print(F("bytesIn ")); Serial.println(bytesIn);
  190. if (bytesIn > 0) {
  191. respLen += bytesIn;
  192. if (respLen > sizeof(respBuf)) respLen = sizeof(respBuf);
  193. }
  194. else if (bytesIn < 0) {
  195. Serial.print(F("read error "));
  196. Serial.println(bytesIn);
  197. }
  198. }
  199. delay(1);
  200. }
  201. httpclient.stop();
  202.  
  203. if (respLen >= sizeof(respBuf)) {
  204. Serial.print(F("respBuf overflow "));
  205. Serial.println(respLen);
  206. delay(DELAY_ERROR);
  207. return;
  208. }
  209. // Terminate the C string
  210. respBuf[respLen++] = '\0';
  211. Serial.print(F("respLen "));
  212. Serial.println(respLen);
  213. //Serial.println(respBuf);
  214.  
  215. if (showWeather_forecast(respBuf)) {
  216. delay(10000);
  217. Serial.println(F("ok"));
  218. }
  219. else {
  220. delay(10000);
  221. Serial.println(F("oooo"));
  222. }
  223.  
  224. if (millis() > Bot_lasttime + Bot_mtbs) {
  225. int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
  226.  
  227. while(numNewMessages) {
  228. Serial.println("got response");
  229. handleNewMessages(numNewMessages);
  230. numNewMessages = bot.getUpdates(bot.last_message_received + 1);
  231. }
  232.  
  233. Bot_lasttime = millis();
  234. }
  235. }
  236.  
  237.  
  238. bool showWeather_forecast(char *json) {
  239.  
  240. //StaticJsonBuffer<8*1024> jsonBuffer;
  241. // Serial.println("JSON data missing");
  242.  
  243.  
  244. char *jsonstart = strchr(json, '{');
  245.  
  246. //Serial.print(F("jsonstart ")); Serial.println(jsonstart);
  247. if (jsonstart == NULL) {
  248. Serial.println(F("JSON data missing"));
  249. return false;
  250. }
  251. json = jsonstart;
  252. DynamicJsonBuffer jsonBuffer1(10000);
  253. // Parse JSON
  254. JsonObject& root = jsonBuffer1.parseObject(json);
  255. if (!root.success()) {
  256. Serial.println(F("jsonBuffer.parseObject() failed"));
  257. return false;
  258. }
  259. // Extract weather info from parsed JSON
  260. JsonObject& wxforecast = root["forecast"]["txt_forecast"];
  261. if (Metric) {String fcttext0 = wxforecast["forecastday"][0]["fcttext_metric"]; wx_forecast = fcttext0;}
  262. else {String fcttext0 = wxforecast["forecastday"][0]["fcttext"]; wx_forecast = fcttext0;}
  263. JsonObject& forecast = root["forecast"]["simpleforecast"];
  264. //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  265. String Temp_mon = forecast["forecastday"][0]["date"]["monthname"];
  266. String Mon0 = forecast["forecastday"][0]["date"]["monthname_short"]; DMon0 = Mon0;
  267. int DateYr0 = forecast["forecastday"][0]["date"]["year"]; DDateYr0 = String(DateYr0).substring(2);
  268. int DateDa0 = forecast["forecastday"][0]["date"]["day"]; DDateDa0 = DateDa0<10?"0"+String(DateDa0):String(DateDa0);
  269. String WDay0 = forecast["forecastday"][0]["date"]["weekday"]; DWDay0 = WDay0;
  270. String TempHr = forecast["forecastday"][0]["date"]["hour"]; observationtime = TempHr+":";
  271. String TempMin = forecast["forecastday"][0]["date"]["min"]; observationtime += TempMin+"Hr on ";
  272. observationtime += DDateDa0+" "+DMon0+" "+DDateYr0;
  273. if (Metric) {
  274. int Htemp0 = forecast["forecastday"][0]["high"]["celsius"]; DHtemp0 = String(Htemp0);
  275. int Ltemp0 = forecast["forecastday"][0]["low"]["celsius"]; DLtemp0 = String(Ltemp0);
  276. int rain0 = forecast["forecastday"][0]["qpf_allday"]["mm"]; DRain0 = String(rain0);
  277. int w_kph0 = forecast["forecastday"][0]["avewind"]["kph"]; DW_spd0 = String(w_kph0);
  278. }
  279. else
  280. {
  281. int Htemp0 = forecast["forecastday"][0]["high"]["fahrenheit"]; DHtemp0 = String(Htemp0);
  282. int Ltemp0 = forecast["forecastday"][0]["low"]["fahrenheit"]; DLtemp0 = String(Ltemp0);
  283. int rain0 = forecast["forecastday"][0]["qpf_allday"]["in"]; DRain0 = String(rain0);
  284. int w_mph0 = forecast["forecastday"][0]["avewind"]["mph"]; DW_spd0 = String(w_mph0);
  285. }
  286. String icon_url0 = forecast["forecastday"][0]["icon"]; Dicon0 = icon_url0;
  287. String pop0 = forecast["forecastday"][0]["pop"]; DPop0 = String(pop0);
  288. String cond0 = forecast["forecastday"][0]["conditions"]; Condi0 = cond0;
  289.  
  290. if (Hybrid && Metric)
  291. {
  292. int w_mph0 = forecast["forecastday"][0]["avewind"]["mph"]; DW_spd0 = String(w_mph0);
  293. }
  294. String w_dir0 = forecast["forecastday"][0]["avewind"]["dir"]; DW_dir0 = String(w_dir0);
  295. String w_dir_deg0 = forecast["forecastday"][0]["avewind"]["degrees"]; DW_dir_deg0 = String(w_dir_deg0);
  296. int humi0 = forecast["forecastday"][0]["avehumidity"]; DHumi0 = String(humi0);
  297. //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  298. String WDay1 = forecast["forecastday"][1]["date"]["weekday"]; DWDay1 = WDay1;
  299. String Mon1 = forecast["forecastday"][1]["date"]["monthname_short"]; DMon1 = Mon1;
  300. int DateDa1 = forecast["forecastday"][1]["date"]["day"]; DDateDa1 = DateDa1<10?"0"+String(DateDa1):String(DateDa1);
  301. int DateYr1 = forecast["forecastday"][1]["date"]["year"]; DDateYr1 = String(DateYr1).substring(2);
  302. if (Metric) {
  303. int Htemp1 = forecast["forecastday"][1]["high"]["celsius"]; DHtemp1 = String(Htemp1);
  304. int Ltemp1 = forecast["forecastday"][1]["low"]["celsius"]; DLtemp1 = String(Ltemp1);
  305. int rain1 = forecast["forecastday"][1]["qpf_allday"]["mm"]; DRain1 = String(rain1);
  306. int w_kph1 = forecast["forecastday"][1]["avewind"]["kph"]; DW_spd1 = String(w_kph1);
  307. }
  308. else
  309. {
  310. int Htemp1 = forecast["forecastday"][1]["high"]["fahrenheit"]; DHtemp1 = String(Htemp1);
  311. int Ltemp1 = forecast["forecastday"][1]["low"]["fahrenheit"]; DLtemp1 = String(Ltemp1);
  312. int rain1 = forecast["forecastday"][1]["qpf_allday"]["in"]; DRain1 = String(rain1);
  313. int w_mph1 = forecast["forecastday"][1]["avewind"]["mph"]; DW_spd1 = String(w_mph1);
  314. }
  315. String icon_url1 = forecast["forecastday"][1]["icon"]; Dicon1 = icon_url1;
  316. String pop1 = forecast["forecastday"][1]["pop"]; DPop1 = String(pop1);
  317. String cond1 = forecast["forecastday"][1]["conditions"]; Condi1 = cond1;
  318. if (Hybrid && Metric)
  319. {
  320. int w_mph1 = forecast["forecastday"][1]["avewind"]["mph"]; DW_spd1 = String(w_mph1);
  321. }
  322. String w_dir1 = forecast["forecastday"][1]["avewind"]["dir"]; DW_dir1 = String(w_dir1);
  323. String w_dir_deg1 = forecast["forecastday"][1]["avewind"]["degrees"]; DW_dir_deg1 = String(w_dir_deg1);
  324. int humi1 = forecast["forecastday"][1]["avehumidity"]; DHumi1 = String(humi1);
  325.  
  326. //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  327. String WDay2 = forecast["forecastday"][2]["date"]["weekday"]; DWDay2 = WDay2;
  328. String Mon2 = forecast["forecastday"][2]["date"]["monthname_short"]; DMon2 = Mon2;
  329. int DateDa2 = forecast["forecastday"][2]["date"]["day"]; DDateDa2 = DateDa2<10?"0"+String(DateDa2):String(DateDa2);
  330. int DateYr2 = forecast["forecastday"][2]["date"]["year"]; DDateYr2 = String(DateYr2).substring(2);
  331. if (Metric) {
  332. int Htemp2 = forecast["forecastday"][2]["high"]["celsius"]; DHtemp2 = String(Htemp2);
  333. int Ltemp2 = forecast["forecastday"][2]["low"]["celsius"]; DLtemp2 = String(Ltemp2);
  334. int rain2 = forecast["forecastday"][2]["qpf_allday"]["mm"]; DRain2 = String(rain2);
  335. int w_kph2 = forecast["forecastday"][2]["avewind"]["kph"]; DW_spd2 = String(w_kph2);
  336. }
  337. else
  338. {
  339. int Htemp2 = forecast["forecastday"][2]["high"]["fahrenheit"]; DHtemp2 = String(Htemp2);
  340. int Ltemp2 = forecast["forecastday"][2]["low"]["fahrenheit"]; DLtemp2 = String(Ltemp2);
  341. int rain2 = forecast["forecastday"][2]["qpf_allday"]["in"]; DRain2 = String(rain2);
  342. int w_mph2 = forecast["forecastday"][2]["avewind"]["mph"]; DW_spd2 = String(w_mph2);
  343. }
  344. String icon_url2 = forecast["forecastday"][2]["icon"]; Dicon2 = icon_url2;
  345. String pop2 = forecast["forecastday"][2]["pop"]; DPop2 = String(pop2);
  346. String cond2 = forecast["forecastday"][2]["conditions"]; Condi2 = cond2;
  347. if (Hybrid && Metric)
  348. {
  349. int w_mph2 = forecast["forecastday"][2]["avewind"]["mph"]; DW_spd2 = String(w_mph2);
  350. }
  351. String w_dir2 = forecast["forecastday"][2]["avewind"]["dir"]; DW_dir2 = String(w_dir2);
  352. String w_dir_deg2 = forecast["forecastday"][2]["avewind"]["degrees"]; DW_dir_deg2 = String(w_dir_deg2);
  353. int humi2 = forecast["forecastday"][2]["avehumidity"]; DHumi2 = String(humi2);
  354.  
  355. //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  356. String WDay3 = forecast["forecastday"][3]["date"]["weekday"]; DWDay3 = WDay3;
  357. String Mon3 = forecast["forecastday"][3]["date"]["monthname_short"]; DMon3 = Mon3;
  358. int DateDa3 = forecast["forecastday"][3]["date"]["day"]; DDateDa3 = DateDa3<10?"0"+String(DateDa3):String(DateDa3);
  359. int DateYr3 = forecast["forecastday"][3]["date"]["year"]; DDateYr3 = String(DateYr3).substring(2);
  360. if (Metric) {
  361. int Htemp3 = forecast["forecastday"][3]["high"]["celsius"]; DHtemp3 = String(Htemp3);
  362. int Ltemp3 = forecast["forecastday"][3]["low"]["celsius"]; DLtemp3 = String(Ltemp3);
  363. int rain3 = forecast["forecastday"][3]["qpf_allday"]["mm"]; DRain3 = String(rain3);
  364. int w_kph3 = forecast["forecastday"][3]["avewind"]["kph"]; DW_spd3 = String(w_kph3);
  365. }
  366. else
  367. {
  368. int Htemp3 = forecast["forecastday"][3]["high"]["fahrenheit"]; DHtemp3 = String(Htemp3);
  369. int Ltemp3 = forecast["forecastday"][3]["low"]["fahrenheit"]; DLtemp3 = String(Ltemp3);
  370. int rain3 = forecast["forecastday"][3]["qpf_allday"]["in"]; DRain3 = String(rain3);
  371. int w_mph3 = forecast["forecastday"][3]["avewind"]["mph"]; DW_spd3 = String(w_mph3);
  372. }
  373. String icon_url3 = forecast["forecastday"][3]["icon"]; Dicon3 = icon_url3;
  374. String pop3 = forecast["forecastday"][3]["pop"]; DPop3 = String(pop3);
  375. String cond3 = forecast["forecastday"][3]["conditions"]; Condi3 = cond3;
  376. if (Hybrid && Metric)
  377. {
  378. int w_mph3 = forecast["forecastday"][3]["avewind"]["mph"]; DW_spd3 = String(w_mph3);
  379. }
  380. String w_dir3 = forecast["forecastday"][3]["avewind"]["dir"]; DW_dir3 = String(w_dir3);
  381. String w_dir_deg3 = forecast["forecastday"][3]["avewind"]["degrees"]; DW_dir_deg3 = String(w_dir_deg3);
  382. int humi3 = forecast["forecastday"][3]["avehumidity"]; DHumi3 = String(humi3);
  383.  
  384. Serial.println(F(""));
  385. Serial.print(F("Emruz: "));
  386. Serial.println(DWDay0);
  387. Serial.print(F("Bishtarin Dama: "));
  388. Serial.println(DHtemp0);
  389. Serial.print(F("Kamtarin Dama: "));
  390. Serial.println(DLtemp0);
  391. Serial.print(F("vaziyate hava: "));
  392. Serial.println(Condi0);
  393. Serial.print(F("rotubate: "));
  394. Serial.println(DHumi0);
  395. Serial.print(F("sorate bad: "));
  396. Serial.println(DW_spd0);
  397. Serial.print(F("jahate bad: "));
  398. Serial.println(DW_dir0);Serial.println(F(""));
  399.  
  400. Serial.print(F("Emruz: "));
  401. Serial.println(DWDay1);
  402. Serial.print(F("Bishtarin Dama: "));
  403. Serial.println(DHtemp1);
  404. Serial.print(F("Kamtarin Dama: "));
  405. Serial.println(DLtemp1);
  406. Serial.print(F("vaziyate hava: "));
  407. Serial.println(Dicon3);
  408. Serial.print(F("rotubate: "));
  409. Serial.println(DHumi1);
  410. Serial.print(F("sorate bad: "));
  411. Serial.println(DW_spd1);
  412. Serial.print(F("jahate bad: "));
  413. Serial.println(DW_dir1);Serial.println(F(""));
  414.  
  415. Serial.print(F("Emruz: "));
  416. Serial.println(DWDay2);
  417. Serial.print(F("Bishtarin Dama: "));
  418. Serial.println(DHtemp2);
  419. Serial.print(F("Kamtarin Dama: "));
  420. Serial.println(DLtemp2);
  421. Serial.print(F("vaziyate hava: "));
  422. Serial.println(Dicon2);
  423. Serial.print(F("rotubate: "));
  424. Serial.println(DHumi2);
  425. Serial.print(F("sorate bad: "));
  426. Serial.println(DW_spd2);
  427. Serial.print(F("jahate bad: "));
  428. Serial.println(DW_dir2);Serial.println(F(""));
  429.  
  430. Serial.print(F("Emruz: "));
  431. Serial.println(DWDay3);
  432. Serial.print(F("Bishtarin Dama: "));
  433. Serial.println(DHtemp3);
  434. Serial.print(F("Kamtarin Dama: "));
  435. Serial.println(DLtemp3);
  436. Serial.print(F("vaziyate hava: "));
  437. Serial.println(Dicon3);
  438. Serial.print(F("rotubate: "));
  439. Serial.println(DHumi3);
  440. Serial.print(F("sorate bad: "));
  441. Serial.println(DW_spd3);
  442. Serial.print(F("jahate bad: "));
  443. Serial.println(DW_dir3);Serial.println(F(""));
  444. /*
  445. Serial.println(DHtemp1);
  446. Serial.println(DLtemp1);
  447. Serial.println(DHtemp2);
  448. Serial.println(DLtemp2);
  449. Serial.println(DHtemp3);
  450. Serial.println(DLtemp3);*/
  451. // JsonObject& current = root["forecast"]["simpleforecast"];
  452. // int DateDa = current["forecastday"][0]["date"]["day"]; Serial.print(String(DateDa)+"/");
  453. // int DateMo = current["forecastday"][0]["date"]["month"]; Serial.print((DateMo<10?"0":"")+String(DateMo)+"/");
  454. // int DateYr = current["forecastday"][0]["date"]["year"]; Serial.print(String(DateYr)+" ");
  455. // int Htemp = current["forecastday"][0]["high"]["celsius"]; Serial.print("High temp :"+String(Htemp));
  456. // int Ltemp = current["forecastday"][0]["low"]["celsius"]; Serial.println(" Low temp :"+String(Ltemp));
  457. //jsonBuffer1.clear();
  458. return true;
  459. }
Advertisement
Add Comment
Please, Sign In to add comment