Skip to content

Commit 2d052b8

Browse files
committed
Switch to OWM location id instead of city,country query
1 parent 9407952 commit 2d052b8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

examples/WeatherStationDemo/WeatherStationDemo.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,14 @@ const int SDC_PIN = 4; //D4;
6969
// OpenWeatherMap Settings
7070
// Sign up here to get an API key:
7171
// https://docs.thingpulse.com/how-tos/openweathermap-key/
72-
const boolean IS_METRIC = true;
7372
String OPEN_WEATHER_MAP_APP_ID = "XXX";
74-
String OPEN_WEATHER_MAP_LOCATION = "Zurich,CH";
73+
/*
74+
Go to https://openweathermap.org/find?q= and search for a location. Go through the
75+
result set and select the entry closest to the actual location you want to display
76+
data for. It'll be a URL like https://openweathermap.org/city/2657896. The number
77+
at the end is what you assign to the constant below.
78+
*/
79+
String OPEN_WEATHER_MAP_LOCATION_ID = "2657896";
7580

7681
// Pick a language code from this list:
7782
// Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el,
@@ -81,10 +86,11 @@ String OPEN_WEATHER_MAP_LOCATION = "Zurich,CH";
8186
// Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk,
8287
// Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi,
8388
// Chinese Simplified - zh_cn, Chinese Traditional - zh_tw.
84-
8589
String OPEN_WEATHER_MAP_LANGUAGE = "de";
8690
const uint8_t MAX_FORECASTS = 4;
8791

92+
const boolean IS_METRIC = true;
93+
8894
// Adjust according to your language
8995
const String WDAY_NAMES[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
9096
const String MONTH_NAMES[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
@@ -234,13 +240,13 @@ void updateData(OLEDDisplay *display) {
234240
drawProgress(display, 30, "Updating weather...");
235241
currentWeatherClient.setMetric(IS_METRIC);
236242
currentWeatherClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
237-
currentWeatherClient.updateCurrent(&currentWeather, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION);
243+
currentWeatherClient.updateCurrentById(&currentWeather, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_ID);
238244
drawProgress(display, 50, "Updating forecasts...");
239245
forecastClient.setMetric(IS_METRIC);
240246
forecastClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
241247
uint8_t allowedHours[] = {12};
242248
forecastClient.setAllowedHours(allowedHours, sizeof(allowedHours));
243-
forecastClient.updateForecasts(forecasts, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION, MAX_FORECASTS);
249+
forecastClient.updateForecastsById(forecasts, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_ID, MAX_FORECASTS);
244250

245251
readyForWeatherUpdate = false;
246252
drawProgress(display, 100, "Done...");

0 commit comments

Comments
 (0)