Weather Forecaset on the Cube

150 views
Skip to first unread message

Danny Ricciotti

unread,
Aug 6, 2015, 11:31:50 AM8/6/15
to cubetalk
I am working on a project to combine the forecast.io API with the Cube.  With forecast.io you can get weather for your exact GPS location and heads up like "it's going to rain in 12 minutes".  I have found their mobile app (Dark Sky) very useful so I would like to bring a similar functionality to the Cube.  My goals are:

1) Cube animations that correspond to the 11 different types of weather they report (clear-day, clear-night, rain, snow, wind, etc)
2) Cube animations that convey when rain will be starting within the next hour. Perhaps a countdown.
3) Cube can get forecast data from Forecast.io. This can be accomplished by either a) making request directly to the API and parsing JSON response or b) use an intermediate server to poll the forecast and relay a simplified version of the forecast to the Cube via a Particle function.
4) Determine location of the Cube in a way that allows the code to be shared (ie. avoid hard-coding coordinates if possible)
5) Instructions on how to run this code on cube via USB (much faster for debugging)

I would love to get some community participation on this project. If you are interested then introduce yourself below, and state which parts of the project you would be excited to work on. 

TECH_GEEK10

unread,
Aug 6, 2015, 10:31:08 PM8/6/15
to cubetalk
Hi Danny! I have been working on the same exact goal. I would love to help you by working on the display/animations. I have not been able to figure out how to read weather yet but I have a lot of visual aspects figured out. 

Danny Ricciotti

unread,
Aug 7, 2015, 1:08:04 AM8/7/15
to cubetalk
Hey that's awesome! I would love to see what visual elements you have in mind! 

I can figure out how to get the weather data. I thought it would actually be easier to write a Node.js server that acts as a middle man between the cube and Forecast.io.  Right now my Node app polls forecast.IO and then sends a small packet of data to the Cube via a cloud function.  It is much easier to parse since my message has a fixed size and fixed byte positions.  Messing with making HTTP requests from the Cube (and not to mention JSON parsing) seems like a big pain in the butt, but would ultimately be better.

TECH_GEEK10

unread,
Aug 7, 2015, 1:11:26 AM8/7/15
to cubetalk
I remember a service run by yahoo that gives you a single number which represents every possible weather condition. Just needed to send a http request and it sends you just a simple number. 

TECH_GEEK10

unread,
Aug 7, 2015, 1:13:11 AM8/7/15
to cubetalk

Danny Ricciotti

unread,
Aug 7, 2015, 1:16:27 AM8/7/15
to cubetalk
Right now my app returns the weather condition as a number (byte) with the following states. I really like forecast.IO because of their rain estimates and because they use GPS instead of city name, so you get hyper-local weather predictions.  Their app has reminded me to bike home right before it rains many times.

var ICONS = {
"unknown":0,
"clear-day":2,
"clear-night":3,
"rain":4,
"snow":5,
"sleet":6,
"wind":7,
"fog":8,
"cloudy":9,
"partly-cloudy-day":10,
"partly-cloudy-night":11
}


On Friday, August 7, 2015 at 1:13:11 AM UTC-4, TECH_GEEK10 wrote:

TECH_GEEK10

unread,
Aug 7, 2015, 1:30:46 AM8/7/15
to cubetalk
Doesn't that method require an external program to be running?

Danny Ricciotti

unread,
Aug 7, 2015, 1:34:36 AM8/7/15
to cubetalk
It does, I just this post about webhook and cloud JSON parsing: https://community.particle.io/t/cloud-json-parsing/11223
I will try to make the weather API request from the Particle.

Danny Ricciotti

unread,
Aug 7, 2015, 1:35:19 AM8/7/15
to cubetalk
I created an open-source repo which we can use to organize the project. Message me with you GitHub username if you want access

TECH_GEEK10

unread,
Aug 7, 2015, 1:46:49 AM8/7/15
to cubetalk
I can't figure out how to use github :P I can send you the code and you can do what you want with it if that is cool with you.

Danny Ricciotti

unread,
Aug 7, 2015, 2:22:00 AM8/7/15
to cubetalk
sounds good! Post a link or email it to me.

Ben Ledbury

unread,
Aug 7, 2015, 3:49:09 AM8/7/15
to cubetalk
I'd be happy to help out with this. Probably on the infrastructure more than the actual animations.
Number 4 is the only one that I see being complicated, I wonder if IFTTT integration would be simpler as that already deals with setting up location and already integrates with particle.io.
Instead of polling for weather data this would instead set up triggers to call a function on the cube to set the weather state, temperate, etc.

Danny Ricciotti

unread,
Aug 7, 2015, 10:31:52 AM8/7/15
to cubetalk
Ben, people seem to be discussing a way to have device-specific variables in the particle cloud: https://community.particle.io/t/particle-publish-passing-arguments/13739

I am working on making the request from a Particle via webhooks, and parsing down the response. I should have something working soon.

Danny Ricciotti

unread,
Aug 7, 2015, 1:00:07 PM8/7/15
to cubetalk
I now have the Particle requesting weather data from the API and getting back an easy to parse response string. I ended up using webhooks which make things a lot simpler.

For example:
"cloudy~74.54~0~0"

icon: cloudy
temperature: 74.54
probability of precipitation: 0
intensity of precipitation: 0

I will post code to the repository once I figure out how to secure your private info (location and API key). 

Ben Ledbury

unread,
Aug 7, 2015, 1:42:52 PM8/7/15
to cubetalk
Cool, sounds like you have a lot figured out already. Looking forward to seeing it.

Werner M.

unread,
Aug 11, 2015, 1:33:37 PM8/11/15
to cubetalk
Wow. That sounds like an interesting idea.

When I was reading through the first comments, first thought was to suggest IFTTT as well (then I saw Ben beat me to it).

I am glad you got it figured out, the part that is tricky is determining your cube's location (since there's no GPS embedded into the hardware). So maybe using a cloud API that you could set to your location (maybe via a UI) would make it work.
I'm very interested in helping you out any way I can. My Github ID is wmoecke.

Werner M.

unread,
Aug 11, 2015, 1:35:20 PM8/11/15
to cubetalk
Maybe another idea, integrating it with Google API for determining your location whenever your phone's GPS is turned on (or, based on the last GPS coordinates gathered).

Danny Ricciotti

unread,
Aug 11, 2015, 5:35:54 PM8/11/15
to cubetalk
I actually think the location problem can be solve quite simply.  

I am using Webhooks to call the weather API.  It makes sense for each of us to create our own webhook, because otherwise we collectively would max out the number of calls you can make to the forecast.io API daily (which is 1000).  One benefit of having individual Webhooks is that we can hard-code our own location into the webhook.  Creating a webhook isn't difficult but would take some command line knowledge (basically entering in a command and hitting Return) and you would need to register for a forecast.io API key (which is free).

Werner, I added you to the repository as a contributor! 

Werner M.

unread,
Aug 12, 2015, 2:05:00 PM8/12/15
to cubetalk
Awesome, thanks!!
I will be looking at the contents of that repo during the weekend (I am still recovering from some heavy jet lag acquired recently), got to rebuild my cube (install new acrylic panels and a battery shield) then put on some additional hardware (I've been postponing that for weeks).

This project should have a good outcome - can't wait to see what ideas I will have after looking at the code. ;-)

-Werner
Reply all
Reply to author
Forward
0 new messages