How get weather data from location using OpenWeatherMap?

IoT Extension
Description
In this tutorial, we will retrieve different weather parameters of a location using latitude and longitude.

OpenWeatherMaps

In this tutorial, we will retrieve different weather parameters of a location using latitude and longitude.

For getting weather data, we will use OpenWeatherMap APIs. It provides current weather of more than 20000 cities across the world.

Follow the steps to get a free API of yours:

  1. Go to OpenWeatherMap website: https://openweathermap.org/ and create a free account.
    Create Account
  2. Choose the API tab to get the API Key.
    Weather API

Free plan has some limitations like only 60 calls per minutes, but it is sufficient for individuals.

Free Plan Features

Connecting evive to Internet

To connect evive with the internet we will use the ESP8266 module.

Connect ESP8266 Module to its header on evive:

WiFi ESP8266

PictoBlox Blocks for Weather

  1. connect to Wi-Fi () with password (): The block connects ESP8266 module connected to evive to the WiFi. The user has to specify the WiFi name and password in the block.
    connect to wifi
  2. get weather data for latitude () & longitude () with API (): The block gets the weather data of the specified location (using latitude and longitude) and stores in the internal variables.
    get weather data for location
  3. get (float) data: The block reports the weather data specified in the input:
    1. latitude,
    2. longitude,
    3. the temperature in C,
    4. the temperature in F,
    5. humidity,
    6. visibility,
    7. wind speed,
    8. wind direction, and
    9. clouds.
      get data 1
  4. get (string) data: The block reports the weather data specified in the input:
    1. weather,
    2. weather description,
    3. country code,
    4. city name,
    5. time of captured data,
    6. sunrise time and
    7. sunset time.
      get data 2

PictoBlox Program

Follow the instructions:

  1. Open PictoBlox.
  2. Select the board as evive:
    Selecting Board
  3. Connect the evive.
    Select Port
  4. Add Internet of Things extension in PictoBlox by clicking on the add extension button on the bottom left corner.
    Load Extensions
  5. Create the following script using when evive starts up block:
    IoT Weather
  6. Upload the code onto evive:
    Upload Code

You can download the PictoBlox program from here: IoT – Displaying Weather Data

When you start your evive, you will see two things happening:

  1. M1 LED glowing:
    1. Yellow: Connected to Wi-Fi.
    2. Red: Not connected to Wi-Fi. Check if your Wi-Fi name and password are correct.
  2. M2 LED glowing:
    1. Yellow: Connected to OpenWeatherMap.
    2. Red: Not connected to OpenWeatherMap.
Table of Contents