The data from Arduino to Google Spreadsheet

details

f6cae68be42176e9a155946b628dd7b8

 

INTRO.

This project is advanced client project. If you have a experience with client project, this will be easy and helpful. It uses Google Spreadsheet as Server.

And Arduino uploads data to it and after that user can check and download it.

 

 

STEPS.

The steps for sending data from Arduino to Google Spreadsheet.

1. You have to create a module from the Google Docs page (registration is required)

Home-page-Google-1024x649

 

2. Select ‘New’ > ‘Form’ from the Google Docs menu

Select-Form

 

3. Create the form with text field. You can enter as many fields you want. Give a name to the form and the questions ( question names are the column names)

Create-Form

 

4. Click on ‘Done’. it has created the form. In the URL you can see the formkey. Take note of this key and it will be used in the Arduino sketch.

Form-OnLine-1024x750

 

5. Normally the text boxes ( data1 and 2 in this example) are called entry.0.single and enrtry.1.single … etc., but the name may change if you change the basic structure. So the best way is to explore the HTML to actually check the names.

inspect-element-1024x628

 

6. This is Google Chrome Browser. The code shows the exact name of the two text boxes. Take note of these names.

Element

 

7. In this project, the names are entry.0.single by Date 1 and entry.2.single to Date 2. To send the data to the module we must use this syntax:

https://spreadsheets.google.com/formResponse?formkey = YOUR FORM KEY & IFQ & YOUR ENTRY = THE VALUE TO STORE & submit = submit

For example :

https://spreadsheets.google.com/formResponse?formkey=dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ&ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit

This is Result >

Form-response-1024x265

 

8. The data are copied to Google spreadsheet. This is the sheet in this project with various data.

Data-on-Google-Spreadsheet-1024x435

 

 

CODE.

After all, have to send the data with Arduino. Use the POST method to send data to the module.

Please refer the below code.

/* Arduino to Google Docs
 created 2011

This example code is in the public domain.

http://www.open-electronics.org
http://www.futurashop.it

https://spreadsheets.google.com/formResponse?formkey=dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ &ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit
Original from http://goodsite.cocolog-nifty.com/uessay/2010/07/arduinogoogle-d.html
Modified by John Missikos 11/6/11
Modified by Andrea Fainozzi 30/6/11
Modified by Boris Landoni 8/7/11

*/

#include <Ethernet.h>
#include <SPI.h>

char formkey[] = "dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ"; //Replace with your Key
byte mac[] = { 0x90,0xA2,0xDA,0x00,0x55,0x8D};  //Replace with your Ethernet shield MAC
byte ip[] = { 192,168,0,109};  //The Arduino device IP address
byte subnet[] = { 255,255,255,0};
byte gateway[] = { 192,168,0,254};
byte server[] = { 209,85,229,101 }; // Google IP
Client client(server, 80);

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip , gateway , subnet);
  delay(1000);
  Serial.println("connecting...");
}

void loop(){
  String data;
  data+="";
  data+="entry.0.single=";
  data+=analogRead(A0);
  data+="&entry.2.single=";
  data+=analogRead(A1);
  data+="&submit=Submit";

  if (client.connect()) {
    Serial.println("connected");

    client.print("POST /formResponse?formkey=");
    client.print(formkey);
    client.println("&ifq HTTP/1.1");
    client.println("Host: spreadsheets.google.com");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Connection: close");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.print(data);
    client.println();

    Serial.print("POST /formResponse?formkey=");
    Serial.print(formkey);
    Serial.println("&ifq HTTP/1.1");
    Serial.println("Host: spreadsheets.google.com");
    Serial.println("Content-Type: application/x-www-form-urlencoded");
    Serial.println("Connection: close");
    Serial.print("Content-Length: ");
    Serial.println(data.length());
    Serial.println();
    Serial.print(data);
    Serial.println();

  }
  delay(1000);
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
  }

  delay(10000);

}

 

 

Thank you

 

http://blog.elettronicain.it/2011/08/29/i-dati-da-arduino-a-google-spreadsheet/

