I have been programming Arduinos for a couple of years and recently purchased a Spark Core - loving it so far.
I have a simple example working where temperature data is logged from a sensor to a Google spreadsheet. Now this is where I get stuck How do I modify the Google script to call a function in the core ie to reset a counter. Basically I need to read temperature data from the core then reset a variable. I guess I need to use spark.function in the script, but this script stuff is new to me.
Glad you like the Spark! As far as the scripting stuff goes, this might prove helpful: https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
I personally haven’t yet played with the google scripts, but you’re supposed to make a post request, which is what’s described in the above link. Take a look, and let us know if you require any further assistance!
Although it should be possible to combine it to a single browser-compatible URL, I don’t think that’s required as per the above link (@bko, could you help out with this?) You can insert your parameters in the “options” field, which should work.
I don’t know too much about the google scripting environment, but to run a Spark function, you need to do a POST request and there is an example of how on that page referenced above.
Here is a “sketch” of what the google code should look like. You need to fill in the “Spark String Arg”, the access_token, device_id, and SparkFunctionName with your actual values.
var payload =
{
"params" : "Spark String Arg",
"access_token" : "1234....4321"
};
// Because payload is a JavaScript object, it will be interpreted as
// an HTML form. (We do not need to specify contentType; it will
// automatically default to either 'application/x-www-form-urlencoded'
// or 'multipart/form-data')
var options =
{
"method" : "post",
"payload" : payload
};
UrlFetchApp.fetch("https://api.spark.io/v1/devices/4321...1234/SparkFunctionName", options);
}