Guest User

Untitled

a guest
Apr 7th, 2015
295
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <EtherCard.h>
  2. #define lm35_1_pin A0
  3.  
  4. float temperature;
  5.  
  6. int lm35_1;
  7.  
  8.  
  9.  
  10. // ethernet interface mac address, must be unique on the LAN
  11. static uint8_t mymac[6] = {
  12. 0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // tutaj możemy zmienić adres mac
  13. static uint8_t ip[4] = {
  14. 192, 168, 0, 115}; // tutaj możemy zmienić adres ip
  15. static uint16_t port = 80;
  16. byte Ethernet::buffer[700];
  17. static uint32_t timer;
  18. const char website[] PROGMEM = "api.thingspeak.com";
  19. // called when the client request is complete
  20. static void my_callback (byte status, word off, word len) {
  21. Serial.println(">>>");
  22. Ethernet::buffer[off+300] = 0;
  23. Serial.print((const char*) Ethernet::buffer + off);
  24. Serial.println("...");
  25. }
  26. void setup () {
  27. Serial.begin(57600);
  28. Serial.println(F("\n[webClient]"));
  29. if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
  30. Serial.println(F("Failed to access Ethernet controller"));
  31. if (!ether.dhcpSetup())
  32. Serial.println(F("DHCP failed"));
  33. ether.printIp("IP: ", ether.myip);
  34. ether.printIp("GW: ", ether.gwip);
  35. ether.printIp("DNS: ", ether.dnsip);
  36. if (!ether.dnsLookup(website))
  37. Serial.println("DNS failed");
  38. ether.printIp("SRV: ", ether.hisip);
  39. }
  40. void loop () {
  41. lm35_1 = analogRead(lm35_1_pin);
  42. temperature = (5.0 * lm35_1 * 100)/1024.0;
  43. ether.packetLoop(ether.packetReceive());
  44. if (millis() > timer) {
  45. timer = millis() + 5000;
  46. Serial.println();
  47. Serial.print("<<< REQ ");
  48. Serial.print(temperature);
  49. int myInt = temperature;
  50. char myIntAsString[7];
  51. itoa(myInt, myIntAsString, 10);
  52. ether.browseUrl(PSTR("/update?key=A4FK3WJW1RZG2OIR&field1="), myIntAsString, website, my_callback); // XXX - należy zamienić właśnym API KEYem
  53.  
  54. }
  55. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×