Tuesday, April 4, 2017

CheerLights, Node-Red, & Raspberry Pi

I first experimented with CheerLights a few months ago while attempting to better understand the Internet of Things.  Today, I'm using a Raspberry Pi Zero, rather than a Photon microcontroller. One dazzling detail about CheerLights is that it allows people all over the world to simultaneously synchronize the color of lights. Anyone can change the color of lights connected through the CheerLights API, by sending a tweet that mentions CheerLights, along with the name of a color.


Using this Node-red tutorial from Magpi magazine, I was able to get CheerLights up and running on my Pi with relative ease. In the process, I learned a little bit about Node-red, a graphical interface for interacting with smart objects through the web.  Of note, I used a 10mm RGB LED with a common cathode, rather than the suggested Ledborg or three separate LEDs.

This diagram shows the flow used to trigger CheerLights on a Raspberry Pi using Node-Red

I'm wondering what else might be achieved with Node-red.  The interface is not entirely intuitive, but it seems like it could be useful tool for learning how smart objects talk and interact on the internet.

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