- #include <EtherCard.h>
- #define lm35_1_pin A0
- float temperature;
- int lm35_1;
- // ethernet interface mac address, must be unique on the LAN
- static uint8_t mymac[6] = {
- 0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // tutaj możemy zmienić adres mac
- static uint8_t ip[4] = {
- 192, 168, 0, 115}; // tutaj możemy zmienić adres ip
- static uint16_t port = 80;
- byte Ethernet::buffer[700];
- static uint32_t timer;
- const char website[] PROGMEM = "api.thingspeak.com";
- // called when the client request is complete
- static void my_callback (byte status, word off, word len) {
- Serial.println(">>>");
- Ethernet::buffer[off+300] = 0;
- Serial.print((const char*) Ethernet::buffer + off);
- Serial.println("...");
- }
- void setup () {
- Serial.begin(57600);
- Serial.println(F("\n[webClient]"));
- if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
- Serial.println(F("Failed to access Ethernet controller"));
- if (!ether.dhcpSetup())
- Serial.println(F("DHCP failed"));
- ether.printIp("IP: ", ether.myip);
- ether.printIp("GW: ", ether.gwip);
- ether.printIp("DNS: ", ether.dnsip);
- if (!ether.dnsLookup(website))
- Serial.println("DNS failed");
- ether.printIp("SRV: ", ether.hisip);
- }
- void loop () {
- lm35_1 = analogRead(lm35_1_pin);
- temperature = (5.0 * lm35_1 * 100)/1024.0;
- ether.packetLoop(ether.packetReceive());
- if (millis() > timer) {
- timer = millis() + 5000;
- Serial.println();
- Serial.print("<<< REQ ");
- Serial.print(temperature);
- int myInt = temperature;
- char myIntAsString[7];
- itoa(myInt, myIntAsString, 10);
- ether.browseUrl(PSTR("/update?key=A4FK3WJW1RZG2OIR&field1="), myIntAsString, website, my_callback); // XXX - należy zamienić właśnym API KEYem
- }
- }
SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.