Guest User

Untitled

a guest
May 21st, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. // arduino to google spreadsheet
  2.  
  3. #include <Ethernet.h>
  4. #include <Client.h>
  5. #include <Server.h>
  6.  
  7. byte mac[] = { 0x00,0x50,0xC2,0x97,0x21,0xD2};
  8. byte ip[] = { 192,168,1,254};
  9. byte subnet[] = { 255,255,255,0};
  10. byte gateway[] = { 192,168,1,1};
  11. byte server[] = { 64, 233, 183, 100 }; // spreadsheets.google.com
  12.  
  13. Client client(server, 80);
  14.  
  15. void setup()
  16. {
  17.  
  18. Ethernet.begin(mac, ip , gateway , subnet);
  19. delay(1000);
  20.  
  21. char body[] = "entry.1.single=arduino0001&submit=Submit";
  22.  
  23. if (client.connect()) {
  24. client.println("POST /formResponse?formkey=dG5pUF9za3NBYWVTblNMc3FxOGxsWHc6MA&ifq HTTP/1.1");
  25. client.println("Host: spreadsheets.google.com");
  26. client.println("Content-Type: application/x-www-form-urlencoded");
  27. client.print("Content-Length: ");
  28. client.println(sizeof(body),DEC);
  29. client.println();
  30. client.println(body);
  31. }
  32.  
  33. delay(1000);
  34. client.stop();
  35.  
  36. }
  37.  
  38. void loop()
  39. {
  40. if (client.available()) {
  41. char c = client.read();
  42. }
  43.  
  44. if (!client.connected()) {
  45. client.stop();
  46. for(;;)
  47. ;
  48. }
  49. }
Add Comment
Please, Sign In to add comment