# OpenWeather

The OpenWeather integration allows you to fetch real-time weather data for your devices based on their approximate location. This data can be used to enhance your IoT applications with weather-based automation, monitoring, and analytics.

{% hint style="success" %}
This feature is currently available only for Enterprise customers.
{% endhint %}

**Device location sources by priority:**

1. Location data from the device (Location datastream)
2. Location metadata
3. IP location

{% hint style="info" %}

* Before the request execution, Blynk will merge the devices within 1 kilometre into a cluster and send a API request with a cluster average location, reducing the total amount of requests executed.
* Location data is updated once every 6 hours, so changes to the device’s location may not be reflected immediately.
  {% endhint %}

### Setting Up the Integration

#### Getting the API Key from OpenWeather

1. Press on your username at the top-right of the OpenWeather dashboard.
2. Select **API keys**.
3. Copy the provided API key for use in the integration.

{% hint style="warning" %}
Make sure your OpenWeather subscription is active.
{% endhint %}

<figure><img src="/files/qemEGFREpIFl2mJwluqj" alt=""><figcaption><p>OpenWeather Integration Get API Key</p></figcaption></figure>

### Data Mapping

Connect your Blynk Template datastreams with OpenWeather data.

Map each field to individual datastreams. The following fields are supported:

* **Sunrise Time** — Unix, UTC. Example: `1645853361`
  * *For polar areas during midnight sun or polar night periods, this field may not be returned.*
* **Sunset Time** — Unix, UTC. Example: `1645891727`
  * *For polar areas during midnight sun or polar night periods, this field may not be returned.*
* **Temperature** — Units are defined by the datastream; defaults to °C if undefined.
* **Feels Like Temperature** — Units are defined by the datastream; defaults to °C if undefined.
* **Atmospheric Pressure (hPa)**.
* **Humidity (%)**.
* **Dew Point Temperature** — Units are defined by the datastream; defaults to °C if undefined.
* **UV Index**.
* **Cloudiness (%)**.
* **Visibility** — Units are defined by the datastream; defaults to meters if undefined.
* **Wind Speed** — Units are defined by the datastream; defaults to m/s if undefined.
* **Wind Direction (degrees)**.
* **Wind Gust** — Units are defined by the datastream; defaults to m/s if undefined.
* **Weather Type** — e.g “Drizzle”.
* **Weather Description** — e.g “Light intensity drizzle”.
* **JSON Payload** — Retrieve all fields as a single JSON string to one datastream. Example:

```json
{
  "dt": 1684929490,
  "sunrise": 1684926645,
  "sunset": 1684977332,
  "temp": 292.55,
  "feels_like": 292.87,
  "pressure": 1014,
  "humidity": 89,
  "dew_point": 290.69,
  "uvi": 0.16,
  "clouds": 53,
  "visibility": 10000,
  "wind_speed": 3.13,
  "wind_deg": 93,
  "wind_gust": 6.71,
  "weather": [
    {
      "id": 803,
      "main": "Clouds",
      "description": "broken clouds",
      "icon": "04d"
    }
  ]
}
```

<figure><img src="/files/jb5nux8sZGueCGV2aFGs" alt=""><figcaption><p>OpenWeather Integration Data Mapping</p></figcaption></figure>

{% hint style="info" %}
You can create datastreams directly from the Integration window. The metric system is used by default.
{% endhint %}

### Data Frequency

Select the desired frequency for the data being pulled from OpenWeather to Blynk.

### Unit Conversion

Ensure you’ve selected the correct units. If the units are incorrect or left empty, data will be sent in the default metric system.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blynk.io/en/hardware-guides/openweather.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
