Weather Library

I created a new weather library for :spark: that is easy to use, easily extendable and uses http://openweathermap.org/.

See instructions on: https://github.com/synox/openweathermap-spark-lib

Here is what I created using this library:

Note: Because you need quite a few librararies, you should currently compile it locally. It’s hard to copy them all into the web-ide.

You can easily enhance this library to use more data. Please share any improvements/bugs. This projects replaces my previous “yahoo-weather”.

9 Likes

Fantastic job Coffee! There are two take-aways for me here. First, I had ported JSMN to Spark but the JsonParser package is excellent. That one is worth making into a standard library. The second is this project has given me an idea for a Maker Kit project! :smile:

2 Likes

It’s awesome that the Json-Parser works without modifications, and small memory footprint. If you agree, we should suggest it for inclusion into the spark-libs.

1 Like

I like the reuse of the packaging!

I think it would be awesome to able to just include json.h and have the functionality available.

1 Like

Coffe, I will absolutely recommend that library become a standard Spark library :ok_hand:

2 Likes

Coffee, I noticed that you don’t grab the current temperature in the weather_response_t structure. Any reason cause it would be great to show the daily min/high and the actual. Any thoughts?

For my project it was important to see the whole day waither, but you can also use the current weahter.

it’s a different URL for the current weather, see here: http://openweathermap.org/API#weather (compared to “5 and 14-days forecast” which I am currently using).

you could just make another http call in the update() method.

@coffee @peekay123 Great to see this web based weather app updated.

I’m currently using a Spark Core and a Temp/Humidity Sensor SHT-15 to display current temp and humidity data in the house and then that data gets displayed on my Digole color LCD display & uploaded to my Google Excel Spreadsheet account and then graphed out over time for review later.

I have been wanting to add the outside weather data to this display also by using the Sparks WiFi connection to eliminate the need of using an extra temp sensor to gather outside weather data.

As @peekay123 mentioned, I would also like to pull in current weather temp, humidity, and data that shows the weather condition like (Cloudy, Rain, Sunny, ect…).

If we took this weather app and combined it with my current local temp sensor app with data upload to Google Drive we would have a pretty cool WiFi enabled weather station. I would like to display the weather data one some sort of LED display like this. https://www.adafruit.com/products/420

RWB, when I get back from Maker Faire tomorrow I’ll post my current/forecast open weather code for you :slight_smile:

1 Like

@RWB by the way the weather provider openweathermap.org supports managing the data of your own weather station: http://openweathermap.org/stations
that might be more convenient than google spreadsheets.

2 Likes

Hi @peekay123 Did you ever post the current/forecast code? I’m new to all this and really looking forward to seeing your code/example

Thanks
Steve

@InventorSteve, doh! I haven’t and it’s a good thing because it needs updating. I will do try to get to that this weekend. Thanks for the reminder! :smile:

1 Like

Fantastic.
Must admit I am having some trouble with https://github.com/synox/openweathermap-spark-lib. All loaded OK to Spark using spark-cli but getting the “weather request failed HttpClient> Connection failed” error. Really don’t know why.

Hope you have a good weekend.
Steve

Hi @peekay123 and @Coffee,

Greetings from Sydney, AU. I’m not a coder and am having some problems attempting to write code to download the next 24hrs weather forecast using the openweather.org API and your technique outlined above.

This is the JSON I’m attempting to run and decode (& yes I do have an API):
http://api.openweathermap.org/data/2.5/forecast?id=2167879&mode=json&units=metric&cnt=1

I realise this gives many days of data, but I’m only interested in the current 24 hours (every 3hr is OK for me).

Which specific libraries do I need to include? I’m using spark-cli to flash the core.

I’m also having problems with the HTTP Client not connecting giving error -" HTTPClient> Connection failed". I actually investigated and the “http_response.status” is returning “-1”.

I’m using the exact code example from here (with my API added):

Any suggestions?
Steve

OK. This is getting silly. I have no idea which .CPP and .H files I need to get this working.

I have now manually uploaded 18 different library files to the Spark IDE and even with a blank program(#includes and void setup and void loop only) it is giving multiple compile errors.

Here is the list I have (both .cpp and .h):
HTTPClient
jsmn
JsonArray
JsonPArser
JsonParserBase
JsonToken
JsonValue
JsonObject

and these only have .h files

JsonArrayIterator (.h only)
JsonObjectIterator (.h only)
JsonPair (.h only)

Am I missing something silly here?

All I need to know is which .CPP and which .H files I need to run this please.

Many thanks
Steve

@InventorSteve, it is not your fault! I tried compiling the code with Spark CLI (which uses the same build servers) and it gives me indeterminate errors as well. I have found that it will only compile locally with the full toolchain and the latest github repo. I will be doing some tests a bit later to see if that still holds true since it has been a couple of months since the last time I tried and much has changed since!

Thanks @peekay123 . I did think I was going crazy :smile:

I’m looking forward to hearing how you suggest I tackle this one to get it working.

Cheers, again,
Steve

@InventorSteve, I can’t get my code to compile locally or with spark cli!!! I get cryptic undefined reference errors which I can’t figure out. Stay tuned.

hey there!

I currently also have problems with the spark-cli, it stops just with the message “Compile failed - compile failed”, and i also had problems with http not connecting.
unfortunately I am currently to busy to debug the issue.

Hey everyone.

My own code works again, let me know if you still have issues?
My Problem was related to the DNS Issue.

1 Like