Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <SPI.h>
  2. #include <stdlib.h>
  3. #include <WiFi.h> // arduino wifi libnrary
  4. #include <Twitter.h> //ardiono twitter library
  5. int outputpin= 0;
  6.  
  7. char ssid[] = "Your Network Name"; //
  8. char pass[] = "Your Network Password";
  9. char temp[6];
  10. char msg[50] = "It is this many degrees Kelvin at my house: ";
  11.  
  12. Twitter twitter("Your Twitter Token");
  13.  
  14. void setup()
  15. {
  16. Serial.begin(9600);
  17. delay(1000);
  18. WiFi.begin(ssid, pass);
  19. delay(10000);
  20. int rawvoltage= analogRead(outputpin);
  21. float kelvin;
  22. float millivolts= (rawvoltage/1024.0) * 5000;
  23. kelvin= (millivolts/10);
  24. dtostrf(kelvin, 3, 3, temp); //4 is mininum width, 3 is precision; float value is copied onto buff
  25. strcat(msg, temp);
  26. Serial.println("connecting ...");
  27. if (twitter.post(msg)) {
  28. int status = twitter.wait(&Serial);
  29. if (status == 200) {
  30. Serial.println("OK.");
  31. } else {
  32. Serial.print("failed : code ");
  33. Serial.println(status);
  34. }
  35. } else {
  36. Serial.println("connection failed.");
  37. }
  38. }
  39.  
  40. void loop()
  41. {
  42. }