Pages: [1]   Go Down
Author Topic: Send data to google spreadsheet with Arduino Yún  (Read 1823 times)
0 Members and 1 Guest are viewing this topic.
Barcelona
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey there!

I'm working in a project in which I want to send data from a sensor to a Google Spreadsheet. I am using an Arduino Yún. As advised in different internet articles, I decided to send sensor data through a Google Form via the curl command and the runShellCommand function. It turns out that the code works fine if the Arduino Yún is connected to my computer. When I unplug the Arduino and connect it to an external battery/outlet the sketch does not work. I am kind of interested in figuring out what is going on with the code (yes, I just started with Arduino...).

I paste the code below... in the variable value is where the sensor data goes:

Thanks a lot guys!
Raimon

Quote
#include <Process.h>

void setup()
{
  Bridge.begin();   // Initialize the Bridge
  Serial.begin(9600);   // Initialize the Serial
  // Wait until a Serial Monitor is connected.
  while(!Serial);
}

void loop()
{
  int value = 0;
 
  Process p;
  p.runShellCommand("curl \"https://docs.google.com/forms/d/1GWcwTGk-B62floIslTgkC4hBIV6niBRUmiU0rE76A10/formResponse?draftResponse=%5B%5D%0D%0A&entry.105098110=" + String(value) + "&pageHistory=0\" -k");
 
  int result = p.parseInt(); /* look for an integer */
  Serial.print("Result:"); /* Some serial debugging */
  Serial.println(result);
  p.flush();

  delay(20000);                // Wait one second before get another temperature reading
}


 
« Last Edit: September 25, 2013, 02:23:07 pm by raimon » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
Product @ Temboo
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Raimon,

The Arduino IDE comes with an example of how to send data to a Google Spreadsheet via Temboo. You can find this under File -> Examples -> Bridge -> Temboo. You can also find it online here:

https://www.temboo.com/arduino/update-google-spreadsheet

The example uses Serial to print data, so it assumes you're connected via USB. You can convert this to work wirelessly by replacing mentions of Serial with Console. Here's what you need to do to make that happen:

1. Convert the setup() method to look like this:

Code:
void setup() {
  Bridge.begin();
  Console.begin();
 
  while(!Console);
}

2. Replace each occurrence of "Serial" throughout the sketch with "Console" e.g., Serial.println("hello"); changes to Console.println("hello");

Hope that helps,
Cormac

P.S. I work at Temboo so feel free to get in touch with any questions.
Logged

Barcelona
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Cormac!

That was useful. I managed to fix the code. I post it below in case someone is interested:

Raimon

Quote
#include <Process.h>

void setup()
{
  Bridge.begin();   // Initialize the Bridge
}

void loop()
{
  int value = 3;
 
  Process p;
  p.runShellCommand("curl \"https://docs.google.com/forms/d/1GWcwTGk-B62floIslTgkC4hBIV6niBRUmiU0rE76A10/formResponse?draftResponse=%5B%5D%0D%0A&entry.105098110=" + String(value) + "&pageHistory=0\" -k");
  while(p.running());
  delay(2000);               
  
}

Logged

Pages: [1]   Go Up
Jump to: