Should I bring an umbrella?

The SparcCore reads the weather forecast from for the next 10 hours (which is about the time I expect to be away from home). If any of these hours include rain (more than a few mm) then light the led. Unlit led obviously means no rain.

Hopefully it will be useful for someone else. It may for example serve as an example of how to use the http client.


@sebnil, awesome project. The Spark team could use the same here in Minneapolis–“Should I bring a coat?”. Although, it’s still the dead of winter here, so it’ll be some months before that’s even a question :smile:

This seems great. I might make something similar. You could go a step further and reduce the needed components by utilizing the built-in LED. Since it is an RGB LED you could setup colors to indicate more than just precipitation. Here’s a first thought: Red - Temperature, Blue - Precipitation, Green - Wind.

Here are more details on the RGB LED control:

1 Like

It seems my account is limited to one link per post, so I’ll post again. The spark team just posted docs on the RGB control library:

Cool, I did not know about that. Thanks!

@sebnil I’m curious why you didn’t just use your php script to POST to the Core api rather than relying on the Core to create the client connection. Is this merely so you can have many devices accessing a single endpoint?

You answered your own question actually. The client-server relationship is in accordance to the KISS principle.

Thanks for a really clear example of getting info to the Spark! This should be used in some “official” tutorial. :smile:

1 Like

kind of hijacking this… sorry

I copied your code from github and uploaded it to my core. connected with putty and actually saw that it’s raining at your place :smiley:

I built myself a web service that returns two color codes according to the weather at my place:

so I just edited your code on line 18 and following to this:

        if (client.connect("", 80)) {
            client.println("GET /api/weather/ HTTP/1.0");

I uploaded it again to the core but this time it somehow messed it up

what i see in putty:


but then nothing more. what i hear is the sound windows makes when you unplug and replug a usb device.
so it looks like the tcpclient call to my service crashes the core somehow?!
but how can this be? all I changed was the url… and the web service seems ok!

could somebody please confirm this?