OSW WEATHER

Author: @LorenzoSciacca

How to install

Add the flag OSW_FEATURE_WEATHER to the file platformio.ini:

; Example code block (make sure to use the one from the platformio config!)
[env:LIGHT_EDITION_V3_2]
build_flags =
    -D OSW_TARGET_PLATFORM_HEADER='"platform/LIGHT_EDITION_V3_2.h"'
    -D OSW_FEATURE_STATS_STEPS
    -D OSW_FEATURE_WIFI ; ADD THIS LINE
build_type = debug

Getting the API key

The weather updates are provided by openweathermap.org, so you need a valid API key. 1. Create an account here 2. Select a free plan 3. From your account select "my API keys" and generate a key.

Configuration

It's possible to configure the app from both the web UI and the configuration file config_defaults.h.

Web UI

  1. Paste your API key in the field API key for Openweathermap.org
  2. Write the name of the location of your interest in the field City name
  3. Write the two letters iso code of the country associated with your location in the field Country code. You can search the two letters code of a given country here selecting country codes.
  4. Save

Without web UI

If you want to configure the app without using the web UI you can set the followings values in config_defaults.h: - OPENWEATHERMAP_APIKEY, the api key - OPENWEATHERMAP_CITY, city name - OPENWEATHERMAP__STATE_CODE, the two letter iso code of the country of your interest

If you are not sure about the geocoding you can perform a simple test. Type in the address bar of your browser: https://api.openweathermap.org/data/2.5/forecast?q=CITY,STATE&appid=APIKEY&cnt=24 substituting CITY, STATE and APIKEY with: city name, two letters code and api key. Beware to not past additional characters, the country code must be separated by a comma from the city name. If you get an answer like this: {"code":"200" ... both api key and location are valid.

Usage

Overview

screen
After the installation you will notice that there are no updates to show, in order to get the updates, press the top right button update. A pop-up should appear, the operation will take a few seconds.

The bottom left button allows the user to select:

  • current update

  • the current day

The / \ and \ / arrows are used to decrease/increase the current selection (day or update).

Units

Weather conditions

Visit this link for a more detailed description of each weather condition.

Icon # Description Openweathermap code
0 Clear 800
1 Clouds min. 801
2 Clouds med. 802
3 Clouds heavy 803, 804
4 Mist 701
5 Fog 741
6 Snow min. 611, 612, 615, 616
7 Snow med. 600, 613, 601, 620
8 Snow heavy 602, 621, 622
9 Rain min. 500, 300, 301, 302, 310, 311, 312, 313, 314, 321
10 Rain med. 501, 502
11 Rain heavy 503, 504, 511, 520, 521, 522, 531
12 Thunderstorm 200, 201, 210, 211, 231, 230
13 Thunderstorm heavy 202, 212, 221, 232
! 14 Squall/tornado 771, 781
? 15 Unknown

Using the emulator

To use this app while using the OSW emulator, in order to retireve the data, it is necessary to perform the API request using the browser and to save the response in file_weather.json in the /build folder.