Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Ethernet.h>
- #include <SPI.h>
- ////////////////////////////////////////////////////////////////////
- //Delay between updates in minutes.
- int Delay = 30;
- char DNS_Server[] = "dynamicdns.park-your-domain.com";
- int DNS_Port = 80;
- byte mac_address[] = {0x91,0xA2,0xDB,0x02,0x05,0x17};
- /////////////////////////////////////////////////////////////////////
- char oldIP[16];
- char newIP[16];
- void setup(){
- Serial.begin(9600);
- Serial.println("\nStarted...");
- Serial.println("Ethernet Configuration (please wait)");
- while(Ethernet.begin(mac_address) == 0){
- Serial.println("failure. Retrying in 5 seconds.");
- delay(5000);
- }
- Serial.println("Successful. Allow 5 seconds to fully initialize.");
- delay(10000);
- }
- void loop() {
- Serial.println("Loop");
- if(GetIPFromServer(newIP)){
- Serial.println(newIP);
- }
- else {
- Serial.println("Didn't get any data?");
- }
- delay(Delay*1000);
- }
- byte GetIpFromServer(char buffer[]){
- EthernetClient client;
- if (client.connect("biranchi.com/",80)){
- client.println("GET /ip.php HTTP/1.0");
- client.println("");
- while (!client.available()){}
- int i = 0;
- char ch = client.available();
- while (ch != '\n'){
- if (client.available()){
- buffer[i] = client.read();
- i++;
- }
- client.stop();
- return 1;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment