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 http://api.met.no
One of the most interresting APIs is http://api.met.no/weatherapi/locationforecast/1.9/documentation
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 http://openweathermap.org/ 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
- worldweatheronline.com free weather API claims to “allow developers and programmers to access current weather conditions and next 5 days of accurate and reliable weather forecast”
- weatherunderground. Claims to have “Reliable data, accurate forecast, & global coverage in 80 languages”. Free usage for developers.
- developer.forecast.io The Dark Sky API lets you query for short-term precipitation forecast data at geographical points inside the United States
- Aeris Weather API at www.hamweather.com claims “Effortless integration of weather for your applications”
- NOAA’s National Weather Service
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 api.met.no, 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:
- weather2-helge.rhcloud.com/weather/history/0 (html page)
- weather2-helge.rhcloud.com/weather/history/0?format=json (json)
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 statuscake.com 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.