Couldn't get values from AccuWeather with MinuteCast API Integration

Hello there!

I have recently got an issue with the integration of API in AccuWeather but it got solved
but now I have another issue in the Integration of MinuteCast, I have all the API keys and there seems to be a different syntax or code for MinuteCast and in my last Topic/Question I had an issue with core weather data (Temp, Humidity, Pressure) (Which got solved ) but now I have an issue on Minutecast which tells the duration of rain and the type of rain or snow

Here is my last topic: Error on API Integration and data request from AccuWeather - #12 by VishanAmarnath

You can get the AccuWeather libraries from my last post over here :arrow_up: :arrow_up:

There is no proper documentation for Minutcast in the GitHub library.......

This is the code for the core weather data :

#include <ArduinoHttpClient.h>


#include <JsonListener.h>
#include <AccuWeatherLibrary.h>

AccuweatherDailyData dataD[2];
AccuweatherHourlyData dataH;
AccuweatherCurrentData dataC;

Accuweather aw("tVhZeddCMqPW9GgbAfHIjlzExAam4T0X", 307525, "en-us", true);
void handleTEMP();

void setup() {
  Serial.begin(115200);
  WiFi.begin("vishan", "jetro2018");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println(".");
    delay(100);   
  } 

  
  Serial.println(String(ESP.getFreeHeap()));
  int timeStart = millis();
  //int ret = aw.getDaily(dataD,2);
  //int ret = aw.getHourly(&dataH, 1);
  int ret = aw.getCurrent(&dataC);
  
  if (ret != 0){
    Serial.println("ERROR");
    Serial.println(ret);
    return;
  }
  
  while (aw.continueDownload() > 0){
  }

  //print_dataD();
  //print_dataH();
  print_dataC();

  timeStart = millis() - timeStart;

  Serial.printf("Downloaded and parsed in %d ms\n", timeStart);
  Serial.println(String(ESP.getFreeHeap()));
  
}

void loop() {
  // put your main code here, to run repeatedly:

}

void print_dataC(){
  Serial.println(dataC.LocalObservationDateTime);
  Serial.println(dataC.EpochTime);
  Serial.println(dataC.WeatherText);
  Serial.println(dataC.WeatherIcon);
  Serial.println(dataC.IsDayTime);
  Serial.println(dataC.Temperature);
  Serial.println(dataC.RealFeelTemperature);
  Serial.println(dataC.RealFeelTemperatureShade);
  Serial.println(dataC.RelativeHumidity);
  Serial.println(dataC.WindDirection);
  Serial.println(dataC.WindSpeed);
  Serial.println(dataC.WindGustSpeed);
  Serial.println(dataC.UVIndex);
  Serial.println(dataC.UVIndexText);
  Serial.println(dataC.Visibility);
  Serial.println(dataC.CloudCover);
  Serial.println(dataC.Pressure);
}

void print_dataH(){
  Serial.println(dataH.DateTime);
  Serial.println(dataH.EpochDateTime);
  Serial.println(dataH.WeatherIcon);
  Serial.println(dataH.IconPhrase);
  Serial.println(dataH.IsDaylight);
  Serial.println(dataH.Temperature);
  Serial.println(dataH.RealFeelTemperature);
  Serial.println(dataH.WindSpeed);
  Serial.println(dataH.WindDirection);
  Serial.println(dataH.WindGustSpeed);
  Serial.println(dataH.RelativeHumidity);
  Serial.println(dataH.Visibility);
  Serial.println(dataH.UVIndex);
  Serial.println(dataH.UVIndexText);
  Serial.println(dataH.PrecipitationProbability);
  Serial.println(dataH.RainProbability);
  Serial.println(dataH.SnowProbability);
  Serial.println(dataH.IceProbability);
  Serial.println(dataH.TotalLiquid);
  Serial.println(dataH.Rain);
  Serial.println(dataH.Snow);
  Serial.println(dataH.Ice);
  Serial.println(dataH.CloudCover);
}

