Uploading Arduino data to Google drive


hello!
i want upload sensor data arduino uno r3 google docs spreadsheet froma google docs form. this, need make http post request using following url:

https://docs.google.com/forms/d/****************************-***************/formresponse?ifq&entry.********=night&entry.********=30&entry.********=27&submit=submit

(**** represent formkey , entry numbers)

when type url in browser, entry added spreadsheet successfully. guess, there no problem url such. there problem in arduino code using url. getting http/1.0 400 bad request error.

any appreciated.  code follows:

code:
#include <spi.h>
#include <dhcp.h>
#include <dns.h>
#include <ethernet.h>
#include <ethernetclient.h>
#include <ethernetserver.h>
#include <ethernetudp.h>
#include <pstring.h>
#include <stdlib.h>

byte mac[] = { 0x**,0x**,0x**,0x**,0x**,0x**};  //ethernet shield mac
ipaddress server(74,125,232,128);// make char server[]= "www.google.com" if dns available
ipaddress ip = (,,,);  //ip address added
ipaddress subnet = (,,,); //subnet mask added
ipaddress gateway = (,,,); //gateway added
ipaddress dns = (,,,); //dns added

ethernetclient client;

void setup()
{
  serial.begin(9600);
  if (ethernet.begin(mac) == 0) {
    serial.println("failed configure ethernet using dhcp");
    // no point in carrying on, nothing forevermore:
    // try congifure using ip address instead of dhcp:
    ethernet.begin(mac, ip,gateway,subnet);//make ethernet.begin(mac,ip,dns,gateway,subnet); if dns available
  }
  delay(1000);
  serial.println("connecting...");
 
  string data;
  data+="";
  data+="entry.********=night&entry.********=30&entry.********=27&submit=submit";

  if (client.connect(server,80)) {
    serial.println("connected");

    client.print("post /forms/d/****************************-***************/formresponse?ifq http/1.0");
    client.println("host: docs.google.com");
    client.println("user-agent: arduino/1.0");
    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("forms/d/****************************-***************/formresponse?ifq http/1.0");
    serial.println("host: docs.google.com");
    serial.println("user-agent: arduino/1.0");
    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();
}

}
void loop()
{
  if (client.available()) {
    char c = client.read();
    serial.print(c);
    }
   
  if (!client.connected()) {
    serial.println();
    serial.println("disconnecting.");
    client.stop();
  }
 
  delay(1000);
}

hello

i'm trying similar.  did manage solve problem?

cheers

rob


Arduino Forum > Topics > Home Automation and Networked Objects > Uploading Arduino data to Google drive


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support