Guest User

Untitled

a guest
Feb 1st, 2013
128
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Arduino to Google Docs
  2. created 2011
  3.  
  4.  
  5. This example code is in the public domain.
  6.  
  7. http://www.open-electronics.org
  8.  
  9.  
  10. http://www.futurashop.it
  11.  
  12. //https://spreadsheets.google.com/formResponse?formkey=dDBMdUx3TmQ5Y2xvX2Z0V183UVp2U0E6MQ &ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit
  13. Original from http://goodsite.cocolog-nifty.com/uessay/2010/07/arduinogoogle-d.html
  14. Modified by John Missikos 11/6/11
  15. Modified by Andrea Fainozzi 30/6/11
  16. Modified by Boris Landoni 8/7/11
  17. https://docs.google.com/spreadsheet/viewform?formkey=dEMyVVE3dGNzbF8yVXNiNXh3R21JMnc6MQ&ifq&entry.0.single=Boris&entry.2.single=Landoni&submit=Submit
  18. */
  19. //90-A2-DA-0D-AA-02
  20. #include <Ethernet.h>
  21. #include <SPI.h>
  22.  
  23. char formkey[] = "dEMyVVE3dGNzbF8yVXNiNXh3R21JMnc6MQ"; //Replace with your Key
  24. byte mac[] = { 0x90,0xA2,0xDA,0x0D,0xAA,0x02}; //Replace with your Ethernet shield MAC
  25. byte ip[] = { 192,168,0,109}; //The Arduino device IP address
  26. byte subnet[] = { 255,255,255,0};
  27. byte gateway[] = { 192,168,0,254};
  28. byte server[] = { 74,943,43,3 }; // Google IP
  29. EthernetClient client;
  30.  
  31. void setup()
  32. {
  33. Serial.begin(9600);
  34. Ethernet.begin(mac, ip , gateway , subnet);
  35. delay(1000);
  36. Serial.println("connecting...");
  37. client.connect(server, 80);
  38. }
  39.  
  40. void loop(){
  41. String data;
  42. data+="";
  43. data+="entry.0.single=";
  44. data+= "noah"; //replace with name
  45. data+="&entry.1.single=";
  46. data+= 4; //replace with timeIn
  47. data+="&entry.2.single=";
  48. data+=2; //replace with timeout
  49. data+="&submit=Submit";
  50.  
  51. if (client.connect(server, 80)) {
  52. Serial.println("connected");
  53.  
  54. client.print("POST /formResponse?formkey=");
  55. client.print(formkey);
  56. client.println("&ifq HTTP/1.1");
  57. client.println("Host: spreadsheets.google.com");
  58. client.println("Content-Type: application/x-www-form-urlencoded");
  59. client.println("Connection: close");
  60. client.print("Content-Length: ");
  61. client.println(data.length());
  62. client.println();
  63. client.print(data);
  64. client.println();
  65.  
  66. Serial.print("POST /formResponse?formkey=");
  67. Serial.print(formkey);
  68. Serial.println("&ifq HTTP/1.1");
  69. Serial.println("Host: spreadsheets.google.com");
  70. Serial.println("Content-Type: application/x-www-form-urlencoded");
  71. Serial.println("Connection: close");
  72. Serial.print("Content-Length: ");
  73. Serial.println(data.length());
  74. Serial.println();
  75. Serial.print(data);
  76. Serial.println();
  77.  
  78. }
  79. delay(1000);
  80. if (!client.connected()) {
  81. Serial.println();
  82. Serial.println("disconnecting.");
  83. client.stop();
  84. }
  85.  
  86. delay(10000);
  87.  
  88. }
RAW Paste Data