Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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
- https://docs.google.com/spreadsheet/viewform?formkey=dEMyVVE3dGNzbF8yVXNiNXh3R21JMnc6MQ&ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit
- */
- //90-A2-DA-0D-AA-02
- #include <Ethernet.h>
- #include <SPI.h>
- char formkey[] = "dEMyVVE3dGNzbF8yVXNiNXh3R21JMnc6MQ"; //Replace with your Key
- byte mac[] = { 0x90,0xA2,0xDA,0x0D,0xAA,0x02}; //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[] = { 74,943,43,3 }; // Google IP
- EthernetClient client;
- void setup()
- {
- Serial.begin(9600);
- Ethernet.begin(mac, ip , gateway , subnet);
- delay(1000);
- Serial.println("connecting...");
- client.connect(server, 80);
- }
- void loop(){
- String data;
- data+="";
- data+="entry.0.single=";
- data+= "noah"; //replace with name
- data+="&entry.1.single=";
- data+= 4; //replace with timeIn
- data+="&entry.2.single=";
- data+=2; //replace with timeout
- data+="&submit=Submit";
- if (client.connect(server, 80)) {
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement