Weather APIs

A lot of stuff can be measured, calculated and presented by a program based on temperature, pressure, humidity etc. However, there is a lot of weather forecast information available online that will give much more relevant and exact data. I’ve started to investigate what’s available. Main focus is high quality information available for Norway.

I’ve started experimenting with some APIs from

One of the most interresting APIs is

Another useful service is sunrise API that can be used to read sunrise/sunset and moonphases for a location directly. This can be used instead of the embedded calculations if network connection is available. Here is the raw xml data for January 2014 where I live.

The services above are norwegian but covers other parts of the world as well.

Looking at more global suppliers, I stumbled across which looks nice. Current, forecast up to 16 days and historical data are available.
Astronomical Applications Department of the U.S. Naval Observatory
Sun and Moon rise and set times, Moon phases, eclipses, seasons, positions of solar system objects, and other data

Others to investigate

And surely there are more. I’ll try to investigate some of them.

Also take a look at michaelwelburn comparing weather APIs.

Parsing API data

What is the best format for data to be read and handled by the Arduino. Is json ok, or should I chose something that is even more simple. This blog explains how to parse JSON on Arduino. Or an alternative json library

Creating a cloud service

In order to avoid a lot of XML parsing in a small i.e. arduino based weather station I’ve experimented with an external application to convert data to a format that is easy for arduino to parse. And also store historical data.

This was a good excuse for experimenting a bit with cloud services. I currently use openshift. Others may prefer Heroku or something else. I’ve written an application in Ruby/Rails. It fetches raw xml data from, caches it and makes it available in html, json and a format that makes it easy for arduino to parse. You may try in with different parameter to get different formats:

The application stores historical forecasts as well, up to 4 days in the past. I.e. if you want to see how the forecast data was yesterday, replace /0 with /24 (24 hours). The ambition is to make a small app/webpage that shows how the forecast changes over time. The theory is that a forecast 4 days ahead is not very reliable (at least not where I live…)

The free Openshift cartridge/gear goes idle if it hasn’t got an external http request the last 48 hours. I’m using a service at to poll the service often enough to keep it running. This is important because my application polls for weather forecast every 30 minutes. If not kept alive, I lose a lot of historical data.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s