f6cae68be42176e9a155946b628dd7b8

 

INTRO.

This project is advanced client project. If you have a experience with client project, this will be easy and helpful. It uses Google Spreadsheet as Server.

And Arduino uploads data to it and after that user can check and download it.

 

 

STEPS.

The steps for sending data from Arduino to Google Spreadsheet.

1. You have to create a module from the Google Docs page (registration is required)

Home-page-Google-1024x649

 

2. Select ‘New’ > ‘Form’ from the Google Docs menu

Select-Form

 

3. Create the form with text field. You can enter as many fields you want. Give a name to the form and the questions ( question names are the column names)

Create-Form

 

4. Click on ‘Done’. it has created the form. In the URL you can see the formkey. Take note of this key and it will be used in the Arduino sketch.

Form-OnLine-1024x750

 

5. Normally the text boxes ( data1 and 2 in this example) are called entry.0.single and enrtry.1.single … etc., but the name may change if you change the basic structure. So the best way is to explore the HTML to actually check the names.

inspect-element-1024x628

 

6. This is Google Chrome Browser. The code shows the exact name of the two text boxes. Take note of these names.

Element

 

7. In this project, the names are entry.0.single by Date 1 and entry.2.single to Date 2. To send the data to the module we must use this syntax:

https://spreadsheets.google.com/formResponse?formkey = YOUR FORM KEY & IFQ & YOUR ENTRY = THE VALUE TO STORE & submit = submit

For example :

https://spreadsheets.google.com/formResponse?formkey=dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ&ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit

This is Result >

Form-response-1024x265

 

8. The data are copied to Google spreadsheet. This is the sheet in this project with various data.

Data-on-Google-Spreadsheet-1024x435

 

 

CODE.

After all, have to send the data with Arduino. Use the POST method to send data to the module.

Please refer the below code.

/* Arduino to Google Docs
 created 2011

This example code is in the public domain.

http://www.open-electronics.org
http://www.futurashop.it

https://spreadsheets.google.com/formResponse?formkey=dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ &ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit
Original from http://goodsite.cocolog-nifty.com/uessay/2010/07/arduinogoogle-d.html
Modified by John Missikos 11/6/11
Modified by Andrea Fainozzi 30/6/11
Modified by Boris Landoni 8/7/11

*/

#include <Ethernet.h>
#include <SPI.h>

char formkey[] = "dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ"; //Replace with your Key
byte mac[] = { 0x90,0xA2,0xDA,0x00,0x55,0x8D};  //Replace with your Ethernet shield MAC
byte ip[] = { 192,168,0,109};  //The Arduino device IP address
byte subnet[] = { 255,255,255,0};
byte gateway[] = { 192,168,0,254};
byte server[] = { 209,85,229,101 }; // Google IP
Client client(server, 80);

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip , gateway , subnet);
  delay(1000);
  Serial.println("connecting...");
}

void loop(){
  String data;
  data+="";
  data+="entry.0.single=";
  data+=analogRead(A0);
  data+="&entry.2.single=";
  data+=analogRead(A1);
  data+="&submit=Submit";

  if (client.connect()) {
    Serial.println("connected");

    client.print("POST /formResponse?formkey=");
    client.print(formkey);
    client.println("&ifq HTTP/1.1");
    client.println("Host: spreadsheets.google.com");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Connection: close");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.print(data);
    client.println();

    Serial.print("POST /formResponse?formkey=");
    Serial.print(formkey);
    Serial.println("&ifq HTTP/1.1");
    Serial.println("Host: spreadsheets.google.com");
    Serial.println("Content-Type: application/x-www-form-urlencoded");
    Serial.println("Connection: close");
    Serial.print("Content-Length: ");
    Serial.println(data.length());
    Serial.println();
    Serial.print(data);
    Serial.println();

  }
  delay(1000);
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
  }

  delay(10000);

}

 

 

Thank you

 

http://blog.elettronicain.it/2011/08/29/i-dati-da-arduino-a-google-spreadsheet/

COMMENTS

Please Login to comment
  Subscribe  
Notify of