Go Down

Topic: Send data to google spreadsheet with Arduino Yún (Read 2652 times) previous topic - next topic

raimon

Sep 25, 2013, 09:17 pm Last Edit: Sep 25, 2013, 09:23 pm by raimon Reason: 1
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 [font=Monospace]curl[/font] 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
}




cormac

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: [Select]
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.

raimon

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);               
  
}


Hi there,

I know this was an old post, but I can not get this to work.  Im trying to get my Arduino Yun to use the curl command to go to the URL to add the data to my goole docs spreadsheet via the form I made. Ive tested the form to make sure its working, but I cant not get my Yun to post to it. Am I missing something simple or very big? Please see my code.


Go Up