OpenWeatherMap (community library)


Name Value
Name OpenWeatherMap
Version 1.1.0
Installs 2871
License MIT
Author Daniel Klose
Maintainer Daniel Klose
Download .tar.gz
All Versions 1.1.0, 1.0.33, 1.0.32, 1.0.31, 1.0.30, 1.0.29, 1.0.28, 1.0.27, 1.0.26, 1.0.25, 1.0.24, 1.0.23, 1.0.22, 1.0.21, 1.0.20, 1.0.19, 1.0.18, 1.0.16, 1.0.15, 1.0.14, 1.0.13, 1.0.12, 1.0.11, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, 1.0.5, 1.0.3, 1.0.2, 1.0.1, 1.0.0

Receives data from to get selective information about the weather. The OpenWeatherMap library receives data from the same named webservice and translates all data to arduino compatible functions.

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.


An Arduino library to get easy readable data from


Before using the library please install the following libraries if they are not already on your system:

  • Arduino
  • ArduinoJson
  • HTTPClient
  • Time


To use the library you have to create a free account on (no creditcard required). After you loged into your account click on API keys whre you will se one key already initialized. You are able to rename this key, delete it or generate a new one.

The key should look something like this:


That's already everything you need to get started. Jump to your favorite Arduino IDE and open the test_OpenWeatherMap.ino file in the examples-folder.

Change your parameters

In the example-file you will have to change a few parameters depending on how you would like to use the library as well as you location from which you want to get your weather data.

First, if you want to go wireless, change your SSID and according password to log into your router to get access to the internet:

const char* ssid = "MySSID";          //Change to your SSID
const char* password =  "password";   //Change to your router password

Next comes the crucial part to log into to get your weather data. To do so, simply change the parameters to your needs:

const String city = "MyCity";       //type your City here
const String cc = "MyCountrycode";  //Enter your countrycode here e.g. (united states = us, germany = de, france = fr, etc.)
const String apiKey = "MyAPIKey";   //enter your uniqe API key which you created on
const String unit = "metric";       //Enter metric, imperial or leave empty for standard values

That's it! Everything is configured!

Getting the data

After changing all parameters you have to initiate the library. Create a new instance with

OpenWeatherMap myCity(endpoint, city, cc, apiKey, unit)

As you can see by initiating more instances you can also get data from multiple citys.

Have in mind that your free account only provides you with 60 datapoints per minute. If you need more datapoints please refer to paid subscriptions on their website.

After initiating your city/cities, start the library with

void setup(){


void loop(){

float temperature = myCity.temperatur();

Now comes the fun part: Getting all the data you want form your city. You have multiple functions to get multiple details provided by

Standard functions

.begin(): output: int Returns the http code of the website. Use this for debugging.

.update(): output: bool Has to be called at least once in the loop() to get the the informations from the website.

.sunrise(): output: String Retruns the time of the sunrise as a String in the format hh:mm:ss. The time is already timecorrected from the UTC time by using your provided city and countrycode parameters.

.sunset(): output: String Returns the time of the sunrise as a String in the format hh:mm:ss. The time is already timecorrected from the UTC time by using your provided city and countrycode parameters.

.weather(): output: String Returns the weathercondition. Please refer to Weather Conditions to find all conditions under:

"Weather condition does" Main. (halfway through the page)

These conditions are a rough estimate of the weather. To get more detailed informations use weatherDetail().

.icon(): output: String Returns a String corresponding to openweathermap's own iconset. You can get more informations on Weather Conditions.

"Icon list" (halfway through the page)

Sadly you can't download the whole iconset but you can access all icons by using for@1x resolutions or for @2x resolutions

.temperature(): output: float Returns the temperature in:

  • °C (metric)
  • °F (imperial)
  • °K (empty)

.windSpeed(): output: float Returns the windspeed in:

  • meter/sec(metric and emtpy)
  • miles/hour (imperial)

.timezone(): output: int Returns the timezone related to the UTC in hours. e.g. Berlin (+1h) or Berlin (+2h summertime)

Advanced functions

Advanced funtions aren't any special or harder to code but deliver more inforamtions than the standard functions. You need the wind direction? Cloudiness? Rain prediction for the next 1h or 3h? Take one of these functions and you are good to go!

.weatherDetail(): output: String To get more detailed weather descriptions use this. Please refer to Weather Conditions to find all detailed conditions under:

"Weather condition does" Description. (halfway through the page)

If you are looking for a rough estimate of the weathercondition please use weather().

.weatherId(): output: int If Strings aren't your favourite or simply don't convey the weather in the kind of manner you like it to appear there are still the weatherIDs you can ask for. A translation to human readable weather can be found here:

Weather Conditions "Weather condition does" ID. (halfway through the page)

.temperature_min(): output: float Returns the current minimum temperature in

  • °C (metric)
  • °F (imperial)
  • °K (empty)

.temperature_max(): output: float Returns the current maximum temperature in

  • °C (metric)
  • °F (imperial)
  • °K (empty)

.coordLat(): output: float Returns the coordinates' latitude (North/South) in 90°-0° from equator to northpole and 0°-90° southpole to equator. It sadly doesn't tell you if it is N° or S°

.coordLon(): output: float Returns the coordinates' longitude in 180° where 0° is Greenwich in Great Britain and then 0°-180° east- and westwards. Same as with the latitude the API doesn't send W° or E°

.humidity(): output: int Outputs the humidity in percent.

.pressure(): output: int Returns the atmospheric pressure meassured from sea-level in hPa.

.windDegrees(): output: int Returns the wind direction on degrees.

Direction Degrees
North 0° / 360°
East 90°
South 180°
West 270°

.windDirections() output: String Outputs easyly readable wind directions: | Short | Long | |-------|-------------------| | N | north | | NNE | north north east | | NE | north east | | ENE | east north east | | E | east | | ESE | east south east | | SE | south east | | SSE | south south east | | S | south | | SSW | south south west | | SW | south west | | WSW | west south west | | W | west | | WNW | west south west | | NW | north west | | NNW | north north west |

.cloudiness(): output: int Returns the cloudiness in percent.

Future features

These are features that still have to be implemented into the library.

uint16_t rain(int hours): //hours = 1||3 in mm

uint16_t snow(int hours):

Browse Library Files