void print_dataD(){
    Serial.println("====DAY 1====");
  Serial.println(dataD[0].Date);
  Serial.println(dataD[0].TempMin);
  Serial.println(dataD[0].TempMax);
  Serial.println(dataD[0].RealFeelTempMin);
  Serial.println(dataD[0].RealFeelTempMax);
  Serial.println(dataD[0].HoursOfSun);
  Serial.println(dataD[0].EpochDate);
  Serial.println(dataD[0].SunRise);
  Serial.println(dataD[0].SunSet);
  Serial.println("====DAY:====");
  Serial.println(dataD[0].Day.IconPhrase);
  Serial.println(dataD[0].Day.LongPhrase);
  Serial.println(dataD[0].Day.Ice);
  Serial.println(dataD[0].Day.Rain);
  Serial.println(dataD[0].Day.RelativeHumidity);
  Serial.println(dataD[0].Day.Snow);
  Serial.println(dataD[0].Day.TotalLiquid);
  Serial.println(dataD[0].Day.Visibility);
  Serial.println(dataD[0].Day.WindGustSpeed);
  Serial.println(dataD[0].Day.WindSpeed);
  Serial.println(dataD[0].Day.WindDirection);
  Serial.println(dataD[0].Day.CloudCover);
  Serial.println(dataD[0].Day.IceProbability);
  Serial.println(dataD[0].Day.PrecipitationProbability);
  Serial.println(dataD[0].Day.RainProbability);
  Serial.println(dataD[0].Day.SnowProbability);
  Serial.println(dataD[0].Day.ThunderstormProbability);
  Serial.println(dataD[0].Day.WeatherIcon);
  Serial.println("====NIGHT:====");
  Serial.println(dataD[0].Night.IconPhrase);
  Serial.println(dataD[0].Night.LongPhrase);
  Serial.println(dataD[0].Night.Ice);
  Serial.println(dataD[0].Night.Rain);
  Serial.println(dataD[0].Night.RelativeHumidity);
  Serial.println(dataD[0].Night.Snow);
  Serial.println(dataD[0].Night.TotalLiquid);
  Serial.println(dataD[0].Night.Visibility);
  Serial.println(dataD[0].Night.WindGustSpeed);
  Serial.println(dataD[0].Night.WindSpeed);
  Serial.println(dataD[0].Night.WindDirection);
  Serial.println(dataD[0].Night.CloudCover);
  Serial.println(dataD[0].Night.IceProbability);
  Serial.println(dataD[0].Night.PrecipitationProbability);
  Serial.println(dataD[0].Night.RainProbability);
  Serial.println(dataD[0].Night.SnowProbability);
  Serial.println(dataD[0].Night.ThunderstormProbability);
  Serial.println(dataD[0].Night.WeatherIcon);
  Serial.println("====DAY 2====");
  Serial.println(dataD[1].Date);
  Serial.println(dataD[1].TempMin);
  Serial.println(dataD[1].TempMax);
  Serial.println(dataD[1].RealFeelTempMin);
  Serial.println(dataD[1].RealFeelTempMax);
  Serial.println(dataD[1].HoursOfSun);
  Serial.println(dataD[1].EpochDate);
  Serial.println(dataD[1].SunRise);
  Serial.println(dataD[1].SunSet);
  Serial.println("====DAY:====");
  Serial.println(dataD[1].Day.IconPhrase);
  Serial.println(dataD[1].Day.LongPhrase);
  Serial.println(dataD[1].Day.Ice);
  Serial.println(dataD[1].Day.Rain);
  Serial.println(dataD[1].Day.RelativeHumidity);
  Serial.println(dataD[1].Day.Snow);
  Serial.println(dataD[1].Day.TotalLiquid);
  Serial.println(dataD[1].Day.Visibility);
  Serial.println(dataD[1].Day.WindGustSpeed);
  Serial.println(dataD[1].Day.WindSpeed);
  Serial.println(dataD[1].Day.WindDirection);
  Serial.println(dataD[1].Day.CloudCover);
  Serial.println(dataD[1].Day.IceProbability);
  Serial.println(dataD[1].Day.PrecipitationProbability);
  Serial.println(dataD[1].Day.RainProbability);
  Serial.println(dataD[1].Day.SnowProbability);
  Serial.println(dataD[1].Day.ThunderstormProbability);
  Serial.println(dataD[1].Day.WeatherIcon);
  Serial.println("====NIGHT:====");
  Serial.println(dataD[1].Night.IconPhrase);
  Serial.println(dataD[1].Night.LongPhrase);
  Serial.println(dataD[1].Night.Ice);
  Serial.println(dataD[1].Night.Rain);
  Serial.println(dataD[1].Night.RelativeHumidity);
  Serial.println(dataD[1].Night.Snow);
  Serial.println(dataD[1].Night.TotalLiquid);
  Serial.println(dataD[1].Night.Visibility);
  Serial.println(dataD[1].Night.WindGustSpeed);
  Serial.println(dataD[1].Night.WindSpeed);
  Serial.println(dataD[1].Night.WindDirection);
  Serial.println(dataD[1].Night.CloudCover);
  Serial.println(dataD[1].Night.IceProbability);
  Serial.println(dataD[1].Night.PrecipitationProbability);
  Serial.println(dataD[1].Night.RainProbability);
  Serial.println(dataD[1].Night.SnowProbability);
  Serial.println(dataD[1].Night.ThunderstormProbability);
  Serial.println(dataD[1].Night.WeatherIcon);
}

