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


#41

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

@bdub do you have any thoughts on this?


#42

Full demo with source here.
http://www.highcharts.com/stock/demo/dynamic-update


#43

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;
    db.save(currentRec);
  }

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

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


#44

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


#45

@gwygonik it is works well. :smiley:


#46

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…


#47

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.


#48

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.


#49

Hi @RWB

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).

http://weather.yahooapis.com/forecastrss?w=2502265

You want to look for

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

and

<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:

http://developer.yahoo.com/weather/

to use these in a commercial setting.


#50

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?


#51

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.


#52

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.


#53

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.


#54

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.


#55

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


#56

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


#57

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:

Thanks,
David


#58

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


#59

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.


#60

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/ ?
[/quote]

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.