Skip to content

Commit

Permalink
Merge pull request #48 from JHershey69/API-UPGRADE
Browse files Browse the repository at this point in the history
Api upgrade
  • Loading branch information
JHershey69 authored Feb 23, 2024
2 parents c3c5390 + a8327fd commit cf14185
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# OpenWeatherOneCall v3.1.9 ![IMAGE OF LIGHTNING](https://github.com/JHershey69/OpenWeatherOneCall/blob/master/images/lightning.jpg)
# OpenWeatherOneCall v3.3.0 ![IMAGE OF LIGHTNING](https://github.com/JHershey69/OpenWeatherOneCall/blob/master/images/lightning.jpg)
## This is for ESP32 only

##This is an upgrade for OpenWeatherMap API 3.0

**Please be advised** OpenWeather has changed ONE CALL to a subscription service. Signing up is
required to get your KEY, but you get 1000 calls a day for free (this is one call every 15 minutes)
required to get your KEY, but you get 1000 calls a day for free (this is one call every 90 seconds and that is A LOT for free)
and you will continue to get all of the features of this library.

**OpenWeatherOneCall** library to gather weather information from OpenWeatherMap
Expand Down Expand Up @@ -49,3 +51,6 @@ v3.0.0 has a **Legacy Mode** to maintain ease of use for previous versions
<br>--Fixed missing code.
<br>**v3.1.9**
<br>--Minor fix to clear old alerts.
<br>**v3.3.0**
<br>--Minor fix to update API change.

14 changes: 7 additions & 7 deletions src/OpenWeatherOneCall.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
OpenWeatherOneCall.cpp v3.1.9
OpenWeatherOneCall.cpp v3.3.0
copyright 2020 - Jessica Hershey
www.github.com/JHershey69
Expand All @@ -20,24 +20,24 @@ OpenWeatherOneCall::OpenWeatherOneCall()
}

// For Normal Weather calls *************
#define DS_URL1 "https://api.openweathermap.org/data/2.5/onecall"
#define DS_URL1 "https://api.openweathermap.org/data/3.0/onecall"
char DS_URL2[100];
#define DS_URL3 "&appid="

// For Air Quality calls current *************
#define AQ_URL1 "https://api.openweathermap.org/data/2.5/air_pollution?lat="
#define AQ_URL1 "https://api.openweathermap.org/data/3.0/air_pollution?lat="
#define AQ_URL2 "&lon="
#define AQ_URL3 "&appid="




// For Historical Weather Calls **********
#define TS_URL1 "https://api.openweathermap.org/data/2.5/onecall/timemachine"
#define TS_URL1 "https://api.openweathermap.org/data/3.0/onecall/timemachine"
#define TS_URL2 "&dt="

// For CITY Id calls
#define CI_URL1 "api.openweathermap.org/data/2.5/weather?id="
#define CI_URL1 "api.openweathermap.org/data/3.0/weather?id="
#define CI_URL2 "&appid="

#define SIZEOF(a) sizeof(a)/sizeof(*a)
Expand Down Expand Up @@ -152,7 +152,7 @@ int OpenWeatherOneCall::setLatLon(int _CITY_ID)
int error_code = 0;

char cityURL[110];
char* URL1 = "http://api.openweathermap.org/data/2.5/weather?id=";
char* URL1 = "http://api.openweathermap.org/data/3.0/weather?id=";
char* URL2 = "&appid=";

sprintf(cityURL,"%s%d%s%s",URL1,_CITY_ID,URL2,USER_PARAM.OPEN_WEATHER_DKEY);
Expand Down Expand Up @@ -421,7 +421,7 @@ int OpenWeatherOneCall::createHistory()

//Gets Timestamp for EPOCH calculation below
char tempURL[200];
sprintf(tempURL,"https://api.openweathermap.org/data/2.5/onecall?lat=%.6f&lon=%.6f&exclude=minutely,hourly,daily,alerts&units=IMPERIAL&appid=%s",USER_PARAM.OPEN_WEATHER_LATITUDE,USER_PARAM.OPEN_WEATHER_LONGITUDE,USER_PARAM.OPEN_WEATHER_DKEY);
sprintf(tempURL,"https://api.openweathermap.org/data/3.0/onecall?lat=%.6f&lon=%.6f&exclude=minutely,hourly,daily,alerts&units=IMPERIAL&appid=%s",USER_PARAM.OPEN_WEATHER_LATITUDE,USER_PARAM.OPEN_WEATHER_LONGITUDE,USER_PARAM.OPEN_WEATHER_DKEY);

HTTPClient http;
http.begin(tempURL);
Expand Down

0 comments on commit cf14185

Please sign in to comment.