Project Description

OrangeBoard WiFi is equipped with a WiFi module in the existing OrangeBoard, so you can use the function of Arduino and WiFi in one board.

Arduino combines a WiFi module that can take a lot of data from the web, so users can see and use it a step further than the traditional Arduino.

 

 

 

summary

In this article, let’s run an example that uses the API to fetch weather information from a WiFi shield.

API is an abbreviation of Application Programming Interface. It refers to a set of functions or subroutines that a program or application calls to the operating system for information processing.

 

WebServer provides an easy-to-use interface to the client through the API, and the client can easily access the desired information by importing and using the API.

 

 

 

 

 

Many Web sites provide these APIs, and there are hundreds of thousands of API types.

For example, if you want to get traffic information for a specific area, you can get traffic information by simply getting the traffic information API and entering the information.

 

 

 

 

The OpenWaetherMap to run this time is also a site that provides the weather information API. If you bring the API, you can also get weather information on WiFi in Arduino.

Let’s run the example and get the weather information.

 

 

 

 

 

Get API key from OpenWeatherMap

 

 

First go to  http://openweathermap.org/ and if you do not have an ID, sign up and sign in.

 

 

 

 

Once you enter the API keys tab, you can see the unique API key values available to you.

The API key value is essential information for getting information from the API.

 

 

 

 

Uploading the Arduino code

 

 

Go back to Arduino and copy the code below and upload it to OrangeBoard WiFi.

 

 

Result screen

The result screen shows the current temperature value of Seoul periodically as shown below.

 

 

 

 

What if you want to change your location?!

If you want to change the region, please modify the code below.

The code is basically Seoul, but if you change the region, you can print out the temperature values in other regions.

 

 

 

 

What if you want to extract other information about the weather ?!

Currently, only the temperature values are taken from the code and output.

In order to output other information, it is necessary to analyze the data delivered by the API first.

 

If you request data as shown in the picture below, it will be delivered in XML format and we will extract only the desired information through parsing in code.

In case of temperature, “temp” is shown as absolute temperature after 306.15.

 

 

 

 

The code below extracts the temperature value from the XML data requested by the API.

When reading the data along the way, a value of “temp”: is read, and then the value is read and stored as temperature.

 

 

 

 

If you want to import other data, you can read other data if you parse it by putting pressure or humidity instead of temp.

Of course, the temperature was -273 because it was received as the absolute temperature, but other data should be adjusted to the data type.

 

 

Dated :

August 2016

 

Original & Source code :

http://kocoafab.cc/tutorial/view/654