# Should I bring an umbrella?

**URL:** <https://community.particle.io/t/should-i-bring-an-umbrella/1317>\
**Category:** Project Share\
**Created:** [January 6, 2014, 9:14pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317 "2014-01-06T21:14:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebnil](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/sebnil/32/20966_2.png) [@sebnil](https://community.particle.io/u/sebnil)\
**Post date:** [January 6, 2014, 9:14pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/1 "2014-01-06T21:14:42Z")

</div>

The SparcCore reads the weather forecast from yr.no 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.

- More info at [http://sebastiannilsson.com/en/blogg/will-it-rain/](http://sebastiannilsson.com/en/blogg/will-it-rain/)
- Code at [https://github.com/sebnil/will-it-rain](https://github.com/sebnil/will-it-rain)

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

---

<div class="post-metadata">

**Author:** ![will](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/will/32/23374_2.png) [@will](https://community.particle.io/u/will)\
**Post date:** [January 6, 2014, 9:40pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/2 "2014-01-06T21:40:33Z")

</div>

@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 😄

---

<div class="post-metadata">

**Author:** ![krets](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/krets/32/20987_2.png) [@krets](https://community.particle.io/u/krets)\
**Post date:** [January 6, 2014, 9:56pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/3 "2014-01-06T21:56:24Z")

</div>

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:

> **[How to change the Core LED color?](https://community.particle.io/t/how-to-change-the-core-led-color/1269/2)**
>
> Hi @hirotakaster, We added functions to do this recently, you can take control of the RGB led using: -- take control of the LED RGB.control(true); -- resume normal operation RGB.control(false); // red, green, blue, 0-255 RGB.color(0, 0, 0);

---

<div class="post-metadata">

**Author:** ![krets](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/krets/32/20987_2.png) [@krets](https://community.particle.io/u/krets)\
**Post date:** [January 6, 2014, 9:57pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/4 "2014-01-06T21:57:46Z")

</div>

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:  
[http://docs.spark.io/#/firmware/libraries-rgb](http://docs.spark.io/#/firmware/libraries-rgb)

---

<div class="post-metadata">

**Author:** ![sebnil](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/sebnil/32/20966_2.png) [@sebnil](https://community.particle.io/u/sebnil)\
**Post date:** [January 6, 2014, 10:37pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/5 "2014-01-06T22:37:56Z")

</div>

Cool, I did not know about that. Thanks!

---

<div class="post-metadata">

**Author:** ![geraldcor](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/geraldcor/32/20965_2.png) [@geraldcor](https://community.particle.io/u/geraldcor)\
**Post date:** [January 23, 2014, 5:39pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/6 "2014-01-23T17:39:16Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![sebnil](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/sebnil/32/20966_2.png) [@sebnil](https://community.particle.io/u/sebnil)\
**Post date:** [January 23, 2014, 9:48pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/7 "2014-01-23T21:48:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spongefile](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/spongefile/32/1995_2.png) [@spongefile](https://community.particle.io/u/spongefile)\
**Post date:** [February 12, 2014, 9:24am UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/8 "2014-02-12T09:24:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kwyjib0](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kwyjib0/32/916_2.png) [@kwyjib0](https://community.particle.io/u/kwyjib0)\
**Post date:** [February 19, 2014, 10:21pm UTC](https://community.particle.io/t/should-i-bring-an-umbrella/1317/9 "2014-02-19T22:21:53Z")

</div>

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 😃

I built myself a web service that returns two color codes according to the weather at my place:  
[http://roman-mueller.ch/api/weather/](http://roman-mueller.ch/api/weather/)

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

```
Serial.println("connecting...");
        if (client.connect("roman-mueller.ch", 80)) {
            Serial.println("connected");
            client.println("GET /api/weather/ HTTP/1.0");
            client.println();
        } 

```

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

what i see in putty:

```
disconnecting.
connecting...
connected

```

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?