Any help would be appreciated
Thank you
vishan

There are warnings on the library code (possibly programing mistakes) and you don't actually use that library so I would remove this line.

Are you getting this output?

18:00:46.711 -> .
18:00:46.810 -> .
18:00:46.908 -> 46352
18:00:47.005 -> ERROR
18:00:47.005 -> 401

A '401' Error means you aren't authorized to make the request. Are you sure your API Key is valid?

No, I didn't get the error
You might have gotten this error because you didn't give the API key

Shall I provide my temporary API key here?

I got the error in compilation..... That said that there is nothing like MinuteCast in the library

So the code you provided is NOT the code you re getting a compilation error in? Why post the wrong code?

Your problem seems to be that the library you are using currently only supports the Current, Daily and Hourly forecasts. To use the Minutecast you will need a different library (if one exists) or direct access to the API. It would be possible to add Minutecast support to the current library but it would not be a simple task..

I have found some documentation regarding MinuteCast on their API website



Is it possible to get the values with the given URL and the commands? Using Arduino

I have tried it without Arduino in their website itself and it works perfectly

Here are some screenshots of it


Yes. That is what the library does with the other APIs.

With all these documentations is it possible to get/call the values from an existing library other than AccuWeather's library?

If so how we can do that?

Look at how the AccuWeather library does the other three APIs. Copy one of those and modify it to work with the MinuteCast API.

Hello,

Sorry for the delays I have tried modifying code where it calls the API and gets the values but it seems that that MinuteCast function seems to be not available in Accuweather's library it always tells me an error when I modify the part of the line where it calls the API...(Unfortunately, the code where I tried it got deleted)

I tried using the same code used for open weather API with a little bit of modification but it doesn't seem to be working there is also some confusion on the way the code calls the API because when comparing Accuweather core weather data and the MinuteCast there seems to be some difference in the way the data is being returned as there a huge difference in the way they told in the documentation and the way code is designed (As you can see from the previous posts)

or do you think is it beter to contact AccuWeather for proper library/support but i think that it will take a lot of time like months or they would just refuse to do it :man_shrugging:

Try this with your SSID, Password, and API key:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <MyHomeWiFi.h>

#define apikey "tVhZeddCMqPW9GgbAfHIjlzExAam4T0X"
#define latlon "35.6762%2C139.6503"

void setup()
{
  Serial.begin(115200);
  WiFi.begin(MyHomeWiFiSSID, MyHomeWiFiPASSWORD);

  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(500);
  }
  Serial.println();

  const char * URL = "http://dataservice.accuweather.com/forecasts/v1/minute?q=" latlon "&apikey=" apikey;

  WiFiClient client;

  HTTPClient http;

  if (http.begin(client, URL))
  {

    Serial.print("[HTTP] GET...\n");
    // start connection and send HTTP header
    int httpCode = http.GET();

    // httpCode will be negative on error
    if (httpCode > 0)
    {
      // HTTP header has been send and Server response header has been handled
      Serial.printf("[HTTP] GET... code: %d\n", httpCode);

      // file found at server
      if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
      {
        String payload = http.getString();
        Serial.println(payload);
      }
    }
    else
    {
      Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
    }

    http.end();
  }

}

void loop()
{
  // put your main code here, to run repeatedly:
}
1 Like

thank you so much @johnwasser the code work perfectly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.