void weatherget(){ HTTPClient http; http.begin(endpoint + key); //URLを指定 int httpCode = http.GET(); //GETリクエストを送信 if (httpCode > 0) { //返答がある場合 String payload = http.getString(); //返答(JSON形式)を取得 //M5.Lcd.println(httpCode); //M5.Lcd.println(payload); //jsonオブジェクトの作成 DynamicJsonBuffer jsonBuffer; String json = payload; JsonObject& weatherdata = jsonBuffer.parseObject(json); //パースが成功したかどうかを確認 if(!weatherdata.success()){ //M5.Lcd.println("parseObject() failed"); } //各データを抜き出し const char* weather = weatherdata["weather"][0]["main"].as<char*>(); const double temp = weatherdata["main"]["temp"].as<double>(); if(weather=="shower rain"||weather=="rain"||weather=="thunderstorm"||weather=="snow"){ weatherflag=1; }else{ weatherflag=0; } //send weather to line if(forecast==1){ line_notify(weather); double tm=temp; tm-=273.15; //int inttmp=tm; line_notify(String(tm)); forecast=0; } //print weather /* M5.Lcd.fillScreen(BLACK); M5.Lcd.setTextColor(WHITE); M5.Lcd.setTextSize(2); M5.Lcd.setCursor(10,10); M5.Lcd.print("weather:"); M5.Lcd.println(weather); M5.Lcd.print("temperature:"); M5.Lcd.println(temp-273.15); */ } //For Debug //weatherflag=1; }