Sunday, March 5, 2017

Raspberry Pi & Weather Underground Data Experiments

Over the past couple of weeks, I've been playing around in an attempt to better understand and apply weather data that's available on the web.

As part of this journey, I hooked up my Raspberry Pi to a Sense hat, and used ThingSpeak to log the data. I lucked into finding this detailed tutorial, which helped me track my home's temperature and humidity levels (although I had to remove some strange characters in the code before it would compile properly).


I also completed Raspberrypi.org's Fetching the Weather exercise, to learn how to access data from a nearby Raspberry Pi Weather Station.  I was surprised that the nearest RPi weather station is in Quebec, Canada; I was hoping to find a school in Vermont that was using one.
Weather data from Canada using a Raspberry Pi Weather Station

This discovery led me down a path that was unrelated to my Python exploration, but splendidly related to weather data.  Finding it hard to believe that the nearest weather station was in Canada, I stumbled upon the Weather Underground API, which connects to weather data in my home town.  This prompted me to do a deeper dive to better understand how I might use that data, perhaps in combination with a Photon microcontroller, as part of an art project I was working on.

To make a long story short, I signed up for a Weather Underground account and was given an API key that allowed me to tap into JSON data using a dedicated channel that I created on ThingSpeak!  While I still have a lot to learn, I was able to use the MATLAB analysis feature (which allows you to "Get Data From a Webpage") to harvest weather conditions by typing in a unique URL containing my API key.  I was then able to record things like wind velocity and temperature. This meant that I could use data ranges that I specified to trigger functions on my Photon!  I know this is dorky, but the learning curve has been exhilarating!

A smattering of JSON data that may be harvested through Weather Underground