Google docs “moved permanently” response to Arduino query?

I need to “send” a tSet (temperature setting / desired room temperaure) to the Arduino. I can set the tSet using buttons on the breadboard, but I certainly would like to set the tSet through a wifi connection over the internet. Ideally, I would have a web based (or mobile android based) app that “pushes” the tSet variable to the Arduino. That seems really difficult, but I would love to try if anybody has any advice for pursuing that (java applet that pushes tSet to Arduino acting as a client…???).
The simpler plan I am proceeding with (one week until project day) is to just type my desired tSet on a webpage and have the Arduino “get” that webpage and read the tSet number. My idea is to use a google doc as the page to upload my tSet, because google docs are easy to edit and upload (maybe this is my bad decision). Here is the google doc I am using for this. It is freely viewable.

https://docs.google.com/document/d/1zzZiicQ5zlc0evlxEkyygvefJj1YpEUcgnJ2B5pdoFw/edit

So to “get” this page, I use the following code in my program:

client.println("GET /document/d/1zzZiicQ5zlc0evlxEkyygvefJj1YpEUcgnJ2B5pdoFw/edit HTTP/1.1");
client.println("Host: docs.google.com");

(Entire Code attached at bottom)
(I have tried this with and without the “edit” at the end of the address)

But I get an unexpected response to this “get” statement. Instead of getting the webpage contents, I get a “HTTP/1.1 301 Moved Permanently” error. The error tells me the page has moved, but then gives me back the exact page address that I was trying to get. Here is the full response to the “get” command:

HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Sat, 22 Aug 2015 07:16:01 GMT
Location: https://docs.google.com/document/d/1zzZiicQ5zlc0evlxEkyygvefJj1YpEUcgnJ2B5pdoFw/edit
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close

<HTML>
<HEAD>
<TITLE>Moved Permanently</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Permanently</H1>
The document has moved <A HREF="https://docs.google.com/document/d/1zzZiicQ5zlc0evlxEkyygvefJj1YpEUcgnJ2B5pdoFw/edit">here</A>.
</BODY>
</HTML>

So my questions are:

  1. Any idea why my query to docs.google.com doesn’t work and how to make it work?
    or
  2. If the problem is inherent to docs.google.com any other domain suggestion where the page is easily editable?
    or
  3. Any tips to pursue my “ideal” solution of actually “push” the tSet variable to the Arduino?

Thanks,
Drew

(entire code here)

/*
  Web client
  This sketch connects to a website using a WiFi shield.
 */


#include <SPI.h>
#include <WiFi.h>

 char ssid[] = "twosom2F"; //  your network SSID (name) 
 char pass[] = "027421008";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)

 char server[] = "docs.google.com";

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 
  
  // attempt to connect to Wifi network:  
  while (status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid, pass);
  
    // wait 5 seconds for connection:
    delay(5000);
  } 
  Serial.println("Connected to wifi");
  printWifiStatus();
  
  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
    if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    
    client.println("GET /document/d/1zzZiicQ5zlc0evlxEkyygvefJj1YpEUcgnJ2B5pdoFw/edit HTTP/1.1");
    client.println("Host: docs.google.com");
    client.println("Connection: close");
    client.println();
  }
}

void loop() {
  // if there are incoming bytes available 
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

It is redirecting your request to a secure (SSL) server. Note the "https" protocol in the Location.

Thank you very much for looking over my question.

Yes, I see where it is redirecting to a secure (SSL) server:

The document has moved <A HREF="https://docs.goo

but I think that the true location of the webpage is indeed a secure (SSL) server. The true location is:

https://docs.google.com/document/d/1zzZiicQ5zlc0evlxEkyygvefJj1YpEUcgnJ2B5pdoFw/edit

.

So I am not sure why it is wrong for it to be directed to a secure server.

I appreciate your response, (don't get me wrong), and I am trying to get my head around it. If you could explain why it is wrong that it is being directed to a secure server and what I might do about it, I really appreciate it.
Thanks!
Drew

It isn't wrong to be redirected to a secure server. The only problem for the Arduino library is it doesn't have SSL capability, so it can't connect to a secure server.

I see, thank you.
That explains it. A bit strange that I can access google pages that start with https such as
arduino - Google Search (this is the WofiWebClient example sketch).

Still, it certainly explains why I cant see the https://docs.google.com/

By chance, any idea of a non-SSL webpage that I can edit easily to "send" commands to my arduino (acting as a client). I thought about putting commands on my facebook page but the arduino certainly cant access that as it is SSL and needs login too.

Thanks,
Drew

There are various places on the web that offer free web hosting, just search Google. Having said that, they tend to be restrictive and cover your web pages in adverts. If you don't need your system to be controllable from the public internet, you could always wire up a second arduino with wifi shield as a "remote" of sorts, and have that serve the necessary data up when accessed via its IP address on your local network. You can take a look at this example for running a Server on an arduino.

There is a complication to the above suggestion, which is dynamic IP allocation on local networks. This can be gotten around, though, with most routers as you can usually assign a static IP address to your device(s), but I can't help you with that as the method is vendor/model specific to your router. Not to mention of course, that you'll have to obtain and program a second arduino and wifi shield.

That explains it. A bit strange that I can access google pages that start with https such as
arduino - Google Search (this is the WofiWebClient example sketch).

The WiFiWebClient example doesn't connect to the Google search engine using SSL (port 443). The example connects using port 80. That is http, not https.

The Google search engine (www.google.com) does not return a "moved permanently" message to a port 80 request. The Google document server (docs.google.com) obviously does.

Thank you all for the feedback on this issue.

I decided to host my "tSet" variable on a webpage on a private domain I recently bought from godaddy. I host the domain for free on http://members.000webhost.com/ . The free hosting opens up some spam windows sometimes, but that doesn't seem to affect the arduino sketch's ability to pick up my variable from there.

It is not the best solution for passing a variable to my sketch, but I am happy to have it working. I'll be working on running a server object in my sketch to receive the "tSet" variable in a more elegant way (discussed in this thread)

Thank you again for your help.
Drew