Example: Logging and graphing data from your Spark Core using Google


Awesome! I’ll give this a try and report back.

@bdub do you have any thoughts on this?


Full demo with source here.


D’oh - just spotted a copy/paste error in my code. Replace this section in my script above with this:

  // check if we need to send alert email
  if (p.data1 > temperatureTriggerValue && !hasSentAlertEmail) {
    // send email
    MailApp.sendEmail("myemail@addy.com", "[ ALERT ] Spark value trigger!!", "The value is greater than the trigger amount. Oh noes!");
    // set the flag in the ScriptDB
    currentRec.hasSentEmail = 1;

  // check if we've fallen below reset value and have previously sent an email
  if (p.data1 < temperatureTriggerReset && hasSentAlertEmail) {
    currentRec.hasSentEmail = 0;

It’s just the variable name in the if statements that were wrong.


Right now , i will write this issue )) thanks. :smiley:


@gwygonik it is works well. :smiley:


I forgot to set it to publicly available! Sorry about that. As for the chart, I realize it won’t auto refresh, but I can’t even view it. Just pasting the code into my webpage gives me a syntax error. I’ve used some debuggers online and it says there is an unexpected “<”. No idea. But when I posted into W3 schools “try html” page Link it works fine! I’m just confused now…


I had the same experience myself. I’m not sure whats going on but I sure would like to be able to embed it without errors. Let me know if you or anybody else figures this out.


Hey guys!

How would I go about getting outside Temp and Humidity readings from some source on the web and have them added to my Temp and Humidity readings from my indoor sensor thats connected to the spark core?

I’m sure there is a way to pull this data from the web by the a google drive script but I have no idea how this would need to be done.

I think it would be good to see outdoor temp and humidity and see how that affects indoor temp and humidity over time.



There are lots of choices: I have used both the National Weather Service site and Yahoo weather.

The Yahoo weather RSS feed is easy to parse (I have been looking at forecasts, not current conditions).


You want to look for

<yweather:atmosphere humidity="86"  visibility="10"  pressure="30"  rising="0" />


<yweather:condition  text="Fair"  code="34"  temp="50"  date="Mon, 24 Feb 2014 7:56 am PST" />

The code field refers to an icon number for the current condition “Fair” in this case. There are lots of other interesting fields.

I am parsing these sections:

<yweather:forecast day="Mon" date="24 Feb 2014" low="46" high="73" text="Sunny" code="32" />

These are free for non-commercial use, see the terms at the bottom of this page:


to use these in a commercial setting.


Awesome. It looks like you have a good source to pull the data from.

Now how exactly would we set our location & then get a script setup in google drive spreadsheet so it will pull this data every 5 mins or along with our temp data from the Spark Cloud? Are you doing this now or differently?


I am displaying the data locally and I have not played with the google spreadsheet scripting yet.

The yahoo data does not change very fast, perhaps every 15 minutes or so, so 5 minutes is overkill.

If you need fast (5 min) outside temp and humidity, I think you need your own outdoor sensors.


15 Mins would be fine. The more accurate the better.

If anybody else knows how to go about pulling this data into a spreadsheet then let us know.


Hi all,

I can log the data with the code provided, but the temperature data is stored in date format.
Even if I format the Temp column in number format it keeps storing in date format.
Am I doing something wrong?

Thanks in advance.


I suspect you’re running into the spreadsheet thinking it knows what format that column is in. Try setting the format for that column as a number or float / double, etc.


Has anyone tried to send data 3D.js? I don’t understand how it works but it looks flexible and quite cool.


Send 3D.js data from the Spark Core? Or to Google Drive Spreadsheets?


I think you mean http://d3js.org/ ?

D3 is a great javascript library for making interactive data visualizations. If you wanted to work with that, it’s just a matter of storing your data somewhere, and building a small page or widget with D3 that does something with that data. If I get a chance I’ll whip up a D3 demo if someone doesn’t beat me to it first. :smile:



@Dave I’d love to see some different data visualization options.


D3 is amazing, but I have very minimal experience with it.
RWB. If you can put something together, I’ll try incorporating it in my Spark Tools web app.


lol Thanks @Dave I need to be more careful with my typing! Yes [quote=“Dave, post:57, topic:2929”]
I think you mean http://d3js.org/ ?

That is what I mean. Looks great.

I like the “it’s just a matter of…” comment. In an similar vein climbing mount Everest is just a matter of putting one foot in front of the other a few times! :slight_smile:

A Demo / tutorial would be very welcome. Thanks for your positive response.