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


#102

@mdfast1 @Dave Thanks for the update! Yes, it works much better now.


#103

thanks! It does work much better!! :slight_smile:


#104

Thanks to the help from @binaryfrost and @bko, here is some working code for a temperature/humidity control utilizing the honeywell hih-8120 with a web interface to set the values and data logging to google. Feedback is welcome! https://github.com/wildhans1/web_temp_humidity_control


#105

This was working great last week. I have the google trigger set to every minute:

Today the timing is erratic. Notice the time stamps here:

Sometimes the data comes more often than each minute, and most of time there are 3-5 minute dead periods between data. Any ideas? The code is identical to the github link in the post above this. Thanks!


#106

So I know we are looking at possibly increasing the 1 minute timer on sheets internally, I would suspect bandwidth issues. Looking at your data it’s not really changing in ~ 1 hour. Do you really need to ping it every 1 minute? Think of the bandwidth.

What do you see if you switch to 5minute timer? Dead on timing?


#107

Hi @mdfast1, the appliance that this thing is controlling is unplugged. I’m just running the Core and a sensor. When turned on, the system changes quite rapidly (full range swing in ~2 minutes) so even 1 minute intervals are pretty slow. I’m trying 5 minute intervals as you suggested- I’ll post back. thanks!


#108

Hmm. Now it doesn’t appear to be working at all. It just works once when I hit “run” and then not again. Is anyone else having issues? Thanks


#109

Hi @wildhans1,

I think the problem we saw earlier is that Google is really cautious when hitting other servers for this kind of request. If your core is offline, then Google is getting a bunch of ‘timeout’ errors, because we can’t see your core. Google sees this as a “oh dang, this server is super busy, I’d better ease up”, and slows down your requests. (I think)

Thanks!
David


#110

Has anyone figured out how to use the Gauge Chart with a spreadsheet that adds data to the last row? The gauge wants to pull from a single row only and I haven’t figured out how to use a formula in the gauge or a script that maybe always copies the last row to row 1 or to another spreadsheet so I can use a gauge and always display the last data. I am using Temboo to collect the data and add rows. Works good for a chart but not a gauge.


#111

Try:

sheet.clear();

before

sheet.appendRow

#112

but won’t that just clear the whole sheet? I want to keep the history but show a gauge of the last sample. I think it can be done with a google script or trigger but this is all new to me. Or a script or formula that will copy the contents of the last row to a new sheet or area of the spreadsheet that the gauge can then act on.


#113

Yep it would. If you want to keep the data I would do something like having two sheets (tabs), one for storing data and one for your most up to data for the gauge.

So load data into your main sheet sheet 0

// The code below will make the first sheet active in the active workbook
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheets()[0]);
ss.appendRow

Then load up sheet 1:

// The code below will make the Second sheet active in the active workbook
ss.setActiveSheet(ss.getSheets()[1]);
ss.clear();
ss.appendRow

#114

Hi @RWB and all,

Perhaps Ubidots can help you graph your data in different ways. You just need to add an HTTP library to your app and a few lines of code where you actually push the sensor data to Ubidots API:

request.path = "/api/v1.6/variables/"VARIABLE_ID"/values";
request.body = "{\"value\":" + String(lightLevel) + "}";
http.post(request, response, headers);

After your data reaches Ubidots, you can create line charts, scatter plots, gauges, maps, etc.

Here’s the full tutorial about it. Any feedback/contribution is welcome!


#115

@aguspg Hey I checked out Ubidots and it looks very promising. I’m going to try to get the tutorial example up and running and then begin tying out different sensors and play with the data graphing and especially the SMS and Email notifications which are the features I really really wanted to use vs just the graphing.

Thanks so much for letting everybody know about this service. I’ll post some pictures of what I have setup once its up and running! :smiley:


#116

Sure! look forward to hear about your results. --Agustín


#117

Hey @aguspg would you be willing to do a guide on how to integrate Adafruits new FONA cellular module with Ubidots if I sent you a Fona? I have a few extra units I’m not using and I would like to use Ubidots with Fona’s cellular data output stream.


#118

Hi @RWB that would be awesome! we’re very interested. Let’s exchange an email about it, my address: agustin at ubidots.com


#119

Does anyone here know of a way to get the core to “push” data a Google spread sheet rather than having Google poll the spark core API?

I am making a temperature + motion(presence) data logger and I want to keep the spark in deep sleep for as long as possible to make the battery life acceptable, using Spark.variable seems to cause issues with this setup. Having the core push the new data to the Google server would make things a lot simpler.

I already have a small web server available on the public net, so one way I am thinking of doing this is having the spark core push the data to this server and then having the google script poll the 3rd party server, it seems a little bit clunky. I’m not familiar enough with the Google Docs APIs to know if there is any functions that could be called directly from the core for sending new data. lack of https support may make this hard. I will do some research to see if I can find anything, but it would be helpful to know if anyone has already done something similar.


#120

@aguspg,

Thanks for suggesting Ubidots. I have it running my thermocouple data and it is brilliant. Good clear graphs or guages and events that can trigger SMS or email at preset values.

Brill.

Thank you.


#121

Thanks for the great “How to”. Being a beginner with Google Script, I’m wonder if its possible to get it to call a function on the spark to set one of the digital I/O ports to high. I’d like to have it flip on my sensors, wait a second then poll the sensors, wait another second and then set the I/O to low, which would flip a relay off. I’ve looked at the spark examples for turning an led on and off, but they use Curl to do this, I’m not sure how to get a Google script to accomplish this.

Thanks in advance.